Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Clojure vs Racket

Name: Anonymous 2011-01-31 6:28

Is Clojure a better language than Racket?

Name: Anonymous 2011-01-31 7:05

Macro in LISP.

(defmacro aif (cond then else)
  `(let ((it ,cond))
     (if it ,then ,else)))


"Macro" in Scheme/Racket.

#lang racket
(require racket/stxparam)
 
(define-syntax-parameter it (lambda (stx) (raise-syntax-error 'anaphora "missed context" stx)))
 
(define-syntax-rule (aif cond then else)
  (let ([temp cond])
    (syntax-parameterize ([it (make-rename-transformer #`temp)])
                         (if temp then else))))

Name: Anonymous 2011-01-31 7:17

(define it ">>6")

(aif (sucks? it)
  (string-append it " sucks")
  (string-append it " still sucks"))

Name: Anonymous 2011-01-31 7:36

>>6
(require mzlib/defmacro)

(defmacro aif (cond then else)
  `(let ((it ,cond))
     (if it ,then ,else)))


Or if that library didn't exist:

(define-syntax (defmacro stx)
  (syntax-case stx ()
    ((defmacro <name> <args> . <body>)
     #`(define-syntax (<name> stx)
         (syntax-case stx ()
           ((<name> . <<args>>)
            (datum->syntax
             #'<name>
             (apply
              (lambda <args> . <body>)
              (syntax->datum #'<<args>>)))))))))


Though neither solve the problem that defmacro is BROKEN AS FUCK.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List