www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8223] New: "auto break" switch proposal


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

--- Comment #0 from David Piepgrass <qwertie256 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: -------
Jun 11 2012