在cljs
中
ClojureScript 1.10.238
app:cljs.user=> (defn f [a] a) (f)
#'cljs.user/f
---- Compiler Warning on <cljs form> line:1 column:2 ----
Wrong number of args (0) passed to cljs.user/f
1 (f)
^---
---- Compiler Warning ----
nil
app:cljs.user=> (defn f [a] a) (apply f [])
#'cljs.user/f
nil
在clj
中
> (defn f [a] a) (f)
#'redacted.ns/f
Execution error (ArityException) at redacted.ns/eval28662 (form-init217321140160545149.clj:2261).
Wrong number of args (0) passed to: redacted.ns/f
> (defn f [a] a) (apply f [])
#'redacted.ns/f
Execution error (ArityException) at redacted.ns/eval28665 (form-init217321140160545149.clj:2265).
Wrong number of args (0) passed to: redacted.ns/f
在cljs中,apply静默地返回nil
,而在clj中,会抛出ArityException
异常。