[Newbies] Re: What is a "weak" reference

nicolas cellier ncellier at ifrance.com
Tue Jul 15 20:23:57 UTC 2008

Bert Freudenberg a écrit :
> Am 15.07.2008 um 08:26 schrieb Herbert König:
>> Hello Randal,
>> RLS> dictionary.  This is how the classic "dependents" system works as 
>> well: the
>> RLS> dependencies are in a WeakDictionary so that when the watched 
>> object goes
>> RLS> away, the dependencies are also cleaned.
>> thanks for some free education (no smiley, I mean it), now I'll do
>> some homework and look up dependency.
>> I use it in some places without knowing of it's "weakness".
> The dependents are weak only for "regular" objects. Proper Models handle 
> their own dependents collection in a non-weak manner.
> - Bert -

Hmm, not really

"Warning: this example is stupid!"
| tmp |
tmp := Model new.
tmp addDependent: #x.
tmp addDependent: #y.
tmp dependents class. "=> DependentsArray"

DependentsArray is a class that holds weakly to its elements...

The difference is that the DependentsArray itself don't have to pollute 
the global WeakIdentityKeyDictionary (Object classPool at: 

But maybe we have just quit the beginners rails...


More information about the Beginners mailing list