There is certainly room for both approaches, and reading from a stream is the 
more logical time to stop at the end of valid input.  There are times when I 
know the stream should be at its end, and I test for that in those cases.

Dolphin contains some *ToText classes that do some very useful things 
(supporting both direction via #leftToRight: and #rightToLeft:), especially 
DateToText and TimeToText, which have a #format aspect.  It's not really the 
same problem, but worth keeping in mind as we tackle this.

The short version, +1.

Bill



________________________________________
From: [email protected] 
[[email protected]] on behalf of Nicolas Cellier 
[[email protected]]
Sent: Sunday, October 30, 2011 12:07 PM
To: The general-purpose Squeak developers list; Pharo Development
Subject: [Pharo-project] readFrom: vs readFromString:

There is a huge mess in #readFrom: implementation.
Some classes will signal trailing characters as a bug, some other
won't and will simply leave the stream positioned after the valid
part.
I propose to change this behaviour uniformly:
- readFrom: aStream will never fail on trailing chars (hey, it's a
stream, it's up to sender to interpret the tail)
- readFromString: aString will always forbid trailing char (it's not a
stream, so this garbage is most probably an error and cannot be
ignored silently)

What do you think ?

Nicolas


Reply via email to