Fork me on GitHub
#beginners
<
2021-11-04
>
sova-soars-the-sora03:11:27

I don't understand the difference between blocking put and normal put / take

sova-soars-the-sora03:11:45

blocking put holds up the thread until it is done put ting?

phronmophobic03:11:10

more or less, yea. on the other hand, parking put, >! ,is for inside of go blocks which will run in a thread pool. since there a limited number of threads, if you block them, then you can prevent other go blocks from running. you don't want to call blocking put, >!! ,inside of a go block

sova-soars-the-sora18:11:16

Ah okay thanks that's a little more clear

Lukas07:11:50

Hey guys, I have trouble starting my project with cider-jack-in

[nREPL] Starting server via /home/linuxbrew/.linuxbrew/bin/clojure -Sdeps '{:deps {nrepl/nrepl {:mvn/version "0.8.3"} refactor-nrepl {:mvn/version "3.0.0alpha13"} cider/cider-nrepl {:mvn/version "0.25.9"}} :aliases {:cider/nrepl {:main-opts ["-m" "nrepl.cmdline" "--middleware" "[refactor-nrepl.middleware/wrap-refactor,cider.nrepl/cider-middleware]"]}}}' -M:cider/nrepl
error in process sentinel: nrepl-server-sentinel: Could not start nREPL server: DEPRECATED: Libs must be qualified, change refactor-nrepl => refactor-nrepl/refactor-nrepl 
after following this step refactor-nrepl => refactor-nrepl/refactor-nrepl
Error building classpath. Could not find artifact refactor-nrepl:refactor-nrepl:jar:3.0.0alpha13 in central ()
Any help is greatly appreciated

phronmophobic07:11:00

the version should probably be "3.0.0" rather than "3.0.0alpha13". there is a "3.0.0-alpha13", but "3.0.0" is the latest, https://clojars.org/refactor-nrepl/refactor-nrepl

Lukas07:11:28

yep that worked

West14:11:07

I never knew people used linuxbrew…

roelof11:11:41

Is there a free way to learn how to make a site with react in clojure ?

Stuart11:11:33

https://youtu.be/ChUzrcB9L1c there is this series. Clojure script for react Devs.

roelof11:11:42

could work only I do not know react

Mno11:11:14

AS far as I've seen, people don't generally use react directly and instead opt for reagent. https://reagent-project.github.io/

Mno11:11:26

But frontend stuff is definitely not my specialty, I've only ever needed to use the basics of that reagent page to make anything I've wanted.

roelof11:11:04

also not mine. I see that more and more loves back-end stuff. Also tried to learn clojurescript but have not enough xp and knowlegde to make a nice layout

vanelsas12:11:45

Reagent is probably a good way to get started. If you have little experience in frontend stuff, just start by realising you are your first user. What do you need, what do you want to accomplish and what is the easiest way to do so. You only need a pencil and a piece of paper to solve that. Once you have figured out what it is you need, start by creating the simplest components and slowly build up the UI. I would recommend taking a look at storybook and its philosophy if interested. It may be a bit much, but its component driven methodology is certainly a good way to reduce complexity and build better code/components.

roelof12:11:00

Oke, if I look at the next challenge the components are there but no css or whatever

Stuart12:11:05

I think you will ahve to learn html / css seperately. I can't imagine anyone writing a tutorial for clojurescript / reagent / re-frame etc is going to be include learning css

roelof12:11:41

This one not

roelof12:11:26

and it also not given any css to let it see as given in the first image

vanelsas14:11:15

there is a reference to bulma's styles at the bottom of the page. I assume that is what it uses for styling

roelof14:11:58

oke, then I can better clone the code then type with the tutorial

roelof14:11:57

and then change things to make a telephone number. Which schould havea type what I think could be personal or a company telephone number

Daniel Craig18:11:25

Jacek Schae has a tutorial but I'm not sure if it's free

roelof19:11:37

but is a small part of a bigger course which costs some 200 euro and that is a lot of money for a hobby developer

roelof14:11:15

pity that all good courses are paid.

George Silva15:11:08

Friends, I have a question: I want to define a multimethod, that based on a type of file (a map), it will download a file from certain place, using a certain protocol (ftp/https). This is what I have for now:

(defn dispatch-download [file datetime output-file]
  (:protocol file))

(defmulti download! dispatch-download)

(defmethod download! :https [file datetime output-file]
  (println "https"))

(defmethod download! :ftp [file datetime output-file]
  (println "ftp"))
See that the download! function takes three parameters? Is there way to shorthand the dispatch-download file, to use the shorthand :protocol function from the first argument? Basically I want my dispatch fn to have only a single argument. (defmulti download! :protocol) But I still want/need it to have three arguments.

Eddie15:11:47

Is this close enough to what you want?

(defmulti download! (fn [file _ _] (:protocol file)))

George Silva16:11:31

let me give it a try...

George Silva16:11:42

What would you say is most idiomatic? The dispatch function is super easy and unlikely to change, meaning I don't think I need to test it

Eddie16:11:56

Or to make even fewer assumptions about the number of arguments:

(defmulti download! (fn [file & _] (:protocol file)))

👍 1
Eddie16:11:13

I often find myself using a dispatch function that has as few assumptions about the arguments as possible. In this case, you only care about the first argument to the function, so I would say the most idiomatic approach is to use a dispatch function that ignores all other arguments (regardless of how many of them there are).

Eddie16:11:27

To your original question, I don’t know of a way to pass a different (sub)set of arguments to the dispatch function.

George Silva18:11:29

No worries. I think your proposal here makes sense. Hiding the other arguments with & is a clever way of making the dispatch function not care.

Eddie18:11:46

Happy to help!

Foxtur20:11:19

Hi, I'm just trying to get the size of a file and wanted to use java.nio.file.Paths for that. I tried to call the static method using Java interop like this

(java.nio.file.Paths/get "filename")
which results in
(err) Execution error (ClassCastException)
(err) class java.lang.String cannot be cast to class java.net.URI (java.lang.String and java.net.URI are in module java.base of loader 'bootstrap')
Looking at the documentation of the method I noticed that the method is overloaded: public static Path get(String first, String... more) public static Path get(URI uri) So I thought I could use a type hint to allow the compiler to resolve the correct method like so:
(defn with-typehint [^java.lang.String s]
  (java.nio.file.Paths/get s))

(with-typehint "filename")
But it still throws the same ClassCastException. Could someone tell me how I can force the correct overload of the method to be called?

dpsutton20:11:02

https://clojure.org/reference/java_interop#_vararg_methods . It’s a bit of confusion because there’s java sugar for var args that Clojure does not have. That signature is actually public static Path get (string first, string[] more), just javac will provide the sugar for you and pass an empty array here

dpsutton20:11:15

(java.nio.file.Paths/get "filename" (into-array String []))

Foxtur20:11:47

Ahh thx a lot I didn't know about the vararg conversion yet!