> -----Original Message----- > From: Sean O'Halpin [mailto:sean.ohalpin / gmail.com] > Sent: Tuesday, November 15, 2005 3:04 PM > To: ruby-talk ML > Subject: Re: toplevel namespace justification > > > On 11/15/05, Trans <transfire / gmail.com> wrote: > > When is using the toplevel constant namespace justified? > > I think the general rule should be as Kirk says, "keep all of > your junk inside your own namespace". > > > How could one pull X up to toplevel if they wanted w/o bringing Y? > > Perhaps: > > > > X = MySpace::X > > > > but there is a caution here b/c poorly written classes would have > > problems with this. > > I guess one of the reasons people pollute the toplevel > namespace is because they don't know how to write > well-behaved classes that can be pulled up in this manner > when required. Perhaps documenting how to do that correctly > would be a start. > > Regards, > > Sean Blech. If I want to bring X up to the toplevel, I simply do "include MySpace" at the top of my code, where I assume "MySpace" is a module. I realize this convention could be abused, i.e. someone could stick instance methods inside "Net" for example, but so far (years now) it just hasn't been an issue. Community policing and general common sense work well enough. If we *really* felt the need for a namespace, we would have to add a "namespace" method/keyword/whatever to Ruby, which would (I imagine) simply be a special form of module. Just rip out all the methods and disallow defining new methods. Not all that useful or needed, though, imho. I now await the implementation of "namespace" Florian Gross has laying around on his hard drive. ;) Regards, Dan