From: "Barnett, Aaron" Date: 2001-12-14T23:59:16+09:00 Subject: [ruby-talk:28505] Re: Package Naming (loading) i missed the begining of this conversation but i'll jump in anyway :) my concerns on this topic are not along the lines of move files, i agree with the comments below. mine are more along the lines of dynammic loading, in the 'plugins' sense. in java i can load a class and get an instance of it if i know its name, having only a string containing the name to guide me. this makes me happy. in ruby, i may know that i want a class called 'Foo', but i have know idea where it is. it may be in Foo.rb, or foo.rb, or utils.rb... i have an application that uses subclasses of a class called Action. the subclass name is given in a action mapping file. some code :: target_class = actions[action_name] eval %Q~ require '#{target_class}' action = #{target_class}.new(request, response, session) ~ action.do() :: using eval for something like this makes me a little uncomfortable, but i see no way around it. -----Original Message----- From: Sean Russell [mailto:ser@germane-software.com] Sent: Friday, December 14, 2001 9:28 AM To: ruby-talk@ruby-lang.org Subject: [ruby-talk:28504] Re: Package Naming Nat Pryce wrote: > files put in, how does the administrator put them there, etc.) .However, > Ruby code does care about the name of the Ruby file in which a class is > deployed, while Java code it does not care about the name of the JAR file > in which a class is deployed. .... > Therefore, we had to tune the packaging of classes into JAR files to > decrease startup time for different client applications. In Java you can I understand what you are saying, but I still don't see how this pertains to Ruby. Tell me again why you'd move Ruby classes around? Ruby doesn't have these deployment issues, although it will eventually suffer from the same path creep that Perl suffers from -- if you're Perl installation is old enough, eventually your load path starts to look like a novella. Either that, or every time you upgrade Perl, you have to reinstall a boatload of packages. When you compare moving Ruby files to moving Java files, you have to make an orthoganal comparison of the practical aspects of the issue. Jar files are just locations in the classpath -- as long as the location is in the classpath, you can move Java class files arbitrarily without any changes to sourcecode. This is no different than Ruby. As long as the target location is in $:, you can move the Ruby file around in the classpath. Now, if you want to actually change the path so that it would affect the "require", I argue that this is like changing the package name in Java, which is *also* a path corresponding to a real filesystem path. package us.fed.fs; class MyClass { } corresponds *directly* to us/fed/fs/MyClass.class Sure, you can move this class around between Jar files, but you *still* have to maintain that full path. The package name is dependant on the filesystem path. So moving the class from one.jar to two.jar is just moving the class, including the entire file hierarchy corresponding to the package name that contains that class, around in the classpath locations. If you want to change the path of the class to, say: us/fed/nsa/MyClass.class you have to change the package name in the source code. The same holds for Ruby. If you have a file: rexml/dtd/dtdparser.rb this is orthoganal to the Java package name. You can move this around within elements of $: without changing any sourcecode, as long as you maintain the pseudo-package name. If you want to change it to nqxml/dtd/dtdparser.rb you have to change the sources. Just like Java. -- --- SER