all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Klaus-Dieter Bauer <bauer.klaus.dieter@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Evaluate a closure in a subprocess?
Date: Sun, 09 Aug 2015 13:29:36 -0400	[thread overview]
Message-ID: <jwvegjcz874.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CANtbJLEC7Ka_iN5zvzKe5RnBAZ_rVZ3SVHB9bfDpmbS9Xi6Xjw@mail.gmail.com> (Klaus-Dieter Bauer's message of "Sun, 9 Aug 2015 18:06:18 +0200")

> 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	other threads:[~2015-08-09 17:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-09 16:06 Evaluate a closure in a subprocess? Klaus-Dieter Bauer
2015-08-09 17:29 ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvegjcz874.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=bauer.klaus.dieter@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.