At 14:58 09/02/27, Charles Oliver Nutter wrote:
>I thought I'd sent this before...hopefully it's still relevant.

>Here's a perfect example, also based on rake: "import"
>
>JRuby added an "import" for Java classes that ends up conflicting with the "import" Rake uses. So we've had no end of hassle because we both want that top-level "import" name and both of them do drastically different things. If we had namespaces, people could have avoided this very easily:
>
>import "my_other_rakefile"
>
>using JRuby::Import
>   import java.lang.System
>end
>
>As it stands, we had to add yet ANOTHER name to import stuff, "import_java".

I'm not exactly sure I'd prefer

using JRuby::Import
   import java.lang.System
end

over

import_java java.lang.System

or

JRuby.import java.lang.System

or some such. The later is shorter (at least for a single import),
and more to the point. 

In general, I think it's always desirable to resolve conflicts
where possible (this is of course often easier said than done).

This seems to apply to quite some of the examples that came up so far:
The String#chars method of Rails and Ruby 1.9: Rails may be helped with
a namespace solution for a while, but Ruby 1.9 should eventually win.
The Merb/ActiveRecord conflicts: It shouldn't be too difficult
to adapt behavior on either side to make sure that something with
the same name behaves the same.

One thing I have been contemplating is the danger of creating
namespaces that (almost) nobody will use. Library users won't like
that they have to declare lots of namespaces for every library they
use, so library writers will not be very motivated to actually use
them. And once a conflict is detected, fixing the conflict may be
as easy as putting the method into a namespace.

Or does the whole namespace thing work without any declarations
unless there is a conflict, or could it be made to work that way?
It would then be similar to having several modules included already,
but being able to say which one to look up a method in first.

Regards,    Martin.


#-#-#  Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University
#-#-#  http://www.sw.it.aoyama.ac.jp       mailto:duerst / it.aoyama.ac.jp