[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Anything better for delayed lexical evaluation than (lambda () ...)?

From: Mark H Weaver
Subject: Re: Anything better for delayed lexical evaluation than (lambda () ...)?
Date: Wed, 14 Dec 2011 02:50:56 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

I have successfully implemented the (capture-lexical-environment)
special form in the evaluator, and also primitive-local-eval.
Here's a transcript from a test session:

  scheme@(guile-user)> (define env1 (primitive-eval '(let ((x 1) (y 2)) 
  scheme@(guile-user)> (primitive-local-eval 'x env1)
  $2 = 1
  scheme@(guile-user)> (primitive-local-eval 'y env1)
  $3 = 2
  scheme@(guile-user)> (primitive-local-eval '(set! x (+ x 10)) env1)
  $4 = 11
  scheme@(guile-user)> (primitive-local-eval 'x env1)
  $5 = 11
  scheme@(guile-user)> (define env2 (primitive-local-eval '(begin (set! x (+ x 
1)) (let ((z 3)) (capture-lexical-environment))) env1))
  scheme@(guile-user)> (primitive-local-eval 'z env2)
  $7 = 3
  scheme@(guile-user)> (primitive-local-eval 'x env2)
  $8 = 12
  scheme@(guile-user)> (primitive-local-eval 'y env2)
  $9 = 2

Note that in addition to the evaluator and memoizer environments, I also
needed to add an expander environment to the overall lexical environment

I will post a preliminary patch shortly.  It's fairly small.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]