[racket] Newbie question: Teach Yourself Scheme in Fixnum Days - macros
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))))
I typed this in to DrRacket substituting 'mywhen' for 'when'
then tried it out by copying in
(mywhen (< (pressure tube)60)
(open-valve tube)
(attach floor-pump tube)
(depress floor-pump 5)
(detach floor-pump tube)
(close-valve tube)))
I checked these very carefully for typos and I think I have
typed correctly, but instead of being 'converted to another expression'
this evoked the error message
"if: bad syntax (must have an "else" expression) in:..."
From this, should I assume that there is a difference between Racket
and mzScheme regarding define-macro? In case the 'require' had not worked
I did try '(require (mzlib "defmacro.rkt"))'
but this evoked
'mzlib: not a require sub-form in: (mzlib "defmacro.rkt")'
What is the best source for learning about macros in Racket, assuming no
previous
knowledge of macros?
Regards
_John Sampson_