[Issue 3825] AAs entries are default initialized before the new value is evaluated
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jan 12 08:58:07 PST 2013
http://d.puremagic.com/issues/show_bug.cgi?id=3825
--- Comment #6 from bearophile_hugs at eml.cc 2013-01-12 08:58:03 PST ---
Hara, I am reading the discussions in Pull 1465, and I have to say I use this
kind of code all the time:
aa[x]++;
It's very handy. It's similar to a Python defaultdict:
>>> from collections import defaultdict
>>> d = defaultdict(int)
>>> x = 'c'
>>> d[x] += 1
>>> d
defaultdict(<type 'int'>, {'a': 1})
If you disallow that If you disallow that, I will have tons of broken code. And
I have to replace:
aa[x]++;
With:
if (x in aa)
aa[x]++;
else
a[x] = 0;
This makes D code longer, and it doesn't make it safer.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list