Alan Post wrote:
(define-macro (char->number ch)
`(- (char->integer ,ch)
(char->integer #\0)))
(define-macro (0= n)
`(= 0 ,n))
(define-macro (begin0 form . forms)
(let ((var (gensym)))
`(let ((,var ,form)) ,@forms ,var)))
If |define-macro| is no longer around, how would the above forms be
written?
With Scheme's standard high-level, hygienic macros, that Chicken now
supports natively:
(define-syntax char->number
(syntax-rules ()
((char->number ch)
(- (char->integer ch)
(char->integer #\0)))))
(define-syntax 0=
(syntax-rules ()
((0= n)
(= 0 n))))
(define-syntax begin0
(syntax-rules ()
((begin0 form forms ...)
(let ((temp form))
forms ...
temp))))
This is kind of the whole point of the hygienic branch ;-)
Notice how more readable they are, without commas and stuff. Yes, the
"..." is very clever and does what you would expect and no, temp won't
collide with *any* other variable named temp, whatsoever. No more
gensym and quasiquote!
On the other hand, why are these written as macros in the first place?
Tobia
_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users