On 02/04/2013 03:38 PM, kenji hara wrote:
2013/2/4 Andrei Alexandrescu <[email protected]
<mailto:[email protected]>>
Couldn't AddressOf use "&(" + exp + ")"?
Yes. It's enough. I wanted to explain that "we should treat
address-expression carefully".
I thought more about this. The problem remains even without
@property, due to optional parens in function invocation. Consider:
ref int fun() { ... }
auto p1 = &fun;
auto p2 = &(fun);
auto p3 = &(fun());
What are the types of the three? The optional parens in invocation
require some disambiguation. I think the sensible disambiguation is
to have &fun take the address of fun and the other two take the
address of fun's result.
Agreed.
Why?
I would agree restricting the properties, but requiring a __trait to
take the address of a regular function or method seems overkill.
Fully agreed.
It is not an interesting point. It is not necessary anyway.
Although it looks strange and unstable, adding new distinction of
semantics between &foo and &(foo) has no ambiguity.
It _is_ strange.
I think this is necessary feature for the D's function and property
semantics.
Why?