[Issue 14353] SDC test0104.d fails under DMD

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Mar 28 12:04:23 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=14353

--- Comment #5 from ag0aep6g at gmail.com ---
(In reply to Shammah Chancellor from comment #3)
> I'm not so sure this is desirable.  What if there add as a ref return.  What
> does &t.foo give then?

You mean something like the following?
----
struct T
{
    int i = 42;
    ref int foo() {return i;}
}
void main()
{
    T t;
    auto dg = &t.foo;
    auto i = &t.foo();
}
----
Here dg is a delegate of the method foo and i is a pointer to the ref-returned
field i.

The spec says this [1]:
"In most places, getter property functions are called immediately. One
exceptional case is the address operator."
"Even if the given operand is a property function, the address operator returns
the address of the property function rather than the address of its return
value."
Now foo is no @property, but the spec says that "[if] a function call does not
take any arguments syntactically, it is callable without parenthesis, like a
getter property functions." So it's reasonable that the same rules apply.

[1] http://dlang.org/function.html#property-functions

--


More information about the Digitalmars-d-bugs mailing list