Weakness

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Weakness

Ben Coman

I'd like to learn a bit more about the implementation of Weak objects.  
For example, I see...

Magnitude>LookupKey>Associaton >> key: aKey value: anObject
    key := aKey.
    value := anObject

Magnitude>LookupKey>WeakValueAssociaton >> key: aKey value: anObject
    key := aKey.
    self value: anObject
Magnitude>LookupKey>WeakValueAssociaton >> value: anObject
    self at: 1 put: anObject

Magnitude>WeakKeyAssociation >> key: aKey value: anObject
    self basicAt: 1 put: aKey.
    value := anObject

The class definitions don't look any different to normal?   I can see
that the weak classes are doing an  #at:put:  for their respective weak
attribute, but lots of non-weak classes also use that.
So what is it that makes   WeakValueAssociaton & WeakKeyAssociation   weak ?

cheers -ben

Reply | Threaded
Open this post in threaded view
|

Re: Weakness

Sven Van Caekenberghe-2
Magnitude weakSubclass: #WeakKeyAssociation
        instanceVariableNames: 'value'
        classVariableNames: ''
        category: 'Collections-Support'

weakSubclass: ...

On 06 Sep 2014, at 16:47, Ben Coman <[hidden email]> wrote:

>
> I'd like to learn a bit more about the implementation of Weak objects.  For example, I see...
>
> Magnitude>LookupKey>Associaton >> key: aKey value: anObject
>   key := aKey.
>   value := anObject
>
> Magnitude>LookupKey>WeakValueAssociaton >> key: aKey value: anObject
>   key := aKey.
>   self value: anObject
> Magnitude>LookupKey>WeakValueAssociaton >> value: anObject
>   self at: 1 put: anObject
>
> Magnitude>WeakKeyAssociation >> key: aKey value: anObject
>   self basicAt: 1 put: aKey.
>   value := anObject
>
> The class definitions don't look any different to normal?   I can see that the weak classes are doing an  #at:put:  for their respective weak attribute, but lots of non-weak classes also use that.
> So what is it that makes   WeakValueAssociaton & WeakKeyAssociation   weak ?
>
> cheers -ben
>


Reply | Threaded
Open this post in threaded view
|

Re: Weakness

Ben Coman
Sven Van Caekenberghe wrote:
Magnitude weakSubclass: #WeakKeyAssociation
	instanceVariableNames: 'value'
	classVariableNames: ''
	category: 'Collections-Support'

weakSubclass: ...
  

Oh! the shame....

Thanks Sven.
 
On 06 Sep 2014, at 16:47, Ben Coman [hidden email] wrote:

  
I'd like to learn a bit more about the implementation of Weak objects.  For example, I see...

Magnitude>LookupKey>Associaton >> key: aKey value: anObject
  key := aKey.
  value := anObject

Magnitude>LookupKey>WeakValueAssociaton >> key: aKey value: anObject
  key := aKey.
  self value: anObject
Magnitude>LookupKey>WeakValueAssociaton >> value: anObject
  self at: 1 put: anObject

Magnitude>WeakKeyAssociation >> key: aKey value: anObject
  self basicAt: 1 put: aKey.
  value := anObject

The class definitions don't look any different to normal?   I can see that the weak classes are doing an  #at:put:  for their respective weak attribute, but lots of non-weak classes also use that.
So what is it that makes   WeakValueAssociaton & WeakKeyAssociation   weak ?

cheers -ben