property aliases to existing functions

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Sep 24 15:00:33 PDT 2011


I'm guessing the following is an accepts-invalid bug:

void test(int) {}
void main() { test = 4; }

Anyway, if/when the above stops being legal I'd be nice if I could
create property functions using aliases. Something like this:

struct Bar
{
    int getFoo() { return 0; }
    void setFoo(int i) { }

    @property alias getFoo foo;
    @property alias setFoo foo;
}

void main()
{
    Bar bar;
    bar.foo = 4;
}

I'm not sure if this is *actually* making "foo" a property right now
or if DMD completely ignores the property keyword there, it's hard to
tell since regular functions already act as properties.

But do you think this code should be legal and maybe create properties
like that? It sure looks handy (admittedly it's not a to-die-for
feature, just a convenience when porting code).


More information about the Digitalmars-d-learn mailing list