emacs-devel
[Top][All Lists]
Advanced

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

Re: Evaluate a closure in a subprocess?


From: Stefan Monnier
Subject: Re: Evaluate a closure in a subprocess?
Date: Sun, 09 Aug 2015 13:29:36 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> 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).

Not only it's not future proof, but it's neither present-proof nor
past-proof since it already breaks in Emacs-24.1 if you byte-compile
the code.

> 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.

As long as the free variables of your closure have values which are
linearizable/marshallable then I think it should work, yes.  Note that
it should work better if you byte-compile your code since in that case
the closure will only include the free variables, whereas if your code
is interpreted the closure includes the whole lexical environment (which
may hence include variables that aren't actually used by your closure
yet whose value is either unmarshallable or very large).
Of course, since closures include (byte-)code, the other side needs to
understand that same (byte-)code.


        Stefan



reply via email to

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