[racket] Newbie question: Teach Yourself Scheme in Fixnum Days - macros

From: Pierpaolo Bernardi (olopierpa at gmail.com)
Date: Wed Mar 30 08:46:08 EDT 2011

On Wed, Mar 30, 2011 at 11:31, John Sampson <jrs.idx at ntlworld.com> wrote:

> Hello -
> I am going through TYSIFD which is said to be compatible with mzScheme.
> Descriptions of macros seem to be different depending which book one reads.
> TYSIFD advises the reader to 'require' the defmacro library
> - '(require (lib "defmacro.rkt"))' when using Racket (I assume) - and gives
> the example
> (define-macro  when
>  (lambda  (test  .branch)
>    (list  'if  test
>      (cons  'begin  branch))))

btw, try substituting the last two lines with:

    (list  'if  test
      (cons  'begin  branch)

the problem is that if's in racket must have both arms, while in other
dialects they can be one-armed.


Posted on the users mailing list.