On 09/01/2011 10:35 PM, Nick Sabalausky wrote:
"Steven Schveighoffer"<[email protected]>  wrote in message
news:[email protected]...
On Thu, 01 Sep 2011 13:31:29 -0400, Nick Sabalausky<[email protected]>  wrote:

You could do something like this:

class AClass
{
    int a = 10;
}

struct AStruct
{
    // Never use this directly, except inside the "aclass" property
functions
    private AClass _aclass;

     @property AClass aclass()
     {
         if(_aclass is null)
             _aclass = new AClass();
         return _aclass;
     }

     @property void aclass(AClass c)
     {
         _aclass = c;
     }
}

-------------------------------
Not sent from an iPhone.

This doesn't work.  It has the same problem as AA's currently do:

foo(AStruct str)
{
   str.aclass.a = 5;
}

void main()
{
    AStruct str;
    // assert(str.aclass.a == 10);
    foo(str);
    assert(str.aclass.a == 5); // fails unless you comment out the line
above.
}


Could using postblit solve that (or am I misunderstanding the issue)?


Postblit has no access to the original struct, so how would you solve the issue using postblit?






Reply via email to