Lack of `outer` keyword makes inner class dup implossible
S. Chancellor
dnewsgr at mephit.kicks-ass.org
Sun Jul 16 12:59:55 PDT 2006
On 2006-07-16 06:42:32 -0700, Bruno Medeiros
<brunodomedeirosATgmail at SPAM.com> said:
> 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!
Hehe, I was just venting my frustration :) His solution seems to
generate syntax errors when I tried it anyways though =/
-S.
More information about the Digitalmars-d
mailing list