From: Kent Dahl Date: 2003-09-18T00:16:23+09:00 Subject: Re: Nested class/module namespace Nathaniel Talbott wrote: > In many cases this form of nesting will create more typing for me than the > normal form of nesting! Yes, in particular something like these three lines: module Constants end include Fully::Qualified::ModuleName::Constants ....where the last line may be repeated. This is a cleaner separation of namespaces anyway. The constants ultimately belong inside the classes that use them, not in some arbitrary common ancestral namespace area which saves you typing. > OTOH, I haven't ever had trouble with too much > namespace exposure except with top-level classes (like Queue) that cause > confusion when I forget to require something and they magically get used > instead of my classes without an (immediate) error. But this new form > doesn't solve that problem, so I don't see any benefit in how it behaves. > Can you give an example where this is beneficial? Replace top-level classes with constants (i.e. classes, constant variables, modules etc) anywhere within the module hierachy, and you have one example. Granted, the average Ruby program isn't of such a size that this becomes much of an issue, but once someone writes a 10kLOC killer app in Ruby, they will be thankful for proper namespace functionality. If we can pop over to C++ land for a short while, the "module M;class C;end;end" style opens a namespace scheme that is akin to "#include " within c.h. The new style "class M::C;include M::Constants;end" has more in common with C++ "using namespace m;". The latter is better in the long run; only take in what you are sure you need. -- (\[ Kent Dahl ]/)_ _~_ _____[ http://www.pvv.org/~kentda/ ]_____/~ ))\_student_/(( \__d L b__/ (pre-) Master of Science in Technology ) ( \__\_�|�_/__/ ) _)Industrial economics and technological management( \____/_�_\____/ (____engineering.discipline_=_Computer::Technology___)