File tree Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Expand file tree Collapse file tree 4 files changed +23
-3
lines changed Original file line number Diff line number Diff line change 1111 <property name =" build" location =" classes" />
1212 <property name =" clojure_jar" location =" clojure.jar" />
1313 <property name =" slim_jar" location =" clojure-slim.jar" />
14+ <property name =" clojure.assert-if-lazy-seq" value =" " />
1415
1516 <target name =" init" depends =" clean" >
1617 <tstamp />
2829 <java classname =" clojure.lang.Compile"
2930 classpath =" ${ build } :${ cljsrc } " >
3031 <sysproperty key =" clojure.compile.path" value =" ${ build } " />
32+ <sysproperty key =" clojure.assert-if-lazy-seq" value =" ${ clojure.assert-if-lazy-seq } " />
3133 <arg value =" clojure.core" />
3234 <arg value =" clojure.main" />
3335 <arg value =" clojure.set" />
Original file line number Diff line number Diff line change 3535 #^{:macro true }
3636 fn (fn* fn [& decl] (cons 'fn* decl)))
3737
38+ (def
39+ #^{:macro true }
40+ if (fn* if [& decl] (cons 'if* decl)))
41+
3842(def
3943 #^{:arglists '([coll])
4044 :doc " Returns the first item in the collection. Calls seq on its
291295
292296(. (var defmacro ) (setMacro ))
293297
298+ (defmacro assert-if-lazy-seq? {:private true } []
299+ (let [prop (System/getProperty " clojure.assert-if-lazy-seq" )]
300+ (if prop
301+ (if (clojure.lang.Util/equals prop " " ) nil true ))))
302+
303+ (defmacro if [tst & etc]
304+ (if* (assert-if-lazy-seq? )
305+ (let [tstsym 'G__0_0]
306+ (list 'let [tstsym tst]
307+ (list 'if* (list 'clojure.core/instance? clojure.lang.LazySeq tstsym)
308+ (list 'throw (list 'new Exception " LazySeq used in 'if'" ))
309+ (cons 'if* (cons tstsym etc)))))
310+ (cons 'if* (cons tst etc))))
311+
294312(defmacro when
295313 " Evaluates test. If logical true, evaluates body in an implicit do."
296314 [test & body]
16421660 ([coll]
16431661 (sort compare coll))
16441662 ([#^java.util.Comparator comp coll]
1645- (when (and coll ( not ( zero? ( count coll))) )
1663+ (when (seq coll)
16461664 (let [a (to-array coll)]
16471665 (. java.util.Arrays (sort a comp))
16481666 (seq a)))))
Original file line number Diff line number Diff line change 155155 meths (concat
156156 (seq (. c (getDeclaredMethods )))
157157 (seq (. c (getMethods ))))]
158- (if meths
158+ (if ( seq meths)
159159 (let [#^java.lang.reflect.Method meth (first meths)
160160 mods (. meth (getModifiers ))
161161 mk (method-sig meth)]
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public class Compiler implements Opcodes{
4040static final Symbol DEF = Symbol .create ("def" );
4141static final Symbol LOOP = Symbol .create ("loop*" );
4242static final Symbol RECUR = Symbol .create ("recur" );
43- static final Symbol IF = Symbol .create ("if" );
43+ static final Symbol IF = Symbol .create ("if* " );
4444static final Symbol LET = Symbol .create ("let*" );
4545static final Symbol DO = Symbol .create ("do" );
4646static final Symbol FN = Symbol .create ("fn*" );
You can’t perform that action at this time.
0 commit comments