No fall-through for switch (WAS: Re: [Submission] D Slices)

bearophile bearophileHUGS at lycos.com
Tue May 31 15:36:15 PDT 2011


Andrei:

> Currently the best proposed behavior is to only require control flow if 
> there is actual code before it. So adjacent case labels don't require 
> any. Your example code would work unmodified.

On the other hand this offers two different ways to write the same thing, because the empty ones can be already be written separated by comma:

case FILE_NEW,
     FILE_OPEN,
     FILE_SAVE,
     FILE_SAVE_AS,
     case EDIT_UNDO:

In Python Zen rule says: "There should be one-- and preferably only one --obvious way to do it.".

Bye,
bearophile


More information about the Digitalmars-d mailing list