On Mon, 15 Apr 2013 18:41:07 +0200 "Idan Arye" <generic...@gmail.com> wrote: > > Having D's `switch` be an expression is problematic, since D does > not have the convention of > blocks-returning-the-value-of-the-last-statement, and since D is > statically typed - adding this might cause unwanted implicit > conversions. > > Maybe it could be pulled off with a syntax similar to Scala: > switch(x){ > case 1 => ... > case 2 => ... > } >
Wouldn't it be possible to just simply choose between these two forms based on whether the switch is used where an expression is expected versus where a statement would be accepted?: switch(cond) { case 1: [...statements...] break; ... } vs switch(cond) { case 1: [...expression...]; ... }