On 7 juin 2013, at 11:19, Pharo Issue Tracker wrote:
> A FogBugz case was edited by Stephane Ducasse.
>
> Case ID: 10840
> Title: WeakSet>>#size utterly broken
> Status: Resolved (Fix Review Needed)
> Category: Bug
> Project: Collection
> Area: Misc
> Priority: 3 - Must Fix
> Milestone: Pharo3.0: 30/03/2014
> Assigned To: Camille Teruel
>
> URL: https://pharo.fogbugz.com/f/cases/10840
>
> Last message:
> Please can you send a mail to the mailing-list so that we all discuss this
> problems.
Hello everyone,
WeakSet>>#size is broken as demonstrated by the following snippet:
set := WeakSet new.
set add: Object new.
Smalltalk garbageCollect.
set size. "answers 1 instead of 0"
That is because a WeakSet has no mean to know when its items get garbage
collected, and thus the tally cannot be updated.
So we need to override #size in Weak, I propose:
size
| counter |
counter := 0.
self do: [ :e | counter := counter + 1 ].
^ counter
But that it rather inefficient for such a simple query.
Any proposition?
The bug entry is: https://pharo.fogbugz.com/f/cases/10840
>
>
> If you do not want to receive automatic notifications anymore, change your
> preferences in the Options screen.
> (https://pharo.fogbugz.com/default.asp?pg=pgPrefs)