On Wednesday, 30 January 2013 at 18:05:08 UTC, Zach the Mystic wrote:
[..]

How about using this new namespace_thingy keyword:

struct S
{
    private int value;

    namespace_thingy prop
    {
        int get() { return value; }
        prop opAssign(int v) { value = v; return prop; }

        // int data; // error: can't have data here
    }
}

The compiler would implicitly create something like:

struct S
{
    private int value;

    int prop_get() { return value; }
    int prop_opAssign(int v) { value = v; return prop_get(); }
}

...

S s;
int v1 = s.prop;        // lowered to s.prop_get()
int v2 = (s.prop = v1); // lowered to s.prop_opAssign(v1)
assert(v1 == v2);

Reply via email to