On 01/25/2013 03:09 AM, kenji hara wrote:
...

@property ref int foo();
auto x = &foo;   // x is a function pointer, or an address of returned
value?


Address of returned value.

This is the most sensible problem.
(a) If typeof(x) should be a function pointer, we need to use a utility
function to get int*.
    ref identity(T)(ref T t) { return t; }
    int* p1 = &(identity(foo));
       // foo is evaluated to ref int in function argument,
       // and identity gets through the reference.
    int* p1 = &foo.identity;
       // with UFCS, parentheses can be removed.

    This is a real issue. In phobos, the ref-ness of front property is
actually checked in std.range.moveFront.


This is a serious issue.

(b) If typeof(x) should be a int*, we will lose the way to getting a
function pointer of foo.
    That is more serious than (a). If we adopt this rule, we will
*really* get lost the way to distinguish property functions and raw data
fields. (Note that: In current typeof(foo) already returns int. So
AddressExp is only one way to getting (normal|property) function
information by its type.) From the view of meta-programming, I think
this makes a serious flaw.


We might add the necessary __traits to make up for it.

Reply via email to