|
7 | 7 | ; You must not remove this notice, or any other, from this software.
|
8 | 8 |
|
9 | 9 | (ns cljs.core
|
10 |
| - (:refer-clojure :exclude [-> ->> .. amap and areduce alength aclone assert binding bound-fn case comment cond condp |
11 |
| - declare definline definterface defmethod defmulti defn defn- defonce |
| 10 | + (:refer-clojure :exclude [-> ->> .. amap and areduce alength aclone assert assert-args binding bound-fn case comment |
| 11 | + cond condp declare definline definterface defmethod defmulti defn defn- defonce |
12 | 12 | defprotocol defrecord defstruct deftype delay destructure doseq dosync dotimes doto
|
13 | 13 | extend-protocol extend-type fn for future gen-class gen-interface
|
14 | 14 | if-let if-not import io! lazy-cat lazy-seq let letfn locking loop
|
|
35 | 35 | cond-> cond->> as-> some-> some->>
|
36 | 36 |
|
37 | 37 | if-some when-some test ns-interns ns-unmap var vswap! macroexpand-1 macroexpand
|
38 |
| - #?@(:cljs [alias assert-args coercive-not coercive-not= coercive-= coercive-boolean |
| 38 | + #?@(:cljs [alias coercive-not coercive-not= coercive-= coercive-boolean |
39 | 39 | truth_ js-arguments js-delete js-in js-debugger exists? divide js-mod
|
40 | 40 | unsafe-bit-and bit-shift-right-zero-fill mask bitpos caching-hash
|
41 | 41 | defcurried rfn specify! js-this this-as implements? array js-obj
|
42 | 42 | simple-benchmark gen-apply-to js-str es6-iterable load-file* undefined?
|
43 | 43 | specify copy-arguments goog-define js-comment js-inline-comment
|
44 | 44 | unsafe-cast])])
|
45 |
| - #?(:cljs (:require-macros [cljs.core :as core])) |
| 45 | + #?(:cljs (:require-macros [cljs.core :as core] |
| 46 | + [cljs.support :refer [assert-args]])) |
46 | 47 | (:require clojure.walk
|
47 | 48 | clojure.set
|
48 | 49 | [clojure.string :as string]
|
49 | 50 | [cljs.compiler :as comp]
|
50 | 51 | [cljs.env :as env]
|
| 52 | + #?(:clj [cljs.support :refer [assert-args]]) |
51 | 53 | #?(:cljs [cljs.core :as core])
|
52 | 54 | #?(:cljs [cljs.analyzer :as ana])))
|
53 | 55 |
|
|
338 | 340 | ([bindings then]
|
339 | 341 | `(if-let ~bindings ~then nil))
|
340 | 342 | ([bindings then else & oldform]
|
341 |
| - (core/assert-args |
| 343 | + (assert-args if-let |
342 | 344 | (vector? bindings) "a vector for its binding"
|
343 |
| - (nil? oldform) "1 or 2 forms after binding vector" |
| 345 | + (empty? oldform) "1 or 2 forms after binding vector" |
344 | 346 | (= 2 (count bindings)) "exactly 2 forms in binding vector")
|
345 | 347 | (core/let [form (bindings 0) tst (bindings 1)]
|
346 | 348 | `(let [temp# ~tst]
|
|
396 | 398 |
|
397 | 399 | Roughly the same as (when (seq xs) (let [x (first xs)] body)) but xs is evaluated only once"
|
398 | 400 | [bindings & body]
|
399 |
| - (core/assert-args |
| 401 | + (assert-args when-first |
400 | 402 | (vector? bindings) "a vector for its binding"
|
401 | 403 | (= 2 (count bindings)) "exactly 2 forms in binding vector")
|
402 | 404 | (core/let [[x xs] bindings]
|
|
410 | 412 |
|
411 | 413 | When test is true, evaluates body with binding-form bound to the value of test"
|
412 | 414 | [bindings & body]
|
413 |
| - (core/assert-args |
| 415 | + (assert-args when-let |
414 | 416 | (vector? bindings) "a vector for its binding"
|
415 | 417 | (= 2 (count bindings)) "exactly 2 forms in binding vector")
|
416 | 418 | (core/let [form (bindings 0) tst (bindings 1)]
|
|
504 | 506 | ([bindings then]
|
505 | 507 | `(if-some ~bindings ~then nil))
|
506 | 508 | ([bindings then else & oldform]
|
507 |
| - (core/assert-args |
| 509 | + (assert-args if-some |
508 | 510 | (vector? bindings) "a vector for its binding"
|
509 |
| - (nil? oldform) "1 or 2 forms after binding vector" |
| 511 | + (empty? oldform) "1 or 2 forms after binding vector" |
510 | 512 | (= 2 (count bindings)) "exactly 2 forms in binding vector")
|
511 | 513 | (core/let [form (bindings 0) tst (bindings 1)]
|
512 | 514 | `(let [temp# ~tst]
|
|
522 | 524 | When test is not nil, evaluates body with binding-form bound to the
|
523 | 525 | value of test"
|
524 | 526 | [bindings & body]
|
525 |
| - (core/assert-args |
| 527 | + (assert-args when-some |
526 | 528 | (vector? bindings) "a vector for its binding"
|
527 | 529 | (= 2 (count bindings)) "exactly 2 forms in binding vector")
|
528 | 530 | (core/let [form (bindings 0) tst (bindings 1)]
|
|
602 | 604 | `(when-not (exists? ~x)
|
603 | 605 | (def ~x ~init)))
|
604 | 606 |
|
605 |
| -(core/defmacro ^{:private true} assert-args [fnname & pairs] |
606 |
| - #?(:clj `(do (when-not ~(first pairs) |
607 |
| - (throw (IllegalArgumentException. |
608 |
| - ~(core/str fnname " requires " (second pairs))))) |
609 |
| - ~(core/let [more (nnext pairs)] |
610 |
| - (core/when more |
611 |
| - (list* `assert-args fnname more)))) |
612 |
| - :cljs `(do (when-not ~(first pairs) |
613 |
| - (throw (js/Error. |
614 |
| - ~(core/str fnname " requires " (second pairs))))) |
615 |
| - ~(core/let [more (nnext pairs)] |
616 |
| - (core/when more |
617 |
| - (list* `assert-args fnname more)))))) |
618 |
| - |
619 | 607 | (core/defn destructure [bindings]
|
620 | 608 | (core/let [bents (partition 2 bindings)
|
621 | 609 | pb (core/fn pb [bvec b v]
|
|
0 commit comments