This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-06-01
Channels
- # announcements (7)
- # beginners (30)
- # boot (6)
- # calva (24)
- # cider (8)
- # clj-kondo (8)
- # cljs-dev (16)
- # cljsrn (8)
- # clojure (60)
- # clojure-italy (19)
- # clojure-mexico (6)
- # clojure-nlp (2)
- # clojure-uk (11)
- # clojurescript (36)
- # datomic (11)
- # hoplon (1)
- # juxt (2)
- # kaocha (1)
- # keechma (13)
- # nrepl (1)
- # off-topic (51)
- # reagent (7)
- # rewrite-clj (17)
- # robots (7)
- # shadow-cljs (2)
- # sql (4)
- # testing (1)
- # tools-deps (11)
- # vim (12)
Heya, apologies if this is a silly question, but how does issue reporting work for ClojureScript? https://clojurescript.org/community/reporting-issues says that issues should be reported on http://dev.clojure.org/jira/browse/CLJS But it doesn't seem possible to comment or create issues there without an account. If an account is needed, how does one go about obtaining it?
thank you for the direction, I will ask there.
Sorry if this is really obvious but I’m left wondering why there is two ways to call a javascript function from cljs
(def btn (.getElementById js/document "my-btn"))
(def btn (js/document.getElementById "my-btn"))
I see the first one more from what I’ve read but have come across the second once or twice
there are a number of ways to call a method on an object. between the two, (.getElementById js/document "my-btn")
is “more correct”
js/document.getElementById
isn’t part of the spec, but was an undocumented thing that many people used and so we can’t ever remove
@lilactown roger that, thanks for the heads up :thumbsup:
sure thing. another one you might run into is:
(. js/document getElementById "my-btn")
it does the same thing, it’s just sometimes easier to read. you can read about the whole gamut here: https://www.verypossible.com/blog/clojurescript-and-javascript-interoperability-a-comprehensive-guide
That was an interesting read, so the first version I posted is actually just syntactic sugar for the dot special form, I’m not quite up to speed with macros yet but after expanding a couple I can see what’s happening just can’t think how it works 🙂
cljs.user=> (macroexpand '(.x))
(. nil x)
cljs.user=> (macroexpand '(.))
(.)
cljs.user=> (macroexpand '(.x blah))
(. blah x)
cljs.user=> (macroexpand '(.x blah a b c))
(. blah x a b c)
Scratch that, maybe you can’t
user=> (defn . [name] (println (str "Hello, " name)))
#'user/.
user=> (. "foobar")
Syntax error (IllegalArgumentException) compiling . at (REPL:1:1).
Malformed member expression, expecting (. target member ...)
now I’m confused 😄Clojure syntax
(op arg1 arg2)
Where op
can be:
- A special form, like if
, def
and .
- A macro
- A object
Clojure you check in this order, so .
function will not work. But you can call (apply .)
and .
function will be called
This cleared that up, I feel pretty stupid now https://purelyfunctional.tv/article/clojure-is-a-better-java-than-java/ 😄
I'm a bit confused, hoping for a sanity check :). I am doing a defmethod
against a multi, and then doing (prn (keys (methods reader)))
. But my :default
is later getting triggered for that method, and when I do (prn (keys (methods reader)))
I can't see the method any more.
This seems to have been caused (according to bisect) by moving some code from .core into a .alpha.core and then referring them in .core
Figured it out (mostly!) I have a different multi-method calling that multi-method, and when it does (update expansion ::value #(reader opts (:tag tl) %))
where reader
is the broken multi-method, that doesn't contain the custom reader. But if I re-evaluate the first multi-method from the REPL, that fixes it.
Aha! The problem is that it's a cljc file! There's two versions of reader
, one in core$macros, and one in core. How do I fix this? 😟
This is an open source project so I can share the failing commit, but I've solved this for now by inlining macrovich into my project. I'd be happy to help someone repro, but I don't understand the environment well enough to progress a repro.
@dominicm depends on what you dispatch the multi on. say you use type
with a defrecord
and re-declare that record
okay, even weirder. If I catch the exception from the :default
and ignore it, then following that do (methods)
, I get a different result...
@qythium Nope. This is a cold run in lumo (nodejs). I've double checked for a double defmulti, just in case.
Does this project need both project.clj
and deps.edn
https://github.com/bhauman/flappy-bird-demo-new or does the author just provide both so that it can be launched from different tools?
@matt.henley both so that it can be launched from different tools
Thanks, I was just wondering why dependencies where being declared in two places. Is this common in a lot of clojurescript projects or just opensource demos/examples?
Cool, I’m able to watch and compile changes using clojure cli tools so my current workflow is change code, save, refresh page (baby steps), I’ve now added figwheel as a dependency to deps.edn
and instead of using running clj -m cljs.main ...
I’m using clj -m figwheel.main ...
so that removes the need to manually refresh (which is awesome) but I’m really struggling to connect to the repl from emacs (I can get it working fine for clj just not cljs)
This seems to have been caused (according to bisect) by moving some code from .core into a .alpha.core and then referring them in .core
Figured it out (mostly!) I have a different multi-method calling that multi-method, and when it does (update expansion ::value #(reader opts (:tag tl) %))
where reader
is the broken multi-method, that doesn't contain the custom reader. But if I re-evaluate the first multi-method from the REPL, that fixes it.
Aha! The problem is that it's a cljc file! There's two versions of reader
, one in core$macros, and one in core. How do I fix this? 😟
Clojure syntax
(op arg1 arg2)
Where op
can be:
- A special form, like if
, def
and .
- A macro
- A object
Clojure you check in this order, so .
function will not work. But you can call (apply .)
and .
function will be called