Closed zellerin closed 9 years ago
I'm not sure I agree. But let's ask @hoytech:
Was it your intention with the anaphoric macros in the let-over-lambda code to have the lexical symbols exported with the top-level package symbols? The way they are written, don't they expand into the package namespace where the macro is called at compile time?
Why I think it should be: I cannot do (aif some-variable (fooize it) 'undefined)
in other package using lol, as it expands to
(LET ((LET-OVER-LAMBDA::IT SOME-VARIABLE))
(IF LET-OVER-LAMBDA::IT
(FOOIZE IT)
'UNDEFINED))
As you can tell, I didn't really think about packages in much detail when I wrote the book so, @thephoeron, thanks for working all this stuff out.
The reason the symbols aren't in the package where the macro is expanded is because symbols are resolved by the reader. In this case, the symbols are resolved when you load lol.lisp and are therefore interned in the let-over-lambda package since that is the package in effect when the defmacro form is read in. Even though the macro can be run later when a different package is in effect, the symbols in its backquote form have already been interned into the let-over-lambda package.
Here's a good description of packages and their corner cases in CL:
http://www.flownet.com/gat/packages.pdf
"The most important thing to understand about packages is that they are fundamentally a part of the Lisp reader and not the evaluator."
Without having thought about it in too much detail, I agree with @zellerin that if we export the aif symbol then we should also export the anaphoric it symbol. If you are importing so you don't have to type the lol in lol:aif, you also shouldn't have to type the lol in lol:it. Of course I'm open to any counter-arguments as well.
Thanks!
@hoytech: good points, and that is a particularly interesting quote you provided. I have exported the symbols IT
, THIS
, and SELF
as @zellerin requested.
Thanks to both, both for looking into this and for writing the book and keeping the code in general.
One minor correction to what @hoytech wrote (that probably does not change anything) - without export, you would not be able to write lol:it
, but only lol::it
.
@zellerin : Thanks, good point.
I believe the anaphoric names (it, this, self) should be exported.
Patch is trivial, but I can push it if wanted.