On Feb 23, 2009, at 1:54 PM, Chouser wrote:
This is much prettier to my eye, but has a couple things that could be better. So, feature request #1 is that if a libspec has an ":as" option, that the ":only []" option be implied. That is, if I'm aliasing an namespace, don't by default refer in all that namespaces vars.
Making only the ":as x" implies ":only ()" change that you proposed would make it easy and pretty for anyone following the style we've been recommending to stick with ":use" exclusively even if ":require" remains in Clojure.
While this would technically be a breaking change, it seems unlikely to me that it will cause much if any real-world disruption. Any usage that actually intended to both alias the namespace and refer all the symbols could say [my.lib :as mylib :exclude ()]
Intentionally referring an entire namespace in and also aliasing it seems a very odd thing to do. The number of libs this change would break is very likely to be tiny and the breakage will be obvious and easy to fix.
I've made the change you proposed on my machine and it works nicely.Here is an updated doc for "use" as would be correct if this change were adopted.
------------------------- clojure.core/use ([& args]) Loads libs, skipping any that are already loaded. Provides options to call clojure.core/alias or clojure.core/refer for each lib's namespace. Each argument is either a libspec that identifies a lib, a prefix list that identifies multiple libs whose names share a common prefix, or a flag that modifies how all the identified libs are loaded. Note: clojure.core/use exists primarily to implement the :use clause in an ns form. Direct calls to clojure.core/use are only appropriate in interactive contexts such as at a REPL. Libs A lib is a named unit of Clojure code that defines a namespace. Each lib is stored in one or more resources in classpath. Lib names are symbols and each lib is associated with the Clojure namespace and the Java package that share its name. Each lib is also associated with a classpath-relative root path via Java's 'package name' to 'classpath-relative path' mapping. For example, the classpath-relative root path for the lib a.b-c.d is a/b_c/d. Given this root path, use will load either the compiled resource a/b_c/d__init.class or the Clojure source resource a/b_c/d.clj, preferring the compiled resource if it's both present and has a later modification date than the source resource. A lib's source resource should begin with an ns form to create the lib's namespace, declare and satisfy any dependencies it has on other libs, and/or load any additional resources. Libspecs A libspec is a lib name or a vector containing a lib name followed by options expressed as sequential keywords and values. Recognized options: :as, :exclude, :only, :rename :as takes a symbol as its value and makes that symbol an alias to the lib's namespace in the current namespace. :exclude, :only, :rename and their associated values are passed along to clojure/refer and have the effect documented there. When no options are given, use will call clojure.core/refer without options to refer the lib's entire namespace into the current namespace. Prefix Lists It's common for a lib to depend on several libs whose names share a common prefix. When specifying libs, prefix lists can be used to reduce repetition. A prefix list contains the shared prefix followed by libspecs with the shared prefix removed from the lib names. After removing the prefix, the names that remain must not contain any periods. Flags A flag is a keyword. Recognized flags: :reload, :reload-all, :verbose :reload forces loading of all the identified libs even if they are already loaded :reload-all implies :reload and also forces loading of all libs that the identified libs directly or indirectly load via require or use :verbose triggers printing information about each load, alias, and refer --Steve
smime.p7s
Description: S/MIME cryptographic signature