Lack of `outer` keyword makes inner class dup implossible

S. user at pathlink.com
Fri Jul 14 17:49:12 PDT 2006


On 2006-07-14 14:06:35 -0700, "Jarrett Billingsley" <kb3ctd2 at yahoo.com> said:

> "S." <S._member at pathlink.com> wrote in message 
> news:e98u9d$oqh$1 at digitaldaemon.com...
>> It seems that because inner classes lack an `outer` keyword it is 
>> impossible for
>> them to create a new instance for the purpose of COW when operators like opCom
>> are called...
> 
> It's irritating, isn't it?  The workaround is to make the ctor for the 
> inner class take a reference to its owning outer class, then you can 
> use the syntax
> 
> Inner dup()
> {
>     Inner n = outerThis.new Inner(outerThis);
>     return n;
> }
> 
> That is, you can 'new' the inner class using the outerThis reference.
> 
> I suppose another way would be to do some terribly ugly, nonportable 
> hacks to _find_ the outer pointer manually.  Maybe if we do that, 
> Walter will see that having an 'outer' reference would be useful.

Yes, I thought of that.  But Alas, WTF IS THE POINT OF INNER CLASSES 
IMPLICITLY HAVING THE THING THEN!?!?!?!?!??!!?

-S




More information about the Digitalmars-d mailing list