Skip to content

Commit 2a4f2a2

Browse files
committed
[lazy] got rid of Sequence, (seq iseq) no longer an identity, ISeqs can be empty, PersistentList.EMPTY and LazySeq.EMPTY are ISeqs, rest returns ISeq
1 parent 20331a1 commit 2a4f2a2

File tree

11 files changed

+244
-241
lines changed

11 files changed

+244
-241
lines changed

src/clj/clojure/core.clj

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696

9797
(def
9898
#^{:arglists '([coll])
99-
:doc "Sequence. Returns a new ISeq on the collection. If the
99+
:doc "Returns a new ISeq on the collection. If the
100100
collection is empty, returns nil. (seq nil) returns nil. seq also
101101
works on Strings, native Java arrays (of reference types) and any
102102
objects that implement Iterable."
@@ -114,11 +114,6 @@
114114
:doc "Return true if x implements ISeq"}
115115
seq? (fn seq? [x] (instance? clojure.lang.ISeq x)))
116116

117-
(def
118-
#^{:arglists '([x])
119-
:doc "Return true if x implements Sequence, true of ISeqs and LazySeqs"}
120-
sequence? (fn sequence? [x] (instance? clojure.lang.Sequence x)))
121-
122117
(def
123118
#^{:arglists '([x])
124119
:doc "Return true if x is a String"}
@@ -138,7 +133,7 @@
138133
#^{:private true}
139134
sigs
140135
(fn [fdecl]
141-
(if (sequence? (first fdecl))
136+
(if (seq? (first fdecl))
142137
(loop [ret [] fdecl fdecl]
143138
(if fdecl
144139
(recur (conj ret (first (first fdecl))) (next fdecl))
@@ -185,7 +180,7 @@
185180

186181
(def
187182
#^{:arglists '([coll])
188-
:doc "Return a sequence of all but the last item in coll, in linear time"}
183+
:doc "Return a seq of all but the last item in coll, in linear time"}
189184
butlast (fn butlast [s]
190185
(loop [ret [] s s]
191186
(if (next s)
@@ -430,7 +425,7 @@
430425
(list* '#^{:once true :super-name "clojure/lang/LazySeq"} fn* [] body))
431426

432427
(defn concat
433-
"Returns a lazy sequence representing the concatenation of the elements in the supplied colls."
428+
"Returns a lazy seq representing the concatenation of the elements in the supplied colls."
434429
([] (lazy-seq nil))
435430
([x] (lazy-seq x))
436431
([x y]
@@ -971,8 +966,8 @@
971966
(. e (getValue)))
972967

973968
(defn rseq
974-
"Returns, in constant time, a sequence of the items in rev (which
975-
can be a vector or sorted-map), in reverse order."
969+
"Returns, in constant time, a seq of the items in rev (which
970+
can be a vector or sorted-map), in reverse order. If rev is empty returns nil"
976971
[#^clojure.lang.Reversible rev]
977972
(. rev (rseq)))
978973

@@ -1021,7 +1016,7 @@
10211016
second item in the first form, making a list of it if it is not a
10221017
list already. If there are more forms, inserts the first form as the
10231018
second item in second form, etc."
1024-
([x form] (if (sequence? form)
1019+
([x form] (if (seq? form)
10251020
`(~(first form) ~x ~@(next form))
10261021
(list form x)))
10271022
([x form & more] `(-> (-> ~x ~form) ~@more)))
@@ -2080,7 +2075,7 @@
20802075
(let [gx (gensym)]
20812076
`(let [~gx ~x]
20822077
~@(map (fn [f]
2083-
(if (sequence? f)
2078+
(if (seq? f)
20842079
`(~(first f) ~gx ~@(next f))
20852080
`(~f ~gx)))
20862081
forms)

src/clj/clojure/core_print.clj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,18 @@
128128
(defmethod print-dup clojure.lang.Var [#^clojure.lang.Var o, #^Writer w]
129129
(.write w (str "#=(var " (.name (.ns o)) "/" (.sym o) ")")))
130130

131-
(defmethod print-method clojure.lang.Sequence [o, #^Writer w]
131+
(defmethod print-method clojure.lang.ISeq [o, #^Writer w]
132132
(print-meta o w)
133133
(print-sequential "(" pr-on " " ")" o w))
134134

135-
(defmethod print-dup clojure.lang.Sequence [o w] (print-method o w))
135+
(defmethod print-dup clojure.lang.ISeq [o w] (print-method o w))
136136
(defmethod print-dup clojure.lang.IPersistentList [o w] (print-method o w))
137-
(prefer-method print-method clojure.lang.IPersistentList clojure.lang.Sequence)
138-
(prefer-method print-dup clojure.lang.IPersistentList clojure.lang.Sequence)
139-
(prefer-method print-method clojure.lang.Sequence clojure.lang.IPersistentCollection)
140-
(prefer-method print-dup clojure.lang.Sequence clojure.lang.IPersistentCollection)
141-
(prefer-method print-method clojure.lang.Sequence java.util.Collection)
142-
(prefer-method print-dup clojure.lang.Sequence java.util.Collection)
137+
(prefer-method print-method clojure.lang.IPersistentList clojure.lang.ISeq)
138+
(prefer-method print-dup clojure.lang.IPersistentList clojure.lang.ISeq)
139+
(prefer-method print-method clojure.lang.ISeq clojure.lang.IPersistentCollection)
140+
(prefer-method print-dup clojure.lang.ISeq clojure.lang.IPersistentCollection)
141+
(prefer-method print-method clojure.lang.ISeq java.util.Collection)
142+
(prefer-method print-dup clojure.lang.ISeq java.util.Collection)
143143

144144
(defmethod print-method clojure.lang.IPersistentList [o, #^Writer w]
145145
(print-meta o w)

src/jvm/clojure/lang/ASeq.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public ISeq cons(Object o){
110110
return new Cons(o, this);
111111
}
112112

113-
public Sequence more(){
113+
public ISeq more(){
114114
ISeq s = next();
115115
if(s == null)
116116
return LazySeq.EMPTY;

src/jvm/clojure/lang/Cons.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212

1313
package clojure.lang;
1414

15-
public class Cons extends ASeq{
15+
final public class Cons extends ASeq{
1616

1717
private final Object _first;
18-
private final Sequence _more;
18+
private final ISeq _more;
1919

20-
public Cons(Object first, Sequence _more){
20+
public Cons(Object first, ISeq _more){
2121
this._first = first;
2222
this._more = _more;
2323
}
2424

2525

26-
public Cons(IPersistentMap meta, Object _first, Sequence _more){
26+
public Cons(IPersistentMap meta, Object _first, ISeq _more){
2727
super(meta);
2828
this._first = _first;
2929
this._more = _more;
@@ -37,7 +37,7 @@ public ISeq next(){
3737
return more().seq();
3838
}
3939

40-
public Sequence more(){
40+
public ISeq more(){
4141
if(_more == null)
4242
return LazySeq.EMPTY;
4343
return _more;

0 commit comments

Comments
 (0)