* Lexical environment for functions?
@ 2014-12-27 17:11 David Kastrup
2014-12-28 0:10 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: David Kastrup @ 2014-12-27 17:11 UTC (permalink / raw)
To: emacs-devel
I read
eval is a built-in function in `eval.c'.
(eval FORM &optional LEXICAL)
Evaluate FORM and return its value.
If LEXICAL is t, evaluate using lexical scoping.
LEXICAL can also be an actual lexical environment, in the form of an
alist mapping symbols to their value.
[back]
Does that mean that lexical environments exist only for value cells? No
function cells? Because it would seem convenient, if one has some
Lisp-like presentation of a parse tree like XML, to just eval it with a
number of function bindings in place.
Does one need to create an obarray for each kind of interpretation and
reread the input with the changed obarray in place?
--
David Kastrup
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Lexical environment for functions?
2014-12-27 17:11 Lexical environment for functions? David Kastrup
@ 2014-12-28 0:10 ` Stefan Monnier
2014-12-28 6:40 ` David Kastrup
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2014-12-28 0:10 UTC (permalink / raw)
To: David Kastrup; +Cc: emacs-devel
> Does that mean that lexical environments exist only for value cells?
Yes, at least for the "native" lexical binding.
> Because it would seem convenient, if one has some
> Lisp-like presentation of a parse tree like XML, to just eval it with a
> number of function bindings in place.
Just like you could simulate the new (eval E ENV) form via
(eval `(lexical-let ,ENV ,E)), you can do the above with
(eval `(cl-flet FENV E)).
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Lexical environment for functions?
2014-12-28 0:10 ` Stefan Monnier
@ 2014-12-28 6:40 ` David Kastrup
0 siblings, 0 replies; 3+ messages in thread
From: David Kastrup @ 2014-12-28 6:40 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> Does that mean that lexical environments exist only for value cells?
>
> Yes, at least for the "native" lexical binding.
>
>> Because it would seem convenient, if one has some
>> Lisp-like presentation of a parse tree like XML, to just eval it with a
>> number of function bindings in place.
>
> Just like you could simulate the new (eval E ENV) form via
> (eval `(lexical-let ,ENV ,E)), you can do the above with
> (eval `(cl-flet FENV E)).
cl-flet is optimized for compilation rather that interpretation. So
this is not likely to make eval a good idea for fast interpretation of
parsed expressions.
--
David Kastrup
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-12-28 6:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-27 17:11 Lexical environment for functions? David Kastrup
2014-12-28 0:10 ` Stefan Monnier
2014-12-28 6:40 ` David Kastrup
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.