This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (3)
- # architecture (1)
- # babashka (52)
- # beginners (228)
- # calva (1)
- # chlorine-clover (31)
- # cider (9)
- # clj-kondo (16)
- # cljs-dev (25)
- # cljsrn (21)
- # clojure (116)
- # clojure-argentina (8)
- # clojure-europe (18)
- # clojure-france (17)
- # clojure-germany (1)
- # clojure-nl (5)
- # clojure-spec (49)
- # clojure-uk (63)
- # clojurescript (59)
- # community-development (14)
- # conjure (89)
- # core-matrix (1)
- # cursive (18)
- # data-science (1)
- # datomic (27)
- # exercism (4)
- # figwheel-main (5)
- # fulcro (38)
- # ghostwheel (8)
- # graalvm (5)
- # hoplon (2)
- # jobs-discuss (17)
- # juxt (1)
- # lambdaisland (5)
- # luminus (1)
- # lumo (9)
- # malli (7)
- # off-topic (32)
- # planck (24)
- # re-frame (14)
- # reagent (14)
- # reitit (14)
- # rum (23)
- # shadow-cljs (80)
- # spacemacs (2)
- # sql (6)
- # unrepl (1)
- # xtdb (2)
Morning :) Fine overall, just miss having people around. I am still not really used to working remotely
Apparently everyone in the village shops at 08:20 on a Wednesday, so I just bailed on that queue.
Figured I'd shop later (now), but now the queue has doubled... I wish I'd brought a coloring book or something.
seems bank-holiday friday nights are a good time to go shopping around here - no queues at all on good friday eve
As part of a effort by the company I work for, and to support people working at home, and to feel connected, I've volunteered to run an Introduction to Clojure/Programming course, starting on Friday!
FYI I'm currently watching a 24 hour live online conference https://www.allthetalks.org/ . Mainly cos I'm bored but also because I strongly suspect my own conference https://bitrconf.org/ is not going to happen 'live' despite being postponed to 12th Nov and I'm looking for ideas about how to stream a multi stream conference.
Hi, question related with clojurescript macros: Given a list of `(def data [:foo :bar :baz])`, I want to dynamically generate:
in clojure, I got something like this doing the job:
(def foo (some-fn foo)) (def bar (some-fn bar)) (def baz (some-fn baz))
the main issue is the `resolve` part I guess 😕
(def data ["foo" "bar" "baz"]) (defmacro test-macro [data] `(do ~@(map (fn [e] (let [e-name (symbol e)] `(def ~e-name (some-fn ~e)))) (deref (resolve data))))) (macroexpand-1 '(test-macro data))
but this rings to me of a case where a macro is papering over a need to step back and reassess the design - although I can't be sure without knowing the exact use-case
@brunex: Without knowing more it looks to me like this is best covered by the first rule of macro club 🙂
What exactly do you want to do? And why do you need a macro? It looks like you’re just partially applying a function with the values of data and building a var for it.
To address the problem you’re finding though; clojurescript’s compiler is written in clojure, and macros are expanded in clojure, not clojurescript, but their expansion is sent to clojurescript/js for execution. Hence the problem is indeed with the
resolve part, as clojurescript doesn’t have proper vars, and hence you can’t resolve them there.
i.e. your macro is resolving the var in the expansion, not at compile time.
If you remove the
(deref (resolve data)) and replace it with just
data you can probably avoid the issue if you’re happy to call the macro like this:
(test-macro ["foo" "bar" "baz"])
At least that’s my suspicion, I haven’t actually tried it.
But again you probably don’t need or want a macro here… or if you do, you probably want to move the goal posts a bit and make it work differently to more easily align with what you require of it. However without knowing more about the real use it’s impossible to say.
something like this:
(doall (for [e data] (eval `(def ~(symbol (->kebab-case e)) (component e)))))
> Your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should.
what I would like todo, is to lookup some data-structure in run-time declare some namespace global accessible vars
somewhere on stackoverflow someone was suggesting:
but shadow-cljs throws a exception 😕
(set! namespace.somehting.variable value)
@brunex ok but clojurescript doesn’t have a self hosted compiler, and compile time in clojurescript is a lot further away from runtime in cljs… i.e. compiling cljs is more like AOT compilation.
so you can indeed resolve stuff available to the clojure runtime; but generally that’s not available at cljs runtime. It depends exactly on what you know/when.
this is starting to sound like a > I'm just putting out a quick production fix. its so simple it doesn't need testing kinda scenario
and you couldn't really stop M$$ doiing all it could to throw a spanner into the cross-browser compatibility in the late 90s
I wonder if the reason people hate it is basically because everybody has to write it at one time or another, so if you have very different opinions about the Right Way to do things, it can be frustrating indeed to be stuck with it anyway. You can just choose not to write PHP, but there just isn't anything like parity of library coverage and community support and so on between CLJS / Elm / Purescript and whatever else and plain old JS, so most people are stuck with it (or with a more semantically similar dialect like Typescript)