On Sun, May 9, 2010 at 8:01 AM, David Nolen <dnolen.li...@gmail.com> wrote:
> If you just need to break up your code into smaller files another technique > is: > > ; me/lib.clj > (ns me.lib) > (load "me/foo") > (load "me/bar") > > ; me/foo.clj > (in-ns 'me.lib) > > ; me/bar.clj > (in-ns 'me.lib) > > I think this solves part of my problem. But as another example, consider that I've developed a library of set functions to augment what comes with clojure. ; me/setlib.clj (ns me.setlib (:use clojure.set clojure.contrib.set)) Right now, if I want to use my own augmented set library, I have to also remember to use clojure.set and clojure.contrib.set to get the "full set library". ; me/setconsumer.clj (ns me.setconsumer (:use clojure.set clojure.contrib.set me.setlib)) What can I do in setlib.clj so that in my consumer file I can just say: (ns me.setconsumer (:use me.setlib)) and get all the set functions? In PLT Scheme, the module system allows you to specify both what you "require" from other libraries and what you want to "provide" to other libraries. There is an easy mechanism to say you want to provide (export) all the things you've required (imported) from another module. Is there any way to do that in Clojure -- to essentially say, "I'm using things from this other namespace, and I want to turn around and make them available as if they were part of my own namespace."? It's also worth noting that PLT Scheme's module system used to require you to begin each file with a (module name) command where the name needed to match the file you were working in, much like the way Clojure currently does things. They eventually reworked things so that this became unnecessary -- the old syntax is still available if you need to specify a module directly at the REPL, or for some reason set up a module that differs from the filename, but in general, the module name is now automatically determined from the filename. It's so much easier this way. So I find myself wondering why Clojure's namespace/file system is the way it is. I'm assuming that some of it has to do with Java cultural and/or classpath baggage that I don't really know much about it. Possibly some of it has to do with limitations of how this code will be interactively loaded in bits and pieces by emacs and other IDEs. But it still seems like it would be possible to make it so each Clojure file would be automatically loaded in it's own namespace, and that require statements could find other Clojure files relative to their own location. So for example: (ns me.setconsumer (:use me.setlib)) would just become (ns (:use setlib)) Is there a benefit to the current system that I'm not fully appreciating? Thanks. References: PLT Module information: http://docs.plt-scheme.org/guide/modules.html (PLT Scheme also has another concept called units, which supposedly can handle even more sophisticated types of polymorphic/dynamic linkages, but I've never fully appreciated what extra benefits you gain from the extra complexity. Modules have been sufficient for my purposes. But for those who are interested: http://docs.plt-scheme.org/guide/units.html) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en