Ryuichi OHORI <> changed:

           What    |Removed                     |Added
                 CC|                            |

--- Comment #11 from Ryuichi OHORI <> 2012-06-15 19:57:43 PDT 
(In reply to comment #9)
> I prefer the number 2. I think it breaks none of my programs.
> The number 3 is a trap, because it silently changes the semantics of old D
> code. And it's bug-prone for new D programmers too because they can change the
> variable by mistake. Generally immutable variables are safer.

In my point of view, as a newcomer to D, more bug-prone is the current

Foreach statement provides iteration over arrays, ranges, etc, and notation of
range "0..n" also *looks like* a collection. So, foreach range statements
should work like foreach over collection.

I have wrote to stuck in my program:
foreach (i; 0..M^^n)
    foreach (j; 0..n)
        a[j] = i % M;
        i /= M;
    // operations which use a but i
which I wrote in Python before:
for i in range(M**n):
    for j in range(n):
        a[j] = i % M
        i /= M
    # operations which use a but i
and was sad to see an infinite loop.

Even a new programmer *intends* to change the value of i when changing, if not
just a typo.
If someone want to affect loop, s/he can write
i = 0;
while (i < 10)
    // operations which change the value of i
    i += 1;

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to