Fork me on GitHub
#beginners
<
2021-08-24
>
Mitul Shah14:08:22

hi all, i’m using cursive with intellij but all my symbols are considered unresolved. which means pretty much every line has the siggly indicating an error (though there isn’t) does anyone know how to fix this?

finchharold16:08:25

Hi, how to use :refer :all? Does that mean the functions can be directly used?

sheluchin16:08:16

Yeah, if you refer all the functions from some namespace you no longer have to use their fully qualified symbols within the current namespace.

finchharold16:08:10

If I do (:requre [name.one] :refer :all) then, I can refer any function from any of the namespaces - (name.one.a or name.one.b)?

sheluchin16:08:19

The :refer :all part goes within the vector and applies only to the symbols in that particular namespace.

sheluchin16:08:41

I don't think you can do a wildcard-like match against multiple namespaces. Remember that the part after the last period should match to a filename while all the parts before periods should map to folder names, so the entire libspec directly maps the namespace symbol to a file in the tree.

seancorfield17:08:59

Namespaces do not represent a hierarchy so there's no sense that name.one.a is "inside" name.one -- they have no relationship to each other.

seancorfield17:08:38

(:require [name.one :refer :all]) is essentially the same as (:use name.one) -- which is not recommended (because then you can't tell which namespace a symbol comes from). You really should use an alias like (:require [name.one :as one]) and then one/stuff to refer to names within that namespace.

seancorfield17:08:15

It's OK to :refer specific symbols if it makes the code more readable -- and in tests sometimes folks will relax that "rule" and just refer in all of clojure.test (but I still think it's better practice to just :refer [deftest is] and be explicit about what symbols you are using).

roonie19:08:23

can anyone recommend a good book/tutorial for building a web server with some simple database logic, that doesn't use luminus? I still feel uncomfortable using it because I'm so completely lost when I have to debug errors. Creating a server with ring is easy enough (for me, at least), but I'm looking for a bit of guidance on best practices, especially testing, as well as using component or a similar library

practicalli-john07:08:35

https://practical.li/clojure-web-services/projects/status-monitor-deps/ is a simple project that covers building a web server https://practical.li/clojure-web-services/projects/banking-on-clojure/ is a big more involved and includes database access too, using next.jdbc

noisesmith19:08:07

@varun.jayaraman if you are comfortable with the ring part, component docs have a sample database component, the final connecting bit is that you put the system map into the request map so the handler can use it https://github.com/stuartsierra/component/blob/master/dev/examples.clj#L32

noisesmith19:08:30

@varun.jayaraman I would usually do this by putting a middleware function into the system map then extracting that into the request handler

roonie19:08:53

alright thanks, i'll take a look

dpsutton19:08:29

might fit the bill