[Submission] D Slices

Andrej Mitrovic andrej.mitrovich at gmail.com
Tue May 31 15:26:52 PDT 2011


On 5/31/11, KennyTM~ <kennytm at gmail.com> wrote:
> In D you'd write it as
>
>         case FILE_NEW, FILE_OPEN, FILE_SAVE, FILE_SAVE_AS, EDIT_UNDO:
>

Maybe. But if each case is going to have its own handler, it makes
sense to separate them each on its own line. Then as you implement
each case from top to bottom your commits might look like:

commit 1:

case FILE_NEW:
    handleFileNew();  // just finished writing handler
    break;
case FILE_OPEN:
case FILE_SAVE:
case FILE_SAVE_AS:
case EDIT_UNDO:
    throw new Exception();

commit 2:

case FILE_NEW:
    handleFileNew();
    break;
case FILE_OPEN:
    handleFileOpen();  // done with this now
    break;
case FILE_SAVE:
case FILE_SAVE_AS:
case EDIT_UNDO:
    throw new UnimplementedException();

Etcetera.. *But*, I wouldn't want my FILE_OPEN case to accidentally
fall through and throw an "UnimplementedException". So I'd be all for
a change in this regard.


More information about the Digitalmars-d mailing list