it may look like you can make a single call to eval with '(let ((foo
<e1>)) <e2> <e3> <e4>), so let me change the example slightly:

(import (rnrs) (rnrs eval))
(define bar <>)
(let ((env (environment <>)))
  (bar (eval '(let ((foo <e1>)) <e2>) env))
  (bar (eval '(let ((foo <e1>)) <e3>) env))
  (bar (eval '(let ((foo <e1>)) <e4>) env)))

On Sun, Jun 14, 2009 at 3:46 PM, Ramana Kumar<[email protected]> wrote:
> Is it possible to write the equivalent of
>
> (import (rnrs) (rnrs eval))
> (let ((env (environment <>)))
>  (eval '(let ((foo <e1>)) <e2>) env)
>  (eval '(let ((foo <e1>)) <e3>) env)
>  (eval '(let ((foo <e1>)) <e4>) env))
>
> in such a way that the expression for foo is evaluated only once?
>
> One way would be to define foo in a library and pass that library's
> name to environment. Is there a portable R6RS way to create such a
> library for use just in this let expression (i.e. on the fly)? I think
> the answer is no. Is there another way to share the definition of foo
> between the evaled expressions?
>
> On Sun, Jun 14, 2009 at 1:48 PM, Ramana Kumar<[email protected]> wrote:
>> One alternative method may be to put my custom exception handler in a
>> macro and try to catch the undefined variables during expansion... I
>> am presuming expansion happens at the same time bindings are
>> checked/determined, so I can get a handle on any exceptions in time...
>>
>> On Sun, Jun 14, 2009 at 12:21 PM, Ramana Kumar<[email protected]> wrote:
>>>> Maybe I don't understand the problem you're trying to solve and why you
>>>> need all the heavy-weight machinery that you're using.
>>>
>>> Yeah I wasn't clear that the issue here is handling undefined
>>> variables. If I didn't worry about skipping expressions with undefined
>>> variables, I could just (import (test-library)) at the top of the
>>> script and let evaluation take its normal course. At present I am not
>>> importing test-library into the testing script, rather I am using
>>> test-library as an argument to eval which is called in the testing
>>> script.
>>>
>>
>

Reply via email to