www.digitalmars.com         C & C++   DMDScript  

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

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 puremagic.com
        ReportedBy: qwertie256 gmail.com



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

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