Nitpicking the D grammar

Stewart Gordon smjg_1998 at yahoo.com
Sun Sep 9 07:40:15 PDT 2007


"Jascha Wetzel" <"[firstname]"@mainia.de> wrote in message 
news:fc0qkl$1men$1 at digitalmars.com...
> Stewart Gordon wrote:
>> "Jascha Wetzel" <"[firstname]"@mainia.de> wrote in message 
>> news:fbrk6q$1cv5$1 at digitalmars.com...
<snip>
>>> Wouldn't it be more appropriate here to change the specs to
>>> "Expressions that can be interpreted as a declaration, like (a*b), are 
>>> illegal in expression statements. If such an expression is needed, 
>>> casting it to void will make it legal."
>>> (http://www.digitalmars.com/d/statement.html#ExpressionStatement)
<snip>
> that was my shot at doing this. it's not very elegant, but it describes 
> exactly what the parser does.

But if you're talking of it in place of the current statement, then:
- it's a completely different statement, even as much as there's an overlap 
between the two
- (a*b) cannot be interpreted as a declaration.  a*b can though.

Perhaps better would be to add a statement here:
"Any statement that can be parsed as either a DeclarationStatement or an 
ExpressionStatement is treated as a DeclarationStatement, for example:
    a * b;    // declares b to be a pointer to type a
"

Stewart. 




More information about the Digitalmars-d mailing list