News and problems about foreach loops
Peter Alexander
peter.alexander.au at gmail.com
Sat Nov 3 07:21:55 PDT 2012
On Saturday, 3 November 2012 at 14:04:45 UTC, bearophile wrote:
>
> A third solution is use idioms, and do not change D. It means
> that on default the programmer puts always a "const" in
> foreach. This avoids most bugs caused by fake Case3, and you
> don't use it in the uncommon true Cases3.
>
> There are few more alternative ways to face this problem.
> Including doing nothing :-)
I never use Case3, except accidentally. It's possibly the most
common language-caused bug in my D code.
That said, I'm not a fan of introducing new keywords or
introducing breaking changes in D code (even though I don't use
Case3). I think this might just be something we have to live
with, although making use of "const" idiomatic may be a good step
forward (unfortunately, it's more unnecessary typing, so it's
unlikely to catch on).
More information about the Digitalmars-d
mailing list