On Thursday, 31 January 2013 at 19:13:03 UTC, Zach the Mystic wrote:
I'm hoping that the community won't close the books on this issue without even *examining* my proposal, found here:

http://forum.dlang.org/thread/[email protected]?page=2#post-yqvrjszzlcpmmuyqyxdz:40forum.dlang.org


I'm just going to repeat the arguments I've already made on the "Property discussion wrap-up" thread against the idea of using a variable as a property:

struct MyArray
{
    int _len;

    // struct2.0 variables have an implicit reference 'outer' to
    // the enclosing object (don't ask how... not my idea)

    struct2.0 Len
    {
        int opCall() const
        {
            return outer._len;
        }

        alias this = opCall;

        void opAssign(int v) const
        {
            outer._len = v;
        }
    }

    Len length; // please ignore the memory overhead over here
}

void func(N)(N n)
    if (isConvertible!(N,int))
{
    n = 123;
}

void main()
{
    MyArray arr;
    func(arr.length); // changes arr._len (not good)
}

Reply via email to