[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: for



You write:
| Do macros really provide that much more than functions + es's quoting
| rules + eval?  I dunno.  I do know that I'd hate to see defmacro and , and
| ` without good reason.

Macros are better because they can obey lexical scoping rules, and can
avoid capturing random free variables.  Here are some examples of
Dyvbig's proposed hygienic macro system, from pub/scheme/tr356.ps,
ftped from cs.indiana.edu just now:

(define-syntax and2
 (lambda (x)
  (syntax-case x ()
   ((_ x y)
    (syntax (if x y #f))))))

(define-syntax when
 (lambda (x)
  (syntax-case x ()
   ((_ e0 e1 e2 ...) (syntax (if e0 (begin e1 e2 ...)))))))

(define-syntax or
 (lambda (x)
  (syntax-case x ()
   ((_) 
    (syntax #f))
   ((_ e) 
    (syntax e))
   ((_ e1 e2 e3 ...) 
    (syntax (let ((t e1)) (if t t (or e2 e3 ...))))))))

They can get much more complicated than these, of course.