---- Original message from Bill Kelly on 11/2/2005 11:23 AM: > From: "Ara.T.Howard" <Ara.T.Howard / noaa.gov> > >> >> i'm unclear how this whole construct is more useful that using >> modules as >> namespaces, which can be nested and manipulated like all other >> module/classes. > > > There's only one reason I've been eagerly awaiting selector namespaces, > and it was that I thought it meant we would be able to, in our own > modules (or namespaces) be able to redefine core methods, and have > these changes be in effect only within our own namespace. > > I was imagining something like: > > namespace foo > require 'mathn' # without changing mathn source > p 5/9 # => 5/9 > end > > p 5/9 # => 0 > > I.e. by defining and working in a namespace, you'd be insulating > the rest of Ruby from changes made within that namespace, > particularly overriding core class' methods. > > > I guess with the proposed scheme, it would be, > > require 'mathn' # presuming mathn changed to use namespaces > > using mathn > > p 5/9 # => 5/9 > > stopusing mathn > > p 5/9 # => 0 > > ??? > > > Is it true that with the proposed approach, the source code of > mathn would have to be changed to make it define its methods > explicitly within a namespace? Is there no way to 'require' > a module into a namespace without having to change the module's > source code? > > I thought there would be specific uses: 1. Global namespace change to allow for transistion from one namespace to another. Example: (please note my alternative syntax) require 'mathn' namespace mathn, :begin p 5/9 # => 5/9 namespace mathn, :end p 5/9 # => 0 or require 'mathn' namespace mathn do p 5/9 # => 5/9 end p 5/9 # => 0 2. A notational convenience for class/module definition. class Bubba using home_security def nickel_plated_45 end end Pardon my syntax. Just try out some different flavors.