Using ()s in @property functions

dsimcha dsimcha at yahoo.com
Mon Jun 28 19:40:06 PDT 2010


Once enforcement of @property is enabled, we need to decide whether calling an
@property function using ()s should be legal.  In other words, should
@property **require** omission of ()s or just allow it?  My vote is for just
allowing omission, because I've run into the following ambiguity while
debugging std.range.  Here's a reduced test case:

struct Foo {
    uint num;

    @property ref uint front() {
        return num;
    }
}

void main() {
    Foo foo;
    uint* bar = &foo.front;  // Tries to return a delegate.
}

If I can assume that @property functions can be called with explicit ()s to
forcibly disambiguate this situation, then I can fix these kinds of bugs by
simply doing a:

uint* bar = &(foo.front());

Can we finalize the idea that this will continue to be allowed now so that I
can fix the relevant bugs in Phobos and know that my fix won't be broken in a
few compiler releases?


More information about the Digitalmars-d mailing list