Question about operations on class/struct properties

Uranuz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 18 12:13:57 PDT 2014


I posted it suddenly. I don't know why.
>
> I'll give short illustration.

struct PropType
{
    void append(int value)
    {
       //implementation
    }

}

class Test
{
    PropType myProp() @property
    {
       return _propValue;
    }

    private PropType _propValue;

}

void main()
{
    Test test = new Test;

    //This line looks like I want to append value
    //to field of *test* object. But it cant't modify
    //it and just doing useless job.
    test.myProp.append(10);

}


I don't know intentions of language designers in part of 
properties. But in this code I see some logical contradiction. 
What I see and thinking of this line of code it is not what it 
really does.

I don't know much about properties behaviour in different 
languages but there is something that confuses me. I believe that 
this problem deserves more attention. There are 5 DIP's in dlang 
wiki. So I think it's important


More information about the Digitalmars-d-learn mailing list