all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Evaluate a closure in a subprocess?
@ 2015-08-09 16:06 Klaus-Dieter Bauer
  2015-08-09 17:29 ` Stefan Monnier
  0 siblings, 1 reply; 2+ messages in thread
From: Klaus-Dieter Bauer @ 2015-08-09 16:06 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1143 bytes --]

Hello!

Currently `lambda' forms evaluate to a `closure' form in lexical
environments, where the first element after the 'closure symbol represents
the lexical environment.

The documentation clearly states that this form shouldn't be relied on, so
e.g. extracting the lexical environment from the closure form is not
future-proof (i.e. using (cadr (lambda ())) as an equivalent to python's
locals() function).

However, the current implementation also allows passing a closure, or even
its byte-code representation, as a string to a different emacs process and
evaluate it there, preserving the values of the captured lexical
environment, e.g.

    (call-process "emacs" nil (current-buffer) nil "--batch" "--eval"
      (format "(print (funcall (quote %S)))"
        (let ((lp load-path))
          (lambda () lp))))

I currently use a similar construct for compiling emacs lisp files in a
clean emacs session (since a long-running session may contain artifacts
that mask or cause errors).

So I was wondering if this is an intended behaviour or also a side-effect
of the current implementation that may change at any time.


regards, Klaus

[-- Attachment #2: Type: text/html, Size: 1489 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-09 17:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-09 16:06 Evaluate a closure in a subprocess? Klaus-Dieter Bauer
2015-08-09 17:29 ` Stefan Monnier

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.