Andrei Alexandrescu:
> Your choice of leading/trailing symbols and of separators makes 'to' 
> friendlier for printing e.g. debug strings. My choice makes it a 
> primitive for text serialization. I'm not 100% sure which is the more 
> frequent use and therefore which is the most appropriate as a default, 
> but I'm leaning towards the latter.

Sorry for losing my temper about this in my last posts.
In Python they have faced this problem using two different things, str() and 
repr(), the first one produces a little more readable output, used for normal 
reading, and then second is a little more for textual serialization (But both 
use the []).
The shell outputs using repr(), the print uses str(), the items inside 
collections are always represented with repr().
Objects can define the __repr__ and __str__. Print calls the __str__. If 
__str__ is missing it's used __repr__.

I like handy defaults, they save time iff they are well chosen.

Bye,
bearophile

Reply via email to