EndOfStream unused

Jason Johnson jason.johnson.081 at gmail.com
Thu Nov 8 17:12:40 UTC 2007

On Nov 7, 2007 4:59 AM, Matthew Fulmer <tapplek at gmail.com> wrote:
> as an aside, Exception handling isn't really squeaky, in that it
> is hardly used at all in most code. More commonly used is stuff
> like custom control structures:
> Dictionary>>at:ifAbsent:
> Dictionary>>at:ifPresent:
> Object>>ifNil:

+1.  I have traditionally been a big user of exceptions but so far in
my Squeaking I have not used them once.  I find the #ifError: type
construct very nice, as I'm usually just interested in return from a
location a few stack frames up in the case of error anyway.  It's much
more code to do:


  [ codeThatCallsThreeMethodsThenCrashes ] on: Error do: [ ^ nil ]

then just:

codeThatCallThreeMethodsThen: [ ^ nil ]

I realize that means this handler has to be passed to several methods,
but usually these methods are themselves an external protocol, so it
makes sense for them to have the handler anyway.

I think it's potentially a good idea to have stream do this common
behavior, i.e.:

  ^ self nextIfAtEnd: [ ^ nil ]

Stream>>nextIfAtEnd: anEndBlock
  " ... "

More information about the Squeak-dev mailing list