Skip to content

Commit

Permalink
in defn, propagate pre/post conditions written as map trailing arglis…
Browse files Browse the repository at this point in the history
…t to metadata on arglist
  • Loading branch information
richhickey committed Jul 1, 2009
1 parent 6201f5e commit 88cb269
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/clj/clojure/core.clj
Expand Up @@ -128,17 +128,6 @@
:doc "Return true if x implements IPersistentVector "}
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
Expand Down Expand Up @@ -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"}
Expand Down

0 comments on commit 88cb269

Please sign in to comment.