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

0 votes
in ClojureScript by

The following code produces different results in clojure and in clojurescript

(defmacro beep [& args] (cons 'list args)) (print (beep 0 1 2 3))

In clojure that code outputs (0 1 2 3)
In clojurescript that code outputs (2 3)

2 Answers

0 votes
by
_Comment made by: mfikes_

Ethan, I suspect this ticket is invalid. Are you defining the macro in the REPL? If you do that, you will see the consequence that macros are really just functions called by the compiler (with two extra special arguments {{&env}} and {{&form}}, which you are passing as {{0}} and {{1}} in your example code).

Macros in ClojureScript need to be defined in a separate namespace and consumed using {{:require-macros}}. See more at https://clojurescript.org/about/differences#_macros
0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-2360 (reported by alex+import)
...