unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: David Kastrup <dak@gnu.org>
To: guile-devel@gnu.org
Subject: Re: A plea for local-eval in 2.0.4
Date: Sat, 14 Jan 2012 09:59:32 +0100	[thread overview]
Message-ID: <87r4z264nf.fsf@fencepost.gnu.org> (raw)
In-Reply-To: 87pqen6qho.fsf@netris.org

Mark H Weaver <mhw@netris.org> writes:

> Probably the easiest way to think about it is that (the-environment)
> acts like (list (lambda () <expr>) ...), with one `lambda' for each
> expression that you will later pass to `local-eval'.  Calling
> `local-eval' simply calls the appropriate procedure in that list.

Well, I experimented around a bit with lambda.  How does this work in
practice?  In Guilev1, the module is probably recorded as part of the
procedure-environment.  In Guilev2, a variable reference is compiled?
How does that work when there is no such variable?  It gets created with
an undefined binding?

> Calling the procedure created by a lambda expression evaluates the
> lambda body within the _lexical_ environment of the lambda expression,
> but within the _dynamic_ environment of the procedure call.  Top-level
> variables are part of the _lexical_ environment.  That means that
> top-level variable references within a procedure are looked up in the
> module where the procedure was defined, _not_ the (current-module) at
> the time of the procedure call.

Ok, here is the clincher and probably what I have actually confused this
with (it is a thin line): within local-eval, what is the return value of
calling (current-module)?  I would expect that it is the same as outside
of local-eval so that (define x 5) inside of local-eval would _not_ be
equivalent to (module-define! (current-module) 'x 5) as the first one
would take the current module at the-environment time, and the second
one would take it at local-eval time.

Correct?

-- 
David Kastrup




  reply	other threads:[~2012-01-14  8:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-12 21:43 A plea for local-eval in 2.0.4 Mark H Weaver
2012-01-12 23:02 ` Bruce Korb
2012-01-13  9:20 ` David Kastrup
2012-01-13 16:21   ` Mark H Weaver
2012-01-13 18:50     ` David Kastrup
2012-01-14  1:07       ` Mark H Weaver
2012-01-14  8:59         ` David Kastrup [this message]
2012-01-14 15:04           ` Andy Wingo
2012-01-14 15:16             ` David Kastrup
2012-01-14 15:33               ` Andy Wingo
2012-01-14 16:17           ` Mark H Weaver
2012-01-14 17:20             ` David Kastrup
2012-01-14 17:59             ` Mark H Weaver
2012-01-14 18:04               ` David Kastrup
2012-01-14 18:35                 ` David Kastrup
2012-01-14 19:04                 ` Mark H Weaver
2012-01-14 15:24 ` Andy Wingo

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

  List information: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=87r4z264nf.fsf@fencepost.gnu.org \
    --to=dak@gnu.org \
    --cc=guile-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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).