bearophile Wrote: > Simen kjaeraas: > > > Well, obviously not. The grammar has one and only one meaning for that > > example - that of an a* called b, being set to c. This can be inferred > > with no other context. > > This little program: > > struct Foo { > int x; > Foo opBinary(string op:"*")(Foo other) { > Foo result = Foo(x * other.x); > return result; > } > void opAssign(Foo other) { > x = other.x; > } > } > void main() { > Foo a, b, c; > a * b = c; > } > > Gives: > test.d(10): Error: a is used as a type > test.d(10): Error: cannot implicitly convert expression (c) of type Foo to > _error_* > test.d(10): Error: declaration test.main.b is already defined > > > While this one gives no errors: > > struct Foo { > int x; > Foo opBinary(string op:"*")(Foo other) { > Foo result = Foo(x * other.x); > return result; > } > void opAssign(Foo other) { > x = other.x; > } > } > void main() { > Foo a, b, c; > (a * b) = c; > } > > Bye, > bearophile
Yeah, and this: struct Foo { } void main() { Foo a, b, c; (a * b) = c; } Gives an error. I don't see any problem here: a * b; // always a pointer declaration (a * b); // always a binary expression -SiegeLord