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

Re: Introductory material on hygienic macros in dr scheme




From: "Chris Wright" <caw@cs.mu.oz.au>
> I guess I'm looking for something a little more gentle than what's in the
> help desk, that might show show some "old-style"  common lisp macros would
> look if converted to the r5 style:

'The Scheme Programming Language' and
'Chez Scheme User Guide'  contains two good
chapters on macros. Both are available from
www.scheme.com.

> eg:
>
> (defmacro while (test &rest body)
>     `(do ()
>         ((not ,test))
>        ,@body))

(define-syntax while
  (syntax-rules ()
    ((_ test expr ...)
     (do ()
  ((not test))
       expr ...))))

===========

I have a question myself on macros.
mzscheme 200alpha9 gives:

> (let-syntax ((foo
  (syntax-rules ()
    ((_ x) (bar x)))))
    (define x 33))
begin (possibly implicit): no expression after a sequence of internal
definitions in: ((define x 33))

While the same expression works in Chez, where the (define x ...) is
considered
top level.

>From reading the r5rs is not clear to me which behaviour is correct.

I have some code that depends on the Chez behaviour, and I am
wondering if I had it working only by luck.

Cheers,
  Pierpaolo