From: Austin Ziegler Date: 2003-08-13T11:07:14+09:00 Subject: Re: Nested class/module namespace On Wed, 13 Aug 2003 08:08:19 +0900, Nathaniel Talbott wrote: > Yukihiro Matsumoto [mailto:matz@ruby-lang.org] wrote: >> "Nathaniel Talbott" >> |Why does the second case fail? It makes me not want to use |the second >> version, since it means I have to fully-qualify |all constants in the >> enclosing namespace, instead of just |using them as I usually do. I >> hope it's just a bug :-/. >> Unfortunately, it's not. "class M::C" notation is not a syntax sugar >> for 'module M; class C". It is something like "M::C = Class.new", so >> that the body of C definition is not nested in the M body. > What is the motivation behind the current behavior? Is it that way > because of difficulty in implementing it differently, or for some other > reason? It makes sense to me. You're defining a new constant C in module M. You're not *in* module M. If you do: module M; end M::B = :foo p M::B This would be the same as doing: module M; end c = Class.new M::C = c p M::C -austin -- austin ziegler * austin@halostatue.ca * Toronto, ON, Canada software designer * pragmatic programmer * 2003.08.12 * 21.59.17