> Does Clojure have away to import all of a namespace? Is that what
> refer does? Does someone have an example they can show me?
Clojure namespaces are distinct from Java packages. The import
command brings specified names from a Java package into the current
namespace. I'm not aware of a way to wildcard the names that are
imported.
The refer command brings names from another Clojure namspace into the
current Clojure namespace.
user=> (doc import)
-------------------------
clojure/import
([& import-lists])
import-list => (package-symbol class-name-symbols*)
For each name in class-name-symbols, adds a mapping from name to the
class named by package.name to the current namespace.
nil
user=> (doc refer)
-------------------------
clojure/refer
([ns-sym & filters])
refers to all public vars of ns, subject to filters.
filters can include at most one each of:
:exclude list-of-symbols
:only list-of-symbols
:rename map-of-fromsymbol-tosymbol
For each public interned var in the namespace named by the symbol,
adds a mapping from the name of the var to the var to the current
namespace. Throws an exception if name is already mapped to
something else in the current namespace. Filters can be used to
select a subset, via inclusion or exclusion, or to provide a mapping
to a symbol different from the var's name, in order to prevent
clashes.
nil
user=>
This contains a simple example of each:
--Steve
Which can be found here (JDK 6):
http://java.sun.com/javase/6/docs/api/
The programmers guide can also be a good place to look for things it
is a superset of the api doc.
http://java.sun.com/javase/6/docs/
Regards,
Bry
There doesn't appear to be anything in java.lang.reflect for
enumerating classes in a package directly. Seems to mainly for
traversing class hierarchies.
This thread ( http://forum.java.sun.com/thread.jspa?threadID=341935&start=0
) seems to suggest parsing the contents of the jar files.
I am not sure if importing all the classes from a package is a good
idea. Convenient maybe, but not a wise idea. Especially since our
import syntax is so much better than plain java.
Also because I am of the opinion that java interop does not belong
outside of libraries, and that we should be VERY wary about where the
java objects are, because of concurrency semantics ( I am stating this
blindly but I think it is right, please correct me otherwise ). I
don't think we should be using import that much.
Though we most likely will be for the near term until we start getting
native wrappers for all this common stuff. At which point our api
wrappers should be a lot better than the java api ;)