Why not all statement are expressions ?

Don Clugston dac at nospam.com
Tue May 8 01:46:19 PDT 2012


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 statement?

The main use for a void expression is so that it can be used in a comma 
expression; this is why assert is an expression.

The curious thing, which may be the source of the confusion, is that 
static assert() is a statement, while assert() is an expression. Maybe 
static assert should also be an expression rather than a statement?


More information about the Digitalmars-d mailing list