Hi,

I noticed that the following doesn't work in Chicken:

(define a 42)

(define (foo b)
    (let ((c (+ b 1)))
        (let ((env (interaction-environment)))
            (eval '(+ a b c) env))))
            ; doesn't work with or without the env.

(print (foo 3))

Error: unbound variable: b

I would expect eval to "know" about b and c as well. The manual, however, points out that it uses (interactive-environment) by default.

A few questions:

1. Why is (interactive-environment) the default? (Or, why doesn't eval have access to all the variables that "regular" code would have?)

2. Is it possible to get the "local environment" (which should have access to b and c)? Is there even such a thing, or am I seeing this completely wrong?

3. Are there other ways to make this work? I am aware of the environments egg, but having to manually add values to an environment does not sound very appealing. :-(

Of course, it's possible that I completely misunderstand the subject, in which case I would love to be enlightened. :-)

Thanks!

--
Chicken Monk
"God loves ya. And she loves me too."



_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to