Changeset 27259 in project
- Timestamp:
- 08/18/12 14:48:02 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wiki/eggref/4/clojurian
r26734 r27259 8 8 === Overview 9 9 10 Currently the only module provided by this egg is {{clojurian-syntax}}. 10 Currently this egg provides two modules: {{clojurian-syntax}} and 11 {{clojurian-atom}}. 11 12 12 13 === Modules … … 94 95 95 96 97 <syntax>(if-let (var val) then else)</syntax> 98 99 Equivalent to {{(let ((var val)) (if var then else))}}. 100 101 102 <syntax>(if-let* ((x1 y1) (x2 y2) ...) then else)</syntax> 103 104 Equivalent to {{(or (and-let* ((x1 y1) (x2 y2) ...) then) else)}}. 105 106 107 ==== clojurian-atom (experimental) 108 109 This module provides an implementation of 110 [[http://clojure.org/atoms|Clojure's atom reference type]]. It is in 111 an experimental state right now and only provides the very basic 112 functionality, e.g. validators and watches are still missing. Note 113 that atoms only work with immutable data structures so they can't be 114 used to coordinate updates of record slots, for example. 115 116 117 <procedure>(atom value)</procedure> 118 119 Returns and atom with the given initial {{value}}. 120 121 122 <procedure>(atom? x)</procedure> 123 124 Checks whether {{x}} is an atom. 125 126 127 <procedure>(atom-value atom)</procedure> 128 129 Returns the current value of {{atom}}. 130 131 132 <procedure>(compare-and-set! atom old new)</procedure> 133 134 Atomically sets the value of {{atom}} to {{new}} if its current value 135 is {{eq?}} to the given {{old}} value. Returns {{#t}} if the update 136 was successful and {{#f}} if not. 137 138 139 <procedure>(swap! atom proc . args)</procedure> 140 141 Atomically swaps the value of {{atom}} to be {{(apply proc (atom-value 142 atom) args)}}. Because {{proc}} may be called multiple times it must 143 be free of side-effects. Returns the new value of {{atom}}. 144 145 146 <procedure>(reset! atom value)</procedure> 147 148 Sets the value of {{atom}} to {{value}}. Returns {{value}}. 149 150 96 151 === About this egg 97 152 … … 110 165 ==== Version history 111 166 167 ; 0.0.2 : Add {{if-let}}, {{if-let*}} and {{clojurian-atom}} 112 168 ; 0.0.1 : Initial release 113 169
Note: See TracChangeset
for help on using the changeset viewer.