diff options
author | Rich Hickey <richhickey@gmail.com> | 2009-07-01 14:06:57 -0400 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2009-07-01 14:06:57 -0400 |
commit | 88cb2692219dfba415e2e6c631077e0d0e8a7699 (patch) | |
tree | 93fafb65acd33b512f30248ff78bdfe4342afee5 /src | |
parent | 6201f5e2ddd52f1b483d75563b0380deba59777c (diff) |
in defn, propagate pre/post conditions written as map trailing arglist to metadata on arglist
Diffstat (limited to 'src')
-rw-r--r-- | src/clj/clojure/core.clj | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index 38c58daf..f44fce09 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -129,17 +129,6 @@ vector? (fn vector? [x] (instance? clojure.lang.IPersistentVector x))) (def - #^{:private true} - sigs - (fn [fdecl] - (if (seq? (first fdecl)) - (loop [ret [] fdecl fdecl] - (if fdecl - (recur (conj ret (first (first fdecl))) (next fdecl)) - (seq ret))) - (list (first fdecl))))) - -(def #^{:arglists '([map key val] [map key val & kvs]) :doc "assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to @@ -169,6 +158,27 @@ with-meta (fn with-meta [#^clojure.lang.IObj x m] (. x (withMeta m)))) +(def + #^{:private true} + sigs + (fn [fdecl] + (let [asig + (fn [fdecl] + (let [arglist (first fdecl) + body (next fdecl)] + (if (map? (first body)) + (if (next body) + (with-meta arglist (conj (if (meta arglist) (meta arglist) {}) (first body))) + arglist) + arglist)))] + (if (seq? (first fdecl)) + (loop [ret [] fdecls fdecl] + (if fdecls + (recur (conj ret (asig (first fdecls))) (next fdecls)) + (seq ret))) + (list (asig fdecl)))))) + + (def #^{:arglists '([coll]) :doc "Return the last item in coll, in linear time"} |