Possible @property compromise
Zach the Mystic
reachBUTMINUSTHISzach at gOOGLYmail.com
Sat Feb 2 10:03:31 PST 2013
On Saturday, 2 February 2013 at 06:28:47 UTC, Era Scarecrow wrote:
> On Saturday, 2 February 2013 at 06:04:01 UTC, TommiT wrote:
>> What do you suppose would happen if I wrote the following?
>>
>> struct A
>> {
> <snip>
>> static int otherFunction()
>> {
>> C cc;
>> return cc.myMemberFunction();
>> }
>
> It would refuse to compile as a static function can't point to
> an instance/parent. I'm convinced you should not be able to
> return (or create an instance of) a nested struct outside of
> it's level of control or ability to reference properly.
>
> Had it not been static on the other hand...
>
> int otherFunction()
>
> cc has the same level as c, so the return would be equal to:
> _a + _b + cc._c
... well, this function requires being called with instances of
A, B, and C, so I believe it would error on that account. The
only way to call this deeply nested thing would be with an
instance of A, which makes sense, since it operates on a variable
contained in A. It would have to look like:
A a;
int z = a.b.c.myMemberFunction();
... to work, I believe.
More information about the Digitalmars-d
mailing list