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 19:35:21 +0100	[thread overview]
Message-ID: <87obu63zfa.fsf@fencepost.gnu.org> (raw)
In-Reply-To: 87wr8u40vg.fsf@fencepost.gnu.org

David Kastrup <dak@gnu.org> writes:

> Mark H Weaver <mhw@netris.org> writes:
>
>> Indeed, (local-eval '(set! x 5) <env>) is _not_ equivalent to
>> (module-set! (current-module) 'x 5).
>
> To clarify: I was thinking about
>
> (local-eval '(set! x 5) <env>) vs
> (local-eval '(module-set! (current-module) 'x 5) <env>)
>
>> Assuming that `x' is not locally bound within the captured lexical
>> environment, the first sets `x' in the module captured by
>> (the-environment), i.e. the module where `x' would have been set if you
>> had put (set! x 5) in place of (the-environment).  The second sets `x'
>> in the (current-module) at the time of evaluation.
>
> Yes, that would be what I would expect given the two local-eval calls
> above.

Let me check with my "reference hack" on Guilev1:

(define (my-eval form env)
  (call-with-current-continuation
   (lambda (x)
     (env (list x form)))))

(define-macro (my-env)
  (call-with-current-continuation identity))

(display
 (save-module-excursion
  (lambda ()
    (let ((env (my-env)))
      (set-current-module (resolve-module '(none)))
      (my-eval '(current-module) env)))))

=> #<directory (none) b786d380>

Even that agrees.  Not that I would be eager to analyze why.

-- 
David Kastrup




  reply	other threads:[~2012-01-14 18:35 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
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 [this message]
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=87obu63zfa.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).