Skip to content

Commit f244a1c

Browse files
committed
removed add/remove watcher, added alpha designation to watches, promises, transients
1 parent 6073890 commit f244a1c

File tree

1 file changed

+18
-32
lines changed

1 file changed

+18
-32
lines changed

src/clj/clojure/core.clj

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@
13661366
[] (clojure.lang.Agent/releasePendingSends))
13671367

13681368
(defn add-watch
1369-
"Experimental.
1369+
"Alpha - subject to change.
13701370
Adds a watch function to an agent/atom/var/ref reference. The watch
13711371
fn must be a fn of 4 args: a key, the reference, its old-state, its
13721372
new-state. Whenever the reference's state might have been changed,
@@ -1383,32 +1383,11 @@
13831383
[#^clojure.lang.IRef reference key fn] (.addWatch reference key fn))
13841384

13851385
(defn remove-watch
1386-
"Experimental.
1386+
"Alpha - subject to change.
13871387
Removes a watch (set by add-watch) from a reference"
13881388
[#^clojure.lang.IRef reference key]
13891389
(.removeWatch reference key))
13901390

1391-
(defn add-watcher
1392-
"Experimental.
1393-
Adds a watcher to an agent/atom/var/ref reference. The watcher must
1394-
be an Agent, and the action a function of the agent's state and one
1395-
additional arg, the reference. Whenever the reference's state
1396-
changes, any registered watchers will have their actions
1397-
sent. send-type must be one of :send or :send-off. The actions will
1398-
be sent after the reference's state is changed. Var watchers are
1399-
triggered only by root binding changes, not thread-local set!s"
1400-
[#^clojure.lang.IRef reference send-type watcher-agent action-fn]
1401-
(add-watch reference watcher-agent
1402-
(fn [watcher-agent reference old-state new-state]
1403-
(when-not (identical? old-state new-state)
1404-
((if (= send-type :send-off) send-off send)
1405-
watcher-agent action-fn reference)))))
1406-
1407-
(defn remove-watcher
1408-
"Experimental.
1409-
Removes a watcher (set by add-watcher) from a reference"
1410-
[reference watcher-agent]
1411-
(remove-watch reference watcher-agent))
14121391

14131392
(defn agent-errors
14141393
"Returns a sequence of the exceptions thrown during asynchronous
@@ -4592,7 +4571,7 @@
45924571
"-SNAPSHOT")))
45934572

45944573
(defn promise
4595-
"Experimental.
4574+
"Alpha - subject to change.
45964575
Returns a promise object that can be read with deref/@, and set,
45974576
once only, with deliver. Calls to deref/@ prior to delivery will
45984577
block. All subsequent derefs will return the same delivered value
@@ -4611,32 +4590,36 @@
46114590
(throw (IllegalStateException. "Multiple deliver calls to a promise"))))))))
46124591

46134592
(defn deliver
4614-
"Experimental.
4593+
"Alpha - subject to change.
46154594
Delivers the supplied value to the promise, releasing any pending
46164595
derefs. A subsequent call to deliver on a promise will throw an exception."
46174596
[promise val] (promise val))
46184597

46194598
;;;;;;;;;;;;;;;;;;;;; editable collections ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46204599
(defn transient
4621-
"Returns a new, transient version of the collection, in constant time."
4600+
"Alpha - subject to change.
4601+
Returns a new, transient version of the collection, in constant time."
46224602
[#^clojure.lang.IEditableCollection coll]
46234603
(.asTransient coll))
46244604

46254605
(defn persistent!
4626-
"Returns a new, persistent version of the transient collection, in
4606+
"Alpha - subject to change.
4607+
Returns a new, persistent version of the transient collection, in
46274608
constant time. The transient collection cannot be used after this
46284609
call, any such use will throw an exception."
46294610
[#^clojure.lang.ITransientCollection coll]
46304611
(.persistent coll))
46314612

46324613
(defn conj!
4633-
"Adds x to the transient collection, and return coll. The 'addition'
4614+
"Alpha - subject to change.
4615+
Adds x to the transient collection, and return coll. The 'addition'
46344616
may happen at different 'places' depending on the concrete type."
46354617
[#^clojure.lang.ITransientCollection coll x]
46364618
(.conj coll x))
46374619

46384620
(defn assoc!
4639-
"When applied to a transient map, adds mapping of key(s) to
4621+
"Alpha - subject to change.
4622+
When applied to a transient map, adds mapping of key(s) to
46404623
val(s). When applied to a transient vector, sets the val at index.
46414624
Note - index must be <= (count vector). Returns coll."
46424625
([#^clojure.lang.ITransientAssociative coll key val] (.assoc coll key val))
@@ -4647,7 +4630,8 @@
46474630
ret))))
46484631

46494632
(defn dissoc!
4650-
"Returns a transient map that doesn't contain a mapping for key(s)."
4633+
"Alpha - subject to change.
4634+
Returns a transient map that doesn't contain a mapping for key(s)."
46514635
([#^clojure.lang.ITransientMap map key] (.without map key))
46524636
([#^clojure.lang.ITransientMap map key & ks]
46534637
(let [ret (.without map key)]
@@ -4656,13 +4640,15 @@
46564640
ret))))
46574641

46584642
(defn pop!
4659-
"Removes the last item from a transient vector. If
4643+
"Alpha - subject to change.
4644+
Removes the last item from a transient vector. If
46604645
the collection is empty, throws an exception. Returns coll"
46614646
[#^clojure.lang.ITransientVector coll]
46624647
(.pop coll))
46634648

46644649
(defn disj!
4665-
"disj[oin]. Returns a transient set of the same (hashed/sorted) type, that
4650+
"Alpha - subject to change.
4651+
disj[oin]. Returns a transient set of the same (hashed/sorted) type, that
46664652
does not contain key(s)."
46674653
([set] set)
46684654
([#^clojure.lang.ITransientSet set key]

0 commit comments

Comments
 (0)