Fork me on GitHub
#clojurescript
<
2023-08-24
>
jpmonettas12:08:59

Hi everybody! Is this a bug or am I missing something? I want to run a repl with a watch using cljs.main : if I do clj -M --main cljs.main --watch "src" --compile hello-world.core --repl the repl starts, and it says Watch compilation log available at: out/watch.log but nothings happens when I modify a file and nothing on that log. if I do the same but removing the --repl the the watch works, but I have no repl And I also tried clj -M --main cljs.main --repl-opts '{:watch "src"}' --compile hello-world.core --repl which starts a repl but doesn't start any watch

jpmonettas12:08:16

all this is using ClojureScript 1.11.60

RJ Sheperd23:08:43

Hi Folks - Trying to write a macro using CLJS "1.11.54" and I can’t seem to even get it to print out the arguments being passed in. Anyone know what I’m doing wrong?

(defmacro print-symbol-macro [ns-str]
    (println ns-str)
    `(println ~ns-str))  

(print-symbol-macro "cljs.core") ; => Returns (println nil), prints nil

kennytilton23:08:56

That works in Clojure. Do you have the macro definition in a .clj file? Then invoke it from a .cljs?

kennytilton23:08:48

And when you say "prints nil", println itself returns nil.

RJ Sheperd00:08:19

Right. Let me try another example:

(defmacro unless
  [pred & body]
  `(if (not ~pred)
     (do ~@body)
     nil))

(unless true
        (do
          (println "I should *not* print")
          (+ 1 2 3)))

RJ Sheperd00:08:03

This ends up printing "I should *not* print", and also shows the following in the console: (if (cljs.core/not nil) (do) nil)

RJ Sheperd00:08:47

In Clojure, this does evaluate properly and does not print anything

RJ Sheperd00:08:11

When I update unless to read:

(defmacro unless
    [pred & body]
    (prn pred body) ; THIS IS NEW
    `(if (not ~pred)
       (do ~@body)
       nil))

RJ Sheperd00:08:11

In CLJS:

I should *not* print
nil nil
In CLJ:
true ((do (println "I should *not* print") (+ 1 2 3)))

RJ Sheperd00:08:20

So it looks to me that CLJS defmacro is just not even taking arguments anymore

RJ Sheperd00:08:30

Here’s another one:

(defmacro infix [[a op b]]
  `(~op ~a ~b))

(infix (1 + 1))
CLJS:
:value "#object[TypeError TypeError: 1.call is not a function]",
     :ua-product :chrome,
     :stacktrace
     "TypeError: 1.call is not a function\n    at eval (eval at figwheel$repl$eval_javascript_STAR__STAR_ (), <anonymous>:1:103)\n    at eval (eval at ...
CLJ: 2

thheller06:08:46

do you define the macro the a .cljs file? then your behavior is more or less undefined since it calls the macro as a function at runtime

p-himik08:08:30

Just in case - that unless is just a built-in when-not.