Fork me on GitHub
#beginners
<
2018-08-19
>
Michael Stokley00:08:16

anyone know how to pass an env to resolve?

Michael Stokley00:08:27

i'm having trouble finding documentation about what a clojure env is

Michael Stokley00:08:25

"clojure env environment" is a particularly difficult google search 🙂

mfikes00:08:24

@michael740 It looks like it is just a map. Check out (source resolve) and (source ns-resolve)

Michael Stokley00:08:07

I don't think it's a map, since you can't pass a map to contains?

Michael Stokley00:08:24

it's a collection.

Michael Stokley00:08:17

oh, nvm... (contains? '{k v} 'k) works just fine

sundarj00:08:03

&env is one of the 'special variables' available to macros: https://clojure.org/reference/macros#_special_variables

sundarj00:08:24

=> (defmacro foo [] (prn &env))
#'boot.user/foo
=> (foo)
nil
nil
=> (let [a 2] (foo))
{a #object[clojure.lang.Compiler$LocalBinding 0x41fdf8ca "clojure.lang.Compiler$LocalBinding@41fdf8ca"]}
nil

stardiviner01:08:05

(defn ^String return-string [] (str "hello, world!")) The ^String is a type hint for function return value of a metadata for function var?

mfikes01:08:59

@stardiviner Yeah, but in ClojureScript that would be (defn ^string return-string [] ...) while in Clojure it would be (defn return-string ^String [] ....)

mfikes01:08:45

(Normally you wouldn’t hint in ClojureScript. The one case where it is even remotely common to put type hints on function return types in ClojureScript is for predicates, in order to avoid checked ifs (see http://blog.fikesfarm.com/posts/2015-12-04-boolean-type-hints-in-clojurescript.html).)

mfikes01:08:56

And the need to add function return type hints will be reduced further in the next release of ClojureScript where the return type is inferred.

JanisOlex07:08:39

hey a question I have I just tried to make multiarity function like (defn myfun [number] (myfun number []) [number list] (...)) But obviously I can't do it as second version is not defined when first is trying to use Essentially I want to get function with 1 or 2 params, and if it is invoked with 1 param, then it is realized as calling itself with 1st param and default 2nd param... Or in other words, how do I supply "default" for params if they are not provided by call?

noisesmith07:08:16

(defn myfun ([n] (myfun n [])) ([n l] ...))

JanisOlex07:08:28

ahh syntax... yea thanks

agigao12:08:13

Hello Clojurians, I’ve read a few articles about Yada, also received a guidance and recommendations by Ray, but somehow I’m unable to follow Yada’s the manual. Details: 1 - cloned edge and ran boot dev (inside edge dir) and I receive the following error:

giga@ubuntu:~/edge/app$ boot dev
                              java.lang.Thread.run              Thread.java:  748
java.util.concurrent.ThreadPoolExecutor$Worker.run  ThreadPoolExecutor.java:  624
 java.util.concurrent.ThreadPoolExecutor.runWorker  ThreadPoolExecutor.java: 1149
               java.util.concurrent.FutureTask.run          FutureTask.java:  266
                                               ...                               
               clojure.core/binding-conveyor-fn/fn                 core.clj: 2022
                                 boot.core/boot/fn                 core.clj: 1032
                                               ...                               
                         boot.core/construct-tasks                 core.clj:  986
java.lang.IllegalArgumentException: No such task (dev)
        clojure.lang.ExceptionInfo: No such task (dev)
    line: 3
2 - boot.properties:
#
#Sun Aug 19 02:23:39 PDT 2018
BOOT_CLOJURE_NAME=org.clojure/clojure
BOOT_VERSION=2.7.2
BOOT_CLOJURE_VERSION=1.9.0
Tried on mac then then on Ubuntu in VM, result is all the same.

Chris O’Donnell13:08:06

@chokheli looks to me like edge is using deps.edn now. See the readme at https://github.com/juxt/edge/tree/master/app. Perhaps that is the problem?

agigao13:08:45

Yeah, I received assistance by JUXT guys, I was following the manual which provides boot instructions.

agigao13:08:10

But one thing that baffles me is why take away “instant reload on each save?” and implement explicit command to enter - (reset)

dangercoder19:08:07

Guys do you use any lib for validating http post requests? I've created my own right now but would be good to see some other code to get some inspiration

Michael Stokley20:08:10

is there a way to define a symbol in clojure such that it's re-evaluated each time it's invoked or named?

Michael Stokley20:08:03

for example, this is evaluated just once (def my-random-number (rand-nth (range 10)))

Michael Stokley20:08:08

alternatively, i could wrap in a fn

noisesmith20:08:17

that's how it's actually done

Michael Stokley20:08:42

(def my-random-number #(rand-nth (range 10)))?

noisesmith20:08:18

yeah, though for that specific example #(rand-int 10) does the same thing

Michael Stokley20:08:33

sweet, thank you sir

bartuka22:08:57

wow… @ryan.russell011 I came here to post the exact same thing

_rj_r_22:08:17

kind of confusing at the moment.

bartuka22:08:36

I am trying to find out if anything changed in the postgresql or jdbc library that might be causing the error

_rj_r_22:08:50

yeah.. I've been looking for that as well

_rj_r_22:08:23

so I changed the dependency in project.clj to [org.postgresql/postgresql "42.2.4"]... and it doesn't throw errors anymore. I haven't tested to see if it works.. but at least the repl didn't throw up on me.

bartuka22:08:15

I was trying something different…

bartuka22:08:50

I used a library to perforl the dsl and tried to run that code (I already had played with dsl and worked just fine…) but the error showed up again

bartuka22:08:45

@ryan.russell011 it worked just fine with this new version. Cheers!

_rj_r_22:08:27

yeah... I think the driver in the video is old. There is a note on the Maven site saying things have been moved. I clicked on that, then on the newest driver in that list... which has a lein tab as well...

đź‘Ť 4