look at the clojure's +
source:
(defn +
([] 0)
([x] (cast Number x))
([x y] (. clojure.lang.Numbers (add x y)))
([x y & more]
(reduce1 + (+ x y) more)))
so for the arity 1 it just casts a value to a Number. That really looks strange, that there is no check for nil
here, i guess someone should submit this as a bug.
on the other hand the clojurescript's variant:
(defn ^number +
([] 0)
([x] x)
([x y] (cljs.core/+ x y))
([x y & more]
(reduce + (cljs.core/+ x y) more)))
just returns the value (which also feels buggy, since (+ "hello")
would return "hello"
(well, haven't tested it, but still))
for other arities clojure uses Numbers.add
(that requires numbers as params, and throws error),
while clojurescript uses this macro as far as I know:
(core/defmacro ^::ana/numeric +
([] 0)
([x] x)
([x y] (core/list 'js* "(~{} + ~{})" x y))
([x y & more] `(+ (+ ~x ~y) ~@more)))
so it's just the javascript addition, that adds nulls as zeros.