Fork me on GitHub
eccentric J02:12:32

Anyone run into an issue where a :cljs reader conditional doesn’t fire on a build targeting the browser?

eccentric J02:12:24

(defmacro dbg!
  [& forms]
  (let [f# #[email protected](:cljs [cljs.analyzer/*cljs-file*]
               :clj  [*file*])
        md# (meta &form)]
    `(let [res# [email protected]]
       (println (str res# " in " ~f# " line " (:line ~md#) " column " (:column ~md#)))
Browser build seems to be picking up the :clj branch and not the :cljs branch

Braden Shepherdson02:12:47

Macros do run in clj; they run at compile time.

Braden Shepherdson02:12:38

I can't find the reference I'm looking for. but basically you can write code that runs at macro execution time that checks whether you're building for CLJS or CLJ, and can emit different code. but you can't use the reader macro #? syntax inside a macro.

eccentric J02:12:21

Ah, interesting!

eccentric J02:12:58

> (defmacro foo [key value] > (if (:ns &env) ;; :ns only exists in CLJS > `(cljs-variant ...) > `(clj-variant ...)) That perfectly solves my problem! Thanks a lot.

eccentric J02:12:17

Oh wait actually it’s not working in cljc

Karol Wójcik13:12:01

Is it possible to create asynchrounous transducer?

Karol Wójcik15:12:42

Ok. It seems not possible after few tests 😛


Just checking something after watching some of @mfikes’s inferencing talk at Clojure/north last year… There’s a reference to hinting return types by adding metadata to the function, via:

(defn ^string f [x] (str "prefix" x))
In Clojure, this will work (and becomes a :tag in the function metadata), but the is to put the tag before the arguments, since different argument lists may have differing return types eg.
(defn f (^long [] 42) (^String [x] (str "prefix" x)))
From what I can see, ClojureScript does not seem to be paying attention to this preferred form from Clojure. I’m not actually sure how to test properly, but this may be showing it:
(defn ^long foo [x] (str "prefix" x))  ;; type hint is a lie
=> (+ (foo :x) 1)                      ;; but it hides the warning

(defn bar ^long [x] (str "prefix" x))
=> (+ (bar :x) 1)
WARNING: cljs.core/+, all arguments must be numbers, got [string number] instead at line 1 <cljs repl>
So, does this mean that type hinting before arguments is not supported in ClojureScript? There’s apparently a difference. This isn’t especially important to me, but I was trying to get a model of it into my head without reading the compiler 🙂


> Type hinting is primarily used to avoid reflection in Clojure. In ClojureScript, the only type hint of significance is the ^boolean type hint: It is used to avoid checked if evaluation (which copes with the fact that, for example, 0 and "" are false in JavaScript and true in ClojureScript).


I was following through on this because of Mike’s talk on type inferencing in ClojureScript, which is more recent work. You can see in the example I provided how this is used for checking the arguments to cljs.core/+


Hello Everyone, I am new to Clojurescript, I have a shadow cljs application with Helix. Currently, I am having trouble while trying to add google recaptcha to the application. Any suggestions or guide would be appreciated


@singhamritpal49 you probably won’t find a guide. If you explain your problem, someone might be able to help you fix it