Re: Why not all statement are expressions ?

2012-07-15 Thread Stewart Gordon
On 07/05/2012 21:27, Nick Sabalausky wrote: snip I'm usually fairly ambivalent about the idea of statements being expressions, but I would *love* for switch to be usable as an expression. snip Switch cases are sequences of statements. Allowing them to alternatively be expressions would

Re: Why not all statement are expressions ?

2012-07-15 Thread bearophile
David Piepgrass: Or how about: auto area = { auto tmp = foo.bar(baz); tmp.width * tmp.height; } Rust is like that, but I don't see it as a significant improvement. I also wish void were a first-class type with sizeof==0 for maximum efficiency: int[void] intSet = [2:(),

Re: Why not all statement are expressions ?

2012-07-09 Thread David Piepgrass
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;

Re: Why not all statement are expressions ?

2012-07-09 Thread David Piepgrass
int[void] intSet = [2:(), 3:(), 4:()] oops, void[int] intSet = [2:(), 3:(), 4:()] rather.

Re: Why not all statement are expressions ?

2012-05-09 Thread Stewart Gordon
On 07/05/2012 18: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 ? Because it wouldn't make sense. The semantic of an ExpressionStatement is to evaluate

Re: Why not all statement are expressions ?

2012-05-09 Thread deadalnix
Le 07/05/2012 19:06, deadalnix a écrit : 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 want to pop this question. This is an important one. And nothing is documented

Re: Why not all statement are expressions ?

2012-05-09 Thread deadalnix
Le 09/05/2012 14:11, Stewart Gordon a écrit : On 07/05/2012 18: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 ? Because it wouldn't make sense. The

Re: Why not all statement are expressions ?

2012-05-08 Thread Jacob Carlborg
On 2012-05-07 22:37, deadalnix wrote: This won't work anyway. We are talking about language grammar here. If made expression, statement would be of type void. Just like assert is. Says who? :) -- /Jacob Carlborg

Re: Why not all statement are expressions ?

2012-05-08 Thread Don Clugston
On 07/05/12 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 ? assert isn't a statement. It's an expression ( same as is() ). What makes you think it's a

Re: Why not all statement are expressions ?

2012-05-08 Thread Timon Gehr
On 05/08/2012 10:46 AM, Don Clugston wrote: On 07/05/12 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 ? assert isn't a statement. It's an expression (

Re: Why not all statement are expressions ?

2012-05-08 Thread Jakob Ovrum
On Tuesday, 8 May 2012 at 18:30:08 UTC, Timon Gehr wrote: On 05/08/2012 10:46 AM, Don Clugston wrote: On 07/05/12 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

Why not all statement are expressions ?

2012-05-07 Thread deadalnix
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 ?

Re: Why not all statement are expressions ?

2012-05-07 Thread deadalnix
Le 07/05/2012 22:27, Nick Sabalausky a écrit : Jacob Carlborgd...@me.com wrote in message news:jo98d1$frl$1...@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

Re: Why not all statement are expressions ?

2012-05-07 Thread Nick Sabalausky
deadalnix deadal...@gmail.com wrote in message news:jo9be0$mgh$1...@digitalmars.com... This won't work anyway. We are talking about language grammar here. If made expression, statement would be of type void. Just like assert is. The question is why assert is an expression ? Why not other