This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: eval inside let
thi <ttn@mingle.glug.org> writes:
> Ceri Storey writes:
>
> > I'd guess i'm missing something here. Any help would be much appreciated.
>
> `local-eval' takes two args, the first an expression and the second a
> macro that references the environment to be considered "local". at
> least, this is what i get from reading libguile/debug.c... anyway, try:
>
> (let ((foo 'bar)) (local-eval (display foo) the-environment))
>
> note that you don't need to quote the first arg. (hmm, when i use a
> quote, guile seems to hang -- does anyone else see this?)
Note that local-eval is a procedure, which means that
(local-eval (display foo) <env>)
will evaluate #<unspecified> (the result of display) to
#<unspecified>.
The interesting case is the quoted one.
The hang is because you try to use a macro (the-environment) as
environment. It should be
(local-eval '(display foo) (the-environment))
The second arg to local-eval should be error checked. But
environments are currently explicitly represented as a list structure,
and it is too costly to check that such a structure is well formed.
The way to solve this is to wrap environments in a smob whenever they
occur on the Scheme level. This has been implemented in scm.