[Issue 11070] Allow auto statement in a switch statement

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 19 13:22:10 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11070



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-09-19 13:22:09 PDT ---
(In reply to comment #1)
> That's easy solved.

That's really ugly. It also gets twice as ugly if you have to use a static if.

> Usually common bodies for case statements are not a big problem in D.

Sometimes you have to call specific code for each of these cases, but then
follow them with a generic call. So you use a goto to a single label. At the
point of the label you won't know what the switch value is unless you stored it
somewhere, e.g. (pseudocode):

void main()
{
    switch (auto x = get)
    {
        case "a": handleA(); goto common;
        case "b": handleB(); goto common;
        case "c": handleC(); goto common;
        common: log_output(x); break;

        default:
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list