On 08/19/2010 09:53 PM, Stéphane Ducasse wrote:
What would you say the right thing is?
Well, intuitively I would say that converting an Array of Character instances (say 5 instances)
using "asString" would give me a String of size 5. Also, "Character space
asString" does NOT give me 'Character space' but actually ' '.
Maybe its just me, but I'd rather not have
SequenceableCollection>> asString mean "If I contain only elements which may
represent characters, return a string containing those, if not, return my printString"
yes you are not the only one. Thanks I was thinking about that after my post :)
Having a fallback on printString is of course fine, in Object. But... well, I
haven't thought *deeply* on this, but a sequencable collection of Characters
should IMHO be able to produce a String
regards, Göran
And it is, using either
collection as: String, or
String withAll: collection
In both cases you then explicitly specify that this collection will contain only elements
which can be converted to a string, rather than have a later reader of the code have to
question "hmmm, does the use of asString here mean he'll be using the collections
printString, or the string with its elements?"
I'm curious about the senders of asString, especially to collection.
Stef
I am all in agreement I think, my gut reaction was that, darn, something
is broken. But perhaps sending asString to a Collection of objects
should... well, what *should* it return?
I think possibly one of the problems in all this is the fallback on
printString - that has clearly muddled the waters IMHO. #printString is
for the tools, it should give a "readable representation". But #asString
is a conversion method - it should give me IMHO the most reasonable
conversion for further "use".
I agree that #as: etc might be a "better" protocol, but let's say we
still want #asString to work for Collections and NOT fall back on
#printString - then what should it do?
regards, Göran
_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project