Fork me on GitHub

your JS doesn’t return a value. you run one function for its side-effect. In clojurescript all functions return values so that is why it returns the value of calling the function.


if you call your CLJS callback function and don’t do anything with the value you have done essentially “the same thing”.


You could alter the CLJS to get the compiled JS to look more similar but I don’t see why


the only thing I can think of to get it to match would be to do something like (defn callback [] (do (js/Acad.Editor.executeCommand "_erase" "all" “") nil)) not exactly sure how that would compile but its semantic goal to what you wrote in JS is similar.


I would read up on Statements vs. Expressions. In clojure there aren’t really statements, but you can make expressions that return no helpful value if you want I suppose.


@jswart: Thanks, I'll try that. The API I'm using in JS expects a JS function and doesn't seem to work with the return value there. It's funny, I'm pretty comfortable when it's all cljs, and pretty comfortable when it's all js, but the interop still just throws me off.


np! good luck.


i have plenty of mishaps with that myself


@guano, @abhishekamralkar : I almost-finished reading #C0M8PCF7U when I felt I needed more hands-on experience, so I started working through the 4clojure exercises, it's been a great progression. I'm at problem #96 now. Even though they are still "toy problems", they have helped a lot in getting a better handle on the standard Clojure functions, and on how to structure pieces of code slightly more complex than the #C0M8PCF7U end-of-chapter exercises.


This is great! @zzamboni . Thanks once again.


I'm curious how I might refactor this so that I don't have both calls to do-node-status


(defn node-status [amx env & node-names]
  (if-let [nodes node-names]
    (do-node-status amx env nodes)
    (let [nodes (list-nodes amx env)]
      (do-node-status amx env nodes))))


if you call it via (node-status amx env), it gets the nodes via list-nodes, but if you pass anything along, it uses that as the nodes


Maybe something along these lines?

(defn node-status
  ([amx env] (apply node-status amx env (list-nodes amx env)))
  ([amx env & nodes] (do-node-status amx env nodes)))


Though it doesn't feel great to have this function to little more than wrap another