On Nov 21, 2008, at 8:39 AM, Stuart Halloway wrote: > The "right way" to use, most of the time, is inside an ns: > > (ns foo > (:use [clojure.contrib.str-utils :only (str-join re-split)])) > > However, for the interactive examples in the book, it is nice to just > switch namespaces at the REPL, where ns is bad form. So instead, you > would do this: > > (in-ns 'bar) > -> #<Namespace bar> > (clojure.core/use [clojure.contrib.str-utils :only (str-join re- > split)]) > -> java.lang.ClassNotFoundException: clojure.contrib.str-utils > (NO_SOURCE_FILE:10) > > Except, as you can see, it doesn't work. You have to quote the vector: > > (clojure.core/use '[clojure.contrib.str-utils :only (str-join re- > split)]) > -> nil > > Is this by design? Quoting a vector doesn't feel right.
The arguments to use are evaluated. Symbols and lists need quoting to represent themselves rather than being resolved and evaluated (symbols) or treated as a call (lists). You can quote the vector or you can quote individual symbols and lists. user=> (clojure.core/use ['clojure.contrib.str-utils :only '(str-join re-split)]) nil I prefer to quote the vector. At one time require and use were macros. I changed that when I saw that it was somewhat difficult to drive them from another program: since their arguments were not evaluated, the arguments couldn't be stored in a var or passed along as arguments by another function, for example. Rich mused about making them macros again at one point to avoid this quoting. Perhaps the convenient use of requre/use/refer/in-ns at the repl is a significantly more important use case than passing their arguments in a way that requires evaluation and we should revisit making the whole suite of them macros. --Steve --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---