Set>>add: should ignore nil argument

Marcin Tustin mt500 at zepler.net
Fri Aug 13 11:07:23 UTC 2004


On Fri, Aug 13, 2004 at 12:38:46PM +0200, radoslav hodnicak wrote:
> On Fri, 13 Aug 2004, Richard A. O'Keefe wrote:
> 
> > Note that the ANSI Smalltalk standard says that a Set may not accept
> > nil elements, but it ALSO says that you CANNOT rely on it NOT accepting them.
> I've seen your arguments already when I searched for previous discussions
> on this subject. You are probably right, except, what you say has no
> practical consequences. Nobody's going to rewrite the collection libraries
> in all smalltalks to be correct, good and non-perverse. It is as it is.
> And I prefer having not correct, but compatible implementation to having
> not correct, but incompatible implementation.

    If your code relies on adding nil to fail quietly, then your code
will not be portable. If your code is written defensively, because
adding nil is undefined, then it should be able to handle an exception
being thrown.

    By Squeak throwing an exception, it becomes easier to detect why
adding an object not contained in a set doesn't cause the size to
increase. Really, exceptions are *always* better than silent failure



More information about the Squeak-dev mailing list