[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: |
David Kastrup |
Subject: |
Re: Anything better for delayed lexical evaluation than (lambda () ...)? |
Date: |
Sun, 11 Dec 2011 10:33:50 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) |
Marco Maggi <address@hidden> writes:
> David Kastrup wrote:
>> Hi, if I have something read that is evaluated later, the
>> lack of procedure-environment in Guilev2 implies that I
>> have to wrap the stuff in (lambda () ...) in order to
>> capture the lexical environment for evaluation.
>
> Sorry to step in without an answer. What are you trying to
> do? What I understand is that a Scheme program reads some
> expressions and tries to evaluate them in a specific context
> of the program. Are you looking for a way to do something
> like the following chunk I found on the Net?
>
> (define x 0)
> (define clo
> (let ((x 1))
> (lambda () '())))
> (local-eval 'x (procedure-environment clo))
> => 1
It is more like
(define (myeval what)
(let* ((x 1)
(clo (procedure-environment (lambda () #f))))
(local-eval (read (open-input-string what)) clo)))
(myeval "(+ x 3)")
Basically a string evaluation of a string that will be captured with
read-hash-extend in our application.
In practice, _both_ the environment created by (let* ((x 1)) ...) as
well as the string to be interpreted later are written by the user, but
they are spliced together at quite different points of time since the
environment from which the string for myeval gets delivered is available
only when the definition is being executed, not yet at its definition
time.
Basically I need to evaluate dynamic code in a given lexical environment
rather than at top and/or module level.
For a language that is supposed to be a building block for extension
languages, not really a concept that is all that unusual I would think.
--
David Kastrup
- Anything better for delayed lexical evaluation than (lambda () ...)?, David Kastrup, 2011/12/03
- Re: Anything better for delayed lexical evaluation than (lambda () ...)?, Andy Wingo, 2011/12/03
- Re: Anything better for delayed lexical evaluation than (lambda () ...)?, Thien-Thi Nguyen, 2011/12/06
- Re: Anything better for delayed lexical evaluation than (lambda () ...)?, Marco Maggi, 2011/12/06
- Re: Anything better for delayed lexical evaluation than (lambda () ...)?,
David Kastrup <=
- Re: Anything better for delayed lexical evaluation than (lambda () ...)?, David Kastrup, 2011/12/11
- Re: Anything better for delayed lexical evaluation than (lambda () ...)?, Mark H Weaver, 2011/12/12
- Re: Anything better for delayed lexical evaluation than (lambda () ...)?, David Kastrup, 2011/12/12
- Re: Anything better for delayed lexical evaluation than (lambda () ...)?, Mark H Weaver, 2011/12/12
- Re: Anything better for delayed lexical evaluation than (lambda () ...)?, David Kastrup, 2011/12/12
- Re: Anything better for delayed lexical evaluation than (lambda () ...)?, rixed, 2011/12/12
- Re: Anything better for delayed lexical evaluation than (lambda () ...)?, David Kastrup, 2011/12/12
- Re: Anything better for delayed lexical evaluation than (lambda () ...)?, Mark H Weaver, 2011/12/12
- Re: Anything better for delayed lexical evaluation than (lambda () ...)?, Mark H Weaver, 2011/12/12
- Re: Anything better for delayed lexical evaluation than (lambda () ...)?, Andy Wingo, 2011/12/12