Message-ID: <32F7C43C.7263@ix.netcom.com>
Date: Tue, 04 Feb 1997 15:20:28 -0800
From: "Daniel S. Hayes" <dsh12@ix.netcom.com>
Reply-To: dsh12@ix.netcom.com
X-Mailer: Mozilla 3.01Gold (Win16; I)
MIME-Version: 1.0
Newsgroups: comp.lang.smalltalk
To: pviennea@foxboro.com
Subject: Re: [VW] WeakDictionary and become
References: <32F773AA.6159@foxboro.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 162.70.64.153
Lines: 57
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!cam-news-feed3.bbnplanet.com!news.bbnplanet.com!cam-news-hub1.bbnplanet.com!uunet!in2.uu.net!162.70.244.3!dns.amsinc.com!162.70.64.153

Paul Vienneau wrote:
> 
> Lets say we have 3 objects (A, B, and C).  A refers to B via an
> instance variable, and B refers to C via and instance variable.
> Also, lets assume I've anchored A somehwere through a strong reference.
> Now lets store A, B and C in a WeakDictionary.
> 
> If we inspect the dictionary we see three entries for A, B, and C.
> Everything is great so far.  Now lets do the following
> 
>         B become: D
> 
> At this point I have assumed the following:
> 
>         A now references D.
>         Both B and C are garbage collected (probably incorrect assumption).
> 
> However, if I inspect the WeakDictionary again, I see A, D, and C.
> 
> My question is, why didn't C get removed from the WeakDictionary?
> _____________________________________________________
> Paul Vienneau           E-Mail: pviennea@foxboro.com
> Software Engineer       Phone:  (508) 549-2052
> The Foxboro Company     Fax:    (508) 549-6788

Maybe D is now referencing C?

Take a look at what I cut from the Smalltalk Archives:

Bug 8:  become:

become: is a very powerful operation.  It is easy to destroy your image
with it.  Its main use is in growing collections (see bug #1), since
it can make every reference to the old version of a collection become a
reference to the new, larger version.  It has slightly different
semantics
in Smalltalk/V and Smalltalk-80, since "x becomes: y" causes every 
reference to x and y to be interchanged in Smalltalk-80, but does not
change any of the references to y in Smalltalk/V.

Suppose that you want to eliminate all references to an object x.
Saying "x becomes: nil" works fine in Smalltalk/V, but will cause
every reference to nil to become a reference to x in Smalltalk-80.
This is a sure calamity.  You want x to become a new object with no
references, such as in "x becomes: String new".


Later,

-- 
Daniel S. Hayes (VW 2.5)
American Management Systems (AMS)
12601 Fair Lakes Circle
Fairfax, VA  22033
703-227-5615 w
800-242-8143 x5615 (work voice mail)
mailto:dsh12@ix.netcom.com
