[squeak-dev] readFrom: vs readFromString:
Sven Van Caekenberghe
sven at beta9.be
Sun Oct 30 16:21:23 UTC 2011
On 30 Oct 2011, at 17:07, Nicolas Cellier wrote:
> 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
> 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 ?
Will that not break the idiom (lazy implementation)
^ self readFrom: string readStream
BTW, what I miss in Smalltalk is a way to read from some position to another without all the terrible copying, either from a stream or from a string.
Consider parsing something like this '2011-10-30T17:17:47+01:00', the fields are fixed and pretty simple, but I can't think of an efficient way to do it, can you ?
More information about the Squeak-dev