kawa-commonlisp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Kawa-commonlisp-dev] [GSoC] Status


From: Jamison Hope
Subject: Re: [Kawa-commonlisp-dev] [GSoC] Status
Date: Fri, 10 Aug 2012 20:40:01 -0400

On Aug 10, 2012, at 4:29 PM, Charles Turner wrote:

Thanks again Jamison, really getting lost with this now though. There
appears to be a difference with how DEFINE-SYNTAX captures the symbols
used in its definition and how DEFMACRO does it. Don't know much about
hygiene, but maybe the problem is related to that:

The general problem can be seen by trying a macro like
DESTRUCTURING-BIND, which expands to functions not def*Fld'd from
CommonLisp:

#|kawa:1|# (destructuring-bind (a b c) '(1 2 3) (list c b a))
<unknown>: warning - no declaration seen for COMMON-LISP:PROPER-LIST- OF-LENGTH-P <unknown>: warning - no declaration seen for COMMON-LISP:ARG-COUNT- ERROR unbound location COMMON-LISP:PROPER-LIST-OF-LENGTH-P (property (function))

That one, at least, has an easy (but annoying) workaround:

$ kawa --lisp
#|kawa:1|# (require class::|gnu.commonlisp.lisp.defmacro|)
#|kawa:2|# (destructuring-bind (a b c) '(1 2 3) (list c b a))
(+ 0 1)
(+ 1 1)
(+ 2 1)
(3 2 1)


I made a smaller test case that, to me, demonstrates a hygiene problem:
[...]
Any pointers on where to look for the difference? I'm struggling to
figure out how where the bindings are actually looked up, and actually
I'm not sure if DEFMACRO is functioning correctly and that I must
instead use define-syntax.


It looks like DEFMACRO macros are having trouble looking up
non-exported symbols defined in their lexical environments.
To be honest, I'm not positive what's supposed to happen here,
either, but my reading of the HyperSpec says your test1 is
supposed to work.

CLHS says that DEFMACRO "Defines name as a macro by associating a macro
function with that name in the global environment. The macro function
is defined in the same lexical environment in which the defmacro form
appears."

The "same lexical environment" part to me says that it should be able
to find the function NONSENSE, but maybe the contract only applies to
stuff appearing outside of the quasiquote, not sure.


Helmut, what's the right behavior for DEFMACRO?

--
Jamison Hope
The PTR Group
www.theptrgroup.com






reply via email to

[Prev in Thread] Current Thread [Next in Thread]