Set>>add: should ignore nil argument

Andres Valloud sqrmax at cox.net
Sat Aug 14 01:05:04 UTC 2004


Hello Roel,

Friday, August 13, 2004, 12:55:03 AM, you wrote:

RW> Noooooooo !!! Do not start to use exceptions for this kind of control
RW> flow!!! It is not an exception. Making it an exception will get *us*
RW> into all kinds of trouble...

I agree :).

RW> I don't have the habit of adding nil to sets (or other things), as
RW> it is undefined (after all). So I didn't notice it :-) But I
RW> consider it really ugly to throw this exception. The fact that nil
RW> is used as a sentinel object is a real implementation detail, and
RW> should not become visible like this. I liked Lex's solution, BTW,
RW> but I don't have the time to do it.

It is handy to use nil as a sentinel value because the underlying
array is initialized to be full of it.  Having to manually set the
array to something else could create small performance issues when
changing the size of the set's internal array...

Anyway, AFAIK there's an example of using Object new as a sentinel
value in WeakSet.

Andres.




More information about the Squeak-dev mailing list