dmd 1.057 and 2.041 release
bearophile
bearophileHUGS at lycos.com
Mon Mar 8 12:41:15 PST 2010
Steven Schveighoffer:
> For completely unambiguous, yes. But still, I find often that quotes are
> more noise than they are worth when just doing simple printouts. What we
> want is the most useful default.
Quotes add a bit of noise, but I prefer to tell apart the cases of two strings from the case of one string with a comma in the middle.
> This would mean that strings have a special case of printing with quotes
> only when printed inside an array. This seems like an oddity to me.
It's how Python works, that's why there are __repr__ and __str__ for objects, the repr of a string includes the quotes, its __str__ doesn't.
>>> a = ["hello world", ["that's right!", "you"]]
>>> a
['hello world', ["that's right!", 'you']]
>>> print a
['hello world', ["that's right!", 'you']]
>>> a[0]
'hello world'
>>> print a[0]
hello world
Notes:
- that 'a' contains a string and an array of strings, you usually can't do this in D, so this is not a fully representative example;
- Python is dynamically typed, so it's more important that what you print shows its type. In D you can often tell it looking at type of the variable you print (unless it's hidden by a labyrinth of 'auto').
Bye,
bearophile
More information about the Digitalmars-d-announce
mailing list