Rich Hickey
unread,Jan 29, 2008, 6:48:46 PM1/29/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Clojure
The wait is over, Clojure now has first-class namespaces (in SVN).
I've made several breaking changes, mostly renames, in an effort to
bundle these up in a single release, and am thinking about
subsequently moving from an alpha to a beta designation.
Renamed eql? to =
= does number value equivalence now, e.g. (= 1 1.0), (= (int 1) (long
1)), etc -> true
added not=
renamed sym to symbol
renamed appl to partial
instance? takes args in opposite order now - (instance? class x), so
it can be partially applied.
identical? is a fn, not a special op
Lots of namespace stuff either new or renamed:
in-namespace renamed in-ns, will create the namespace if it doesn't
exist
*current-namespace* renamed to *ns*, and is a Namespace object, not a
symbol
import has same syntax as before, but creates mappings from names to
Class objects, not strings
find-ns [sym]
create-ns [sym]
remove-ns [sym]
all-ns []
ns-name [ns]
ns-unmap [ns sym], removes the mapping from the namespace, whether an
interned var, referred var, or imported class
ns-map [ns], a map of all mappings in the namespace, union of interns/
imports/refers.
ns-exports [ns], a map of the exported vars
ns-imports [ns], a map of the imported classes
ns-refers [ns], a map of the referred-to vars from other namespaces
ns-interns [ns], all of the internal vars of the namespace, exported
or not
ns-resolve [ns sym], returns the object to which the symbol refers in
the namespace.
resolve [sym] -> (resolve *ns* sym)
export [syms], sets the vars named, by the syms, which must be
interned in *ns*, to be exported
refer [ns-symbol & filters]
refers to all exported vars of ns, subject to filters
filters can include at most one each of (CL keyword arg style):
:exclude list-of-symbols
:only list-of-symbols
:rename map-of-fromsymbol-tosymbol
You can find the above by diffing boot.clj against itself at rev 615
Other changes:
No need to load boot.clj, now included and loaded from the jar
But you must build with Ant, which you can do in IntelliJ.
Go to Ant build window and add build.xml
Take any launching configurations (e.g. Repl) and add -cp
clojure.jar to the VM parameters
Take src/boot.clj off the program parameters
Under Before launch
deselect Make
select run Ant target, push ... and select jar
If someone could send me the changes needed for the Maven script I'd
appreciate it.
added Class literals, you can just use fully.qualified.Classname or
any imported Classname, no need for (class Classname), and get the
Class object - the class special op is gone
A new namespace doesn't refer to or intern anything (but imports
java.lang), so you'll need to
(clojure/refer 'clojure)
to get the built-ins from boot.clj (the Repl already does this for
user namespace)
Added:
take-nth [n coll], lazy seq of every nth item
interleave [& colls], lazy seq of one item from each collection etc
filter-key [keyfn pred amap], a lazy seq of those items for which
(pred (keyfn item)) is logical true
array-map [keyval*] ,a map implementation on an array of alternating
keys and values. Linear lookup time, so only good for very small maps.
Has the property that keys stay in the order they are supplied.
For use of non-interned vars:
var-get [#^clojure.lang.Var x]
var-set [#^clojure.lang.Var x val]
macro with-local-vars [name-vals-vec & body]
Added some simple emit and emit-element functions to src/xml.clj to go
back to XML
Added simple GUI inspector capability in src/inspector.clj:
inspect-tree [x], will load the data structure into a JTree
inspect-table [x], will load the data structure into a JTable. The
data structure must be a seq of uniform vectors or maps
Many under-the-hood improvements.
For intrepid souls interested in any or all of the above, I'd
appreciate if you'd kick the tires.
Thanks again for all the input and feedback,
Rich