No more fall through in case statement?

Janice Caron caron800 at googlemail.com
Thu Jan 3 07:20:42 PST 2008


On 1/3/08, Dan <murpsoft at hotmail.com> wrote:
> It's creative, and syntactically coherent.  I like it.  Even if it breaks my old programs, this one makes sense.  : )

I don't think it would break any old programs at all (which means,
maybe it has a fighting chance of getting accepted?). All old and
existing code would behave exactly as before, without change. That's
because the new behaviour would only come into effect if you used the
new syntax. Specifically:

    case x:

(with a colon) implies the existing C behavior - keep executing code
until you reach a break, a continue, or a right-brace. Wheras:

    case x { /*...*/ }

(without a colon, but with a left-brace) would mean to execute only
that which was within the braces. This construction will never occur
in old code, because in existing switch/case syntax, the colon in
mandatory.



More information about the Digitalmars-d mailing list