[Glass] [Pharo-dev] printString and asString

Otto Behrens otto at finworks.biz
Fri Jan 3 03:24:41 PST 2014


> #printString and #printOn: protocol should be used for printing and #asString for conversion. This implies that #asString should not depend on #print protocol.

Ah, I used it the other way around: printOn depends on asString. I saw
'conversion' as the lower level.

Why do you distinguish here between conversion and 'printing'?
Especially if displayString is being replaced with asString - to me
that sounds against your thinking in principle.

> If we are going to use #asString to mimic #displayString (instead of as a conversion method) then to me #asString should be viewed at a higher level abstraction than #printOn:. If not then we can run into these issues when calling the higher-level abstraction from a lower level in the same objectt, as you mentioned. Calling #printString from #asString from an API perspective should not cause issues (as displaying something is very different from converting something) so I’d say this is an API design problem.

Yes, I think the API could be clearer. So this becomes the essence of
the question here: What is the meaning of these methods from an API
perspective?

Thanks for the response


More information about the Glass mailing list