Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add read-seq and make useful.debug embeddable

  • Loading branch information...
commit be93b3da93e915cf3e4124747d450559b176cd2e 1 parent 70c4675
@ninjudd ninjudd authored
View
2  project.clj
@@ -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
8 src/useful/debug.clj
@@ -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
18 src/useful/macro.clj
@@ -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
8 src/useful/utils.clj
@@ -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))))))
Please sign in to comment.
Something went wrong with that request. Please try again.