Why not all statement are expressions ?
Nick Sabalausky
SeeWebsiteToContactMe at semitwist.com
Mon May 7 13:27:17 PDT 2012
"Jacob Carlborg" <doob at me.com> wrote in message
news:jo98d1$frl$1 at digitalmars.com...
> On 2012-05-07 19:06, deadalnix wrote:
>> Hi,
>>
>> Working on D I noticed that some statement, notably assert, are
>> expression of type void. Why not all statement (that are not expression
>> already) are expression ?
>
> I would like that as well.
>
I'm usually fairly ambivalent about the idea of statements being
expressions, but I would *love* for switch to be usable as an expression.
For instance, in Haxe, you can do stuff like the following, which I get a
ton of use out of and often wish D had:
a = switch(b)
{
case 1: "foo";
case 2: "bar";
case 3: "baz";
case 4: "whee";
default: "blork";
}
The D equivalents aren't terrible, but they aren't nearly as nice.
More information about the Digitalmars-d
mailing list