declaration/expression

BCS none at anon.com
Mon Jun 22 23:43:54 PDT 2009


Hello Ellery,

> How does dmd resolve the declaration/expression ambiguity?
> 

Could you elaborate? I'm not understanding the problem.

> 
> import tango.io.Stdout;
> void main(){
> int[4] i = [1,2,3,4];
> T(t); // compiler: I think this is an expression *barf*

I don't think this can be interpreted as a declaration

> t(i[])(i[]); //compiler: I think this is a declaration *barf*

nor that

> }
> class T{
> public T opCall(int[] i){
> Stdout(i).newline;
> return this;
> }
> }

the only problem case I know of is:

a * b = d;

where this can be a decl of a pointer to type a called b and set to d
or the result of the expression a times b getting assigned d (operator overloading 
can make this valid).





More information about the Digitalmars-d mailing list