[squeak-dev] Ideas about sets and dictionaries

Eliot Miranda eliot.miranda at gmail.com
Thu Nov 12 00:32:48 UTC 2009


On Wed, Nov 11, 2009 at 3:56 PM, Igor Stasenko <siguctua at gmail.com> wrote:

> @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
>
>
Neat.  It might be even easier to use floating point to indicate nil :)
So if
        tally class = SmallInteger
it doesn't include nil, but if
        tally class = Float
it does.  Once tally has been set to a Double all the loops still work,
increasing the tally still works, etc.

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.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20091111/a014eb24/attachment.htm


More information about the Squeak-dev mailing list