dmd 1.057 and 2.041 release
bearophile
bearophileHUGS at lycos.com
Mon Mar 8 12:23:17 PST 2010
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
More information about the Digitalmars-d-announce
mailing list