Fork me on GitHub
#clojure
<
2017-09-17
>
noisesmith00:09:53

that is what cljc is supposed to be for but no, you cannot, that doesn't work

noisesmith00:09:45

you might notice that in cljs it's usually either foo.bar vs. foo.bar.macros or cljs.foo vs. cojure.foo

cddr10:09:13

In an xml doc that starts like <?xml version=\"1.0\" encoding=\"UTF-8\">, how is the encoding of the document made available to the calling code?

buzzdan12:09:22

has anyone worked with "lein auto" or "lein watch" ?

buzzdan13:09:00

i'm trying to setup a hot reloader for my http kit service so for every change in one of my file it would re-run "lein run"

buzzdan13:09:10

i'm using: lein auto run

buzzdan13:09:17

which doesnt work

buzzdan13:09:26

lein compile does work

buzzdan13:09:33

lein auto compile

buzzdan13:09:40

lein auto run just gets stuck on the server listening to requests - it probably waits for the process to finish its work (and it never does since its listening)

buzzdan13:09:58

any idea how to solve this issue ?

noisesmith14:09:36

buzzdan the common approaches here are 1) pass the var for the handler to the server process and not the handler itself, that way when you redefine your handler, it gets used on the next request without needing to restart the server 2) define a start up and tear down such that every stateful condition in your code is reset when tearing down (so hold onto the return value given to you when the server starts, and later call its stop method after reloading code in order to start it up again)

noisesmith14:09:01

when a globally defined function is called inside another function, your code will automatically see and use changes to the definition, but when the function is an argument to a long running process, the process itself won't see changes to the thing you passed as your argument - the var was dereferenced once when you called it. By passing #'handler instead of handler you are passing a var instead of resolving one, and conveniently if you try to call the var itself as if it were a function, it dereferences and calls the current value when called

noisesmith14:09:46

for start up and tear-down, there are libraries like stuartsierra/component and weavejester/integrant made for this

seancorfield22:09:51

@buzzdan I'll reiterate what @noisesmith said. We do live development on our web apps from the REPL, by using vars and Component.

didibus23:09:33

QUESTION: What happens when you type hint something to the wrong type? Does Clojure try/catch the cast and defaults back to reflection?

Nick Drew23:09:56

@noisesmith that’s great advice. Do you have code samples demonstrating this somewhere?