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@anest.ufl.edu Tel: (352) 846-1285 FAX: (352) 392-7029