Set>>add:

Stephan Rudlof sr at evolgo.de
Mon Nov 11 00:05:05 UTC 2002


Nevin Pratt wrote:
> The final draft of the ANSI standard (and presumably the actual 
> standard) specifies that if the argument to #add: for Set is nil, the 
> results are undefined.
> 
> VisualWorks for this case just returns nil, and otherwise does nothing.
> Squeak throws an exception.

Raising an exception seems to be correct here: it says to you: 'Hey,
something has gone wrong here!'

> 
> GLORP appears to depend upon the VisualWorks behavior.

Why does GLORP adding nil to a Set and expecting it to silently do nothing?

> Since GLORP has 
> been ported to VA and Dolphin, I'm guessing that they also have VW's 
> behavior.  Thus, Squeak appears to be the odd-man out.
> 
> I personally am not a fan of exceptions, and use them very sparingly, if 
> at all.  And in this case, I personally prefer VW's behavior.

You can't rely on a behavior, which is defined as 'undefined'.

> 
> But I was curious what anybody else thought about this difference.
> 
> Comments?

Bad: changing throwing an Exception to silently do nothing.
Dirty: catching the Exception and simulating the VW behavior *then*.
Best: fixing the call to Set>>add: to not adding nil.

IMHO.


Greetings,

Stephan

> 
> Nevin
> 
> 
> 
> 
> 


-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3




More information about the Squeak-dev mailing list