macro expansion bug?
Wen-Chun Ni
wcn@tbcommerce.com
Fri Dec 20 10:36:00 GMT 2002
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
More information about the Kawa
mailing list