[squeak-dev] Ideas about sets and dictionaries

Igor Stasenko siguctua at gmail.com
Wed Nov 11 23:56:37 UTC 2009


@Levente..
there is no need to introduce a 'containsNil' flag, nor use other than
nil filler object.
The tally ivar, which is already there can be used to reflect if set
contains nil:

tally >= 0  - set contains tally number of elements without nil
tally == -1 - set contains only single element - nil
tally < -1  - set contains a (tally abs) number of elements including nil

i can implement it, if you want.

The number of changes is quite minimal, and won't make image to die
violently, because:
 - currently all sets having tally >=0, so even if you change things
to support nils as i proposing, no existing sets having chances to
behave differently
 - currently all sets can't meaningfully include nil, and there is no
code which intentionally puts nil in sets, because it leads to error.

2009/11/12 Eliot Miranda <eliot.miranda at gmail.com>:
>
>
> On Wed, Nov 11, 2009 at 3:14 PM, Russell N Hyer
> <hrothgar.ofstingan at gmail.com> wrote:
>>
>> I still don't comprehend the purpose behind having more than one
>> flavour of empty in regards to empty set based mathematics.
>
> nil is an object like any other, and Sets can contain arbitrary objects.
> An empty Set contains no objects.  The fact that internally an empty Set has
> some slots intialized to nil is an implementation detail that in no way
> implies that it contains nil.
> So if sets are capable of including arbitrary objects they should be able to
> contain nil.  There are lots of contexts in which having collections that
> can include nil is useful.  The compiler is one.  Storing and reconstituting
> object graphs is another.
> Or in summary nil ~~ #isEmpty.
> HTH
> Eliot
>>
>> 2009/11/11, Igor Stasenko <siguctua at gmail.com>:
>> > Just want to add that enabling a set to contain nils already discussed
>> > before.
>> >
>> >
>> > http://n4.nabble.com/squeak-dev-Letting-Set-contain-nils-td69437.html#a69437
>> >
>> > ... and as you may guess, i supporting Levente in this :)
>> >
>> > --
>> > Best regards,
>> > Igor Stasenko AKA sig.
>> >



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list