This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
using Kawa's extended lambda formals syntax in macros
- From: "Hoehle, Joerg-Cyril" <Joerg-Cyril dot Hoehle at t-systems dot com>
- To: kawa at sources dot redhat dot com
- Date: Tue, 9 Dec 2003 12:28:52 +0100
- Subject: using Kawa's extended lambda formals syntax in macros
Hi,
trying to find a replacement for brl-sql-repeat (cf. 2 reported bugs in brl-users list), I came across the following:
(defmacro foo (stmt #!rest bar)
`(list ,stmt ,@bar))
#|kawa:13|# (foo 2)
<stdin>:13:2: no matching case while expanding foo
#|kawa:14|# (foo 1 2)
<stdin>:14:2: no matching case while expanding foo
#|kawa:15|# (foo 1 2 3)
<stdin>:15:2: no matching case while expanding foo
It feels like Kawa's macro expander doesn't recognize Kawa's extended lambda
syntax.
There would be a real need for this working in Common Lisp mode.
The documentation says:
defmacro name lambda-list form ... Syntax
Defines an old-style macro a la Common Lisp, and installs (lambda lambda-list
form ...) as the expansion function for name.
>From a Common Lisp point of view, a lambda-list including &optional, &rest or
&key (#!optional etc. in Kawa) is as legal as any other.
Even more so, it's very common.
Work-around
a) Use a neutral macro formals list and an inner funcall or apply as
appropriate, e.g.
(defmacro foo x
(apply
(lambda (stmt #!rest bar)
`(list ,stmt ,@bar))
x))
b) Or use ancient-style dot-notation instead of #!rest destructuring (that's
been in some Lisps for decades, and it's also the normal way in Scheme).
Regards,
Jorg Hohle
Using Kawa-1.7 on Suse-Linux 9