[Issue 8223] New: "auto break" switch proposal

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 11 10:50:18 PDT 2012


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

           Summary: "auto break" switch proposal
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: qwertie256 at gmail.com


--- Comment #0 from David Piepgrass <qwertie256 at gmail.com> 2012-06-11 10:52:26 PDT ---
The switch statement is somewhat tedious due to the need for "break" on every
case. It's needed for C compatibility, but it would be nice to be able to
request that cases break automatically. Hence, something like:

    switch(z) auto break
        {
        case 0:       writeln("empty!");
        case 1, 2:    writeln("small!");
        case 3, 4, 5: writeln("medium!");
        default:      writeln("large!");
    }

In case empty cases are adjacent, such as "case 1: case 2:", D should logically
make "case 1" a no-op, but warning should be issued because this is the C#
syntax for "case 1, 2:". e.g.:

warning: "case 1" does nothing. To clarify your intention, use "break" or "case
1, 2".

-- 
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