From: Timothy J. H. <tim...@ma...> - 2004-04-04 17:58:31
|
On Apr 3, 2004, at 4:19 PM, david wrote: > > if I create a java object in a let > > (let ((o (java.util.Hashtable.))) ..blah o ) Since "let" is a macro, this gets converted to ( (lambda (o p q ..) ...blah o) (java.util.Hashtable.) ... ) So the o,p,q,... are put into a lexical environment and bound to their corresponding values in the "let" The body is then evaluated (...blah o) and at the end the lexical symbol "o" is evaluated and its value is returned. The lexical closure then will be garbage collected unless it gets captured during the evaluation of the body and is reachable from non-garbage, eg. (define f (let ((o (java.util.Hashtable.)) (y (java.util.Hashtable.)) ) (set! g (lambda(z) (list o y z))) o )) but in normal situations the lexical environment will be garbage collected ... (define f (let ((o (java.util.Hashtable.)) (y (java.util.Hashtable.)) ) (.put y 'a 1) (.put o 'b y) o )) Does this help?? ---Tim--- > > and return that object so that a reference to it > is saved , does this prevent other objects > in the let from being garbage collected? > > davud > > > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > Jscheme-user mailing list > Jsc...@li... > https://lists.sourceforge.net/lists/listinfo/jscheme-user |