Fork me on GitHub
#beginners
<
2020-06-09
>
mjw00:06:59

I’m incorporating Integrant into a side project, and I’m wondering if it’s common to put all of the init-key and halt-key! multimethods in the same file, or if folks more often break up those declarations into multiple files and rely on side-effectful imports to ensure the system is composed properly?

Phil Hunt07:06:42

Hi. Has anyone got suggestions for introductory hands-on Clojurescript material. Recent enough that it's not going to collapse in a muddle of broken dependencies and with enough context that you don't have to be thoroughly conversant with the modern JS ecosystem to know what's going on?

MorongÖa13:06:07

Trying to make start a repl this error. Run a project

MorongÖa13:06:25

Could not locate cognitect/rebl__init.class

MorongÖa13:06:49

Caused by: .FileNotFoundException: Could not locate cognitect/rebl__init.class, cognitect/rebl.clj or cognitect/rebl.cljc on classpath.

MorongÖa13:06:03

What am I missing?

alexmiller13:06:16

not sure what you're doing

alexmiller13:06:26

what do you mean by "make rebl"

MorongÖa13:06:09

Trying to make start a repl this error. Run a project

alexmiller13:06:04

the error is saying that you're trying to run rebl, but rebl is not on the classpath. but I'm not sure what you're doing so I don't know how to help

MorongÖa13:06:47

How do I add rebl to my class path than?

alexmiller13:06:53

there are some wiki pages with more info on other envs https://github.com/cognitect-labs/REBL-distro/wiki

MorongÖa13:06:22

Ahh, I see what the issue is. Thank you

dharrigan15:06:04

I seem to recall a trick, discussed a while ago that involved some sort of compliation of the code during startup/repl? I can't recall. @alexmiller I think you mentioned it?

dharrigan15:06:55

thank you dan 🙂

readyready1572816:06:13

I'm still trying to figure out the purpose of dynamic variables when let exists

readyready1572816:06:49

What is the use case here

alexmiller16:06:07

dynamic vars let you pass context down the call stack but not as parameters

readyready1572816:06:22

Oh so it's just dynamic scope then?

alexmiller16:06:40

generally, you should avoid dynamic variables imo - usually it's better to make that stuff explicit in the call

readyready1572816:06:37

That's an ... interesting feature

Jim Newton16:06:14

dynamic variables are very powerful, but with power comes responsibility.

vlad_poh17:06:37

what is the right away to share global variables in clojure. e.g i have 3 different namespaces with ring routes and I want to pass db information

vlad_poh17:06:01

Another namespace with those variables ?

hiredman17:06:09

Don't make globals, pass arguments

✔️ 1
hiredman17:06:09

A common way to pass extra stuff to ring handlers is middleware that assocs that stuff into the request map

☝️ 1
vlad_poh18:06:24

so i'm using the environ library to hold db information

dharrigan18:06:52

I pass "configuration" as a map (usually I leave it the in last position, if a reasonable n-arity is required)

dharrigan18:06:29

I also use juxt clip to manage some state, like a shared database connection, or a redis connection. That state is held in the map and passed around.

dharrigan18:06:49

Yes, I use aero extensively

dharrigan18:06:58

It's part of my juxt clip setup 🙂

dharrigan18:06:12

But I don't use lein, I'm a deps guy 🙂

jpmicena22:06:17

Hi all! I am trying to understand how to use the component library from Stuart Sierra, but I am struggling to understand the record part. In the example, he creates a record using (defrecord Database), and then a constructor using map->Database. My doubt is: What exactly this map-> is doing? Is it mutating the Database record? How it was created? Thank you in advance!

seancorfield22:06:11

@joao.micena When you use (defrecord Foo), Clojure automatically generates two constructor functions for you: map->Foo that accepts a regular hash map and returns a Foo record populated from the hash map and ->Foo that accepts positional parameters matching the fields you declared in defrecord (and returns a populated record).

👍 1
seancorfield22:06:32

Records -- like other Clojure data structures -- are immutable.

seancorfield22:06:06

user=> (defrecord Foo [a b])
user.Foo
user=> (->Foo 1 "Two")
#user.Foo{:a 1, :b "Two"}
user=> (map->Foo {:a "One" :b 2})
#user.Foo{:a "One", :b 2}
user=> 

jpmicena23:06:23

Hmmm I see, this helps a lot, thank you! By the way, I am also using your usermanager-example repo and it has been really helpful!

2