No more fall through in case statement?
Daniel Lewis
murpsoft at hotmail.com
Sat Jan 12 03:07:29 PST 2008
Janice Caron Wrote:
> On 1/12/08, Robert DaSilva <sp.unit.262+digitalmars at gmail.com> wrote:
> > Yes, but it would be 'A' .. 'Z' not 'A' ... 'Z'.
>
> In D parance, that would mean 'A' to 'Y' inclusive, but excluding 'Z'.
>
> (The three dot form could be used to mean "inclusive" though)
Not only;
it would violate the 0..length meaning, and he also failed to recognize the syntax we've been pushing for to distinguish the new switch from the old.
The new one looks like this:
switch(x) {
case(y) {
}
case (z) {
}
case (a) {
}
}
Why?
1) It's more consistent with other structured D statements.
2) It differentiates it from the old way in our minds
3) It allows us to support both ways for a transition period.
4) The {} is syntactically associated with only affecting what's inside, while : is used to mean "everything after here" which is semantically correct.
Regards,
Dan
More information about the Digitalmars-d
mailing list