[plt-scheme] namespaces and environments
On Jun 25, Corey Sweeney wrote:
> now, I was wondering if there's somthing that would let you pull
> from the current environment, so i could do:
>
> > (let ((x 4))
> (namespace-defined? 'x))
>
> and get #t. (it currently returns #f, cause i think it only checks
> the top level environment)
Yes, and there will not be a way to do that. The thing that you
should be aware of is that once code is compiled, names do not matter,
and so they disappear. For example, you can inspect the bytecode
representation of some expressions and see it:
> (compile '(let ((xyz 4)) (namespace-defined? 'abc)))
#~^C209^B+\201^^^Q\\200^N^A^Q^W?namespace-defined?^@^N^@^X éA\200^^^\0abc^A
You can see that `abc' appears there since it's part of the code, and
the same for `namespace-defined' -- but `xyz' is gone. (Your string
will be different when you require the library etc.)
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!