Lisp Machine Lisp had "#," which was like "#." but delayed executing the
form until load time. "#," was removed from Common Lisp because it was difficult for everyone to agree on what that meant exactly.
Stefan Monnier <monnier@iro.umontreal.ca> writes:
I've been toying with the idea of defining (in ELisp) `,` as a macro
which would "naturally" generalize the `,` of the backquote macro to its
meaning outside of backquotes:
(defmacro \, (exp)
(eval exp))
Then you have that
,`EXP
is equivalent to
EXP
at top-level as well.
AFAICT this is not done in Common-Lisp, so I'm wondering if there's
a particular reason why it is so, and whether other Lisps have adopted
such a thing (or not and why not),
Random unconnected thoughts:
Your simple defmacro above will be evaluating that expression in an environment other than the lexical one where the expression appeared.
Common Lisp has "#." which calls eval at read time.
Lisp Machine Lisp had "#," which was like "#." but delayed executing the
form until load time. "#," was removed from Common Lisp because it was difficult for everyone to agree on what that meant exactly.
Scheme allows you to write ",foo" anywhere and just reads it as
"(unquote foo)".
I always thought that it was an advantage in Common Lisp that ","
outside of a backquote was an error, because it would catch mistakes
where I missed a backquote somewhere -- similar to checking that my parentheses were balanced.
But you are proposing that a naked ",(+ x 5)" will be evaluated in an environment that does _not_ lexically surround the site where it
occurred.
> Common Lisp has "#." which calls eval at read time.
>
> Lisp Machine Lisp had "#," which was like "#." but delayed executing the
> form until load time. "#," was removed from Common Lisp because it was
> difficult for everyone to agree on what that meant exactly.
Hmm... these are quite different: the purpose of the above `,` is to be
able to build *code* at compile-time.
They seem pretty similar to me, actually. I can use "#." to build code
as well as data. Read-time and compile-time are pretty close to each
other in practice.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 86:13:37 |
Calls: | 6,658 |
Files: | 12,203 |
Messages: | 5,333,786 |