I tried to migrate swank-clojure to lazy branch rev1282. Here are steps I did.
1) search and replace rest to next 2) search and replace seq? to sequence? 3) change lazy-cons to lazy-seq following the recipe 4) fixed if LazySeq exceptions see attached diff at the end. Code loads fine. However, I got below error as soon as emacs slime- connect to swank server. The failing code occurred in eval form read from emacs connection. In jswat debugger, I can see form.toString() in clojure.lang.Compiler.eval frame as "(#'swank.commands.contrib/swank- require (quote (:swank-repl ...)))". I even cut & pasted it to plain repl and it ran fine. However, browsing object shows form.more() is a clojure.core$map_xxx$fn_xxx, which looks like a lazy-seq closure. What could be wrong here? clojure.lang.PersistentList [Thrown class java.lang.ClassCastException] Restarts: 0: [ABORT] Return to SLIME's top level. Backtrace: 0: swank.commands.contrib$eval__1128.<clinit>(Unknown Source) 1: sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 2: sun.reflect.NativeConstructorAccessorImpl.newInstance (NativeConstructorAccessorImpl.java:39) 3: sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:27) 4: java.lang.reflect.Constructor.newInstance(Constructor.java:494) 5: java.lang.Class.newInstance0(Class.java:350) 6: java.lang.Class.newInstance(Class.java:303) 7: clojure.lang.Compiler$FnExpr.eval(Compiler.java:3263) 8: clojure.lang.Compiler.eval(Compiler.java:4209) 9: clojure.core$eval__3811.invoke(core.clj:1695) 10: swank.core$eval_in_emacs_package__272.invoke(core.clj:55) 11: swank.core$eval_for_emacs__346.invoke(core.clj:123) 12: clojure.lang.Var.invoke(Var.java:344) 13: clojure.lang.AFn.applyToHelper(AFn.java:179) 14: clojure.lang.Var.applyTo(Var.java:453) 15: clojure.core$apply__3084.doInvoke(core.clj:410) 16: clojure.lang.RestFn.invoke(RestFn.java:428) 17: swank.core$eval_from_control__275.invoke(core.clj:62) 18: swank.core$spawn_worker_thread__369$fn__397$fn__399.invoke (core.clj:157) 19: clojure.lang.AFn.applyToHelper(AFn.java:171) 20: clojure.lang.AFn.applyTo(AFn.java:164) 21: clojure.core$apply__3084.doInvoke(core.clj:410) 22: clojure.lang.RestFn.invoke(RestFn.java:428) 23: swank.core$spawn_worker_thread__369$fn__397.doInvoke(core.clj: 153) 24: clojure.lang.RestFn.invoke(RestFn.java:402) 25: clojure.lang.AFn.run(AFn.java:37) 26: java.lang.Thread.run(Thread.java:613) thanks, - Feng diff --git a/swank/commands/basic.clj b/swank/commands/basic.clj index 79d4354..8072d5b 100644 --- a/swank/commands/basic.clj +++ b/swank/commands/basic.clj @@ -98,8 +98,9 @@ :short-message ~(.toString t))) (defn- exception-causes [#^Throwable t] - (lazy-cons t (when-let [cause (.getCause t)] - (exception-causes cause)))) + (lazy-seq + (cons t (when-let [cause (.getCause t)] + (exception-causes cause))))) (defn- compile-file-for-emacs* "Compiles a file for emacs. Because clojure doesn't compile, this is diff --git a/swank/commands/contrib.clj b/swank/commands/contrib.clj index 6c0ed07..2185efd 100644 --- a/swank/commands/contrib.clj +++ b/swank/commands/contrib.clj @@ -3,7 +3,7 @@ (defslimefn swank-require [keys] (binding [*ns* (find-ns 'swank.commands.contrib)] - (doseq [k (if (seq? keys) keys (list keys))] + (doseq [k (if (sequence? keys) keys (list keys))] (try (require (symbol (str "swank.commands.contrib." (name k)))) - (catch java.io.FileNotFoundException fne nil))))) \ No newline at end of file + (catch java.io.FileNotFoundException fne nil))))) diff --git a/swank/commands/contrib/swank_arglists.clj b/swank/ commands/contrib/swank_arglists.clj index 4a87d89..e7a6cd9 100644 --- a/swank/commands/contrib/swank_arglists.clj +++ b/swank/commands/contrib/swank_arglists.clj @@ -9,8 +9,8 @@ print-lines]} (apply hash-map options)] ;; Yeah, I'm lazy -- I'll flesh this out later (if (and raw-specs - (seq? raw-specs) - (seq? (first raw-specs))) + (sequence? raw-specs) + (sequence? (first raw-specs))) ((slime-fn 'operator-arglist) (ffirst raw-specs) *current- package*) nil))) diff --git a/swank/commands/indent.clj b/swank/commands/indent.clj index 6248399..af58ce3 100644 --- a/swank/commands/indent.clj +++ b/swank/commands/indent.clj @@ -33,10 +33,7 @@ (filter (comp var? val) (mapcat ns-map nss))))) (defn- every-other [coll] - (when coll - (lazy-cons - (first coll) - (every-other (drop 2 coll))))) + (take-nth 2 coll)) (defn- update-indentation-delta "Update the cache and return the changes in a (symbol '. indent) list. @@ -53,15 +50,15 @@ (let [vars (filter (comp var? val) (mapcat ns-map nss))] (mapcat in-cache? vars)))] (if force - (when-let [updates (considerations-for (all-ns))] + (when-let [updates (seq (considerations-for (all-ns)))] (dosync (apply alter cache assoc updates)) - (every-other (rest updates))) + (every-other (next updates))) (let [ns (maybe-ns *current-package*) in-ns? (fn [[sym var]] (and (var? var) (= ns ((meta var) :ns))))] (when ns - (when-let [updates (filter identity (considerations- for (list ns)))] + (when-let [updates (seq (filter identity (considerations-for (list ns))))] (dosync (apply alter cache assoc updates)) - (every-other (rest updates)))))))))) + (every-other (next updates)))))))))) (defn- perform-indentation-update "Update the indentation cache in connection and update emacs. @@ -71,7 +68,7 @@ (let [delta (update-indentation-delta cache force)] (dosync (ref-set (conn :indent-cache-pkg) (hash (all-ns))) - (when delta + (when (seq delta) (send-to-emacs `(:indentation-update ~delta)))))))) (defn- sync-indentation-to-emacs diff --git a/swank/commands/inspector.clj b/swank/commands/ inspector.clj index a91f724..80f66f8 100644 --- a/swank/commands/inspector.clj +++ b/swank/commands/inspector.clj @@ -72,7 +72,7 @@ (vector? obj) :vector (var? obj) :var (string? obj) :string - (seq? obj) :seq + (sequence? obj) :seq (instance? Class obj) :class (instance? clojure.lang.Namespace obj) :namespace))) @@ -189,7 +189,7 @@ (fn spec-value [val] (cond (string? val) val - (seq? val) (spec-seq val)))] + (sequence? val) (spec-seq val)))] (map spec-value specs))) ;; Works for infinite sequences, but it lies about length. Luckily, emacs doesn't @@ -258,7 +258,7 @@ (defslimefn inspector-pop [] (with-emacs-package (cond - (rest @*inspector-stack*) + (next @*inspector-stack*) (inspect-object (dosync (ref-pop *inspector-stack*) diff --git a/swank/core.clj b/swank/core.clj index 260cdd7..87c6623 100644 --- a/swank/core.clj +++ b/swank/core.clj @@ -59,7 +59,7 @@ "Blocks for a mbox message from the control thread and executes it when received. The mbox message is expected to be a slime-fn." ([] (let [form (mb/receive (current-thread))] - (apply (ns-resolve *ns* (first form)) (rest form))))) + (apply (ns-resolve *ns* (first form)) (next form))))) (defn eval-loop "A loop which continuosly reads actions from the control thread and @@ -67,8 +67,9 @@ ([] (continuously (eval-from-control)))) (defn- exception-causes [#^Throwable t] - (lazy-cons t (when-let [cause (.getCause t)] - (exception-causes cause)))) + (lazy-seq + (cons t (when-let [cause (.getCause t)] + (exception-causes cause))))) (defn- debug-quit-exception? [t] (some #(identical? *debug-quit-exception* %) (exception-causes t))) @@ -110,7 +111,7 @@ (send-to-emacs (list :debug-return (current-thread) level nil)))))) (defn doall-seq [coll] - (if (seq? coll) + (if (sequence? coll) (doall coll) coll)) @@ -118,7 +119,7 @@ (try (binding [*current-package* buffer-package] (if-let [f (slime-fn (first form))] - (let [form (cons f (rest form)) + (let [form (cons f (next form)) result (doall-seq (eval-in-emacs-package form))] (run-hook *pre-reply-hook*) (send-to-emacs `(:return ~(thread-name (current-thread)) (:ok ~result) ~id))) diff --git a/swank/core/protocol.clj b/swank/core/protocol.clj index 35dfa43..d8bf4c4 100644 --- a/swank/core/protocol.clj +++ b/swank/core/protocol.clj @@ -45,7 +45,7 @@ (let [len (hex->num (read-chars 6 rdr)) msg (read-chars len rdr) form (read-from-string (fix-namespace msg))] - (if (seq? form) + (if (sequence? form) (deep-replace {'t true} form) form)))) diff --git a/swank/util.clj b/swank/util.clj index 3ba2ecc..fcb9c22 100644 --- a/swank/util.clj +++ b/swank/util.clj @@ -31,10 +31,10 @@ ([item coll] (position item coll 0)) ([item coll start] (loop [coll (drop start coll), i start] - (when coll + (when (seq coll) (if (= (first coll) item) i - (recur (rest coll) (inc i)))))) + (recur (next coll) (inc i)))))) {:tag Integer}) (defn categorize-by @@ -54,7 +54,7 @@ (defn deep-replace [smap coll] - (map #(if (or (seq? %) (vector? %)) + (map #(if (or (sequence? %) (vector? %)) (deep-replace smap %) %) (replace smap coll))) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---