Way of indicating an error

Brian Rice water at tunes.org
Mon Feb 26 17:38:20 UTC 2007


On Feb 26, 2007, at 8:54 AM, Damien Cassou wrote:

>> 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.

That reminds me, in Common Lisp, the stream object itself or some  
derived value could often be used as an end-of-stream marker since it  
is unlikely that a stream will contain itself (maybe a lazy stream  
would, but it doesn't cost *too* much to create a new lazy stream  
just to represent a continuation). Or, of course, you could make a  
special Exception type (which should note which stream has ended in  
case there is a nesting of stream exhaustions).

Have you also consulted Flow's Stream classes?

--
-Brian
http://briantrice.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20070226/1e4bd33c/PGP.pgp


More information about the Squeak-dev mailing list