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

Bert Freudenberg bert at freudenbergs.de
Tue Jul 15 20:44:09 UTC 2008


Am 15.07.2008 um 13:23 schrieb nicolas cellier:

> 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:  
> #DependentsFields).

You are right, I was mislead by Object>>dependents ...

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


... and you are right again.

- Bert -




More information about the Beginners mailing list