[Pharo-dev] printString and asString

Stéphane Ducasse stephane.ducasse at inria.fr
Fri Jan 3 12:49:08 EST 2014


>> So we don't have this in Pharo anymore. Looks like it is mostly
>> asString now. But then, really,
>> 
>> Object asString
>>  ^ self printString
>> 
>> does not make sense?

why not as a default?

> 
> I never fully understood the "intention" of #asString other than to
> convert the object to the String "protocol". But I don't use its
> answer for anything UI-dependant.
> 
> That's why I have my own #displayOn: and #displayString methods.

Indeed 
to me asString is a really a conversion method and we should not use it 
when we mean printString.

this is why there is a difference between

#foo asString -> ‘foo’
#foo printString -> ‘#foo’

now the problem with displayString is that it works only on few case: the case where you 
have a single nice textual representation. I think that in general the list or other should provide a hook
to display the items nicely.







More information about the Pharo-dev mailing list