clojurescript

itaied 2025-09-25T07:30:18.570969Z

why

(identity 1 2 3)
throws, but
(apply identity [1 2 3])
return 1? what am i missing about apply?

Roman Liutikov 2025-09-25T08:20:51.177979Z

Arity check is compile time, apply is a dynamic operation and there are no runtime arity warnings in cljs

👍 1
👉 2
schadocalex 2025-09-25T08:28:50.145439Z

it gets run into identity.call(identity, 1, 2, 3) in JavaScript, and Javascript doesn't care about extra argument for a function like function identity(x) { return x }

schadocalex 2025-09-25T08:30:25.753859Z

btw as identity is defined in clojure, it might be possible to check at compile time for the number of arguments, but not implemented.