From: "Damien Cassou" damien.cassou@gmail.com Reply-To: The general-purpose Squeak developers listsqueak-dev@lists.squeakfoundation.org To: "The general-purpose Squeak developers list"squeak-dev@lists.squeakfoundation.org Subject: Re: Way of indicating an error Date: Mon, 26 Feb 2007 17:54:53 +0100
But consider also how those same languages handle the problem of "item not found", whether it's not finding a substring in a larger string, an object in a collection, or a web resource. Nearly always, the programmer expects to check for the possibility that the item wasn't found, and so it's natural in those cases to return nil (or whatever) to say so. Only a few raise an exception when something isn't found. Smalltalk's common way of having an #...ifNotFound: block is another kind of exception handling.
What would you expect from iterating over #(1 nil 2) ? The second #next will return nil. But it does not indicate the end of stream.
-- Damien Cassou
Sounds easy then. If there is no suitable return value, then exceptions are the way to go. You might still provide #next:ifAtEnd: or some such in case the user has some other option.
_________________________________________________________________ Find what you need at prices youll love. Compare products and save at MSN® Shopping. http://shopping.msn.com/default/shp/?ptnrid=37,ptnrdata=24102&tcode=T001...