[Glass] printString and asString

Richard Sargent richard.sargent at gemtalksystems.com
Fri Jan 3 13:50:37 PST 2014


I agree with everything Martin wrote. He nailed it 100%.



Martin McClure-5 wrote
> #printString and #printOn:
> These should answer a human-readable description of the receiver. 

Human-readable does not necessarily mean appropriate for an end user. In
fact, it doesn't even guarantee the emitter's class can recreate an
equivalent object from the print string.



> #asString
> There should not be an Object>>asString. This message is *only* for
> converting string-like things to actual strings. 

This generalizes to families of objects, such as numbers allowing conversion
between different number representations. Again, conversions are not
guaranteed to be reversible. (Float to Integer, for example.)

Like Martin, I don't agree with the notion of #asString applying to every
object.



> #storeString
> Produces legal Smalltalk source code that when executed will produce an
> equivalent object to the receiver. Needs to be implemented only for
> objects that can be specified as literals in Smalltalk syntax, but could
> probably be implemented for a few other simple objects.

What Martin says is correct, but one /might/ want to override the default
implementation to produce more readable and more succinct representations.





--
View this message in context: http://forum.world.st/Glass-printString-and-asString-tp4733778p4734001.html
Sent from the GLASS mailing list archive at Nabble.com.


More information about the Glass mailing list