Fork me on GitHub
#clojure
<
2018-10-07
>
andy.fingerhut00:10:53

Actually, digging a little more into Clojure's compiler source code (in Java), it is also likely that it is wrapping try and catch bodies inside (fn ...)

hiredman02:10:02

for a number of different more complex expressions (try/catch, loop/recur, etc) if that expression isn't in the tail of the function, or in the middle of the do (the compiler calls these contexts, and those two are return and statement contexts respectively, the alternative is expression context), the compiler will hoist the code out in to an immediately invoked fn

hiredman02:10:40

I have a patch on a jira issue somewhere that changed that to hoist them out as static methods on the fn's class, but the patch still doesn't work right (it interfered with local's clearing), and it was a real pain to do given the single pass nature of the compiler

hiredman03:10:01

(despite it not actually working, it is still my favorite patch)

pbaille05:10:59

Hello, i've got an utils library that i would like to :use everywhere (implicitly), what is the way to do so with leiningen?

seancorfield05:10:55

@pbaille The simple answer is "you can't" -- and I'd say you really shouldn't even if you can figure out a way.

seancorfield05:10:42

Clojure favors more explicit approaches -- which is why :use is considered bad practice, along with :refer :all.

pbaille06:10:17

@seancorfield thank you for your answer, i understand. even if sometimes, i have to admit that i'm tired to always rewrite mapvals or things like that... but it's ok 🙂

pbaille06:10:18

also, i'm wondering what is the rational behind

(merge {:x 1} [:y 2]) ;=> {:x 1 :y 2}
?

seancorfield06:10:26

Well, Clojure often defines the behavior of a function only for certain types of input -- and other inputs may or may not given sensible output. Some people call that garbage-in, garbage-out. Others just call it undefined behavior 🙂

seancorfield06:10:43

It's part of what allows Clojure to be fast in the good cases.

seancorfield06:10:55

merge is defined on maps, only.

pbaille06:10:07

ok, i understand, thank you!

seancorfield06:10:32

It's implemented in terms of conj however, and that just happens to be able to add vector pairs or MapEntry objects into a map.

kwcharllie37912:10:30

(sh "git" "clone" "[email protected]:clojure/clojure.git")
Why output is in :err? It seems like a bug in git command WDYT?

lmergen12:10:52

i think it's related to the practice of outputting nothing on stdout when everything is successful

lmergen12:10:08

so then when you do git clone foo | baz bar, it still prints its output to the console, rather than piping to the baz bar command

kwcharllie37913:10:45

😮 Had no idea that such practice exists. To conclude the errors will go to stdout

lmergen15:10:02

it's common in pretty much all of unix, although i think it's a matter of taste / style what to do in the case of git clone

andy.fingerhut18:10:58

@lmergen There are many Unix commands where errors go to stderr and 'normal' output go to stdout. I think the surprise here is that the no-error case output goes to stderr.

andy.fingerhut18:10:05

Looks like at least a few other people consider this odd behavior on the part of git that surprises them, although I guess it is now fairly well known and documented: https://stackoverflow.com/questions/37561240/why-does-git-submodule-add-write-to-stderr-rather-than-stdout

joelsanchez20:10:55

thanks to @lmergen now I know why I couldn't grep the output of lein deps :tree...although now I need an alias for this mouthful lein deps :tree 2>&1 >/dev/null | grep 😛

noprompt20:10:25

lein-grep-tree 😄

andy.fingerhut20:10:46

@joelsanchez On my MacOS machine, I can do lein deps :tree | grep foo and get the filtered output. Your system doesn't?

joelsanchez20:10:13

@andy.fingerhut I'm on Linux, that might be it

andy.fingerhut20:10:14

My Ubuntu 18.04 VM also works without the extra piping trickery.

andy.fingerhut20:10:36

I think it is the git commands specifically that have the unusual behavior of sending progress output to stderr

dominicm21:10:56

I've done grep on tree before too, Linux. Something is wonky.

dominicm21:10:16

Fun fact, --help is supposed to go to stderr.