Jeffrey Siegal <email@example.com> wrote:
| Rob Warnock wrote:
| > | Global variables *can* be GC'd in an environment where there is no REPL,
| > | etc.
| > +---------------
| > Point taken, if by "no REPL, etc." you *also* mean "no eval", yes?
| I don't think so. As I mentioned that in another part of this thread,
| eval doesn't directly reference the symbol table (read, load,
| symbol->string do) and therefore, even in the presence of eval, the
| symbol table and symbols that are only accessible by name can be
| collected. So if the symbol that names a global gets collected, the
| global can get collected (assuming, as in the no-eval case, that there
| are no other references to the global), even with eval.
Hmmm... Seems to me this would a counterexample:
(eval '(define foo 37)
(collect-garbage) ; or anything else likely to cause one
(eval '(begin (display foo) (newline))
It's important not to collect *either* the symbol "foo" or
the global variable named by it between the two "eval" calls,
or the 2nd "foo" will get an "undefined variable" error.
So if you allow "eval", don't collect top-level variables or
any symbols which name them. You never know when you might
need them next.
 Or you'll lose object identity for the symbol and won't
be able to find the global.
Rob Warnock, 30-3-510 <firstname.lastname@example.org>
SGI Network Engineering <http://www.meer.net/~rpw3/>
1600 Amphitheatre Pkwy. Phone: 650-933-1673
Mountain View, CA 94043 PP-ASEL-IA
[Note: email@example.com and firstname.lastname@example.org aren't for humans ]