This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-04-15
Channels
- # 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
morning
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.
maybe it's a hump day thing
everybody down my way seems to do it fri night and sat, like a proper activity
Morning.
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!
Which workshop had the larger sign up?
I suppose that is to be expected 🙂
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:
(def foo (some-fn foo))
(def bar (some-fn bar))
(def baz (some-fn baz))
in clojure, I got something like this doing the job:
(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))
the main issue is the `resolve` part I guess 😕kind of seems like you might want a multi method
though it depends on how you want to call it I guess
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.
thanks @rickmoynihan,and yes it works if I use the data literal ["foo" "bar" "baz"]
what do you mean?
you mean declaring the data
var?
something like this:
(doall (for [e data]
(eval `(def ~(symbol (->kebab-case e)) (component e)))))
indeed — but eval is also evil (except when it’s not 😁 )
> Your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should.
@brunex clojurescript doesn't have vars!
what I would like todo, is to lookup some data-structure in run-time declare some namespace global accessible vars
generally, use an atom and wrap the access in a fn
somewhere on stackoverflow someone was suggesting:
(set! namespace.somehting.variable value)
but shadow-cljs throws a exception 😕@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.
I always feel like Clojurescript would be great if it wasn't for Javascript 😉. I'd quite like to go back in time and tell Brendan Eich, "Hey dude, so in 25 years, this language you are hacking up will be the foundation of the worlds largest and most important information and commerce platform.... take a couple of extra days... "
i reckon clojurescript is pretty great despite javascript, and even javascript isn't so bad apart from the horror of type-coercion. you should definitely use your time-machine to get rid of that
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
you don't have a crystal ball and you never get everything right
its the way you improve the language over time that mattters
Javascript seems to be able to grow and better itself at the moment
so its all good
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 have to say that a few of the many changes to the language made a huge amount of difference to how enjoyable I find it to write today (basically destructuring, promises and lambdas). I don't do so much Javascript as I used to, but I find it pleasant to come back to every time.
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)