From: Nathaniel Talbott Date: 2003-08-13T08:03:56+09:00 Subject: Re: Nested class/module namespace Kent Dahl [mailto:kentda+news@stud.ntnu.no] wrote: > I can't help thinking that it might be a feature, not a bug. > > Class and module provide namespaces. In the old style, we > could not help but opening all the layers of modules (and > thusly their namespaces) when defining a class within them. > > With the new style, we get a cleaner, neater and minimalistic > namespace, where we can include those namespaces we want. > (With the exception of nested classes, but a work-around for > that only requires a little refactoring). > > So unless "class M::C" and friends is just meant to be > syntactic sugar, (phoey!) this might help us create cleaner > code, IMHO. I wouldn't write it off as a bug just yet. I don't understand the benefit... when I use classes and modules for namespacing, I group related things under the same namespace, and it's great for those related things to be able to access one another without fully qualifying names. For instance: table.rb: module SE class Server module DB class Table ... end end end end tc_table.rb: module SE class Server module DB class TC_Table < Test::Unit::TestCase def test_stuff t = Class::new(Table) do # Table is visible in the DB namespace ... end ... end end end end end I'd love to change this to: table.rb: class SE::Server::DB::Table ... end tc_table.rb class SE::Server::DB::TC_Table < Test::Unit::TestCase def test_stuff t = Class::new(Table) do # Can't find Table! ... end end end In many cases this form of nesting will create more typing for me than the normal form of nesting! 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? Thanks, Nathaniel <:((><