Hacker News new | ask | show | jobs
by tincholio 2495 days 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.

1 comments

I 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