Does anyone know why #upToAll: '' returns a Stream instead of a
collection? E.g. try 'foo' readStream upToAll: ''. The code is crystal clear, but I don't understand the purpose. I came across this while looking what the Japanese locale stuff does. It overrides EncodedStream>>upToAll: to return self rather than an empty string. Obviously someone thinks this odd behaviour is important, but since none of the base senders of upToAll: provide an empty argument, it's hard to know why. Cheers, Steve |
Looks like a bug. I found a number of implementers of upToAll:
and 2 of them return "self" if the stream is empty -- I think these are bugs. One returns '' if the stream is empty, and the rest don't test for that special case. In all other cases they return some content of the stream. Steven Kelly wrote: > Does anyone know why #upToAll: '' returns a Stream instead of a > collection? E.g. try 'foo' readStream upToAll: ''. The code is crystal > clear, but I don't understand the purpose. > > I came across this while looking what the Japanese locale stuff does. It > overrides EncodedStream>>upToAll: to return self rather than an empty > string. Obviously someone thinks this odd behaviour is important, but > since none of the base senders of upToAll: provide an empty argument, > it's hard to know why. > > Cheers, > Steve > > -- Dennis Smith [hidden email] Cherniak Software Development Corporation +1 905.771.7011 400-10 Commerce Valley Dr E Fax: +1 905.771.6288 Thornhill, ON Canada L3T 7N7 http://www.CherniakSoftware.com |
Dennis Smith wrote:
> Looks like a bug. I found a number of implementers of upToAll: > and 2 of them return "self" if the stream is empty -- I think these are > bugs. > One returns '' if the stream is empty ...which is a bug, too. "(EncodedStream on: ByteArray new readStream encodedBy: #ucs2) binary upToAll: ''" should return a byte array, not a string |
Holger Kleinsorgen wrote: > Dennis Smith wrote: >> Looks like a bug. I found a number of implementers of upToAll: >> and 2 of them return "self" if the stream is empty -- I think these >> are bugs. >> One returns '' if the stream is empty > > ...which is a bug, too. Yes -- I was thinking that as I looked at it -- but was more interested in the self returns. I wonder if any other stream methods return things like that? ('' I mean) > > "(EncodedStream on: ByteArray new readStream encodedBy: #ucs2) binary > upToAll: ''" should return a byte array, not a string > -- Dennis Smith [hidden email] Cherniak Software Development Corporation +1 905.771.7011 400-10 Commerce Valley Dr E Fax: +1 905.771.6288 Thornhill, ON Canada L3T 7N7 http://www.CherniakSoftware.com |
In reply to this post by Steven Kelly
Holger Kleinsorgen [[hidden email]] wrote:
> Dennis Smith wrote: > > Looks like a bug. I found a number of implementers of upToAll: > > and 2 of them return "self" if the stream is empty -- I think these are > > bugs. > > One returns '' if the stream is empty > > ...which is a bug, too. > > "(EncodedStream on: ByteArray new readStream encodedBy: #ucs2) binary > upToAll: ''" should return a byte array, not a string OK, that's what I thought: rather than ^self or ^'' we should have an empty collection of the correct class (mutable and not shared with a CompiledMethod): ^self contentsSpecies new: 0 Steve |
In reply to this post by Steven Kelly
And indeed there appear to be ARs for both of these issues existing already (42762 and 50184). I'm not sure why the Japanese Locale code would override the behaviour back again.
At 07:30 AM 10/4/2006, Steven Kelly wrote: >Does anyone know why #upToAll: '' returns a Stream instead of a >collection? E.g. try 'foo' readStream upToAll: ''. The code is crystal >clear, but I don't understand the purpose. > >I came across this while looking what the Japanese locale stuff does. It >overrides EncodedStream>>upToAll: to return self rather than an empty >string. Obviously someone thinks this odd behaviour is important, but >since none of the base senders of upToAll: provide an empty argument, >it's hard to know why. > >Cheers, >Steve -- Alan Knight [|], Cincom Smalltalk Development [hidden email] [hidden email] http://www.cincom.com/smalltalk "The Static Typing Philosophy: Make it fast. Make it right. Make it run." - Niall Ross |
Free forum by Nabble | Edit this page |