Haskell

bearophile bearophileHUGS at lycos.com
Wed Aug 24 16:36:01 PDT 2011


Timon Gehr:

> Statement at line 40 is necessary to make 
> the /type inference/ work out, and such things are the reason I don't 
> usually turn warnings on.

I think this fools DMD, and removes the warning:
return assert(0, "Tried to get tail of empty list!"), List.init;
(Your coding style is really compact.)


>  Another example where warnings are a pita:
> 
> case "bla","blu","blo": // Warning: fallthrough
> case "xxx","yyy","zzz":
> 
> What the code expresses is: There are two cases, one occurs if the input 
> is bla blu or blo, and the other one if it is xxx or yyy or zzz. Those 
> cases should be handled the same way. (At least for now).
> goto case; is both unnecessary and ugly in that case.

Are you sure the DMD head gives a warning in that case?

This program shows me no warnings:

void main() {
    int c;
    switch (c) {
        case 1:
        case 2: break;
        default: break;
    }
}

Bye,
bearophile


More information about the Digitalmars-d mailing list