cljs-dev

dgr 2025-01-22T19:46:52.453919Z

Is this expected?

cljs.user=> (apply inc [2 17])
3
cljs.user=> (inc 2 17)
Unexpected error (ArityException) compiling at (<cljs repl>:1:1).
Wrong number of args (2) passed to: cljs.core/inc
Seems like apply should throw an exception when the number of parameters doesn’t match the function signature. This can also cause issues with partial since it uses apply under the hood.

borkdude 2025-01-22T20:32:49.388649Z

This is because inc is both a macro and function. The macro version is ran inside the JVM and yields more optimal code

p-himik 2025-01-22T20:34:01.387979Z

To add to that - it is indeed known and expected. In general, neither Clojure nor ClojureScript check argument types and amount. It's just that on JVM, the argument amount is enforced by the JVM.

dgr 2025-01-22T20:36:08.926489Z

Ah, OK. Understood.