Fork me on GitHub

Good Morning!


Good morning lovely people. How are you all this morning?

👍 4
Jakob Durstberger07:04:09

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


yeah i queued for food today as well


I think its a wednesday thing yeah, agree with alex


seems bank-holiday friday nights are a good time to go shopping around here - no queues at all on good friday eve



👋 8

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!

👍 12

3 people have signed up 🙂

🎉 8

A colleague of mine is doing a Javascript workshop.


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 . Mainly cos I'm bored but also because I strongly suspect my own conference 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.

👍 4

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
     ~@(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 😕


does anyone already tried something similar in clojurescript ?


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

👍 4

Morning 😄

👏 8

@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"]


is there anyway of declaring global namespace vars in clojurescript run-time


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)))))


eval is also missing 😛


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.


yep I need to change my approach


thanks guys

Wes Hall15:04:11

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... "

🚀 8

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

Ben Hammond15:04:41

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

Ben Hammond15:04:20

you don't have a crystal ball and you never get everything right

Ben Hammond15:04:38

its the way you improve the language over time that mattters

Ben Hammond15:04:13

Javascript seems to be able to grow and better itself at the moment

Ben Hammond15:04:20

so its all good

Ben Hammond15:04:32

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)


Just a quick check to any emacs/cider user the keyboard shortcut to take this:

  (+ 1 1)|)  ;; the | stands for the cursor...
and send it to the repl is CTRL-x CTRL-e right?