Fork me on GitHub
Dmitry K04:04:56

Hi, I trying to setup editor for Clojure, currently struggling with Calva. I have fullstack project (cljs via Figwheel main) and whe I run repl (jack-in) then both repls get started (Lein + Figwheel Main config), but I cant switch to cljs repl, geting error "Cannot read properties of null (reading 'switchNS')"


Tagging @U0ETXRFEW to make sure he sees this.

👍 1
calva 1

Thanks, @U04V70XH6! @U03BG5ZLZGR it sounds like a bug. Let's see if we can find a workaround. What do you mean that you ”cant switch to the cljs repl”?, what is it you do, and what have you just done before that?

👍 1

@U03BG5ZLZGR, I see that @U0ETXRFEW already found his way to this thread. For future issues related to Calva, I would suggest posting them in the #calva channel for increased detection probability and response time. Many people are ready and able to help there. Also, thank you for reporting issues and thus contributing to making Calva even better for everyone.


For everyones information. I have Calva as one of my highlight keywords, so I'll find them when they are posted here as well. It's probably a good idea that more people who want to help out with Calva questions do that. (I actually missed this one because Slack refused to show me which message it was even though it has badged the channel. But then we have @U04V70XH6!

💡 1

Ah, I was not aware of that feature in Slack! Thanks for the advice, @U0ETXRFEW. Now it will be a lot easier for me to notice relevant things.


Derailing it a bit further. What I do is that I join lots of channels, then mute most of them. And rely on my keywords to highlight things I am extra interested in. I also make use of custom sections in the channel list. Now let's give the thread back to @U03BG5ZLZGR. 😃 I'd like to both figure out the bug so that it can be fixed, and to help you find a workaround.

💡 1

@U03BG5ZLZGR I wrote some kind of answer here: Please let us know if it helps you or not. 🙏

Arjen van Elteren10:04:54

Any advice on selecting a unit handling library? when searching for "units" on the clojars site I get many options, "units2" looks good to me, but I wonder what others have used.


my first instinct would be to look for the most popular java unit library and use that via interop. if it has too many weird compicated javaisms (less likely for units than for other libs) then I'd look for a "wrapper" library for it that makes it easier to use from clojure


if using cljs, javascript rather than java, but the same


I noticed Luminus (with +re-frame and +SCSS profile) uses bulma by default. As a clojure newbie, I’m having some issues using bulma extensions with js code. I saw that recom could be a good alternative for bulma components. Which do you recommend is the better way to go? Bulma + js interop vs recom?


Let’s say you have a map with an unknown amount of imageX: {"image0" {:filename "green.png", :size 36413}, "noise1" {...}, "noise2" {...}, "image1" {:filename pink.png, :size 168810}} How would you select all imageX?

Danilo Oliveira11:04:21

In clojure for the brave and true, the author states: Another feature that differentiates special forms is that you can't use them as arguments to functions. In general, special forms implement core Clojure functionality that just can't be implemented with functions. I understand this makes sense for forms like "defn", but if is also a special form and you can use an if form as argument to a function. What did the author mean in this sentence?


How do you use if as an argument? e.g. (pr if) => syntax error


(defn- foo [x] x)
=> #'user/foo
(foo if)
Syntax error compiling at (/private/var/folders/5g/cm05t9894qxcw76vdc7k6hfc0000gn/T/form-init11782572858813704572.clj:1:1).
Unable to resolve symbol: if in this context


You're probably thinking that the result of if is equivalent to passing if as an argument.

👍 3
Danilo Oliveira12:04:57

Ohhhh! Yes, of course, now the sentence makes complete sense. I'm sorry for the silly question then lol


going back to your original example:

ser=> (prn (defn foo [x] (str x x)))
not only is a defn form a valid argument, it's passed to prn in your repl (that's why the only difference between what that looks like and a normal repl is the extra nil)


of course (prn defn) is an error


Hey Everyone, I have a redis cluster as datastore in one of my clojure services, I need to fetch multiple hashmaps from the redis cluster in that service. What is the most efficient way to perform that operation?


need to perform multiple hgetall at once somehow


Does Jedis provide a direct operation to perform mhgetall ?


don't want to do hgetall in a loop for multiple hashes


I've not gone through the source extensively but redisson seem to use hgetall etc.


Clojuescript: I am a beginner and II have a question about the require in (ns .. :require ..). I do have some sample code

(ns ^:figwheel-hooks
   [goog.dom :as gdom]
   [reagent.core :as reagent :refer [atom]]
   [reagent.dom :as rdom]))
Where is actually the code for the namespaces goog.dom or reagent.core loaded from?


this is more complicated in cljs, but we can build it up from standard jvm clojure (which is how cljs is implemented) for a given require, the symbol is converted to a path, and looked up relative to classpath, you can see the location by doing the lookup manually with

(ins)user=> (require '[ :as io])
(ins)user=> (io/resource "clojure/core.clj")
#object[ 0xd1a10ac "jar:file:/home/justin/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar!/clojure/core.clj"]
the result is a resource object, which is like a file but more general (it can be a file, usually it's an entry inside a jar) in your deps.edn or project.clj (or even pom.xml if using maven for some reason), you define dependencies, and those dependencies will be added to the classpath, which is the ordered path of locations to look for artifacts so (ns (:require [bax.quux])) will scan the class loader (including, and usually most relevantly, entries in the classpath) and use the first match it finds for bax/quux.init__class or bax/quux.cljc or baz/quux.clj or in the cljs case, also baz/quux.cljs


in general, you'll find the most beginner friendly answer for most things in jvm clojure, and the clojurescript version will be some attempt to be as close to that as possible, but it's nearly always more complicated and weird


there are many cases where cljs is made more complex so it can more like clj, I don't know any cases where clj is made more complex so it can be more like cljs

Michael Stokley19:04:47

Suppose I have an existing protocol, A. I would like to define a new protocol, B, that requires A. Anything that wants to implement B should also implement A. How would folks approach this?

Michael Stokley19:04:46


Alex Miller (Clojure team)19:04:08

no, that's for extending a protocol to multiple types

Michael Stokley19:04:27

extend protocol provides implementations

Alex Miller (Clojure team)19:04:05

usually we don't layer protocols directly like this. one technique is to wrap protocol methods with functions and those functions can optionally detect and route to a lower level protocol if needed. other approaches mostly involve extending to Object and doing dynamic registration or routing there

Michael Stokley19:04:25

i see. thank you