From: Austin Ziegler Date: 2005-09-30T08:04:47+09:00 Subject: Re: Require Namepaces and RubyGems' effect on LoadPath problem On 9/29/05, TRANS wrote: > On 9/26/05, mathew wrote: >> XML has namespaces so that there can be multiple elements with the >> same base name. Ruby 'require' already supports that--you can have >> require 'foo/set.rb' and require 'bar/set.rb', the same way you can >> have and . > Sort of. XML namespaces are references. So foo: and bar: could > actually be referencing the same space, in which case they'd be the > same 'set'. That's kind of what Require Namespaces does: It allows you > to require a 'name' that will be searched for in alternate/multiple > directories. That doesn't change that the primary purpose of namespaces in XML is to solve a real problem ... that doesn't exist in Ruby. Frankly, what you've written is code in search of both a problem and a solution. It's neat, but ultimately useless for anything meaningful or helpful. >> I still don't understand how this namespace proposal improves things, >> other than to reduce typing. Can you give an example? > I use it to organize a very large library. I've organized the lib > according to principles that make sense for development --in this case > it's a collection of general purpose libs so I've put classes in one > directory, modules in another, etc. But I don't want the end user to > have to "path down" so far, so the namespace allow all the folders to > be grouped together. So intead of: Then it may make more sense for you to reorganise your lib for development. Or maybe -- just maybe -- it's time to split nano and mega into different release collections. If that's not desirable, then reorganise the files dynamically during packaging. The Rakefile that I use to package PDF::Writer does *exactly* that with the .tar.gz files. I'd like to be able to get into that level of rewriting the internals of .gems, but I haven't yet asked for it. > Morover, it makes it easy to add aliases. For instance this could work too: > > mylibs/foo.rb > mylibs/bar.rb > > As things stand there is no way to do this. One could use symlinks but > you'd have to maintain them and they are not cross-platform. Again, code in search of a reason and use. Why would you *want* to do this? It ends up *defeating* Ruby's load-protection mechanisms (e.g., if mylib/foo and mylibs/foo are the same thing, they *will* be loaded twice because they appear to be unique files). -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca