> -----Original Message-----
> From: Nat Pryce [mailto:nat.pryce / b13media.com]
> Sent: Thursday, December 06, 2001 11:25 AM
> To: ruby-talk ML
> Subject: [ruby-talk:27708] Re: Package Naming
> 
> 
> I think you misunderstood my point.  The physical location of a 
> Java package
> is separate from its logical name.  The language only exposes the logical
> name.  It just happens that the default system class loader maps logical
> class names to directory paths.  Other class loaders can translate logical
> class names to something else -- a file with the same name as the fully
> qualified class name, or an SQL query into a database, or whatever.  For

And you could override the behavior of "require" to allow for loading from alternative locations/methods as well.  You could write a require (that aliased the old require, then inserted itself) that uses URI syntax to pass the required ruby source document identifier to a handler/plugin.

require '/rexml/document' #=> old behavior (prepend file://)
require 'file://rexml/document' #=>same as above

or...

require 'db://dbi/dbname/table#index?user="me"&password="secret"'

or...for really safe way of getting the exact file you want...

require 'file:hash="40 byte hex of SHA hash of file'

etc...etc...

> example, if I move a package from a directory in the classpath and instead
> store it in a JAR file, I don't have to change any of the client 
> code, only
> the configuration of the JVM.

Java did not always have JAR files.  The primordial class loader on Java was extended to allow loading from JAR files in ~1.1.  There is work going on in the RubyGems space to build a package management structure like JARs (but better with version management, etc)

> 
> Ruby on the other hand exposes *both* the logical name of a package/class
> *and* the physical location in which the Ruby code defining that class is
> stored.  If I change the way I've organised my files I do have to change
> client code.  This is an unavoidable artifact of Ruby's dynamic nature.

Not if you move the (relative) directory structure into a new directory that is included in the LOAD_PATH.  In a VERY similar way to moving directories around and updating the Java (file-based) CLASSPATH.

> However, it does mean that clients of a class are more tightly coupled in
> Ruby than in Java, because they rely on two unrelated details -- 
> the logical
> name of the class and the physical location of the definition of 
> that class.

You could just as easily say that a person needs to know two unrelated things in Java...the package structure and the class names.  Again... the physical location issue is an artifact of the behavior of the existing require statement.  YES clients have to know the Classes/Modules within the require'd source document in Ruby just like they need to know the Classes in a Package in Java they include.  I'm not saying the two architectures are exactly the same, I'm just saying they have similarities.  In Java, there is a namespace in the context of each Java class which is used (at compile time) to resolve external dependancies.  In Ruby all the Classes (and Modules) live in one happy(?) Objectspace built at Runtime.  Like you say...this is an artifact of Ruby's dynamic nature.

> 
> ________________________________
> Dr. Nathaniel Pryce
> B13media Ltd.
> 40-41 Whiskin St, London, EC1R 0BP, UK
> http://www.b13media.com
> 
> XP Day, London, UK. 15th December 2001. http://xpday.xpdeveloper.com/
> 
> ----- Original Message -----
> From: "Sean Russell" <ser / germane-software.com>
> Newsgroups: comp.lang.ruby
> To: "ruby-talk ML" <ruby-talk / ruby-lang.org>; <undisclosed-recipients: ;>
> Sent: Thursday, December 06, 2001 3:33 PM
> Subject: [ruby-talk:27694] Re: Package Naming
> 
> 
> > Nat Pryce wrote:
> >
> > > the storage of those packages.  Therefore, in Java, moving a class
> between
> > > directories or machines, or even organisations, doesn't require any
> > > refactoring.  It just requires some configuration changes.
> >
> > No, you have to go through and change all of the package names of the
> > classes that you move, and you have to change the includes of all of the
> > files that include that package... unless you use block 
> includes, which is
> > also against the recommended style guide.
> >
> > Also, if you have some products which use classes whose names conflict
> > within a single sourcefile, then you have to find all instances of that
> > class name and fix the package name.  EG:
> >
> >   public com.mycompany.math.Vector multiplyVectors( 
> java.util.Vector v ) {
> >     // ...
> >   }
> >
> > Thankfully, Java is compiled, and the strong typing catches 
> most of these
> > problems.  Ruby is not, and I dread the thought of having to track down
> all
> > of the bugs that will result from situations like this.
> >
> > --
> > --- SER
> >
>