Permalink
Browse files

add read-seq and make useful.debug embeddable

  • Loading branch information...
1 parent 70c4675 commit be93b3da93e915cf3e4124747d450559b176cd2e @ninjudd ninjudd committed Oct 22, 2011
Showing with 23 additions and 13 deletions.
  1. +1 −1 project.clj
  2. +5 −3 src/useful/debug.clj
  3. +9 −9 src/useful/macro.clj
  4. +8 −0 src/useful/utils.clj
View
@@ -1,4 +1,4 @@
-(defproject useful "0.7.4-alpha1"
+(defproject useful "0.7.4-alpha2"
:description "A collection of generally-useful Clojure utility functions"
:dependencies [[clojure "1.2.0"]
[org.clojure/tools.macro "0.1.1"]])
View
@@ -1,5 +1,7 @@
-(ns useful.debug
- (:use clojure.stacktrace))
+(ns useful.debug)
+
+;; leave out of ns decl so we can load with classlojure.io/resource-forms
+(require 'clojure.stacktrace)
(letfn [(interrogate-form [list-head form]
`(let [display# (fn [val#]
@@ -8,7 +10,7 @@
(catch Throwable t#
(display# {:thrown t#
:trace (with-out-str
- (print-cause-trace t#))})
+ (clojure.stacktrace/print-cause-trace t#))})
(throw t#)))))]
(defmacro ?
View
@@ -21,16 +21,16 @@ myconst 10)."
list, where N is the number of arguments the macro accepts. The
result of all expansions will be glued together in a (do ...) form.
- Really, the macro is only called once, and is adjusted to expand
- into a (do ...) form, but this is probably an implementation detail
- that I'm not sure how a client could detect.
+ Really, the macro is only called once, and is adjusted to expand
+ into a (do ...) form, but this is probably an implementation detail
+ that I'm not sure how a client could detect.
- For example,
- (macro-do [[f & args]]
- `(def ~(symbol (str \"basic-\" f))
- (partial ~f ~@args))
- [f 'test] [y 1 2 3])
- expands into (do
+ For example,
+ (macro-do [[f & args]]
+ `(def ~(symbol (str \"basic-\" f))
+ (partial ~f ~@args))
+ [f 'test] [y 1 2 3])
+ expands into (do
(def basic-f (partial f 'test))
(def basic-y (partial y 1 2 3)))"
([macro-args body & args]
View
@@ -171,3 +171,11 @@
thread-local objects."
[& body]
`(thread-local* (fn [] ~@body)))
+
+(defn read-seq
+ "Read all forms from *in* until an EOF is reached. Throws an exception on incomplete forms."
+ []
+ (lazy-seq
+ (let [form (read *in* false ::EOF)]
+ (when-not (= ::EOF form)
+ (cons form (read-seq))))))

0 comments on commit be93b3d

Please sign in to comment.