Nested struct member has no access to the enclosing class data
Era Scarecrow
rtcvb32 at yahoo.com
Mon Aug 6 16:42:43 PDT 2012
On Monday, 6 August 2012 at 22:28:40 UTC, RivenTheMage wrote:
> On Monday, 6 August 2012 at 21:51:24 UTC, Andrej Mitrovic wrote:
>
>> There is no "outer". A nested struct has the same access as a
>> nested static class, meaning no access to any outer members
>> unless they're static.
>
> Is there somewhere I can read the rationale behind that
> decision?
I'm sorta half guessing on my logic here:
If structs are value types that can be re-locatable (And
separate entities) then having them dependent on something that
you can't relocate means... what?
Let's assume you create the struct, then pass it back out as a
returned item (quite common); Later the class gets destructed.
What happens with/to the struct? Since static functions/members
are always accessible at compile time nothing changes. Perhaps
your struct should probably be a class instead?
More information about the Digitalmars-d-learn
mailing list