I saw some discussion of how to fix this on the IRC log but I can't get on at the moment.
It looks like the current plan is to change "ns" to remove the sensitivity to "the namespace is already defined" and add "(:refer- clojure ...)" to the list of supported reference arguments. The new ":refer-clojure" would have arguments like those of clojure/refer and apply them to the clojure namespace. If an "ns" call contains no "(:refer-clojure ...)" reference argument , that "ns" call refers to all of Clojure. I have been thinking recently that "(:refer ...)" would make a good supported reference argument. Instead of "(:refer-clojure ...)", I suggest "(:refer ...)" which acts like any other call to refer but doesn't require its arguments to be quoted. "ns" would still refer to all of clojure if there is no explicit "(:refer clojure ...)" argument present. The reference arguments would then play these roles: :require (when you need to be sure a lib is loaded from classpath resource(s)) :use (ditto, but also refers to the namespace with filters) :load-resources (when you're just loading resources from classpath, as in a lib implementation) :refer (when you know another namespace is already present and you want to bring some or all of it into this namespace with filters) One important case of knowing the namespace is already present is the clojure namespace, but there could be others in a particular deployment of Clojure or given a particular policy for a program about how it loads itself. I like ":refer" over ":refer-clojure" because it's more general and shorter. On the subject of shorter, the name "clojure/load" is already in use, but would be a better name for "load-resources" than "load-resources". I think we should consider changing the name of the former to something else like "load-reader" and using "load" for what is now load-resources (and :load for what is now :load-resources). --Steve On Sep 2, 2008, at 12:54 PM, Stuart Sierra wrote: > > I think there's a problem with the new clojure/ns and gen-and-save- > class. > > Suppose you define: > (clojure/ns com.example > (:use clojure.contrib.pred)) > (defn MyClass-close [this] > (println "Hello, World!")) > > And you generate a .class file with: > (gen-and-save-class > *classes-dir* > "com.example.MyClass" > :implements [java.io.Closeable]) > > Then, at runtime, when com/example/MyClass.clj gets loaded, clojure/ns > does not (refer 'clojure) because the namespace already exists. So > you get: > > Exception in thread "main" java.lang.ExceptionInInitializerError > at com.example.Main.main(Main.java:5) > Caused by: clojure.lang.Compiler$CompilerException: MyClass.clj:8: > Unable to resolve symbol: defn in this context > > If you replace (clojure/ns...) with: > (clojure/in-ns 'com.example) > (clojure/refer 'clojure) > (use 'clojure.contrib.pred) > then it works fine. > > -Stuart > > --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---