This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
macro expansion bug?
- From: Wen-Chun Ni <wcn at tbcommerce dot com>
- To: kawa at sources dot redhat dot com
- Date: Thu, 14 Nov 2002 08:35:05 -0800
- Subject: macro expansion bug?
I was trying to learn some tricks shown in CPS-style macro programming
and picked up the example shown by Oleg:
(define-syntax mreverse
(syntax-rules ()
((_ . args)
(letrec-syntax
((go
(syntax-rules ()
((_ (first . rest) result)
(go rest (first . result)))
((_ () result)
'result)))
(aux
(syntax-rules ()
((_ (elem . tail))
(go (elem . tail) ()))
((_ elem . tail)
(go (elem . tail) ())))))
(aux . args)))))
This does the thing like reverse does but in a "CPS" way to sidestep
some of the problems in syntax-rules's limitation.
So (mreverse (1 2 3 4)) should return (4 3 2 1). MzScheme, MIT Scheme,
and Chicken return this answer. However, both Kawa and Bigloo
failed to produce the answer. Bigloo is worse: it doesn't see
how to expand 'go' here. Kawa return the symbol 'result.
Is it a bug? Or my understanding of syntax-rules still leaves
something to be desired?
Thanx!
Wen-Chun