4 ms·
Because function arguments are evaluated before the function itself. In this case, that evaluation would fail because numbers do not implement IFn, and hence ca
by tincholio 7y ago
Because function arguments are evaluated before the function itself. In this case, that evaluation would fail because numbers do not implement IFn, and hence cannot be called.
Macro arguments are not evaluated, and so this works.
You could make it a function, and pass the arguments quoted, but it'd be more cumbersome.
- dmitriz 7y agoI have just tried it in REPL and got this cryptic error: cljs.user=> (defmacro swap [x] (list (second x) (first x) (last x))) #'cljs.user/swap cljs.user=> (swap (1 + 2)) Execution error (Error) at (<cljs repl>:1). 1.call is not a function