summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2009-12-17 14:01:10 -0500
committerRich Hickey <richhickey@gmail.com>2009-12-17 14:01:10 -0500
commitd3fe37cfd73592082ab37c62744d1baf5560a98b (patch)
tree2fbafb9bda47debd4d19ffc84b5d5de78b73bc7b
parent42e45b9988bfa17584f259d422b39c64cebabcce (diff)
parent6109d41a975bf24b17681342591116a9897e4a27 (diff)
Merge branch 'master' into new
-rw-r--r--.gitignore2
-rw-r--r--build.xml29
-rw-r--r--src/clj/clojure/core.clj84
-rw-r--r--src/clj/clojure/genclass.clj3
-rw-r--r--src/clj/clojure/main.clj6
5 files changed, 75 insertions, 49 deletions
diff --git a/.gitignore b/.gitignore
index c78bb655..4fce825e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,5 @@ pom.xml
clojure.iws
clojure.ipr
nbproject/private/
+*.zip
+dist
diff --git a/build.xml b/build.xml
index fccb3bb9..1c894931 100644
--- a/build.xml
+++ b/build.xml
@@ -13,6 +13,7 @@
<property name="jsrc" location="${src}/jvm"/>
<property name="cljsrc" location="${src}/clj"/>
<property name="build" location="classes"/>
+ <property name="dist" location="dist"/>
<!-- version related properties -->
<property file="${cljsrc}/clojure/version.properties"/>
@@ -166,9 +167,18 @@
<target name="clean"
description="Remove autogenerated files and directories.">
<delete dir="${build}"/>
+ <delete dir="${dist}"/>
<delete file="pom.xml"/>
</target>
+ <target name="distclean" depends="clean"
+ description="Remove all generated files, including JARs.">
+ <delete verbose="true">
+ <fileset dir="${basedir}" includes="*.jar"/>
+ <fileset dir="${basedir}" includes="*.zip"/>
+ </delete>
+ </target>
+
<target name="-setup-maven">
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant"/>
</target>
@@ -205,5 +215,22 @@
<deploy target-dir="${stable.repo.dir}"/>
</target>
-
+ <target name="dist" depends="distclean,jar"
+ description="Build distribution ZIP file">
+ <property name="distdir" value="${dist}/clojure-${clojure.version.label}"/>
+ <mkdir dir="${distdir}"/>
+ <copy todir="${distdir}" includeEmptyDirs="false">
+ <fileset dir="${basedir}">
+ <exclude name="pom.xml"/>
+ <exclude name="**/.git/**"/>
+ <exclude name="**/*.class"/>
+ <exclude name="**/*.iml"/>
+ <exclude name="**/*.ipr"/>
+ <exclude name="**/*.iws"/>
+ <exclude name="**/*.jar"/>
+ </fileset>
+ </copy>
+ <copy file="${clojure_noversion_jar}" todir="${distdir}"/>
+ <zip basedir="${dist}" destfile="clojure-${clojure.version.label}.zip"/>
+ </target>
</project>
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index 052cbff8..f78b385f 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -527,7 +527,8 @@
[x] (. clojure.lang.Delay (force x)))
(defmacro if-not
- "Evaluates test. If logical false, evaluates and returns then expr, otherwise else expr, if supplied, else nil."
+ "Evaluates test. If logical false, evaluates and returns then expr,
+ otherwise else expr, if supplied, else nil."
([test then] `(if-not ~test ~then nil))
([test then else]
`(if (not ~test) ~then ~else)))
@@ -1151,12 +1152,13 @@
`(. ~(with-meta multifn {:tag 'clojure.lang.MultiFn}) addMethod ~dispatch-val (fn ~@fn-tail)))
(defn remove-method
- "Removes the method of multimethod associated with dispatch-value."
+ "Removes the method of multimethod associated with dispatch-value."
[#^clojure.lang.MultiFn multifn dispatch-val]
(. multifn removeMethod dispatch-val))
(defn prefer-method
- "Causes the multimethod to prefer matches of dispatch-val-x over dispatch-val-y when there is a conflict"
+ "Causes the multimethod to prefer matches of dispatch-val-x over dispatch-val-y
+ when there is a conflict"
[#^clojure.lang.MultiFn multifn dispatch-val-x dispatch-val-y]
(. multifn preferMethod dispatch-val-x dispatch-val-y))
@@ -1186,7 +1188,8 @@
(defmacro if-let
"bindings => binding-form test
- If test is true, evaluates then with binding-form bound to the value of test, if not, yields else"
+ If test is true, evaluates then with binding-form bound to the value of
+ test, if not, yields else"
([bindings then]
`(if-let ~bindings ~then nil))
([bindings then else & oldform]
@@ -1363,7 +1366,7 @@
[] (clojure.lang.Agent/releasePendingSends))
(defn add-watch
- "Experimental.
+ "Alpha - subject to change.
Adds a watch function to an agent/atom/var/ref reference. The watch
fn must be a fn of 4 args: a key, the reference, its old-state, its
new-state. Whenever the reference's state might have been changed,
@@ -1380,32 +1383,11 @@
[#^clojure.lang.IRef reference key fn] (.addWatch reference key fn))
(defn remove-watch
- "Experimental.
+ "Alpha - subject to change.
Removes a watch (set by add-watch) from a reference"
[#^clojure.lang.IRef reference key]
(.removeWatch reference key))
-(defn add-watcher
- "Experimental.
- Adds a watcher to an agent/atom/var/ref reference. The watcher must
- be an Agent, and the action a function of the agent's state and one
- additional arg, the reference. Whenever the reference's state
- changes, any registered watchers will have their actions
- sent. send-type must be one of :send or :send-off. The actions will
- be sent after the reference's state is changed. Var watchers are
- triggered only by root binding changes, not thread-local set!s"
- [#^clojure.lang.IRef reference send-type watcher-agent action-fn]
- (add-watch reference watcher-agent
- (fn [watcher-agent reference old-state new-state]
- (when-not (identical? old-state new-state)
- ((if (= send-type :send-off) send-off send)
- watcher-agent action-fn reference)))))
-
-(defn remove-watcher
- "Experimental.
- Removes a watcher (set by add-watcher) from a reference"
- [reference watcher-agent]
- (remove-watch reference watcher-agent))
(defn agent-errors
"Returns a sequence of the exceptions thrown during asynchronous
@@ -3452,7 +3434,7 @@
`(binding [*math-context* (java.math.MathContext. ~precision ~@rm)]
~@body)))
-(defn bound-fn
+(defn mk-bound-fn
{:private true}
[#^clojure.lang.Sorted sc test key]
(fn [e]
@@ -3463,30 +3445,30 @@
>=. Returns a seq of those entries with keys ek for
which (test (.. sc comparator (compare ek key)) 0) is true"
([#^clojure.lang.Sorted sc test key]
- (let [include (bound-fn sc test key)]
+ (let [include (mk-bound-fn sc test key)]
(if (#{> >=} test)
(when-let [[e :as s] (. sc seqFrom key true)]
(if (include e) s (next s)))
(take-while include (. sc seq true)))))
([#^clojure.lang.Sorted sc start-test start-key end-test end-key]
(when-let [[e :as s] (. sc seqFrom start-key true)]
- (take-while (bound-fn sc end-test end-key)
- (if ((bound-fn sc start-test start-key) e) s (next s))))))
+ (take-while (mk-bound-fn sc end-test end-key)
+ (if ((mk-bound-fn sc start-test start-key) e) s (next s))))))
(defn rsubseq
"sc must be a sorted collection, test(s) one of <, <=, > or
>=. Returns a reverse seq of those entries with keys ek for
which (test (.. sc comparator (compare ek key)) 0) is true"
([#^clojure.lang.Sorted sc test key]
- (let [include (bound-fn sc test key)]
+ (let [include (mk-bound-fn sc test key)]
(if (#{< <=} test)
(when-let [[e :as s] (. sc seqFrom key false)]
(if (include e) s (next s)))
(take-while include (. sc seq false)))))
([#^clojure.lang.Sorted sc start-test start-key end-test end-key]
(when-let [[e :as s] (. sc seqFrom end-key false)]
- (take-while (bound-fn sc start-test start-key)
- (if ((bound-fn sc end-test end-key) e) s (next s))))))
+ (take-while (mk-bound-fn sc start-test start-key)
+ (if ((mk-bound-fn sc end-test end-key) e) s (next s))))))
(defn repeatedly
"Takes a function of no args, presumably with side effects, and returns an infinite
@@ -3531,8 +3513,9 @@
(defmacro amap
"Maps an expression across an array a, using an index named idx, and
- return value named ret, initialized to a clone of a, then setting each element of
- ret to the evaluation of expr, returning the new array ret."
+ return value named ret, initialized to a clone of a, then setting
+ each element of ret to the evaluation of expr, returning the new
+ array ret."
[a idx ret expr]
`(let [a# ~a
~ret (aclone a#)]
@@ -3545,8 +3528,8 @@
(defmacro areduce
"Reduces an expression across an array a, using an index named idx,
- and return value named ret, initialized to init, setting ret to the evaluation of expr at
- each step, returning ret."
+ and return value named ret, initialized to init, setting ret to the
+ evaluation of expr at each step, returning ret."
[a idx ret init expr]
`(let [a# ~a]
(loop [~idx (int 0) ~ret ~init]
@@ -4667,7 +4650,7 @@
"-SNAPSHOT")))
(defn promise
- "Experimental.
+ "Alpha - subject to change.
Returns a promise object that can be read with deref/@, and set,
once only, with deliver. Calls to deref/@ prior to delivery will
block. All subsequent derefs will return the same delivered value
@@ -4688,32 +4671,36 @@
(throw (IllegalStateException. "Multiple deliver calls to a promise"))))))))
(defn deliver
- "Experimental.
+ "Alpha - subject to change.
Delivers the supplied value to the promise, releasing any pending
derefs. A subsequent call to deliver on a promise will throw an exception."
[promise val] (promise val))
;;;;;;;;;;;;;;;;;;;;; editable collections ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn transient
- "Returns a new, transient version of the collection, in constant time."
+ "Alpha - subject to change.
+ Returns a new, transient version of the collection, in constant time."
[#^clojure.lang.IEditableCollection coll]
(.asTransient coll))
(defn persistent!
- "Returns a new, persistent version of the transient collection, in
+ "Alpha - subject to change.
+ Returns a new, persistent version of the transient collection, in
constant time. The transient collection cannot be used after this
call, any such use will throw an exception."
[#^clojure.lang.ITransientCollection coll]
(.persistent coll))
(defn conj!
- "Adds x to the transient collection, and return coll. The 'addition'
+ "Alpha - subject to change.
+ Adds x to the transient collection, and return coll. The 'addition'
may happen at different 'places' depending on the concrete type."
[#^clojure.lang.ITransientCollection coll x]
(.conj coll x))
(defn assoc!
- "When applied to a transient map, adds mapping of key(s) to
+ "Alpha - subject to change.
+ When applied to a transient map, adds mapping of key(s) to
val(s). When applied to a transient vector, sets the val at index.
Note - index must be <= (count vector). Returns coll."
([#^clojure.lang.ITransientAssociative coll key val] (.assoc coll key val))
@@ -4724,7 +4711,8 @@
ret))))
(defn dissoc!
- "Returns a transient map that doesn't contain a mapping for key(s)."
+ "Alpha - subject to change.
+ Returns a transient map that doesn't contain a mapping for key(s)."
([#^clojure.lang.ITransientMap map key] (.without map key))
([#^clojure.lang.ITransientMap map key & ks]
(let [ret (.without map key)]
@@ -4733,13 +4721,15 @@
ret))))
(defn pop!
- "Removes the last item from a transient vector. If
+ "Alpha - subject to change.
+ Removes the last item from a transient vector. If
the collection is empty, throws an exception. Returns coll"
[#^clojure.lang.ITransientVector coll]
(.pop coll))
(defn disj!
- "disj[oin]. Returns a transient set of the same (hashed/sorted) type, that
+ "Alpha - subject to change.
+ disj[oin]. Returns a transient set of the same (hashed/sorted) type, that
does not contain key(s)."
([set] set)
([#^clojure.lang.ITransientSet set key]
diff --git a/src/clj/clojure/genclass.clj b/src/clj/clojure/genclass.clj
index 3fa23087..6a06bd77 100644
--- a/src/clj/clojure/genclass.clj
+++ b/src/clj/clojure/genclass.clj
@@ -577,7 +577,8 @@
:impl-ns name
- Default: the name of the current ns. Implementations of methods will be looked up in this namespace.
+ Default: the name of the current ns. Implementations of methods will be
+ looked up in this namespace.
:load-impl-ns boolean
diff --git a/src/clj/clojure/main.clj b/src/clj/clojure/main.clj
index 5f480a60..6f08c6f0 100644
--- a/src/clj/clojure/main.clj
+++ b/src/clj/clojure/main.clj
@@ -291,6 +291,9 @@
"Called by the clojure.lang.Repl.main stub to run a repl with args
specified the old way"
[args]
+ (println "WARNING: clojure.lang.Repl is deprecated.
+Instead, use clojure.main like this:
+java -cp clojure.jar clojure.main -i init.clj -r args...")
(let [[inits [sep & args]] (split-with (complement #{"--"}) args)]
(repl-opt (concat ["-r"] args) (map vector (repeat "-i") inits))))
@@ -298,6 +301,9 @@
"Called by the clojure.lang.Script.main stub to run a script with args
specified the old way"
[args]
+ (println "WARNING: clojure.lang.Script is deprecated.
+Instead, use clojure.main like this:
+java -cp clojure.jar clojure.main -i init.clj script.clj args...")
(let [[inits [sep & args]] (split-with (complement #{"--"}) args)]
(null-opt args (map vector (repeat "-i") inits))))