Subject: Re: generational gc and large root set
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 17 Jan 2002 03:19:19 GMT
Newsgroups: comp.lang.scheme
Message-ID: <a25frn$4aa79$1@fido.engr.sgi.com>
Jeffrey Siegal  <jbs@quiotix.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:

	(begin
	  (eval '(define foo 37)
		(interaction-environment))
	  (collect-garbage) ; or anything else likely to cause one
	  (eval '(begin (display foo) (newline))
		(interaction-environment)))

It's important not to collect *either* the symbol "foo"[1] 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.


-Rob

[1] Or you'll lose object identity for the symbol and won't
    be able to find the global.

-----
Rob Warnock, 30-3-510		<rpw3@sgi.com>
SGI Network Engineering		<http://www.meer.net/~rpw3/>
1600 Amphitheatre Pkwy.		Phone: 650-933-1673
Mountain View, CA  94043	PP-ASEL-IA

[Note: aaanalyst@sgi.com and zedwatch@sgi.com aren't for humans ]