Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by
edited by

In ClojureScript forms can't always be replaced by they macroexpanded forms. This is the case for defrecord and defn on its multi arity version.

 clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.11.60"}}}' -M -m cljs.main                                                                          
ClojureScript 1.11.60
                                                                                                                                                   
cljs.user=> (defrecord ARecord [a])                                                                                                                                     
cljs.user/ARecord                                                                                                                                                  

cljs.user=> (macroexpand '(defrecord ARecord [a]))
(let* [] (do (defrecord* ...)))

cljs.user=> (let* [] (do (defrecord* ...)))
WARNING: Wrong number of args (4) passed to ARecord at line 1 <cljs repl>
WARNING: Wrong number of args (4) passed to ARecord at line 1 <cljs repl>
WARNING: Wrong number of args (4) passed to ARecord at line 1 <cljs repl>
WARNING: Wrong number of args (4) passed to ARecord at line 1 <cljs repl>
WARNING: Wrong number of args (4) passed to ARecord at line 1 <cljs repl>
WARNING: Wrong number of args (4) passed to cljs.user/ARecord at line 1 <cljs repl>
WARNING: Wrong number of args (4) passed to cljs.user/ARecord at line 1 <cljs repl>

Same thing happens trying to evaluate the forms resulting from this macroexpansion:

(macroexpand '(defn foo ([a] (foo a 5)) ([a b] (+ a b))))

Please log in or register to answer this question.

...