while(...){ ... }else ...

via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 18 10:16:45 PST 2015


Unfortunately, this would break existing code:

     if(some_condition)
         while(some_other_condition) {
             // ...
         }
     else
         // ...

Currently, the `else` branch belongs to the `if`; with your 
proposal, it would belong to the `while`.

An `else` always attaches to the closest construct where it can 
be accepted; AFAICS, this cannot be changed without making the 
language grammar context-sensitive (it would require parsing 
`while` inside an `if` differently from other `while`s).


More information about the Digitalmars-d mailing list