This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Tail sets
- From: Helmut Eller <eller dot helmut at gmail dot com>
- To: kawa at sources dot redhat dot com
- Date: Sun, 15 Mar 2009 09:42:58 +0100
- Subject: Tail sets
Hi,
I'm using a pattern matching macro that looks like:
(define-syntax mif
(syntax-rules ()
((mif ((p . ps) value) then else)
(let ((fail (lambda () else))
(tmp value))
(if (instance? tmp <pair>)
(let ((tmp :: <pair> tmp))
(mif (p tmp:car)
(mif (ps tmp:cdr)
then
(fail))
(fail)))
(fail))))
((mif (var value) then else)
(let ((var value)) then))))
The else branch is abstracted out to avoid code duplication and there
are three calls to (fail). At least CMUCL recognizes that those three
calls have the same continuation and compiles the calls as direct
jumps. It seems to me, that Kawa compiles them as ordinary calls (and
presumably has to allocate a closure). Would it be hard to teach the
compiler to optimize situations like the above? Alternatively, is
there something like TAGBODY/GO in Kawa?
I'm asking just out of curiosity, not because I need the optimization.
Helmut.