This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-02
Channels
- # adventofcode (76)
- # announcements (1)
- # asami (1)
- # babashka (31)
- # beginners (302)
- # calva (3)
- # cider (1)
- # clj-kondo (1)
- # cljdoc (1)
- # cljfx (63)
- # cljsjs (2)
- # clojure (36)
- # clojure-europe (29)
- # clojure-gamedev (2)
- # clojure-nl (5)
- # clojure-sanfrancisco (2)
- # clojure-spec (2)
- # clojure-uk (71)
- # clojurescript (19)
- # conjure (21)
- # core-async (10)
- # core-matrix (1)
- # cryogen (4)
- # cursive (12)
- # datomic (22)
- # emacs (4)
- # events (1)
- # figwheel-main (7)
- # fulcro (9)
- # graalvm (1)
- # jobs (1)
- # kaocha (17)
- # lambdaisland (1)
- # meander (7)
- # mount (2)
- # nrepl (12)
- # off-topic (35)
- # re-frame (15)
- # reagent (17)
- # remote-jobs (1)
- # reveal (41)
- # shadow-cljs (13)
- # spacemacs (2)
- # tools-deps (24)
Anyone run into an issue where a :cljs reader conditional doesn’t fire on a build targeting the browser?
(defmacro dbg!
[& forms]
(let [f# #?@(:cljs [cljs.analyzer/*cljs-file*]
:clj [*file*])
md# (meta &form)]
`(let [res# ~@forms]
(println (str res# " in " ~f# " line " (:line ~md#) " column " (:column ~md#)))
res#)))
Browser build seems to be picking up the :clj branch and not the :cljs branchMacros do run in clj; they run at compile time.
there's some details here https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html though nothing about this specifically.
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.
> (defmacro foo [key value] > (if (:ns &env) ;; :ns only exists in CLJS > `(cljs-variant ...) > `(clj-variant ...)) That perfectly solves my problem! Thanks a lot.
Is it possible to create asynchrounous transducer?
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 https://clojure.org/reference/java_interop#typehints 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
"prefix:x1"
(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>
"prefix:x1"
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