Ok. Question was from Martin. What behaviour we want from WeakValueDictionary for garbaged values?
dictionary := WeakValueDictionary with: 'hello' -> 'world' copy. > Smalltalk garbageCollect. > { > dictionary values includes: nil. > dictionary at: 'hello'. > dictionary at: 'hello' ifAbsent: [ 'absent' ]. > dictionary at: 'hello' ifAbsentPut: [ 'put' ]. > } > is: > #(true nil nil nil) My opinion is: it should work in same way when 'hello' item is absent. It is intuitive for me and It would be consistent to WeakSet behaviour: set := WeakSet with: Object new. Smalltalk garbageCollect. set includes: nil "=>false" But after writing it I realized how much WeakSet is inconsistent: set := WeakSet with: Object new. Smalltalk garbageCollect. set isEmpty. "=>false" set size. "=>1". set anyOne. "=> nil" set includes: nil. "=>false" set collect: #yourself. "=>a WeakSet()" We definitely have something to improve here. 2017-02-21 13:36 GMT+01:00 Guillermo Polito <guillermopol...@gmail.com>: > Everything has a tradeoff. I do not understand the question. > > On Tue, Feb 21, 2017 at 1:19 PM, Denis Kudriashov <dionisi...@gmail.com> > wrote: > >> >> 2017-02-21 13:07 GMT+01:00 Guillermo Polito <guillermopol...@gmail.com>: >> >>> But in any case, whatever the alternative you give users, they must >>> understand the tradeoff. If all Weak*Dictionaries were subscribed by >>> default to the weak registry for cleanup, that would provoke a lot of >>> overhead during garbage collection. >>> >> >> So you think my suggestion for implementation will lead to some tradeoff? >> What exactly? (if yes). >> > >