#clojure log - May 13 2015

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

0:49 hiredman: huh, clojure 1.7 breaks my favorite trick for clojure scripting

0:49 puredanger: which is?

0:50 hiredman: https://gist.github.com/hiredman/05befd5b39eef89b86ca#file-bench-clj-L3-L20

0:50 I'll have to fiddle with it, I am sure there is something that'll work just as well

0:52 puredanger: what's broken?

0:54 hiredman: not that script, but another I have locally throws an exception with 1.7 there, not with 1.6

0:55 puredanger: the classloader name lookup stuff now routes more universally through the DCL if it exists

0:55 hiredman: https://gist.githubusercontent.com/anonymous/08f83e037ffe5ff506f6/raw/d3f7a300e593ceedde4463f4174aea62fb6b751b/gistfile1.txt

0:55 huh

0:56 puredanger: http://dev.clojure.org/jira/browse/CLJ-979

0:56 hiredman: maybe I should update the pomegranate uberjar I use

0:57 puredanger: which version of 1.7 are you using? there was a regression like this in the first version

0:58 http://dev.clojure.org/jira/browse/CLJ-1663 in particulra

0:58 hiredman: lemme check the HEAD of master

0:58 puredanger: that was fixed in alpha6

0:59 hiredman: I dunno, I just have the script using whatever jar is in the target/ of my local clojure checkout

1:00 puredanger: sounds solid :)

1:00 java -cp thatclojure.jar clojure.main -e "*clojure-version*" would tell you I think

1:00 hiredman: this is real бизнес critical stuff

1:00 deleting old dumps of clojurebot's database

3:37 mnngfltg2: Question about cider: suppose I have (+ 4 5) in my buffer and the cursor on the closing parenthesis. If I hit ^C^E in cider, I get 5.

3:37 That seems surprising to me. If I'm in lisp-interaction-mode (elisp), the same thing gives me 9.

4:08 xinau: mnngfltg2: you need to place the cursor behind the parenthesis

4:09 cause it evaluets the last expression before the cursor

4:09 wich would be 5

4:56 vagrant-: i can read a file line by line using doseq, but how do i read only the first 5 lines?

4:56 hyPiRion: vagrant-: loop and recur, for example

4:59 hellofunk: i'm trying to parse some EDN in a Ring handler. what am I missing? http://stackoverflow.com/questions/30209769/unable-to-parse-out-edn-in-this-server-request

4:59 crocket: ㅍㅁㅎㄱ뭇

4:59 おお

4:59 ouch

5:34 mnngfltg2: xinau, yeah that's how it works but it's inconvenient if like me you use evil-mode -- plus it's different to how lisp-mode works

5:42 wasamasa: mnngfltg2: evil actually hacks C-x C-e to behave differently

5:42 mnngfltg2: this hack only works for emacs-lisp-mode though

5:42 mnngfltg2: wasamasa, aha!

5:42 wasamasa: mnngfltg2: so perhaps this explains your observation

5:42 mnngfltg2: that's a good place to start

5:43 * wasamasa has disabled it and pushing the cursor back

5:43 wasamasa: I guess I prefer more consistency, would be nice to be able to control these independently though

5:44 the cursor pushing happens when you're in normal state and point would be after the end of line

5:45 sqd: in the clj repl, is there a way to reload java code with (import), similarly to using (require 'myns :reload)?

5:47 also, is there a way to debug "No matching ctor found for class" errors? i'm calling a constructor (new RRport myapplet), and i'm quite sure myself the myapplet instance is of the right class

5:50 ok, reloading java code seems to require restarting the repl and the java code update fixed the ctor error. still would be nice to be able to reload java code in a running repl

5:58 escherize: Is there a resource for doing regex that grab groups - in clojure?

5:59 ,(use 'clojure.string)

5:59 clojurebot: #error {\n :cause "denied"\n :via\n [{:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]}]\n :trace\n [[clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]\n [clojurebot.sandbox.proxy$java.lang.SecurityManager$Door$f500ea40 checkPropertyAccess nil -1]\n [java.lang.System getProperty ...

6:00 mnngfltg2: escherize, sure, re-matches

6:16 sqd: when i have a MyClass instance in clj, can i add a method to it that java's .getClass().getMethod() will recognise?

6:27 crocket: clj

6:32 ddellacosta: what's the right way to specify a byte array in schema?

6:34 mpenet: (Class/forName "[B") maybe

6:34 or (type (byte-array 0))

6:35 (untested)

6:36 ddellacosta: mpenet: okay, thanks.

6:36 augustl: how would you convert [3 11 8] into [3 14 22] - each item is the sum of itself and the previous number

6:36 ddellacosta: don't love (Class/forName "[B") but seems to work for now

6:40 augustl: here's one way

6:40 &reduce #(conj %1 (+ (or (last %1) 0) %2)) [] [3 11 8])

6:40 lazybot: ⇒ #<core$reduce clojure.core$reduce@7bed0b7a>

6:40 ddellacosta: d'oh

6:40 &(reduce #(conj %1 (+ (or (last %1) 0) %2)) [] [3 11 8])

6:40 lazybot: ⇒ [3 14 22]

6:40 ddellacosta: augustl: ^

6:43 augustl: ddellacosta: ah, nice :)

6:45 &(reduce #(conj %1 (+ (last %1) %2)) [3] [11 8])

6:45 lazybot: ⇒ [3 14 22]

6:45 augustl: with first/rest instead of hardcoding

6:49 ddellacosta: augustl: and then you could do...

6:49 &(defn foo [c] (reduce #(conj %1 (+ (last %1) %2)) [(first c)] (rest c)))

6:49 lazybot: java.lang.SecurityException: You tripped the alarm! def is bad!

6:49 ddellacosta: woops

6:49 well, anyways, you get the idea I think...

6:53 TEttinger: wow I can't believe no one mentioned ##(reductions + [3 11 8])

6:53 lazybot: ⇒ (3 14 22)

6:53 TEttinger: I love reductions

6:55 augustl: how's the reductions answer look?

6:55 ddellacosta: TEttinger: I didn't know about that! Thanks.

6:55 TEttinger: reductions rules!

6:56 ddellacosta: seems clearly superior to the vanilla reduce version, basically encapsulates that semantics itself. Quite cool

6:56 TEttinger: it comes up often enough that you want to reduce to generate a collection, but the existing stuff is a bit clunky until you find reductions

6:56 ddellacosta: right, that's quite cool

6:57 * ddellacosta adds that to his bag of tricks

7:00 TEttinger: if you wanted to specifically add the two most recent numbers, ##(let [coll [3 11 8 5 100 13]] (map + coll (concat [0] coll)))

7:00 lazybot: ⇒ (3 14 19 13 105 113)

7:33 bcn-flor: I would like to add text to the pprinted objects, but clojure.pprint/pprint takes only one argument. Is there a pprint which takes multiple arguments ? eg. (pprint "Temperature is:" x " degrees")

7:35 augustl: TEttinger: ah, nice

7:35 TEttinger: I'm actually using mori, so I don't have it, but nice to know!

7:35 justin_smith: bcn-flor: maybe pr-str instead of pprint?

7:36 if not, there is (with-out-str (pprint x)) wrapped in println

7:36 err, the pr-str would also be wrapped in println

7:37 ,(println "The temperature is" (pr-str {:degrees 44 :scale :ferenheit}) "degrees")

7:37 clojurebot: The temperature is {:degrees 44, :scale :ferenheit} degrees\n

7:37 irctc_: Is there a way to divide factions with a whole component? like (/ 9 1/2 4 2/3 ).

7:38 justin_smith: ,(+ 9 2/3)

7:38 clojurebot: 29/3

7:38 irctc_: Preventing 4 numbers from being read.

7:38 justin_smith: there is no input format that accepts "9 2/3" as a single input

7:41 dysfun: except with the quotes ;)

7:41 justin_smith: haha

7:42 hyPiRion: ,9 2/3

7:42 clojurebot: #<NumberFormatException java.lang.NumberFormatException: Invalid number: 9 2/3>

7:42 hyPiRion: oh well, close enough

7:42 justin_smith: interesting that it wanted 9 2/3 to be one number though, rather than treating it as two numbers input

7:43 that looks like a clojurebot thing only

7:43 hyPiRion: justin_smith: return of the non-breaking space

7:43 justin_smith: d'oh, I should have suspected

7:43 hyPiRion: :p

7:44 timvisher: i'm trying to extend a the clojure.data.json.JSONWriter protocol to java.util.Date. i have it working at the repl but an ns unrelated to the one in which i wrote the extend form is still claiming that it can't write java.util.Date. any clues?

7:45 i sort of have the impression that extending a protocol is something like monkey patching so that if i do it anywhere it's available everywhere within the same vm. no idea how accurate that is.

7:46 (having never done any monkey patching in real life anyway, it seems like an apt comparison :)

7:47 justin_smith: yes, if you extended java.util.Date to implement the clojure.data.json.JSONWriter protocol, it should just work

7:47 hyPiRion: timvisher: have you required the namespace where you extend jsonwriter to date?

7:48 timvisher: hyPiRion: in the ns in which i'm writing?

7:48 or in the jvm

7:48 rather, in the ns in which i'm getting the error

7:48 hyPiRion: timvisher: yes, the ns where your error occurs

7:48 clojurebot: Pardon?

7:49 timvisher: hyPiRion: ah. no i don't believe so. i don't have direct access to that ns, though.

7:49 justin_smith: how could you make it load if you don't have access to it?

7:49 bcn-flor: justin_smith: thank you. is there way to make pprint *not* add a newline character after the printed object ?

7:50 hyPiRion: hm, you have to load it somehow, I think

7:50 timvisher: justin_smith: it's in a dependency

7:50 justin_smith: bcn-flor: you could use subs to take the newline out, but that is about it I think

7:50 timvisher: you can't require code from a dependency?

7:50 timvisher: so my-app → third-party-dep - ns throwing the error

7:51 sorry, i think i'm missing something here :)

7:51 justin_smith: oh, I get it

7:51 timvisher: i'm interpreting what hyPiRion is saying as 'require the ns in which you extend the protocol in the ns that's throwing the error'

7:51 is that incorrect?

7:51 justin_smith: so, make sure to require your extending ns before calling the third party dep

7:51 hyPiRion: timvisher: oh, right. It should be sufficient to have it loaded on the jvm, but I'm not 100% sure on that

7:52 timvisher: ok, that's what i expected to work. i guess my ns isn't being required in the test runners then

7:52 but my assumption was valid, that so long as the extend form makes it through the repl in a particular vm, the protocol is extended for all parties involved

7:52 justin_smith: timvisher: the trick is to require the code because otherwise the file never gets loaded, it's good practice to do it from where the functionality is needed, but as you demonstrate sometimes other things happen

7:53 timvisher: 'it' being extend the protocol?

7:53 justin_smith: right

7:53 timvisher: yes

7:55 justin_smith: timvisher: have you been able to make your json-writing date object work in a repl context?

7:55 hyPiRion: justin_smith: he said so

7:55 justin_smith: hyPiRion: sorry, I missed that part

7:55 timvisher: justin_smith: yes. i developed it interactively at the repl so i know it works from that context :)

7:56 essentially what's happening is that in the repl my extension's working fine but running lein midje it's blowing up

7:56 i haven't tried calling the code that's blowing up from the repl though, that's probably worthwhile.

7:57 justin_smith: or, since you are doing tests, you could directly test generating json from a date, as you did in the repl

7:58 hyPiRion: timvisher: hm, did require the ns extending date in the test ns?

8:00 timvisher: hyPiRion: that was it. :) i had extended the protocol in an ns that wasn't required from the tests

8:00 (inc hyPiRion justin_smith)

8:00 lazybot: ⇒ 1

8:00 timvisher: is that variadic? :)

8:00 justin_smith: (identity hyPirion justin_smith)

8:00 lazybot: hyPirion justin_smith has karma 1.

8:01 timvisher: it should be

8:01 lol

8:01 (inc hyPirion)

8:01 lazybot: ⇒ 74

8:01 timvisher: (inc justin_smith)

8:01 lazybot: ⇒ 253

8:01 timvisher: hahaha

8:01 actually i worked at place that exclusively paired and we had some scripts written around git that would change the author name so you would sit down, change the author name to 'tim and joe' and work

8:02 justin_smith: haha, nice

8:02 tdammers: oh god

8:03 justin_smith: next you need an email server that does set theory, so that you can do union emails to go with the union commiter names

8:03 timvisher: i sort of like that the member 'hyPirion justin_smith' now has one point :)

8:03 tdammers: you should propose adding some "security" to your git server to make sure only authorized people are allowed to commit

8:04 hyPiRion: timvisher: it's sad it isn't commutative =/

8:04 (inc justin_smith hyPiRion)

8:04 lazybot: ⇒ 1

8:04 timvisher: tdammers: oh it gets worse. we also all used the same email address and all pushed to the same central repo without branches

8:04 but hey! it was faster than svn so… :)

8:05 justin_smith: the union email idea would have been brilliant :)

8:05 tdammers: oh boy

8:05 I worked at a place once were e-mail addresses were considered a scarce good

8:06 you could not get a personal e-mail address unless you had worked there for at least a year

8:06 and when you did, it wasn't really personal

8:06 instead, you'd get an address bound to your role

8:06 or rather, named after your role, but bound to you personally

8:07 so we had support@, development@, programming@, it@, and they all belonged to programmers

8:07 hyPiRion: I once had an email address with an apostrophe in it (it's legal according to the spec!), but it bounced so often I didn't bother to keep it

8:07 tdammers: we also had a standing order that under no circumstances was the "trash" folder to be emptied, because that's where you were supposed to keep your "archived" e-mail

8:08 (in a nutshell, boss had a stupid workflow and demanded everyone else also use it, because it worked for him, so it clearly was the perfect workflow)

8:09 justin_smith: hyPiRion: yeah, email validators suck

8:10 timvisher: has anyone else been experiencing an unusual amount of connectivity issues with freenode lately? i get disconnected once or twice a day lately.

8:11 hyPiRion: justin_smith: seen http://ex-parrot.com/~pdw/Mail-RFC822-Address.html ?

8:11 justin_smith: timvisher: I have been disconnected maybe twice since I got a digital ocean server about 6 months ago, I just keep my irc client running inside screen and ssh in

8:12 timvisher: I am more likely to get disconnected randomly by ssh (especially from work), but on irc I stay connected

8:12 months at a time

8:12 timvisher: justin_smith: yeah. i have a permanent tmux session on a server and mosh over to it. what are you using to connect?

8:13 justin_smith: irssi

8:13 "comments in email addresses" - I should have figured this went deeper

8:14 wow, email addresses allow parens (even nested) and they are not counted as part of the address

8:15 how did I not notice this before

8:15 oddcully: emailrepl!

8:15 crocket: Clojure data types are simple.

8:15 Simplicity rules.

8:16 * wasamasa is not sure whether crocket is a bot or human

8:16 hyPiRion: justin_smith: Somebody just had to add it, eh

8:16 justin_smith: crocket: they are one of the best things about the language

8:16 crocket: wasamasa, Humans are clever bots.

8:16 justin_smith: john(this is allowed)@example(this is too).com

8:17 wasamasa: crocket: nope

8:17 hyPiRion: and(so (is this))@example((I do) not (know why)).com

8:17 justin_smith: haha

8:17 Glenjamin: does that become andsoisthis@exampleIdonotknowwhy.com ?

8:17 * justin_smith is off to test sending weird emails to himself.

8:17 hyPiRion: Glenjamin: no, it becomes and@example.com

8:18 justin_smith: Glenjamin: it becomes and@example.com

8:18 Glenjamin: what

8:18 justin_smith: they are comments

8:18 Glenjamin: that's crazy!

8:18 hyPiRion: yes. yes it is.

8:18 mavbozo: woot! space before @ is considered to be part of a valid email address

8:18 justin_smith: hyPiRion: in fixed width, we made our messages line up perfectly

8:18 mavbozo: i check it here: http://sphinx.mythic-beasts.com/~pdw/cgi-bin/emailvalidate

8:19 hyPiRion: justin_smith: great minds align their text

8:19 mavbozo: what a coincidence! today i find out that one of my customer entered 'xxxx @gmail.com'

8:20 i thought that was a invalid email address

8:20 justin_smith: gmail does not allow me to use email addresses with comments

8:20 hyPiRion: Well, comments in emails give you the option to send legal clojure expressions in your address, so there's that.

8:21 justin_smith: best form of communication ever

8:22 mail to: joe(apply str (map char [116 104 101 121 32 97 114 101 32 119 97 116 99 104 105 110 103]))@example.com

8:23 mavbozo: mavbozo(remove-last-email-from-me)@mavbozo.com ;; in case someone accidentally sends unwanted message

8:24 hyPiRion: justin_smith: hah, one should put a quine as a comment

8:24 justin_smith: indeed

8:25 mavbozo: or mavbozo(burn-after-read)@mavbozo.com ;; mission impossible style

8:34 te: I'm doing some wiring together of liberator & swagger compojure-api, is it considered bad form if your using a var value at macro expansion time ? (via var-get) - an macro example here : https://www.refheap.com/101041

8:38 justin_smith: te: resolve already returns a var, why not just deref it?

8:39 in fact, why even explicitly call resolve?

8:40 te: in my usage, resolve is useful when you need to use something at runtime, but it can't be available while compiling

8:40 which is not a constraint here at all

8:40 so I don't really understand what is being gained

8:42 what would break in your macro if (var-get (resolve verbs)) was replaced with verbs

8:46 te: Instead of using a literal list with symbols in my macro like (rest-service [get post] ... ...) i would like it to generate x number of forms based on a def list. but because of ~@ the verb parameter to the macro is not expaned. Another way it is to (eval the output of the macro without the gensym)

8:54 stain: hi, is it possible to get almost all the benefits of (defrecord) (e.g. IMap, toString, etc) while being able to also override toString and hashCode() as you can with deftype?

8:55 I tried using deftype, but I'm overwhelmed with having to implement all of the things you get for free from defrecord

8:55 perhaps there's a shortcut macro or something?

8:56 dnolen: stain: there is no simple way

8:57 Bronsa: ztellman should have a library for that IIRC

8:58 Glenjamin: i can find collection-check, i was sure he had a lib for generating collections too

8:59 Bronsa: maybe something in potemkin.collections but i might be wrong

9:11 te: justin_smith, since I need the values from the def at expansions time to generate X number of forms - it would fail since the verbs is a symbol not a collection eg: https://www.refheap.com/101042

9:11 justin_smith: te: that's what ~ is for

9:12 te: justin_smith, but not along with the splice @

9:12 justin_smith: oh, wait, OK

9:17 n8dawg: Hi All, wondering if i've found a memory leak in loop/recur: heres the simple code to reproduce: http://pastebin.com/e6sznesX

9:25 sm0ke: hey clojurelings

9:25 hyPiRion: n8dawg: with what kind of numbers do you run that with?

9:25 sm0ke: so this new build tool boot doesnt seem to compile java eh?

9:26 hellofunk: can anyone advise what i'm missing in this EDN parsing from a Ring response? http://stackoverflow.com/questions/30209769

9:26 n8dawg: hyPiRon: anything where the cumulative size is bigger than the heap, so say set size = (* 1024 1024) and n = (* 10 1024)

9:26 thats 10GB

9:27 justin_smith: hellofunk: what did you intend to do to r?

9:28 hyPiRion: n8dawg: I did 1000 and 1e8, which failed

9:29 n8dawg: hyPiRon: seems like loop is holding onto the head, is tht expected behaviour?

9:29 justin_smith: n8dawg: how do you know it's doing that?

9:30 hyPiRion: justin_smith: I'm not sure how else it would manage to get out of memory this way though.

9:30 hellofunk: justin_smith: at the moment I am just reading it to see if the EDN stuff has been parsed out

9:32 hyPiRion: n8dawg: yeah, that smells like a bug. https://www.refheap.com/101045 works just fine

9:33 justin_smith: hellofunk: I bet the body has already been consumed, but if not you can get it with slurp

9:34 hellofunk: I really don't know how wrap-edn-params and a put request would combine properly though

9:34 maybe I just need coffee

9:34 sm0ke: justin_smith: if it had been consumed he would have got a cannot reset seek error

9:35 justin_smith: sm0ke: when?

9:35 sm0ke: hellofunk: do you think the edn is proper and parsable?

9:35 hyPiRion: n8dawg: yep, the macroexpansion expands outside of the loop. I think this has been discussed earlier though, but I can't find any jira ticket for it right now

9:36 sm0ke: justin_smith: if the body had been consumed previously

9:37 hellofunk: sm0ke: it is being sent using cljs-ajax which automatically formats into EDN

9:37 justin_smith: I mean previously to what

9:38 sm0ke: so he has two middlewares, but the content type is end so wrap-params will not slurp the body

9:38 hyPiRion: woah, that's a really stupid expansion

9:38 sm0ke: edn*

9:38 it is most probably being consumed by wrap-edn-params only

9:39 hellofunk: could you check the request instead?

9:40 i think if the middleware is sane it should add a param to req map like :edn-params

9:40 stain: Glenjamin: thanks -- I found https://github.com/ztellman/potemkin which might or might not help me :)

9:40 sm0ke: ah there indeed is a :edn-params but it is nil

9:41 hellofunk: what is the edn?

9:43 what ever it is, it is being parsed to nil, if you have some custom edn you probably better of writing you own middleware

9:45 weird it seems to just do a `read-string` and merge with existing params https://github.com/tailrecursion/ring-edn/blob/master/src/ring/middleware/edn.clj#L26

9:45 so anything should work

9:45 i mean given its a map

9:45 hellofunk: sm0ke: {:a 1 :b 2} as a test

9:45 sm0ke: no way

9:45 that should work

9:46 hellofunk: could you remove the wrap-param middleware, just to be sure

9:50 justin_smith: wait, is the body of a put even considered a location for params?

9:51 I'd consider it to be a document

9:51 sm0ke: ?

9:51 justin_smith: it's a put request

9:51 sm0ke: dont be old fashioned

9:51 i have seen people do -d '' in a GET

9:52 justin_smith: sm0ke: OK, I'm just thinking of reasons this would be failing

9:52 not being prescriptive

9:52 IOW see if changing it to post changes anything

9:52 sm0ke: afaict there is no racism in this code https://github.com/tailrecursion/ring-edn/blob/master/src/ring/middleware/edn.clj

9:52 based on type of request

9:54 hellofunk: sm0ke: let me try that, one moment

9:54 sm0ke: to be honest i dont think that will make one bit difference

9:55 as wrap-params looks for content-type before slurping

9:55 just getting hellofunk 's hope high here

9:56 hellofunk: could you do yourself a favour an try with a curl request instead please?

9:56 curl -X PUT -H "Content-Type: application/edn" -d '{:name :barnabas}' http://localhost:8080/whatever

9:56 hellofunk: sm0ke: so removing wrap-params made no difference. i'll try curl next. but looking at the nrepl output from println on a server has always worked.

9:57 sm0ke: http://localhost:6542/ajax-example in your case

9:58 hellofunk: sm0ke: I assume my :body in the response will just be my full request as (str r) ?

9:58 sm0ke: first, what you are printing is not response but resuest

9:59 puredanger: Clojure 1.7.0-beta3 is now available https://groups.google.com/d/msg/clojure/bCmETw2F1jY/OQfrQH_39zoJ

9:59 wasamasa: yay

9:59 sm0ke: request*

9:59 ddellacosta: omg was just wondering about the status of 1.7

9:59 * wasamasa wonders what version clojure will have once project jigsaw has been completed

9:59 hellofunk: sm0ke: i meant, right now in the SO code snippet, I am not returning anythign that would be useful in a curl response

9:59 * ddellacosta bows thankfully to puredanger

9:59 n8dawg: hyPiRion: good catch its the macroexpansion, using loop* doesn't seem to exhibit issue

9:59 sm0ke: hellofunk: does not matter

10:00 puredanger: nice work! +1

10:00 hellofunk: sm0ke: well, the curl reponse looks identical to the nrepl println

10:00 sm0ke: hellofunk: dont care about response, see the server log

10:00 hellofunk: is there a :edn-params there?

10:02 also i dont really like that PUT definition , looks weird, its amazing how may type of dsl in there for route definitons

10:02 i am always confused to see someones route defintions

10:02 hellofunk: sm0ke: the nrepl response is the same with curl.

10:03 sm0ke: PUT vs POST should make no difference in this

10:03 sm0ke: hellofunk: so :edn-params is nil?

10:03 hellofunk: sm0ke: yes

10:03 sm0ke: I give up

10:05 hellofunk: sm0ke: thanks all the same. when/if i figure out what the issue is, i'll update the SO question in case you are curious

10:05 sm0ke: hellofunk: thanks bookmarked

10:07 tdammers: well, fwiw, route semantics tend to differ quite a bit between websites/applications

10:07 makes sense to have different ways of specifying them

10:07 sqd: does anyone have experience running clojure on an intel edison? i wonder about the performance. doing some serial, ble and http communication and simple number processing

10:07 maybe also sound

10:26 luxbock: Bronsa: using clojure.tools.analyzer.jvm/analyze-ns, for a :binding node, is it somehow possible to retrieve the non-macroexpanded forms for the value of the binding?

11:19 hellofunk: sm0ke: justin_smith: the interesting development in this saga is a (slurp (:body r)) is empty, despite that the content-length is correct for the passed-in map

11:25 justin_smith: hellofunk: the body has a type that only can get read once

11:25 it's stateful

11:26 I thought it would error, but not super-surprised if it would give nil

11:27 ,(require '[clojure.java.io :as io])

11:27 clojurebot: nil

11:27 justin_smith: ,(def i (io/reader (.getBytes "hi")))

11:27 clojurebot: #'sandbox/i

11:27 justin_smith: ,(slurp i)

11:27 clojurebot: "hi"

11:27 justin_smith: ,(slurp i)

11:27 clojurebot: #error {\n :cause "Stream closed"\n :via\n [{:type java.io.IOException\n :message "Stream closed"\n :at [java.io.BufferedReader ensureOpen "BufferedReader.java" 115]}]\n :trace\n [[java.io.BufferedReader ensureOpen "BufferedReader.java" 115]\n [java.io.BufferedReader read "BufferedReader.java" 172]\n [clojure.core$slurp doInvoke "core.clj" 6650]\n [clojure.lang.RestFn invoke "RestFn.java" 4...

11:27 justin_smith: that's what I expect...

11:28 hellofunk: justin_smith: does that mean that the middleware is reading it therefore it is empty when i println it?

11:28 justin_smith: that's what I would expect

11:29 in my experience the body is already read by the time it hits my handler

11:30 hellofunk: justin_smith: but I took out the middleware completely and the body is still empty, despite a valid content-length that is not otherwise reflected by anything else in the request map. the content is clearly in there somewhere.

11:33 clojer: Submitting a form in my Luminus app produces this error: {"type":"unknown-exception","class":"java.lang.IllegalArgumentException"}

11:33 Is there any way of getting more detail?

11:37 justin_smith: there was no stack trace printed?

11:39 clojer: justin_smith: Yes, but only "java.lang.IllegalArgumentException: Key must be integer" seems relevant

11:40 justin_smith: Could do with at least a relevant file and line number

11:40 justin_smith: well, the stack trace should have lots of files and line numbers

11:40 sqd: is there a transducer i can apply to seqs so that (nth my-transduced-seq n) is the average of (take n my-seq)?

11:41 clojer: justin_smith: Yes but it all seems to point to core.clj and various middleware files.

11:41 sqd: (i'm actually using an async chan, but this may be easier to explain)

11:42 justin_smith: clojer: it should at least tell you which code of yours last touched the data before it went into clojure.core etc.

11:43 if you read closely

11:46 clojer: justin_smith: Just copied the stacktrace into Vim then grep -v 'ed anything containing "core.clj", "org.eclipse" and "middleware". What's left doesn't refer to anything I've edited.

11:54 justin_smith: clojer: at the very least you should see the namespace that defined the handler or launched the server

12:22 hellofunk: can anyone summarize like i'm in 5th grade the difference between transit and EDN and which to use when?

12:23 puredanger: edn is for people

12:23 transit is for machines

12:23 transit over json is best for browser to backend

12:23 both have extensible type systems

12:24 hellofunk: if using it for ajax, which would be a better format to pass between?

12:24 puredanger: transit has much better performance due to 1) leveraging high-perf json (or messagepack) parsers and 2) caching of values in the stream

12:24 I'd use transit over json

12:25 it has a "verbose" mode you can use for debugging so you can get the human-readable aspect if you need it

12:25 hellofunk: i see

12:25 puredanger: more: https://groups.google.com/d/msg/clojure/9ESqyT6G5nU/2Ne9X6JBUh8J

12:25 hellofunk: cool thanks

12:28 bensu: in a ns declaration, should the order of the :import and :require clauses matter?

12:29 * justin_smith ported component to cljc, it's working so far...

12:29 justin_smith: bensu: it shouldn't, it becomes a hash-map iirc.

12:30 bensu: justin_smith: thanks, I'll investigate further then.

12:30 justin_smith: the idiom is to put :require before :import though

12:31 puredanger: it does not matter

12:32 mdrogalis: justin_smith: That's great news. :)

12:34 bensu: puredanger justin_smith: thanks

12:57 justin_smith: mdrogalis: I don't have the tests running (need to figure out how to integrate it with cljs.test) but the actual functionality is there so far. Should be on my github soon.

13:06 bensu: justin_smith: if there are no async tests, adding cljs.test should be as simple as requiring it with #?

13:09 justin_smith: bensu: cljs.test is there, but it acts like the deftest forms never got run

13:09 it's weird

13:09 probably some error on my end

13:12 steffan42: (println (read-line)) in an emacs cider repl fails to print this input - it accepts a stdin from the minibuffer but hangs after pressing return. I have to kill the process.

13:14 Calling (read-line) a second time then prints the previous input. Ideas?

13:15 justin_smith: sounds like a bug in cider

13:15 steffan42: okay thanks

13:16 noncom: in cursive, how do i make it so that pressing "(" encloses the selected terms in () instead of replacing them with a "(" ?

13:20 puredanger: I think on mac, cmd-shift-( does that

13:21 actually I guess that just encloses the next form

13:21 not the selected

13:21 noncom: puredanger: hmm, i am on win...

13:22 there is Wrap in () in Structural Editing, i have assigned Shift+9 to it, to no avail...

13:22 simply does not work

13:22 puredanger: well mash down some different modifiers then :)

13:22 noncom: ah, it works as you said - encloses the next form instad of enclosing the selection

13:23 (that's different from how it works in ccw eclipse)

13:23 puredanger: I usually just make empty and slurp forms :)

13:23 noncom: what is your hotkey for slurping?

13:24 will assign the same.. already got some headache on figuring out good hotkeys with cursive :)

13:24 puredanger: I use Cmd-Shift-K

13:24 but I think I just grabbed one of the sets that comes with Cursive to get that

13:25 yeah, I use the "Mac OS X 10.5+" settings + various tweaks

13:25 noncom: no, nothing comes with cursive... they say "figure it out for yourself" in the getting started..

13:25 hmm.. somehow your setup was different...

13:26 ah, i have the config you say

13:26 puredanger: no that changed a while ago - it comes with mulitple binding sets now

13:26 noncom: the mac 10.5+

13:26 puredanger: under (in IJ 14) Other Settings -> Clojure -> Keybindings there is a "binding set" control

13:26 to install a whole set

13:27 noncom: gmmm (println "\n\nCORE: execute with args " args "\n\n")

13:27 oooops

13:27 http://joxi.ru/VrwoVvYsRGKMrX - this one

13:28 i just don't have it :)

13:28 puredanger: don't have the set or don't have the control?

13:28 noncom: don't have the sets you mention. i have them, but in the general Settings -> Keymap thing

13:28 well, maybe i'll go with Emacs se tthen...

13:29 or Cursive..

13:29 puredanger: the Cursive one is basically the same as what I have

13:29 noncom: alright, so i'll set this one too. had enough of this already on the few days trying to get accustomed to cursive :)

13:31 whoooa! so much fun! now it maps half of the things to Meta + something, and it just does not work on win

13:31 alt is not meta...

13:31 puredanger: well I can't help you there :)

13:32 noncom: yeah... btw, the whole mapping did not apply anyway.. it is reset back to NONE when i go back to the keybindings..

13:32 ahh, no problem... it's just software :)

13:34 puredanger: maybe ping cfleming for that

13:41 noncom: oh, he is very budy right now.. i have already loaded him with lots of questions ))

13:42 *busy

13:44 fourq: Where in the docs will I find info about the caret symbol?

13:44 Evaluations?

13:45 TimMc: fourq: Check out http://clojure.org/reader (Macro characters)

13:45 fourq: ty

13:45 ToxicFrog: fourq: I generally look at "the reader" first

13:45 fourq: gtk

13:45 ToxicFrog: And indeed going there and looking for ^ will take you straight to the section on metadata

13:48 dfletcher: is there something with a similar api as get-in but to set a value? like, set it and return me a new nested map with the changed value? similar to procedural languages when you do a['foo']['bar'] = 'baz'; except more clojure-ish.

13:48 Glenjamin: (doc assoc-in)

13:48 dfletcher: ty

13:48 clojurebot: "([m [k & ks] v]); Associates a value in a nested associative structure, where ks is a sequence of keys and v is the new value and returns a new nested structure. If any levels do not exist, hash-maps will be created."

13:48 dfletcher: I guessed "set-in" hehe

13:49 TimMc: dfletcher: There's also update-in which is more general.

14:08 hellofun`: justin_smith: http://stackoverflow.com/questions/30209769/unable-to-parse-out-edn-in-this-server-request/30222274#30222274

14:14 sqd: jvisualvm tells me fmp.web$app$fn__11124$state_machine__8430__auto____11125$fn__11127.invoke () seems to be causing trouble. does that mean that the clojure.core.async/go state machine defined in fmp.web/app is the culprit or could it be a state machine elsewhere?

14:25 OscarZ: is there some function etc. for this: evaluate something and if its truthy, then it will be the value, otherwise null ?

14:30 arohner: OscarZ: that sounds like 'if to me

14:30 or 'when

14:30 justin_smith: hellofun`: weird

14:31 hellofun`: maybe it's because wrap-edn-params is destructive

14:31 amalloy: OscarZ: so that function would be (fn [x] (when x x))

14:32 justin_smith: hellofun`: so in order to route, it passes in the request, the body is consumed by wrap-edn-params

14:32 hellofun`: by the time you do this again, there is no longer a body to consume

14:32 OscarZ: ok, but wouldnt that evaluate it twice ? i would like to avoid that if possible

14:32 hellofun`: justin_smith: seems totally against the functional paradigm encouraged by Ring

14:32 amalloy: OscarZ: alternatively, it is just like identity, except it replaces false with nil. do you really need to tell false and nil apart?

14:32 no, of course not

14:32 justin_smith: hellofun`: which tells me that you should combine all param manipulation into one middleware, that wraps all routes that need the params

14:33 amalloy: function arguments are evaluated when they're passed into the function

14:33 hellofun`: justin_smith: yeah that's how I fixed it, but I'd have never thought this was the problem in a functional routing library like Ring, last thing I'd expect

14:33 OscarZ: amalloy, oh yes that works of course..

14:34 amalloy: (fn [x] ({false nil) x x)) is another silly way to write it

14:34 or, no, i guess that doesn't work. has to be (fn [x] ({false nil nil nil} x x))

14:34 justin_smith: hellofun`: I guess you could fork wrap-params, wrap-edn-params etc. with a version that creates a synthetic body after consuming the original (see for example what my groundhog lib does to recreate request bodies)

14:36 OscarZ: amalloy, whats going on there :D

14:36 amalloy: OscarZ: well remember that all your function does is replace false with nil

14:36 mikerod: This is interesting

14:36 https://github.com/clojure/clojure/commits/04c59e81c4f16bfcaef2fdfd3f5bc5d887445045/src/jvm/Reader.g

14:36 first cut at ANTLR-based Reader

14:36 so this was tried earlier on

14:36 amalloy: so you look x up in a map, which just maps nil and false both to nil, and then if it's not there you return x instead

14:38 OscarZ: i see.. i didnt remember map can be used like that :)

14:38 could i write a macro to make that more clean ?

14:40 amalloy: OscarZ: you could write a macro to make it less clean

14:40 OscarZ: hehe ... i mean this one: (fn [x] (when x x)) ...

14:40 function will do i guess

14:40 amalloy: it's just a function. defn it to be a function

14:40 mikerod: I read somewhere that as of clj 1.7 Symbols are no longer intern'ed. Is there a Jira related to this? Also, I never thought they were intern'ed in the first place? The Strings they refer to were interned.

14:40 puredanger: that's more accurate

14:41 I think I may have been sloppy in the beta3 email re that

14:41 mikerod: This is relation to https://groups.google.com/forum/#!topic/clojure-dev/58fYUSIEfxg

14:41 puredanger: ok, that's fine. It just got me thinking about it more, since it differed from what I thought.

14:42 puredanger: keywords are cached though, as always

14:43 we found that String.intern() was a performance bottleneck in symbol/keyword creation

14:45 I think with the string de-duplication they're adding to the jvm, we'll get some of that memory tradeoff back too

14:47 mikerod: puredanger: yeah, I read some about the keyword performance in some thread at one point a bit back. I know keywords need to be cached/singleton/comparable by ==, but symbols never had that contract.

14:49 puredanger: no

15:29 bensu: puredanger: beta3 worked fine

15:29 puredanger: cool :)

15:30 bensu: puredanger: how many releases until it's called stable?

15:31 puredanger: I think we're pretty much done, hope to do an RC soon

15:33 bensu: puredanger: great! it really has been a seamless transition. thanks

15:51 fourq: when using :refer from a ns require it's "referring" to only those macros opposed to including the entire ns correct? https://gist.github.com/fourq/ac139f1cadc8ade5b807#file-core-cljs-L4

15:52 or functions not macros I thinkg

15:52 think*

15:54 arohner: fourq: it means you can use those fns / macros in the current ns without a qualifier

15:54 i.e. (put! ...) rather than (cljs.core.async/put! ...)

15:54 fourq: ok, thanks arohner

15:54 arohner: and correct, it doesn't affect other fns in core.async

15:54 fourq: and :refer opposed to :as?

15:54 as is singlular?

15:56 arohner: :as is shorthand for every fn in that namespace

15:56 (:require [cljs.core.async :as a])

15:56 (a/put! ...)

15:57 fourq: ahh, ty again

15:57 arohner: :as only affects macros in very new versions of CLJS

15:58 fourq: I'm still struggling with the difference between a macro and a function tbh

15:59 but then again all I had to do was search: https://newcome.wordpress.com/2012/02/12/functions-vs-macros-in-clojure/

16:11 cfleming: noncom: https://cursiveclojure.com/userguide/paredit.html: "Settings→Editor→Smart Keys→Surround selection on typing quote or brace. If this option is selected, opening a balanced form will wrap the selection"

16:13 noncom: I replied to your mail, haven't heard back - did you get it?

16:20 brainproxy: I have a deftype with a field that is an Integer, and I'm getting warnings from case in a method on that type about it not being primitive

16:20 I can get rid of the warning by running case against (int myfield)

16:21 but is there another way?

16:30 justin_smith: "there has to be a better way!" (cue infomercial for haskell)

16:31 melipone: hello! I have a namespace question. I want to modify just a few functions in a namespace, call it A, and "inherit" all the other from another namespace, call it B. Ok, I know about :require and :use. Now, I have another namespace, call it C, from which I want to call functions from A and B without knowing which one is which. How can I do that? I tried to :require A but C does not know about B. Only A does.

16:33 justin_smith: melipone: require / use are never transitive

16:33 in a given namespace, you only have those things you explicitly map to that namespace

16:33 (plus some core defaults)

16:33 melipone: justin_smith: So, I can't do what I want to do?

16:34 justin_smith: namespace "inheritance" isn't a thing, so I think you can't, no

16:34 I mean you can patch together something that acts like that of course, but I think it would be a hack (see vinyasa)

16:34 melipone: justin_smith: jeez... I can't remember how I used to do that in Lisp

16:35 justin_smith: https://github.com/zcaudate/vinyasa

16:35 melipone: justin_smith: ok, thanks, I'll look at vinyasa

17:02 arohner: is there an idiomatic (i..e built-in) way to convert an int from 0-255 to a byte?

17:02 I'm dealing with java.io.InputStream and NIO, and InputStream helpfully returns int "bytes", and NIO needs 'real' bytes

17:03 (byte (- x 128)) isn't too bad

17:04 hrm, that's wrong

17:05 also, InputStream.read() returning ints rather than bytes is idiotic

17:07 TimMc: arohner: How would you have it signal end of stream?

17:07 arohner: TimMc: nil?

17:08 TimMc: I'm just really annoyed by the interplay between APIs that use bytes and APIs that use ints masquerading as bytes

17:08 also really annoyed by signed bytes

17:22 TimMc: arohner: nil would mean giving up primitives

17:24 arohner: TimMc: if you really care about performance, you shouldn't be casting byte->int and back. At that point, just go to full NIO land, and only operate on byte-arrays

17:28 bostonaholic: I'm creating a new clojure newsletter. Email me at subscribe@clojurelive.com for the latest news and tips on Clojure, ClojureScript, and Datomic.

18:52 ztellman: arohner: (bit-and n 0xFF)

18:54 arohner: ztellman: I'm going the other way, so I'm using (byte (+ (- (bit-and 0x80 i)) (bit-and 0x7f i)))

18:54 ztellman: oh, sorry

18:54 arohner: ztellman: I knew how to do it "by hand", I'm just grumpy that path isn't smoother :-)

18:55 ztellman: arohner: hmm, I had to look up how I did it in primitive-math, but this is simpler: https://github.com/ztellman/primitive-math/blob/master/src/primitive_math.clj#L227

18:56 ,(byte 0xFF)

18:56 clojurebot: #error {\n :cause "Value out of range for byte: 255"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Value out of range for byte: 255"\n :at [clojure.lang.RT byteCast "RT.java" 1095]}]\n :trace\n [[clojure.lang.RT byteCast "RT.java" 1095]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Compiler eval "Compiler.java" 6792]\n [clojure.lang.Compiler eval "Compiler.j...

18:56 amalloy: ztellman: unchecked-byte ?

18:56 ztellman: ,(unchecked-byte 0xFF)

18:56 clojurebot: -1

18:56 ztellman: ok

18:57 oh, right, I wasn't using clojure.core/byte, I was using primitive-math/byte

18:57 so yeah, that works

18:57 arohner: amalloy: aha! thanks

19:13 cfleming: I'm trying to reproduce the Compiler's method disambiguation (getMatchingParams) in Cursive

19:14 I'm struggling to come up with a test case that triggers the subsumes() checks - can anyone suggest one?

19:15 hiredman: is that what does the widening from int to long?

19:15 cfleming: It seems to be for disambiguating similar param lists, but I'm not clear exactly what it's doing

19:16 amalloy: hiredman: it looks that way

19:16 hiredman: (and similar such things?)

19:16 amalloy: cfleming: try class Foo {public void f(int x) {...} public void f(long x) {...}}

19:16 cfleming: I think it's more for boxing

19:17 if (!c1.isPrimitive && c2.isPrimitive || c2.isAssignableFrom(c1))

19:18 amalloy: cfleming: f(Integer x), f(long x)? or the other way around possibly, int/Long

19:19 cfleming: amalloy: I've tried that, the trick is I think have to invoke it passing short, or similar. That takes one of the code paths, but I can't provoke the other - I'll play around with it.

19:19 amalloy: Yeah, I think it's to do with matching boxing/unboxing rather than type width

19:21 hiredman: actually, it appears to be primarily related to the inheritence hierarchy

19:24 the docs for the isAssignableFrom method reference 5.1.4 of the jls (but I think they mean 5.1.5, since it mentions widening ref conversions) https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.1.5

19:26 Bronsa: cfleming: it should be for cases where you have like foo(Object, Number), foo(Object, Long) and you're invoking (.foo x bar ^Number baz)

19:26 or uhm probably (.foo x bar 1)

19:27 cfleming: Bronsa: Ok, so it's for disambiguating between boxed number types? I think it must be because I can't provoke it with primitives

19:28 Bronsa: cfleming: no, not just number types, as hiredman said it has to do with inheritance hierarchy

19:29 hiredman: well, subsumes does contain the not primitive check on one of the classes, which I forgot about

19:30 cfleming: Bronsa: Ok, got it. So this is between Object types when one derives the other, and it's trying to match the lowest point in the hierarchy?

19:30 hiredman: Yeah, there's some primitive/Object check in there too

19:30 hiredman: Which I don't understand

19:30 hiredman: so subsumes does appear to be trying to match primitive and reference types

19:30 Bronsa: hiredman: that's for nil argtypes

19:31 hiredman: huh

19:31 Bronsa: say you have foo(int x) and foo(Integer b), (fn [a] (.foo x a)) cannot match foo(int x)

19:32 I'm going from memory here, might be something slightly different a

19:33 there are a lot of weird edge cases and inconsistencies in the method matching stuff scattered between Compiler.java and Reflector.java

19:34 cfleming: Bronsa: Tell me about it. I'm trying to come up with some test cases for the original code so that I can then test them against the code I've migrated to IntelliJ's test system, but it's proving difficult

19:34 Bronsa: Suggestions for edge cases very welcome :-)

19:36 I'm actually considering just exhaustively testing them and comparing the results, but it's difficult because it depends on the methods available in the class you're testing.

19:36 Bronsa: cfleming: I still haven't gotten it right for tools.analyzer.

19:36 cfleming: Although I could just generate arg/param types randomly and test those I guess.

19:37 Bronsa: Do you have test cases there I can look at?

19:38 Bronsa: cfleming: no, sorry. lots of experiments at the repl but I never got to write them down

19:38 cfleming: Bronsa: Ok, no worries. The more I think about it the more I think that just generating test cases is probably the best way to go.

19:40 Bronsa: Fortunately I just copied the code and ported it to IntelliJ's type system which has a fairly similar interface, so fingers crossed I get the edge cases right by default

19:44 fourq: Could someone help explain how this anon func is working in this case? https://gist.github.com/fourq/b739a45c817f3292b63c#file-cljs-clj-L6 I don't understand what is going to replace the %

19:45 ztellman: fourq: presumably the existing list of contacts?

19:46 fourq: ztellman I'm not sure. I'm following a tutorial from https://github.com/omcljs/om/wiki/Basic-Tutorial#dealing-with-text-input-fields

19:46 scroll down about 4 setions

19:46 I don't understand the syntax, and I've read the #() docs too.

19:47 ztellman: fourq: that's equivalent to (fn [contacts] (conj contacts new-contact))

19:47 does that make sense?

19:48 fourq: not really, where is "contacts" coming from?

19:49 ztellman: fourq: I haven't used Om, but I presume "data" is a map that has a :contacts key

19:49 and transact! is updating that particular key

19:50 fourq: yeah data is a map and :contacts is a key, but I don't understand how that makes its way into the following form and replaces %

19:51 ztellman: ,(update {:contacts ["abc"]} :contacts #(conj % "def"))

19:51 clojurebot: {:contacts ["abc" "def"]}

19:51 ztellman: this takes an input, and then applies the function to a particular sub-field, and returns a modified version of the map

19:51 transact! (again, I assume) is doing the same, but then updating an internal atom

19:52 does the update example make sense?

19:52 fourq: thanks ztellman. i'm going to process this a bit more.

19:52 ztellman: np, these are all very reasonable questions

19:54 fourq: ztellman ahh. I see it now. I went to the transact! doc "(transact! cursor :text (fn [_] "Changed this!"))"

19:54 the last part you mentioned makes this make sense

19:58 cfleming: Bronsa: I should be able to exhaustively test all cases using single-element arglists, right? I can't see any interactions between parameters there.

20:00 Bronsa: cfleming: I seem to recall differences between i.e. foo(Number) foo(Long) and foo(Object, Number) foo(Object, Long) actually.

20:01 cfleming: Bronsa: Ugh. I'll see how many cases I'm looking at for one or two element arglists then.

20:01 Bronsa: or, something else. but there was definitely some strange behaviour I tried to fix (and failed) that had to do with multi-element arglist

20:26 irctc__: Test

20:27 Awesome. Large Clojure community.

20:28 tahmid: Yep

20:30 brainproxy: justin_smith: no, it was a serious question (re: case,int); I just wasn't sure whether there was a proper way to hint the expression

20:31 doing (case (int x) ...) seems to be the least expensive of various options I tried, so I can live with that of course

20:32 progrocker: got a rather simple conversion of a sequence

20:32 https://gist.github.com/anonymous/38f6f285a97be27fd381

20:32 unsure how to proceed

20:33 i know i could build a list up in a loop but that feels wrong

20:36 amalloy: ,(doc mapcat) ; progrocker

20:36 clojurebot: "([f] [f & colls]); Returns the result of applying concat to the result of applying map to f and colls. Thus function f should return a collection. Returns a transducer when no collections are provided"

20:37 progrocker: amalloy: oh, i was actually looking at mapcat but was unsure

20:37 thanks

20:39 amalloy: here you want something like (mapcat (partial drop-while #{:pair}) xs)

20:39 '(mapcat (partial drop-while #{:pair}) '([:n] [:pair [:number 1] [:number 1]] [:n] [:pair [:number 2] [:number 2]] [:n]) )

20:39 ,(mapcat (partial drop-while #{:pair}) '([:n] [:pair [:number 1] [:number 1]] [:n] [:pair [:number 2] [:number 2]] [:n]) )

20:40 clojurebot: (:n [:number 1] [:number 1] :n [:number 2] ...)

20:40 amalloy: oh, but you wanted to keep the :n in a vector. well, it's more work then but you can write the mapper function

20:41 progrocker: thanks again

20:43 timvisher: is anyone aware of a way to do static initalization in clojure?

20:43 like java static blocks?

20:43 http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.7

20:46 amalloy: timvisher: you want to produce the same bytecode as a static initializer in java, or you want to do something like static initialization but for clojure objects?

20:47 timvisher: amalloy: hmm... asking for a friend. sec. :)

20:48 amalloy: my guess would be, you don't need anything like static initialization, because it solves a problem that doesn't really exist

20:49 timvisher: amalloy: i'm not even sure i fully understand your question. the idea is that he wants to have code that is run at classloader time which is compatible with aot

20:49 does that mean producing the same byte code?

20:49 amalloy: why do you want code run at class load time? it is not a very good time to run code

20:50 timvisher: so the other option he's aware of is to provide an `init` function that consumers of his library just know to call

20:50 amalloy: hm. aside from the "very", that message was all monosyllabic. not trying hard enough

20:50 timvisher: for instance: `(defonce hostname (.getHostName (java.net.InetAddress/getLocalHost)))`

20:51 amalloy: timvisher: (def hostname (delay (.getHostName ...))) (defn get-host-name [] @hostname)

20:51 timvisher: so if you aot that iiuhc the localhost address is set at compile time? that wouldn't make any sense.

20:51 amalloy: interesting. :)

20:52 amalloy: but try not to do too much of this, because the set of things that you really only want exactly one of is pretty small. remember this is basically a singleton, which is a wall-known causer of problems

20:53 timvisher: yeah. my friend is not being very responsive and i definitely don't understand his goal well enough :)

20:53 amalloy: in general i put pretty much everything behind a function call. i haven't run into almost anything that the performance hit of just looking it up every time is really an issue.

20:53 and if it is an issue, i find it by profiling and _then_ get it defined only once :)

20:54 although i do defonce my nrepl and http servers...

21:11 sobel: timvisher: when i'm helping people i make them be clear on the problem. often enough they needed support on the problem domain more than the implementation domain.

21:11 timvisher: sobel: indeed :)

21:11 sobel: and more importantly, saves me getting too far down the road of assumptions while also making me appear wise

21:12 ...which i understand is a Lisp family value

21:13 timvisher: so, short of more context, is the answer basically that clojure has no `(static ...)` form that does what a stic block would do in java?

21:14 sobel: it solves a problem clojure does not pose

21:14 at last, based on information available

21:17 timvisher: got it :)

21:18 cfleming: timvisher: Right, there's no way to do that. I generally just create a Java class and put the items I want in there, and then access it from Clojure that way. However I generally want to be initialising things that are easily available from Java, which may not be your case.

21:19 timvisher: cfleming: yeah. it seems like he has some very complex things he's trying to do which don't lend themselves directly to memoization. i have no idea though what it actually is. he doesn't want to write a java class which will call back into his clojure code just to get static blocks. :)

21:19 do midje map checkers support a get-in style?

21:19 cfleming: timvisher: Sadly he's out of luck

21:20 timvisher: i.e. `=> (contains {:a {:b}}}`

21:25 ah. looks like you can nest the contains... `(fact "asthaeu" {:a {:b :c :d :c}} => (contains {:a (contains {:b identity})}))`

21:46 jumblemuddle: Anyone have thoughts on a new clojure user wanting to get into web game development in clojurescript? I've looked into chocolatier (a library ontop of pixi.js), but I couldn't quite get my head around the figwheel repl workflow.

23:37 justin_smith: having figwheel set up ends up making things much smoother, once it is there

Logging service provided by n01se.net