On 08/25/2011 01:36 AM, bearophile wrote:
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;

Thank you, that works. But I generally don't want to be fighting with the D compiler, that is what C++ is for. x)

> (Your coding style is really compact.)

It is especially compact in that program, because it is almost purely functional code. But it is true that there are typically many inline delegates in my code, that is why I have asked for more concise ones.



  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?

I am always waiting for releases, because I am too lazy to install the compiler myself. :) (polluting my path is not an option)


This program shows me no warnings:

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


Same for me, but try this:

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

I am starting to think this is not as intended.


Reply via email to