On Thursday 01 June 2006 4:04 pm, Minkoo Seo wrote:
> Thank you Kirk.
>
> Actually, the second question was my effort to think of some nice
> example which mandates namespace concept in Ruby.
>
> But, you actually solved my contrived example. And I'm wondering
> if there is any real problem that needs namespace.

Sure.  When I work on my web framework, I am pretty carefule to keep the whole 
thing within the ::Iowa namespace.  I do this so that I avoid unexpected 
conflicts/interactions with other code.

For instance, there are several useful extensions to String that I wanted to 
use, but I didn't want to risk a bad interaction between those extensions and 
other code.  So, there's Iowa::String available for when I need those 
extensions.  The various cache implementations, TMail wrapper, utility 
methods, constants, and other generally useful code is all inside of the Iowa 
namespace.  In an application running within the framework, the framework 
takes pains to load application code into separate namespaces, as well.  All 
of this makes sure that if someone writes or downloads a piece of code to use 
in an application, that it won't butt heads with the Iowa code and cause 
difficult to resolve problems.

Ruby's namespaces, perhaps, are not perfect, but they are simple and pretty 
good and work well when trying to keep my code from stepping on your code.  
It's always been a bit of a puzzle to me why, historically, there hasn't been 
more extensive use of them in libraries that people release.  That single 
thing was the strangest single thing that I found when I came to Ruby from 
the Perl world.


Kirk Haines