Where should I put a `condp` like function?
Nick Sabalausky
SeeWebsiteToContactMe at semitwist.com
Mon Apr 15 10:06:36 PDT 2013
On Mon, 15 Apr 2013 18:41:07 +0200
"Idan Arye" <GenericNPC at 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...];
...
}
More information about the Digitalmars-d
mailing list