I should mention that I want to be able to nest the definitions, e.g.
(letrec ((foo <>)) (letrec ((bar <>)) (test <> res)))
where all the <>s should be evaluated in (test-library) extended with
definitions of foo and bar.

And the reason why I have thought eval is necessary is that I want to
be able to skip expressions that have (certain) undefined variables in
them... essentially I'm looking for an automatic way to determine
whether an expression should be tested based on the available exports
from the test library.

On Sun, Jun 14, 2009 at 11:27 AM, Ramana Kumar<[email protected]> wrote:
> I have an R6RS script file containing expressions like this
>
> (letrec ((foo (lambda args body-referencing-foo))) (test expr result))
>
> I want expr and body-referencing-foo to be evaluated in a particular
> environment extended with the binding for foo. How would you go about
> setting that up? I thought I had a solution involving using a custom
> macro in place of letrec, but it doesn't work.
>
> I can get expressions like
>
> (test expr result)
>
> on their own to behave the way I want, by using this macro (among other 
> things)
>
> (define-syntax test-eval
>  (syntax-rules ()
>    ((_ e)
>     (call/cc
>       (lambda (k)
>         (with-exception-handler
>           (lambda (x) (if (and (undefined-violation? x)
>                             (memq (condition-who x) valid-exports))
>                         (k (condition-who x))
>                         (raise x)))
>           (lambda () (eval 'e (environment '(rnrs) test-library)))))))))
>
> which gives you an idea of what I want to accomplish. The problem with
> this approach is that (environment '(rnrs) test-library) is immutable,
> but I need to add the definition of foo somehow.
>
> I look forward to seeing your ideas!
>

Reply via email to