#clojure log - May 22 2015

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:18 kennyjwilli_: Hey, can anyone help me with a problem that I am having with Datomic? I'm newer to Datomic and Clojure. Thanks! :)

0:36 Raynes: kennyjwilli_: I know nothing about datomic and thus am useless, but a general tip for IRC channels is to just ask the question you have (even if it's long) and see if anyone bites. If you just ask for help, you're asking folks to commit to helping solve a problem that could potentially be quite time consuming.

0:47 kennyjwilli_: Got it. Thanks Raynes :)

1:29 justin_smith: kennyjwilli_: you still haven't asked your question

1:39 kennyjwilli_: I actually got it answered in #datomic. Thanks though :)

2:25 [mad]: hi

2:26 escherize: hi.

2:26 [mad]: sup escherize :)

2:27 escherize: hi [mad]

2:27 your name is hard to type because i have smartparens on. :()

2:27 [mad]: :D

2:32 is anyone using coreos with clojure? need a guide or something to start from 0

2:46 wasamasa: wait, wasn't that the deployment platform?

2:46 how is that related to programming clojure generally

2:51 heurist`: [mad]: if you can get a coreos java container (and there must be plenty of those) then clojure should be simple to add to it. clojure is just a jar file.

2:53 [mad]: wasamasa yep

2:53 heurist i'm looking some info from digitalocean about it

2:54 searching for examples on github, but nothing for now

2:56 heurist: [mad]: google has links to deploying java on digital ocean, and also coreos specific ones. get java working then worry about clojure. you can make an uberjar out of your clojure project and java -jar my-uber.jar it on the container once it works. I can not give more specifics since I have not done java on coreos, but it should not be complicated. good luck.

2:57 [mad]: thanks dude :)

3:28 stanford_drone: Does anyone know C/C++, Computer Vision/Image Processing, Machine Learning, AI, linux systems programming, or electronics? I'm looking for a programmer to join my Startup. We're going to China (manufacturing is there) from July to November. We're a team of 4. We're building a flying computer. A drone that you can play games with and install apps on.

3:31 kaiyin: stanford_drone: do you use clojure?

3:32 alright. anyone care to have a look at this? http://stackoverflow.com/questions/30390817/core-typed-not-reporting-type-error-in-repl

3:34 [mad]: stanford_drone cool, what stack r u using on that project? :D

3:35 stanford_drone: [mad], linux computer with CUDA gpus, flying on a drone. C++/OpenCV

3:35 engblom: [mad]: Unless you really type this from a phone, please use as good English as you are able to use. Especially in programming channels, stuff like "r u" feels really disturbing.

3:35 stanford_drone: are you interested in joining?

3:37 [mad]: stanford_drone sounds interesting, no sorry, noob here :D

3:37 engblom okay

3:38 dstockton: r u for real engblom ?

4:30 kaiyin: could anyone help with this? http://stackoverflow.com/questions/30391847/is-order-guaranteed-when-multiple-processes-are-waiting-to-put-data-in-the-same

4:32 WickedShell: are there any seesaw/font whizes around? I'm finding registering a TTF font to be a problem

4:33 [mad]: re

4:34 heurist i find that http://palletops.com/blog/lein-uberimage/ :D

5:11 entity: is def and defn slower than let? I'm currently using those two to define local functions and variables and I'm wondering, if it's slowing things down

5:11 I didn't know that def and defn is for global bindings, so I'll rewrite it anyway

5:11 I'm just wondering what's the impact on performance, because I'm getting some really slow function evaluations

5:18 amalloy: def creates a Var, registers it in your namespace, sets its value, gives it metadata...and let is free, costing you maybe one bytecode instruction depending on JIT

5:18 entity: okay, so calling def 10k times per second = bad

5:19 amalloy: entity: don't call def at runtime, at all. there are exceptions, but they are not common

5:19 entity: and I was wondering why the REPL was seeing all my local variables, heh

5:19 amalloy: not just for performance reasons, but because that's not what defs are "for"

5:19 entity: thanks a lot :)

6:23 ionthas_: Hei! I have a vector [1 1 0 0] and I want to have the inverse [0 0 1 1]. 0 and 1 are not treated as true,false so I cannot apply the function (map not [1 1 0 0]). Is there any way to do that? Thanks!

6:26 katratxo: ionthas_: reverse ? http://conj.io/store/v1/org.clojure/clojure/1.6.0/clj/clojure.core/reverse/

6:26 AimHere: ionthas_, what do you mean by inverse, specifically?

6:26 oddcully: ,(map (partial bit-xor 1) [1 1 0 0])

6:27 clojurebot: (0 0 1 1)

6:27 AimHere: ,(mapv #(- 1 %) [1 1 0 0])

6:27 clojurebot: [0 0 1 1]

6:27 ionthas_: That was exactly what I needed. Tanks.

9:00 entity: is there no parallel sort-by in the standard library?

9:35 fourq: Does anyone have the vim rainbow parens plugin working on load? I'd like to see what you set in your vimrc to avoid having to toggle it on each src file.

9:35 A bit off topic, but then again...parens

9:37 entity: the readme says to put let g:rainbow_active = 1

9:38 I'm going to try it out now :P

9:38 (https://github.com/luochen1990/rainbow)

9:38 fourq: where do you....oh

9:38 dif repo

9:38 I was looking at https://github.com/kien/rainbow_parentheses.vim

9:39 but i'll try the one you found

9:40 entity: do you use pathigen by chance? Any idea how to install the plugin properly?

9:40 fourq: yeah

9:40 I go to my .vim root first

9:40 then

9:40 git submodule add <git url> bundles/<name of bundle>

9:40 but that's with submod

9:41 you can also just drop it in bundles

9:42 entity: thanks

9:43 seems to work nicely

9:43 fourq: I can't wait to change the colors on it =)

9:44 entity: yay for fruit salad code :)

9:44 fourq: hehe

9:53 escheriz`: nice

9:55 entity: I'm wondering if someone would be willing to look at a function I wrote and tell me if there are some obvious performance issues? It's running slower than I'd like

9:55 here it is: https://github.com/osense/clojure-robby/blob/master/src/clojure_robby/core.clj#L79

9:56 basically, make-step is iterated a hundred times and each iteration computes the newly modified map, position and score

10:00 maybe it's because current-map is copied between each step, but I'd have thought that this would get optimized away

10:01 dnolen: entity: is `dna` always a vector? otherwise you have a linear cost to calling `nth` on it

10:01 entity: yes, dna is always a vector

10:02 same for the map

10:02 dnolen: entity: so it sounds like simulate is an inner loop for you. It doesn't not appear this code was written for perf but for clarity. It too much code for me to give you a better suggestion than - use a profile.

10:02 s/profile/profiler

10:03 entity: yeah, I did write it for clarity, especially as it's the first thing in CLojure for me :)

10:03 thanks for the suggestion, I'll also try to integrate pmap somewhere I guess

10:04 dnolen: entity: then I honestly wouldn't worry about perf, unless it's a blocker for your learning process.

10:05 entity: it's possible to write very, very fast Clojure code but that's a fairly big topic on it's own.

10:07 jtmarmon: does anyone know of an example web app using stuartsierra's component? trying to figure out how to structure a compojure API using it

10:11 gfredericks: jtmarmon: not sure what your exact problem is, but I've taken two approaches to compojure + component

10:11 one is you make a function for the routes

10:11 (defn make-the-routes [server-component] (routes ...))

10:11 ^ which lets you use the server lexically

10:11 the other is to have middleware that attaches relevant components to the request

10:12 (defn wrap-components [some-component handler] (fn [req] (-> req (assoc ::component some-component) (handler))))

10:12 jtmarmon: ah makes sense. the former definitely looks cleaner but seems like it would be a pain in the ass for project structure

10:12 gfredericks: because all the routes have to go in one place?

10:13 jtmarmon: ya

10:14 gfredericks: yeah, that's why the second is more flexible; but you could also compose several such route functions

10:14 (defn make-the-routes [server-component] (routes (make-these-routes server-component) (make-those-routes server-component)))

10:15 jtmarmon: right, yeah. I'll consider which one makes more sense for us. thanks for the advice!

10:18 gfredericks: np

10:22 wmealing: is this the wrong place to ask about clojurescript questions ?

10:23 bensu: wmealing, #clojurescript

10:23 wmealing: thanks bensu.

10:52 TimMc: justin_smith: From a quick look, lein-diff seems more complicated than I thought. Dependencies get resolved in the context of a project; a project is loaded from file; the file *might* need to be in the context of the entire repo in case of lurking middleware.

10:54 so it might have to be orchestrated by a shell script, I'm not sure

10:59 Maybe you have a shell script that clones the project to two locations, checks out the appropriate commit in each, then calls lein diff with paths to the project.clj in each project. That lein diff then invokes lein diff from the working directory of each project to extract data, receives the results, and outputs the diff results.

11:05 justin_smith: TimMc: well, can't you compare the data structures returned from lein/load-project ?

11:06 load, bind, checkout branch, load, compare

11:07 TimMc: maaaaaybe

11:07 Mucking around with the working directory while I have code running in it sounds pretty fragile.

11:08 justin_smith: in fact, instead of checkout out branches, it should suffice to checkout the project.clj from each branch into temp files, then load each of those temp files

11:08 TimMc: I'm still unclear whether it's enough to just have project.clj.

11:08 I didn't have time to go into depth on that.

11:08 justin_smith: you would want project.clj plus all instances you can find of profiles.clj

11:08 TimMc: I might just say "to heck with local middleware" but I'd like to have a more comprehensive solution.

11:09 justin_smith: iirc

11:09 TimMc: Wait, how many profiles.clj can there be?

11:09 justin_smith: TimMc: it's one of those classpath based things

11:09 so you can have ~/.lein/profiles.clj and project/profiles.clj

11:09 TimMc: yikes, didn't know that

11:09 justin_smith: but that's enough to generalize to "find all of them" for the corner cases

11:10 TimMc: I think I'd use the :production profile by default, for that matter.

11:10 justin_smith: TimMc: but iirc leiningen.core/load-project (or whatever the function / namespace combo) should be doing all that for you, and returning your final effective lein config data structure

11:11 though the comparing branches thing could be a mess...

11:12 TimMc: git-cat-file might help you here (it can copy a file from a given git state I think)

11:14 oh, no, git show

11:14 git show TREEISH:project.clj > tmp1; git show TREISH2:project.clj > temp2

11:14 etc.

11:15 the lein function foading a project can take an explicit file arg

11:15 foading ~= for loading

11:15 * TimMc updates Urban Dictionary

11:16 TimMc: The shell script idea would allow me to support other VCSs, which would be nice.

11:19 but I'd settle for an option pointing to a script that can be called with args "setup", "switch-first", "switch-second", "cleanup" so arbitrary commands could be used.

11:19 That way lein-diff could drive the show.

11:43 ToBeReplaced: any success/failure with an ssh lib from clojure? needs to support kerberos auth from rsa key

11:52 wink: ToBeReplaced: only ssh thingy I can think of is stuff from pallet

11:52 but no clue about your specifics

11:57 ToBeReplaced: it uses clj-ssh which is an opinionated wrapper on jsch... jsch seems to be the known evil and most likely to work for complex cases, so it looks like i'll go with that

14:47 clojer: Is there a better way to test if something is map than (if (= (type x) clojure.lang.PersistentArrayMap) .... ?

14:48 justin_smith: ,(map? {})

14:48 clojurebot: true

14:48 clojer: justin_smith: I searched for that in clojuredocs but couldn't find it. Great.

14:49 justin_smith: clojer: because arraymaps are only for small maps, when they get more keys they become persistenthashmaps

14:49 and also it's more clear too :)

14:54 puredanger: you really should never refer to concrete types inside Clojure as a general rule

14:54 if you must, use IPersistentMap etc

14:55 justin_smith: the big exception to that would be type hints maybe? at least primitive type hints

14:55 otherwise 100% agreed, excellent point

14:55 puredanger: even then

14:55 there's no reason to typehint the concrete class over the interface

14:56 justin_smith: wait, for primitives?

14:56 chouser: primitive types look like hints but are really more than that

14:56 puredanger: not talking about primitives, that's different

14:56 justin_smith: OK, got it

14:56 chouser: because of the difference of implementation, or an explicitly different thing?

14:57 chouser: Hm, not sure how to differentiate between those options. :-)

14:58 justin_smith: welcome to the blurry world of clojure I guess

14:58 haha

14:58 chouser: both the meaning of the interface and the meaning at the bytecode level are different

14:59 a type hint is a "hint," it allows the compiler to generate bytecode that does less work at runtime

14:59 justin_smith: and with a primitive...

14:59 bensu: puredanger, 1.7.0-RC1 passed all the tests without issues

14:59 puredanger: yay

15:00 chouser: a primitive typed fn parameter can only support that exact kind of argument. It declares a key part of the interface to that fn.

15:00 justin_smith: oh yeah, I vaguely recall some very weird stack traces this can lead to

15:01 chouser: (fn f [^Foo x]) means the body of f will be treating x as a Foo in some cases, but it isn't explicitly checked at the fn call boundary. It's a hint to the compiler inside the body of f.

15:02 andyf: This may be a question best for the clojure-dev group, but is there an at-most-2-sentence description of what in Clojure's Java code guaranteed that the older transient implementation safely published changes it made to other threads? (I'm also curious about the answer for the newer one, but realized I probably didn't understand why this worked before, either)

15:02 chouser: (fn g [^long x]) means g only takes a primitive long, and passing anything incompatible *will* break at the call boundary.

15:03 justin_smith: chouser: aha, that's really helpful. One of these days I will do some more work on hint-hint (a repo with unit tests that demonstrate what works / breaks / does nothing in the world of hinting)

15:04 and I'll make a note to demonstrate how primitive hinting can break

15:05 chouser: justin_smith: That sounds very interesting. Visibility into the compiler's understanding of type hints and primitives has always been a bit poor.

15:05 There is that nice disassembler that I always forget to try.

15:06 justin_smith: chouser: the trick so far is eval inside with-out-str with warn-on-reflection turned on, and unit tests about the messages given. a more advanced iteration might make assertions about the disassembled output?

15:08 puredanger: no.disassemble ?

15:08 you can use ASM to make assertions about the bytecode, but prob no picnic

15:08 chouser: puredanger: that's the one

15:09 justin_smith: puredanger: yeah, that's another options - but a regex test on the output of no.disassemble/disassemble seems straightforward enough

15:11 or even a tree walk on the right part of the disassemble-data output actually... gee this is a cool lib!

15:11 (inc gtrak)

15:11 lazybot: ⇒ 14

15:19 gfredericks: (inc gtrak)

15:19 lazybot: ⇒ 15

16:01 arohner: if I have an uberjar created by lein, is there a way to figure out which version of a dependency got used?

16:10 puredanger: yeah, the version info is in the pom.properties under META-INF

16:10 there will be a file in uberjar like META-INF/maven/org.clojure/core.async/pom.properties

16:17 arohner: puredanger: thanks

16:18 hrm, I have tools.nrepl specified as 0.2.10, but lein is resolving to 0.2.6. I also have tools.nrepl in :exclusions, to try to prevent any dep from specifying it. Not sure where to look now

16:23 looks like leiningen injects it?

16:24 gfredericks: arohner: um

16:24 arohner: is this uh

16:24 arohner: so

16:24 are you running `lein repl` outside a project?

16:24 arohner: gfredericks: nope

16:25 gfredericks: okay then I don't know; lein is supposed to respect an [org.clojure/tools.nrepl "..."] in your deps list

16:25 it only works for me when running with an existing project though

16:25 puredanger: lein deps :tree ?

16:26 arohner: puredanger: it's hard to read, because I have so many exclusions. but tree says it's using 0.2.6

16:28 puredanger: <that shrug emoticon thing>

16:28 set table on fire, then flip?

16:28 arohner: I'm not sure this is a smoking gun yet, but it is suspicious: https://github.com/technomancy/leiningen/blob/2.5.1/leiningen-core/src/leiningen/core/project.clj#L483

16:29 puredanger: there is some way to get rid of hte default profile, cna't remember how

16:30 Bronsa: (╯°□°)╯︵ ┻━┻

16:32 bensu: arohner, you can usually get what you want out of lein deps :tree with grep!

16:32 TEttinger: ,(def ╯°□° (print "(╯°□°)╯︵ ┻┻")

16:32 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

16:32 TEttinger: ,(def ╯°□° (print "(╯°□°)╯︵ ┻┻"))

16:32 clojurebot: (╯°□°)╯︵ ┻┻#'sandbox/╯°□°

16:33 TEttinger: ,(def ╯°□° #(print "(╯°□°)╯︵ ┻┻"))

16:33 clojurebot: #'sandbox/╯°□°

16:33 TEttinger: ,(╯°□°)╯︵ ┻┻

16:33 clojurebot: (╯°□°)╯︵ ┻┻

16:34 arohner: :profiles {:base {:dependencies ^:replace []}

16:35 just strips out the deps that leiningen injects

16:35 justin_smith: TEttinger: did you intend that to be a defn?

16:35 amalloy: justin_smith: the most recent definition is one

16:35 TEttinger: I didn't want to have square brackets

16:35 justin_smith: ahh

16:37 TEttinger: ,(first (sort-by #(- (count (filter (partial = \) %))) (clojure.string/split "loser, loser, winner, loser, loser, loser" #", ")))

16:37 clojurebot: "winner"

16:37 TEttinger: this is a fun tool for loaded decisions

16:38 ,(first (sort-by #(- (count (filter (partial = \) %))) (clojure.string/split "a, b, c, d, e, f, g, h" #", "))) ; d will win

16:38 clojurebot: "d"

16:39 amalloy: TEttinger: there's an nbsp in there somewhere, i guess?

16:39 TEttinger: BOM

16:39 please, amalloy, what am I a filthy peasant?

16:39 there's two BOMs

16:40 amalloy: TEttinger: i think the (partial = \) is not subtle enough. the \ is obviously dangling

16:40 TEttinger: yes

16:40 amalloy: try replacing it with #{\ \n \r \t}

16:41 or i guess #{\ \n \r \t} so it looks like \space

16:41 TEttinger: there's a definite way to do this... I think by determining what will hash to feff it might work

16:41 justin_smith: ,(int \)

16:41 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

16:41 justin_smith: oh this tty doesn't do it right

16:41 amalloy: well i didn't put an actual BOM in, if you were just copying from me

16:42 justin_smith: ,(int \)

16:42 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

16:42 TEttinger: ,(.toHexString (hash :a))

16:42 clojurebot: #error {\n :cause "No matching field found: toHexString for class java.lang.Integer"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching field found: toHexString for class java.lang.Integer"\n :at [clojure.lang.Reflector getInstanceField "Reflector.java" 271]}]\n :trace\n [[clojure.lang.Reflector getInstanceField "Reflector.java" 271]\n [clojure.lang.Reflector invokeNo...

16:42 TEttinger: ,(Integer/toHexString (hash :a))

16:42 clojurebot: "816f5f1e"

16:42 TEttinger: hmmm

16:44 ,(reduce #(if (= (hash %2) 0xfeff) (reduced %2)) (range))

16:45 clojurebot: eval service is offline

16:45 TEttinger: yep

16:45 ,(reduce #(if (== (short (hash %2)) 0xfeff) (reduced %2)) (range))

16:45 clojurebot: #error {\n :cause "Value out of range for short: 1392991556"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Value out of range for short: 1392991556"\n :at [clojure.lang.RT shortCast "RT.java" 1116]}]\n :trace\n [[clojure.lang.RT shortCast "RT.java" 1116]\n [sandbox$eval103$fn__104 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Iterate reduce "Iterate.java" 64]\n [clojure.core$...

16:50 entity: hm, when I launch the uberjar (java -jar ...), after finishing it's thing, it hangs for a minute before exiting

16:50 what's going on?

16:51 puredanger: (shutdown-agents)

16:52 the agent pool has non-daemon threads in a background pool with a 60s timeout

16:52 so add the shutdown call to kill them

16:52 entity: yup, that fixed it

16:52 thanks

16:59 andyf: entity: And if you have (or are willing to create) an account on JIRA, vote on this ticket: http://dev.clojure.org/jira/browse/CLJ-124

17:00 puredanger: I think that was the first ticket I ever commented on in Clojure :)

17:04 entity: andyf: hehe, good to know this is getting some attention

17:04 w01fe: ,(->> (range 10000) (mapcat (fn [_] (java.util.ArrayList. (range 10)))) (reduce (constantly nil)))

17:04 clojurebot: #error {\n :cause nil\n :via\n [{:type java.lang.StackOverflowError\n :message nil\n :at [clojure.lang.AFunction <init> "AFunction.java" 18]}]\n :trace\n [[clojure.lang.AFunction <init> "AFunction.java" 18]\n [clojure.core$concat$cat__4214$fn__4215 <init> "core.clj" 697]\n [clojure.core$concat$cat__4214 invoke "core.clj" 696]\n [clojure.core$concat$cat__4214$fn__4215 invoke "core.clj" 702]\...

17:06 w01fe: (seems like a bug in 1.7-RC1?)

17:07 puredanger: isn't this the classic concat stack problem?

17:07 amalloy: puredanger: no, it's a different classic problem

17:07 lesser known

17:08 w01fe: well, it ran fine under 1.6 ... i think this is specific to the new internal reducing stuff

17:08 amalloy: you get the same thing if you (reduce (constantly nil) (apply concat (take 10000 (cycle [[1] '(1)]))))

17:09 if it ran fine in 1.6 maybe it is a different issue

17:10 puredanger: could be range changes

17:11 well I am about to shut down my computer and disconnect from Clojure for a week

17:11 so file a jira :)

17:11 amalloy: puredanger is so horrified by this issue he's gone into shock

17:11 can't look at a computer for a week

17:11 puredanger: vacation :)

17:11 w01fe: haha will do :) thanks, have a good break

17:26 tvanhens: I'm running into a weird issue that i can't solve for the life of me. I am trying to develop a webserver and I have some middleware that converts responses into a buffered input stream (wrap-middleware-format). If I slurp the body of the response and call edn/read-stream on the body I can read it no problem. If I do the same and assoc the resulting body back into the original map I get a FileNotFound exception which makes now

17:26 sense to me

17:27 basically whenever I try to put the result in a map I get a file not found exception

17:27 if I return the result plain I get what I expect

17:28 (defn request

17:28 "Makes a request to a catalyst system."

17:28 [system method uri & {:keys [params token]}]

17:28 (let [handler (handler system)

17:28 {:keys [body

17:28 status] :as response}

17:28 (handler

17:28 {:request-method method

17:28 :uri uri

17:28 :params params

17:28 :headers (-> {"content-type" "application/edn"

17:28 "accept" "application/edn"}

17:28 thats fine but if I do:

17:28 amalloy: tvanhens: stop pasting

17:28 if you want to paste a large code snippet, use refheap or gist or something

17:28 tvanhens: sorry didn't know it would do that

17:28 gotcha

17:28 thanks

17:30 https://www.refheap.com/101489 that summarizes the problem. I'm flabbergasted as to what the difference is

17:31 any help would be greatly appreciated because this is driving me mad feel like I've tried every workaround I can

17:33 amalloy: tvanhens: why are you mucking with the response body at all? typically responses should be a string, not a clojure data structure

17:34 tvanhens: This is for a repl util I'm trying to mock requests and get a response back in edn

17:35 justin_smith: tvanhens: using ring-mock?

17:35 tvanhens: no I'm just passing in {:uri "" :params {} :headers {}} manually

17:35 the input seems to go fine

17:36 its the reading of the response thats causing trouble

17:38 TEttinger: ,(first (sort-by (fn [_] (rand-int 0xffff)) (clojure.string/split "a, b, c, d, e, f, g, h" #", "))) ; g will win

17:38 clojurebot: "g"

17:38 tvanhens: I suppose the crux of it is I'm not using a webserver in local tests because I don't want any port bind errors if the tests fail and the state can't be cleared

17:39 so I am manually crafting "mock" requests similar to ring mock but having trouble converting the body of the response to edn for testing

17:40 amalloy: tvanhens: convert the body to edn in your test, not in the handler

17:41 the stuff returned by a ring handler should conform to the ring spec

17:42 tvanhens: gotcha I thought I was though. That funciton linked in the refheap is a util funciton in the test ns

17:42 I'm not trying to convert anything in the handler

17:43 I'm trying to convert the response of the request to the handler

17:43 amalloy: tvanhens: okay, so what are you doing with the result of this request function? there is no way for just calling (request whatever) to throw an exception for one of these definitions of request but not the other

17:43 so it has to be a problem in what you are doing with the result

17:45 tvanhens: just running it in the repl right now. I've disabled the tests I def one version of the funciton, eval it in the repl and then def the second version eval it in the repl and get an error

17:45 I've been using clojure for 2 years now and I've never seen anything quite like it. Moving it into the map changes the behavior

17:46 I've tried wrapping the the (-> body slurp edn/read-string) in a do all and letting the result and then returning it in a map just in case there was some tricky lazyness or some thing but no success

17:48 actually it gets even stranger

17:48 https://www.refheap.com/101492

17:48 those two when evaled with the same args: one returns an error the other is fine

17:49 it seems like as long as I don't name the key body it works

17:50 amalloy: the two things you just posted appear identical

17:50 justin_smith: tvanhens: is there a typo in "works"?

17:50 tvanhens: oops sory yes there is

17:50 the first one should have :body as a key in the return map

17:51 if :body is a key in the return map it doesnt work

17:51 https://www.refheap.com/101493

17:51 thats what I'm experiencing

17:52 justin_smith: I see body in both of those

17:52 I think they are identical

17:52 amalloy: not this time, justin_smith

17:52 the last line of each is different

17:52 tvanhens: http://imgur.com/5wR7HCP

17:52 justin_smith: oh, you mean :body in what comes out

17:52 OK

17:53 tvanhens: thats my repl session evaling one and and then the other

17:53 the imgur

17:53 request* just wraps request passing in a token

17:53 does no other transformations

17:54 justin_smith: tvanhens: is the content of the body a string that slurp might think is the uri of a file?

17:55 that would be the parsimonous cause of an error like that

17:55 usually a handler would return a string in the body

17:55 and slurping it should throw that exception

17:55 amalloy: tvanhens: imgur screenshots are a crime against debugging. please get a full stacktrace via (.printStackTrace *e *out), and then make a textual paste with its contents. ideally the repl session would also include the redefinition of request, so that we don't have to take your word for it that you redefined it in between

17:56 tvanhens: ok I can get you that one sec amalloy. I appreciate your patience I know this might seem like a beginner issue. I've been working with clojure for 2 years and never seen anything like this

17:57 justin_smith when I return just (-> body slurp edn/read-string) I get the expected response which isn't a uri

17:57 amalloy: well, it doesn't seem like a beginner issue. it seems like an issue being caused by some tiny mistake somewhere that is hidden in code you don't think is important to show (eg, request* or something)

17:57 tvanhens: ok I'll get it all out there with repl results on sec

17:58 amalloy: tvanhens: also, try just taking the working value (the one with :notcool), replacing the key with :body, and pasting that into the repl. maybe your repl is broken and somehow misinterpreting maps with a :body keyword

18:02 tvanhens: https://www.refheap.com/101494

18:03 amalloy: tvanhens: ! well of course it behaves differently, request* is calling request twice, and expecting a map with :body in it

18:03 tvanhens: I missed a line in the copy paste process... after the second deffing of request I run the same (user/request* ...) command as the previous dev

18:05 I'm still confused... the first time it gets called... its expecting the body to be converted to edn

18:05 to pull out the token

18:05 and that works

18:05 now it gets called again using that token

18:06 why would the first call affect the second call?

18:06 amalloy: no it doesn't. try printing body in request* both times, and you'll see it's different. probably nil in one case

18:06 tvanhens: trying one sec

18:08 so the first time it grabs the token fine then it calls request again and I get that file not found exception before it returns and prints

18:10 amalloy: right, i'm taking issue with "it grabs the token fine". if you change the contract of request, so that sometimes it returns {:body x} and other times it returns just x, without making a corresponding change to request*, then request* will not find the information it was looking for

18:11 at some point this miscommunication causes body to be a string instead of an inputstream, and as justin_smith said if you slurp a string it tries to open a file or whatever

18:11 ,(slurp "abcde")

18:11 clojurebot: #error {\n :cause "denied"\n :via\n [{:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__887 invoke "sandbox.clj" 69]}]\n :trace\n [[clojurebot.sandbox$enable_security_manager$fn__887 invoke "sandbox.clj" 69]\n [clojurebot.sandbox.proxy$java.lang.SecurityManager$Door$f500ea40 checkRead nil -1]\n [java.io.FileInputStream <init> "FileInp...

18:16 tvanhens: gotcha thanks I think I've figred it out based on that... looks like I have a middleware in front of format params that was getting triggered and that was returning pure edn and not getting converted into the stream

18:17 thank you thank you thank you that was driving me mad. I appologize for pasting in the channel. I don't frequent IRC much

18:18 amalloy: it's fine. everybody is new once

18:30 oddcully: (inc justin_smith)

18:30 lazybot: ⇒ 255

18:30 oddcully: (inc amalloy)

18:30 lazybot: ⇒ 274

19:14 kaiyin: could anyone help me with this macro? https://gist.github.com/kindlychung/2a1f5bc141ae9fb4a8e4

19:19 amalloy: (pprint expr#)

20:07 icedp: (identity icedp)

20:07 lazybot: icedp has karma 0.

20:10 icedp: (inc 0)

20:10 lazybot: ⇒ 4

20:10 icedp: (inc 1)

20:10 lazybot: ⇒ 10

20:10 icedp: em what?

20:11 adereth: (inc 0)

20:11 lazybot: ⇒ 5

20:11 icedp: (inc 0)

20:11 lazybot: ⇒ 6

20:11 icedp: ah..

20:11 (source inc)

20:17 WickedShell: I'm having some problems with lein and rescources (particularly loadign things from sub directories). Anyone have a link to a good tutorial on resource management within lein?

20:20 andyf: WickedShell: I don't have a link to a tutorial, but I have successfully loaded resources in Clojure programs before, and may be able to help.

20:21 WickedShell: andyf, basically I can load anything from the root resources folder succesfully, but if I try to load an asset from a subfolder within my resources directrory, the file isn't found

20:21 That and apparently I'm supposed to be loading it differently to handle being built into a jar, although my uberjar appears to be working at the moment

20:21 andyf: I am looking through the part of Eastwood that successfully does this, to remind myself what I did, since it has been a few months.

20:22 Did you try (clojure.java.io/resource "path/within/resource/dir/filename") to get .. whatever that returns?

20:23 I'll check what it returns, but it is probably a Java File or URL

20:24 It returns something that you can call clojure.java.io/reader on to return a Java Reader

20:29 WickedShell: is (clojure.java.io/resource ) the appropriate way to load content for the jar as well?

20:29 I wonder if.... I bet seesaw has been protecting me from myself till now... (you pass it the name of say the image to load, and I've been simply passing it the name of the file in the resource directory)

20:31 well thats somewhat working (clojure.java.io/resource) does find it, but I explicitly need a file object

20:31 amalloy: WickedShell: you can't get a file object for something in an uberjar, because they aren't files that exist on the filesystem

20:33 WickedShell: hm theres a version that takes an input stream, but it didn't match the resource

20:33 converting the resource to io/file works, although it remains to be seen if it works in the jar

20:34 amalloy: WickedShell: you can get an input stream from a resource easily enough

20:34 i think it's just c.j.io/input-stream

20:34 WickedShell: probably :P

20:35 yeah looks like it is

20:35 also possibly a stupid question, when building a uberjar I get a warning about reflection in clojure/core/memoize.clj is that expected or did I cause it?

20:37 amalloy: don't worry about it

20:39 WickedShell: kk, thanks for the assistance!

20:40 * WickedShell wonders why the first project selected had such a larger scale...

20:43 WickedShell: actually still having a problem with that, I dropped in (io/input-stream (io/resource "foo.bar")) which workc currectly in the repl/lein run but creates a java exception in the uberjar

20:44 well actually its (io/input-stream (io/resource "foo/bar.txt"))

20:44 amalloy: i don't know why foo.bar ever would have worked there, but i'm glad you got it sorted out

20:45 WickedShell: thats not what I should have done? uh oh... :P

20:53 Ahh I see the problem was I had windows \\ in the path (which was from before when I was providing an absolute path, the nice stanard *nix method of / in the path works beautifully

20:56 andyf: WickedShell: Yeah, I am pretty sure that Java resources should use / as the path separator regardless of the platform. That isn't universally true for all Java APIs, but I think it is for resource names.

20:56 Sorry I went away there. Glad you found other help.

21:18 justin_smith: yeah, windows can handler /, but other platforms can't handler \\

21:18 *handle

21:18 can't tell I've been writing backend web code all day

21:20 WickedShell: I hate the \ that windows uses... makes for the messiest set of \\ everywhere (also when using compiled regex's that can get a little crazy)

21:20 anyone here familiar with clj-serial (or java realcomm)

21:21 er not realcomm, purejavacomm

23:32 does clojure gurantee lazy evaluation? ie (if (and false (.bar nil)) (println "shouldneverrun") (println "lazyEval")) is that guranteed to always print lazyEval?

23:33 justin_smith: WickedShell: that's not laziness

23:33 but yes, (.bar nil) won't run, and (println "shouldneverrun") won't either

23:33 WickedShell: justin_smith, that's what I'd call it from C I guess (although usually thats applied to (true || expensiveFoo())

23:34 justin_smith: WickedShell: in clojure laziness is a specific behavior of the datatype LazySeq

23:34 we would call the and / if / or behaviors short-circuiting

23:34 WickedShell: justin_smith, thats it! thanks my bad

23:34 im tired

23:35 but you are correct

23:35 justin_smith: np, just making sure we're on the same page with the terminology

23:49 WickedShell: If I require/use a file in one file and then require/use it in the other file does it get executed twice or simply share the namespace?

23:50 justin_smith: unless you specify :reload the top level does not get executed again

23:51 but you should always write your code so that the result wouldn't be different whether the top level ran again or not

23:51 by having no top level side effects (nothing stateful in a def, no top level code that isn't in a def or defn)

23:52 WickedShell: hm.... only way I can see how to do that in this case is to forward declare the gui elements I need to access, which seems... bad as well?

23:53 justin_smith: WickedShell: there are various ways this can be handled. Including local bindings inside a defn instead of top level def

23:53 WickedShell: I'm having trouble adjusting to this aspect I think, I keep thinking interms of header files/pragma's

23:53 justin_smith, do you have an example of that?

23:53 justin_smith: the most reliable way to handle this stuff is stuartsierra's component library

23:54 which has many good examples, including in the lib's readme

23:59 WickedShell: justin_smith, will read through that, thanks

Logging service provided by n01se.net