Lack of `outer` keyword makes inner class dup implossible

Bruno Medeiros brunodomedeirosATgmail at SPAM.com
Sun Jul 16 06:42:32 PDT 2006


S. wrote:
> 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
> 

I believe he mentioned that as just a "workaround", a temporary 
solution, not a final one!

-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list