[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] eval and local variables
From: |
Chicken Monk |
Subject: |
[Chicken-users] eval and local variables |
Date: |
Sat, 05 May 2007 12:27:41 -0400 |
User-agent: |
Thunderbird 2.0.0.0 (Macintosh/20070326) |
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] eval and local variables,
Chicken Monk <=