From: Nathaniel Talbott Date: 2003-08-14T00:34:09+09:00 Subject: Re: Nested class/module namespace Yukihiro Matsumoto [mailto:matz@ruby-lang.org] wrote: > "Nathaniel Talbott" writes: > > |Oops... I guess I've been using it incorrectly :-). So it's not for > |this reason? > | > | module M > | class C > | M::FOO # want to access M here. > | end > | end > > I didn't express my idea correctly. M too should be covered > by nested constant scope. OK. > |Well, this seems a little confusing to me: > | > | class M::C > | def C.m > | end > | end > | > | => NameError: uninitialized constant M::C::C > | > |If it had nested scope, this wouldn't happen, right? > > Right, but you were going to define M::C, not plain C, were you? Ah, now I begin to understand (but perhaps not agree). I think of M & C in 'class M::C' as separate entities. But it seems that you think of M::C in 'class M::C' as a single entity. I guess our intuitive view of what that construct represents is in conflict. Of cousre, yours always wins... My biggest concern is not so much for my code, as I can either leave it as-is or just adapt it to use this new construct as it makes sense. My concern more lies in the fact that when I saw that 'class M::C' now worked, I thought that it would work exactly like 'class M; class C end; end', but it didn't. Having two very similar constructs that behave in such different ways seems surprising, and I fear it will become a frequent puzzlement for new users. Plus, while I can understand it working that way, I still can't give a pragmatic reason other than, "It would confuse matz if it were the other way." Nathaniel <:((><