Angry citizen stikes once again. forward references problems
Derek Parnell
derek at nomail.afraid.org
Mon Jul 31 01:07:58 PDT 2006
On Mon, 31 Jul 2006 09:22:26 +0200, Dawid Ciężarkiewicz wrote:
> Derek wrote:
>
>> On Sun, 30 Jul 2006 21:55:59 +0200, Dawid Ciężarkiewicz wrote:
>>
>>> Dawid Ciężarkiewicz wrote:
>>>> In extremal situations you can even get something you can't compile in
>>>> any way:
>>>> http://d.puremagic.com/issues/show_bug.cgi?id=104
>>>
>>> I mean:
>>> http://d.puremagic.com/issues/show_bug.cgi?id=102
>>
>> I don't understand this Dawid. It seems you are trying to use a nested
>> class inside another class, and I'm sure you can't and shouldn't do that.
>>
>> I thought the purpose of nested classes was to restrict the scope of the
>> nested class to its parent and thus trying to use it outside of the parent
>> doesn't seem right to me.
>
> Not right. Nested _static_ classes are just like all other classes. The only
> change is just namespace. BTW. I do want use them like that and personally
> I think it has many advantages.
Thank you Dawid for helping me to understand your reasoning. I'm still
learning things too.
However, your response of "Not right." is a bit too restricting. From what
you and others have mentioned, it seems that there are at least three
purposes of nested classes ... to limit the scope, as a convenience to
access parent data members, and to provide a namespace. Of course I can see
now that 'static' nesting is just for namespace purposes.
However it still seems like a 'hack' to me and the issue of namespaces
ought to be better handled by some more explicit mechanism rather than
relying on some side-effect of D. But that is an argument for another day
<g>.
> But it's not about classes. It's about symbols used as types. This should
> make more sense to all unconvinced:
I was totally aware of the issue with enums etc... as I keep bumping into
it too. I just gave up and now use module namespaces for enums.
$ cat test1.d
import test2;
import yenum;
class X {
yenum.NY t;
}
$ cat test2.d
import test1;
import xenum;
class Y {
xenum.NX nx;
}
$ cat xenum.d
enum NX {
BLA,
BLA1
}
$ cat yenum.d
enum NY {
FOO,
BAR
}
--
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
31/07/2006 5:52:32 PM
More information about the Digitalmars-d
mailing list