Outer class reference oddity?
Walter Bright
newshound2 at digitalmars.com
Wed Aug 21 20:16:17 UTC 2024
On 8/20/2024 2:48 AM, Manu wrote:
> Some further odd observations:
>
> If at the point of error, I refer `outer.value2`, I get: "error : undefined
> identifier `outer`" ... which seems odd, because I thought `outer` was the name
> of the implicit outer context?
> So I tried `this.outer.value2`, and that worked! It's typed correctly too.
>
> So... I guess there are 2 variables called `outer`, super.outer, and this.outer?
> And for some reason I don't understand, /neither/ of them are present in the
> local namespace... but I can refer to them explicitly via super.outer, or
> this.outer.
> And for some reason that I don't understand, the local outer (this.outer) does
> NOT shadow the parent outer (super.outer), which seems backwards. Local
> definitions should always shadow base class members?
>
> I'm not happy with the idea that there are 2 members called outer, because
> they're both the same pointer! Hopefully it's dirty implementation magic and
> they are actually the same member internally...
`this` and `super` are keywords with magic properties, and so are not in the
symbol table.
`outer` is not a symbol, and is not in the symbol table. It's a magic property
and so needs to be used as something.outer.
More information about the Digitalmars-d
mailing list