all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Klaus-Dieter Bauer <bauer.klaus.dieter@gmail.com>
To: emacs-devel@gnu.org
Subject: Evaluate a closure in a subprocess?
Date: Sun, 9 Aug 2015 18:06:18 +0200	[thread overview]
Message-ID: <CANtbJLEC7Ka_iN5zvzKe5RnBAZ_rVZ3SVHB9bfDpmbS9Xi6Xjw@mail.gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2015-08-09 16:06 UTC|newest]

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

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=CANtbJLEC7Ka_iN5zvzKe5RnBAZ_rVZ3SVHB9bfDpmbS9Xi6Xjw@mail.gmail.com \
    --to=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.