unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: David Kastrup <dak@gnu.org>
Cc: guile-devel@gnu.org
Subject: Re: A plea for local-eval in 2.0.4
Date: Sat, 14 Jan 2012 11:17:23 -0500	[thread overview]
Message-ID: <87ty3y5kdo.fsf@netris.org> (raw)
In-Reply-To: <87r4z264nf.fsf@fencepost.gnu.org> (David Kastrup's message of "Sat, 14 Jan 2012 09:59:32 +0100")

David Kastrup <dak@gnu.org> writes:
> 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

Actually, this is not true.  Within `local-eval', (current-module) is
temporarily restored (using dynamic-wind) to the module saved in the
lexical environment.

This is probably not optimal.  Among other things, it breaks the nice
equivalence <expr> == (local-eval '<expr> (the-environment)), but
`local-eval' and `local-compile' are based on `eval' and `compile', and
this is what `eval' and `compile' do (for some reason unknown to me).

> so that (define x 5) inside of local-eval

As Andy pointed out, I deliberately restrict the form passed to
`local-eval' (or `local-compile') to be an _expression_.  (define x 5)
is not an expression; it is a definition.  I explained the reason for
this restriction a few days ago[1] on this list.

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

Actually, because `local-eval' restores (current-module) to the one
saved in the lexical environment, (module-define! (current-module) 'x 5)
within `local-eval' actually defines the variable within the saved
module, i.e. the module used for lookup if you replace (the-environment)
with a top-level variable reference.

      Mark


[1] Message to guile-devel dated 08 Jan 2012 15:39:36 -0500, with
    subject "Re: [PATCH] Implement local-eval, local-compile, and
    the-environment"



  parent reply	other threads:[~2012-01-14 16:17 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
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 [this message]
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=87ty3y5kdo.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=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).