This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-24
Channels
- # announcements (1)
- # beginners (113)
- # calva (16)
- # cider (6)
- # cljsrn (1)
- # clojure (104)
- # clojure-argentina (2)
- # clojure-dev (3)
- # clojure-italy (1)
- # clojure-nl (10)
- # clojure-spec (6)
- # clojure-uk (4)
- # clojuredesign-podcast (44)
- # clojurescript (25)
- # core-async (2)
- # datomic (21)
- # emacs (14)
- # events (1)
- # figwheel-main (12)
- # fulcro (7)
- # joker (2)
- # leiningen (1)
- # mount (7)
- # music (1)
- # off-topic (16)
- # pedestal (3)
- # re-frame (8)
- # reagent (8)
- # reitit (11)
- # shadow-cljs (4)
- # spacemacs (16)
- # sql (1)
- # tools-deps (14)
- # vim (1)
Hi. Is there any reason to use loop form in CLJS? Or is it just a waste of time, because recursion will do the same thing?
Recursion has an implicit limit based on the stack. Loop/recur do not have this limitation
even for javascript
About which? Loop/recur are loops which have no stack issues and recursion is function invocation on both jvm and js vms. You can recur to a function to get recursion without adding onto the stack though
It’d be interesting if one of the vms got tail recursion while the other didn’t to see if the languages would forego tail call optimization on the platform where it was available.
@dpsutton pretty sure ES6 has tail call optimization
Didn’t know that. But looks like it’s just the spec. >> Update 2018-05-09: Even though tail call optimization is part of the language specification, it isn’t supported by many engines and that may never change. The ideas are still interesting, however and explained in this blog post.
ah, yea that makes sense. thanks
Not sure if that’s authoritative though and I didn’t know es6 included it so thanks for letting me know!
Hi, I'm just wondering about how I would go about instantiating a library wrapper around a series of api calls. I am developing a library in which I have an initialisation step which takes some configuration from the user and puts it in an atom, and sets an initialized?
flag as true. There are then multiple functions in the library with which I want to run a check on the initialized?
flag and throw an error if false. I have created a macro for this which works but is somewhat unsatisfactory:
(defmacro defn2 [name args body]
`(def ~name (fn ~args (system-check ~body))))
The reason why I find it unsatisfactory is that much of the codebase of the library is interdependent, so I want to prevent the user calling f(x), g(x), h(x)
and so I would instantiate all those functions with defn2
. However, I have other functions which may call h(g(f(x)))
and so I would call system-check
three times rather than once. Even having to call system-check
once per function seems a bit unneccessary.
Is there a pattern to solve this?Just a thought: Create an fn to deref the atom and check for nil there (throw an error if nil), and call this fn rather than derefing the atom directly when you need it.
You wouldn't need an initialized?
flag.
Hi, I'm watching
this course to start learning about clojurescript and I'm getting some weird behaviour. Not sure what's happening. Can someone help me out? I will try to explain what's happening in a thread 🙂
This is the app component.
When I uncomment the header stuff a clojurescript error appears saying Invalid :refer, var giggin.components.header/header does not exist
The other three components gigs, orders and footer have no problem.
What's weirder is that sometimes the header works, until I make a change inside the header.cljs file and it starts crashing again with the same error.
The folder structure is:
src
|
giggin
|
components
footer.cljs
gigs.cljs
header.cljs
orders.cljs
core.cljs
state.cljs
Did you check if the namespace is written correctly in the griffin.components.header and if the header var exists in that file?