Possible @property compromise

TommiT tommitissari at hotmail.com
Sat Feb 2 09:33:37 PST 2013


On Saturday, 2 February 2013 at 17:25:57 UTC, Zach the Mystic 
wrote:
>> What do you suppose would happen if I wrote the following?
>>
>> struct A
>> {
>>  int _a = 1;
>>  B b;
>>  struct B
>>  {
>>    int _b = 1;
>>    C c;
>>    struct C
>>    {
>>      int _c = 1;
>>      int myMemberFunction() { return _a + _b + _c; }
>>    }
>>    static int otherFunction()
>>    {
>>      C cc;
>>      return cc.myMemberFunction();
>>    }
>>  }
>> }
>>
>> void main()
>> {
>>  int i = A.B.otherFunction();
>> }
>
> I was simply using A.B.C.myMemberFunction as a shorthand for 
> whatever name the compiler uses underneath the hood to 
> represent the non-static version of the function.

Yes, I can see that now. I didn't understand that the code wasn't 
actual code but something that the compiler sees.

But, you didn't answer my question. What would happen if I 
actually did write that code and click "compile". What would 
there be in the 'i' variable?

Era Scarecrow already answered the question for you. The correct 
answer is that the code wouldn't compile. But I just want to see 
that you understand why it must be so.


More information about the Digitalmars-d mailing list