[UI] Streams - a beginning

Bill Schwab BSchwab at anest.ufl.edu
Mon Nov 26 17:42:38 UTC 2007


Hello all,

I am open to suggestions, but I do not see a non-breaking way to get
stream behavior that is consistent with other dialects.  In particular,
to get #next to signal an error on exhaustion.  Squeak's #next: acts
like what others call #nextAvailable:.  IM(NS)HO, the others have it
right.  If a protocol calls for 41 characters to remain in a stream, I
want to be able to read 41, and would like to be warned if there are
fewer remaining.  If I do not care, #nextAvailable: allows me to
"authorize truncation."  Truncating silently can lead to the same kinds
of problems that (rightly) doomed "defensive programming."  Exceptions
offer the solution.

Attached is a beginning of an alternate stream heirarchy; it adds
classes vs. replacing them.  There are no file streams as yet.  One of
my design goals will be to get the user interaction out of the latter.  

My recommendation for working out of #next's Squeaky behavior is to add
#nextIfNone: that takes a block, and #nextOrNil.  It would then be a
relatively simple task to clean up many of the nil-checking sends of
#next.

Please take a look and let me know what you think.  Suggestions for
tests would be greatly appreciated.  If you can see a way to integrate
something like this into Squeak w/o pain, please let me know.

Bill



Wilhelm K. Schwab, Ph.D.
University of Florida
Department of Anesthesiology
PO Box 100254
Gainesville, FL 32610-0254

Email: bschwab at anest.ufl.edu
Tel: (352) 846-1285
FAX: (352) 392-7029

-------------- next part --------------
A non-text attachment was scrubbed...
Name: EndOfStreamTests.1.cs
Type: application/octet-stream
Size: 13411 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/ui/attachments/20071126/7ac0f184/EndOfStreamTests.1.obj


More information about the UI mailing list