From: Gavin Sinclair Date: 2004-02-01T21:00:47+09:00 Subject: Re: Constant visibility On Sunday, February 1, 2004, 10:19:53 PM, Robert wrote: >> The problem is that when you use 'class M::C' to open a class, you >> can't access constants declared in M, whereas if you use 'module M; >> class C', you can. >> >> 1) Why is this? > Because when doing "class M::C" you're still in another scope while defining > class C. So you have to explicitely scope constants from module M. (see > below) "Another scope"? Sounds convincing, but I don't know what it means. 'self' is the same object in the following two examples: module M class C p self.id end end class M::C p self.id end >> 2) Is is an intentional behaviour of Ruby? > I think so. Can it be justified in terms of correctness, language design principles, POLS, convenience, expedience, or anything else? To my mind, the way things work (scope-wise) should depend on the value of 'self' and little if not nothing else. Cheers, Gavin