Fork me on GitHub
#beginners
<
2020-01-11
>
brandon14904:01:50

I’m trying to add reagent to a shadow-cljs project, but I keep getting “react is not defined” errors. I read the docs on the reagent site, and it looks like I shouldn’t have to do anything but install it. Anybody familiar with this issue?

brandon14905:01:23

I set up a new browser project, and it works just fine, but when I try to use reagent in the electron example from the website, electron throws the “react is not defined” error

dpsutton05:01:41

shadow-cljs requires you to install react through npm or yarn rather than cljsjs/react. have you installed it like this?

brandon14915:01:24

I…had it installed like that, and it did not work, but I just reinstalled and now it’s working fine

brandon14915:01:28

Thanks for the help 🙂

ashnur12:01:28

nowadays i don't even understand what the readme of any clojure repository says

ashnur12:01:57

"a clj-based uberjarrer " what does that mean? i can't even google the references hidden in it...

ashnur12:01:36

überjarring, that's what it is.

ashnur13:01:45

:man-gesturing-ok::skin-tone-2:

ashnur13:01:27

and clj is tools.deps?

michael.e.loughlin19:01:00

deps.edn file and the command line tool clj

ashnur19:01:28

what is the difference between "tools.deps" and "deps.edn file and cli tool clj"?

andy.fingerhut20:01:46

The commands clj and clojure are the CLI tools, i.e. commands you can run from the command line.

andy.fingerhut20:01:28

tools.deps is a library that those commands use. The library tools.deps is also published separately, and can thus be used by programs that do not use clj or clojure commands.

andy.fingerhut20:01:20

clj and clojure commands read one or more files named deps.edn in your file system when you run them, in a specific list of directories, combining their contents in a defined way, and use that combined contents. tools.deps I have not examined, but I would guess that it takes the data from the caller of various functions in tools.deps, and whether that data came from a file or not is up to the caller.

iagwanderson18:01:57

hi, I am reading the joy of clojure and after the chapter about collections I end up with some questions about PersistentQueue. What are the use-cases for them?

alexmiller19:01:31

If you’re doing an algorithm that traverses a tree or graph, you can use it to turn a recursive impl into an iterative impl

alexmiller19:01:18

You push the root node on the queue and then loop over pulling stuff out, putting new child nodes on the queue until done

alexmiller19:01:46

That lets you handle data structures of arbitrary depth without getting stack overflow

andy.fingerhut19:01:48

bread-first traversal, specifically, I think.

drewverlee19:01:45

mmmm bread first

alexmiller19:01:16

Could be either potentially

alexmiller19:01:53

I’d go so far as to say this is the only time I use the persistent queue in Clojure

andy.fingerhut19:01:22

At least every depth-first traversal implementation I have seen uses a stack, where a Clojure vector conj/pop is useful.

alexmiller19:01:26

Exactly this lives in the heart of tools.deps to drive dependency graph expansion

iagwanderson19:01:16

uhmm... interesting! I think I could not see this patterns because I never encounter them before at work

iagwanderson19:01:45

many situations the stack was as far as I needed

fana21:01:33

As a learning exercise I'm making a terminal based interactive program (a game). I want the program to process input one character at a time. Every time a user presses a button, the program processes it and gives output. I couldn't find a way to do it using standard library. I know read and read-line functions but they take an entire line (until enter is pressed). That is not what I want. I searched online and found this solution that uses jline3 Java library: https://stackoverflow.com/questions/58571928/how-can-i-read-a-single-character-from-stdin-in-clojure. I tried to follow it but when I run my program I'm getting the following warning and error.

WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
Exception in thread "main" Syntax error compiling at (/private/var/folders/nt/26pz2dqj4y70z38vrtgd8t4m0000gn/T/form-init7411586405251765923.clj:1:125).
Caused by: java.lang.IllegalArgumentException: No matching field found: read for class org.jline.terminal.impl.DumbTerminal
I don't know how to enable debug logging. I'm working on OSX and iTerm2. I have asked the same question here https://clojureverse.org/t/reading-standard-input-one-character-at-a-time/5354?u=jewiet

michael.e.loughlin22:01:08

is it problematic to store multiple atoms inside an atom?

michael.e.loughlin22:01:24

maybe there should just be a top level atom

dpsutton22:01:59

Unless you’re in rare waters most probably you just want an atom with a map holding all the values you would have put in the sub atoms

dpsutton22:01:25

Can you describe what you need to accomplish?

michael.e.loughlin22:01:27

I'm only writing a toy lib for fun so I'll go with one atom. It's by far the smallest concession I'll have made so far

michael.e.loughlin22:01:16

(def db (atom [
                ["some/file/location/5" (atom {})] ... ["some/file/location/0" (atom {})]
              ]))
I'm converting what was a single key value pair ["some/file/location/0" (atom {})] into a list of multiple KVPs

didibus23:01:58

Atom in atom isn't a very great pattern in my opinion

didibus23:01:50

I also believe it breaks the atomicity guarantees

didibus23:01:04

If you have such a situation, you might be better served using refs