#clojure log - May 06 2012

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

0:00 Bretzky: I guess clojure.pprint doesn't belong in dependencies because it's int he core?

0:00 Frozenlock: But to give you an idea: I currently use lein 1.5.2 and clojure 1.3 in my projects without any problems

0:01 Yup. Since 1.2 if the source is right

0:01 Bretzky: well, now I feel like an idiot

0:01 clojurebot: No entiendo

0:02 Bretzky: glad to have that sorted out though

0:27 Frozenlock: I'll write the solution to my problem here for future logging reference: class org.codehaus.jackson.smile.SmileParser overrides final method getBinaryValue.(Lorg/codehaus/jackson/Base64Variant;)[B

0:27 [Thrown class java.lang.VerifyError] was because (I think) Noir uses clj-json. Both Cheshire and clj-json use Jackson. The solution is to simply use clj-json instead of Cheshire. See: https://github.com/dakrone/clj-http/issues/41

0:35 robertstuttaford: what's the way to convert a json string to clojure forms?

0:38 gf3: Chesire?

0:39 technomancy: cheshire.

0:39 robertstuttaford: superduper, thank you

0:39 gf3: Sp, sorry

0:41 Frozenlock: Weeeeee, fun with bitcoins (json/parse-string (slurp "http://blockchain.info/rawaddr/1P8uWY8w3Y6nVWM1FYjC3z2Phmzgpi12vd")

0:47 zakwilson: Slurp takes URLs?

0:47 technomancy: zakwilson: added in 1.2 IIRC

0:49 zakwilson: How did I not know this? I'm sure this would have saved me some time at some point.

0:52 technomancy: did someone port -> to elisp, or was it just the destructuring stuff?

0:54 fhd: It seems to me that "(require '[namespace :as ns]) (ns/foo)" is usually preferred over "(use '[namespace :only (foo)]) (foo)", does anyone have some reasoning for this?

0:55 Frozenlock: fhd: I prefer it because I can instantly know form where is the function.

0:56 fhd: Frozenlock: True, but if you use :only, it's just a search away.

0:58 Frozenlock: So near, yet so far at the same time.

0:59 There's also the possible name conflict if your `use' a lot of stuff.

1:03 Raynes: fhd: I don't think anyone minds :use (or the new require in 1.4) with :only (:refer in 1.4's require).

1:03 leo2007: technomancy: this patch https://gist.github.com/2614567 from the autodoc branch will stop clojure to drop connection to swank when slime-autodoc is accidentally called.

1:03 Frozenlock: Awww I'm just getting used to 1.3

1:05 zakwilson: I still have a project that's on 1.2.

1:05 Raynes: ibdknox: You around?

1:05 zakwilson: This is why we can't have nice things.

1:08 zakwilson: Raynes: well, it was using ClojureQL which didn't support 1.3, and I haven't finished moving over to korma.

1:15 muhoo: is this really the only way to turn a map into a sorted map? ##(apply sorted-map (flatten (seq {3 "foo" 2 "bar" 1 "baz"}))

1:16 &(apply sorted-map (flatten (seq {3 "foo" 2 "bar" 1 "baz"})))

1:16 lazybot: ⇒ {1 "baz", 2 "bar", 3 "foo"}

1:18 alandipert: &(into (sorted-map) {2 :a 1 :b})

1:18 lazybot: ⇒ {1 :b, 2 :a}

1:18 alandipert: muhoo: ^

1:27 robertstuttaford: does anyone know of a more up to date tutorial than this? http://mmcgrana.github.com/2010/08/clojure-rest-api.html

1:34 muhoo: alandipert: thanks!

1:56 robertstuttaford: the stuff in clojurebook.com is pretty current

1:56 ah, my favorite error message: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long

1:56 robertstuttaford: cool. i'm actually reading that book right now. just haven't gotten there yet

1:57 just managed to patch something together with ring, compojure, and cheshire

1:57 muhoo: chapter 16

1:57 robertstuttaford: great book. i'm learning so much

2:01 szx: is there any way to rename/alias java classes, more specifically, static inner classes? this foo$bar business is so verbose...

2:05 muhoo: hahahaah (not (= map hash-map))

2:05 i'm tired

2:08 szx: vars should work, i'd guess

2:08 Raynes: &(range 1000)

2:08 lazybot: ⇒ (0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81... failed to paste: Connection to http://localhost:8080 refused

2:08 Raynes: Oops.

2:08 Man, and I released that crap too.

2:08 muhoo: 8080?

2:09 szx: muhoo: they don't seem to work, at least with new - i guess because it's a macro?

2:09 Raynes: muhoo: I just added the ability for refheap to return Clojure data structures in the API. I modified my Clojure client lib to use that feature, but I forgot to remove the testing stuff.

2:10 muhoo: neat! is it pr-str'ing?

2:11 Raynes: muhoo: Tis.

2:17 forsakendaemon: Anyone around today?

2:18 I've got an issue where I'm trying to parse command sentences, of the form '[cmd1] [cmd2] [cmd3] lots of other parameters', and match them to functions.

2:18 It seems like the kind of problem that would have been solved for URL routing, but all the libraries that I can find are really tied into URLs.

2:18 Anyone have any ideas?

2:28 muhoo: is there a non-painful way to get an iso-8601 date out of clojure/java?

2:29 hmm, nm, google to the rescue http://snipplr.com/view/61835/clojure-iso-8601-current-date/

2:33 Raynes: muhoo: Oh man, dates in Clojure. You poor thing.

2:36 muhoo: wat? it it a nasty evil thing?

2:36 i understand java dates are miserable, but i expect someone'd have made it nicer for clojure

2:37 auugh, joda

2:39 huh, that first snippet just worked. no problem. oh well.

3:08 fhd: Raynes: Yeah, I think it's safe too, but people (including me) seem to prefer require, and I just wonder why. I don't have a very good reason myself, it adds a bit of clutter.

3:08 Raynes: fhd: Well, the different is irrelevant in Clojure 1.4. require can do the same thing use does.

3:09 So meh!

3:09 :p

3:09 fhd: Raynes: Oh, didn't even know that. With refer?

3:09 Raynes: Yep.

3:09 &(require '[clojure.string :refer [join]])

3:09 lazybot: java.lang.ClassNotFoundException: clojure.string

3:09 Raynes: Bluh.

3:09 You get the point.

3:10 fhd: Yeah. Still wondering why/when to use one style over the other though.

3:10 Raynes: :as vs :refer in 1.4

3:12 Raynes: I guess my reasoning for :as is that I prefer clarity in a local piece of code over saving a few bytes. Plus it's less ugly in Clojure than in C++ (which has pretty much the same mechanisms).

3:16 Raynes: fhd: I use :refer or use in situations where it'd look weird otherwise. For example, noir's defpage macro. You don't want to have (noir/defpage ..), you want (defpage ..)

3:17 fhd: Raynes: Through, same goes for clojure.test, forgot I do that :)

3:18 Raynes: Thanks, I think I've got a heuristic for this now. I always like to know why I'm doing something :)

3:19 s/Through/True/, of course. I don't even...

3:20 michaelr525: hi

3:22 anyone knows which is the best way to setup emacs+slime to work with a remote host? Locally I use clojure-jack-in.

4:18 hiredman: ugh, dispatching through a multimethod grabs a lock, how disgusting

4:23 amalloy: hiredman: they're mutable things; not much you can do about it, right?

4:24 hiredman: amalloy: well, I don't mutate them at runtime, so it is a drag to see all my threads fighting over that damn method

4:26 amalloy: yeah, that does seem like a nonoptimal approach

4:26 but even if you don't mutate them, they are mutating themselves by caching the hierarchy as new dispatch values arrive

4:26 hiredman: I am just dispatching on the type of the first arg, so switching to a protocol gets rid of the lock contention, but I hate to abandon the flexibility of multimethods

4:28 ugh

4:29 amalloy: i agree with you it seems like there's a way to make it work, but it's hard to imagine what it would be

4:30 hiredman: I've been trying to get this tree search to go faster by parallelizing it, but the parallel version was always slower (2.9 seconds vs. 800 millis) and as soon as I get rid of the multimethod the parallel version is now 200ms

4:31 amalloy: ouch

4:44 tomoj: michaelr525: you can just create an ssh tunnel to swank on the remote machine and slime-connect to it

4:49 scottj: you'd know that if you watched the first 10 minutes of slime.mov :)

5:02 michaelr525: tomoj: yeah, but I wonder whether there is something like 'clojure-jack-in' for this :)

5:04 tomoj: don't know of anything, you could maybe easily write a function that shells out to ssh and calls slime-connect?

5:04 getting tramp set up properly is something I haven't figured out

5:07 robermann: Hello, suppose I have this map: (def orders {:order1 ['a 'b 'c] :order2 ['x 'y 'z]}). Can I "decorate" the map's get method so that, for example, every call such (:order1 orders) could increase a counter or log the operation? Should I rebind any function?

5:14 _KY_: &(false ())

5:14 lazybot: java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn

5:14 _KY_: &(false? ())

5:14 lazybot: ⇒ false

5:14 amalloy: not really, robermann. you can do it if you're willing to put in an amount of work/code that's out of proportion to its usefulness

5:14 _KY_: That's weird isn't it?

5:15 amalloy: no. it's not false; it's not even falsey

5:15 _KY_: Ahhh right =)

5:16 amalloy: &(false? nil) is also false, because nil isn't false; it's just falsey (ie, treated as false in a boolean context)

5:16 lazybot: ⇒ false

5:34 _KY_: I have some code where I do a "for" and it freezes but when I changed it to "doseq" it runs, why is that?

5:36 tutysra: installed auto-complete and ac-slime in emacs24 using elpa and marmalade. should I have to make any manual settings to use them?

5:48 ben_h: hi all, any textmate users here? i'm trying to get a decent editor/repl set up, but i can't find an up-to-date clojure tmbundle.

5:48 the ones i've found seem to be incompatible with recent cake.gem

5:52 krunaldo: ben_h: Most just run vim or emacs now days

5:52 ben_h: heh, thought that might have been the answer :)

5:53 any pointers on getting a decent repl set up via vim?

5:53 i'm comfortable enough with vim that i might just give that a go

5:54 krunaldo: ben_h: I use http://www.vim.org/scripts/script.php?script_id=2501

5:55 ben_h: cool, i'll check it out now. thanks

5:55 krunaldo: ben_h: I've been thinking to switch to http://code.google.com/p/conque/ for a more general repl setup

5:55 so you may want to check that out.

5:56 ben_h: looks interesting

5:56 i guess it has shortcuts for writing the current selection/buffer/etc to the repl?

5:56 krunaldo: yes

5:57 but I'd still use vimclojure for the indent and stuff

5:58 michaelr525: ok, i got slime to connect to a remote swank! that was easy :)

5:58 but I still don'

5:59 t see arguments in stack traces

6:03 oh wait, it isn't supposed to work with repl evaluated code, right?

6:10 err, it's now working really well. when I try to slime compile a file it sends my local path to remote swank and of course it can't find it..

6:12 tutysra: copied the usage snippet from ac-slime.el to init.el and it worked, thx everyone

7:07 wei_: how do i run a regex in multiline mode?

7:17 gfredericks: you have to include the multiline flag in the regex

7:18 I don't know off the top of my head what that is, but it's the same as java, so you cat try googling for that

7:39 espeed: How do you see the form params submitted by clj-http? I'm running it with :debug true, but it just says ":body #<StringEntity org.apache.http.entity.StringEntity@714c7f58>"

7:40 gfredericks: espeed: you could use `nc -l 8080` to debug it

7:43 Borkdude: what is the best way to trace a recursive function?

7:43 Licenser: Borkdude recursively

7:43 Borkdude: Licenser: explain?

7:45 gfredericks: Borkdude: https://github.com/clojure/tools.trace might help

7:49 Borkdude: gfredericks: I don't see any recursive functions tested in the tests

7:49 Licenser: Borkdude you can just put a print in there, perhaps make a wrapper fn to expose and a inner one with a counter that you can see recursion deepoth

7:50 Borkdude: Licenser: println is the way I do it now, indeed

7:50 gfredericks: Borkdude: I was saying use that lib to do the printing instead

7:51 Borkdude: gfredericks: ok, will look at it

8:04 _KY_: Can someone help debug a piece of code, rather complex:

8:04 https://www.refheap.com/paste/2601

8:05 The program won't run to line 98

8:05 Seems that the "for" loop at 96 is not running

8:06 hiredman: ~for

8:06 clojurebot: for is complected

8:06 hiredman: ~for

8:06 clojurebot: for is not a loop

8:06 _KY_: (Oops lines numbers are wrong)

8:06 gfredericks: _KY_: you know that for is lazy right?

8:07 _KY_: The "for" in line 56 is not executing as I expected

8:07 espeed: gfrenderick: thanks; is there not a way to view the request params in emacs?

8:07 _KY_: Yes I am aware of laziness of for

8:07 gfredericks: espeed: you could run nc from an emacs shell?

8:07 _KY_: But it already added "doall" in front of it

8:08 Borkdude: _KY_: the first thing I would do, after looking at that code, is taking the large function apart to pieces...

8:08 espeed: well, I'm surprised that the clj-http debug mode doesn't display them in a viewable form

8:09 _KY_: I mean, there were "println" calls right below the "for", but I don't even see anything printed

8:10 Which is weird, isn't it?

8:10 gfredericks: _KY_: what for are we talking about?

8:10 oh 56

8:10 _KY_: The for at 56

8:11 gfredericks: _KY_: the indentation here makes this terribly difficult to read

8:11 Borkdude: _KY_ this code doesn't invite the reader to read it

8:11 _KY_: Yes, the debug stuff is not indented so you can ignore them

8:11 I deliberately put them to the leftmost

8:11 Also, tab size should have been 4...

8:12 Borkdude: _KY_ my advise for what it's worth: divide it up into smaller pieces and test each piece separately

8:12 gfredericks: +1

8:12 _KY_: The formatting up to 56 is perfect....

8:13 Let me paste again with tab size fixed...

8:16 Ok.. hope it looks better:

8:16 https://www.refheap.com/paste/2601

8:16 So it's just a big "for", followed by "if", and then another "for"

8:17 But the second "for" seems not running

8:21 I mean, the println at 59 is not even printing...

8:23 But I'm sure the "if" at 54 passes control to 56

8:29 Borkdude: what would be the most idiomatic to 'remove' an element from a vector, take the subvectors leaving out that one element and concat them?

8:29 wei_: to answer my question above: (?s) enables multiline

8:29 followup: how do you convert html encoding to unicode? e.g. Ferenc Juh&#225;sz > Ferenc Juhász

8:34 _KY_: (Back to my problem... I suspect it's sko laziness that causes the whole "for" to be skipped...?)

8:38 Borkdude: hmm, it's kind of nice that you can just write (def set1 #{1 2 3}), (def set2 #{3 4 5}) on one line in clojure

9:00 chouser: Borkdude: I'd do (into (subvec ...) (subvec ...))

9:01 Borkdude: chouser, why not concat?

9:03 _KY_: (Ok... found the bug... =))

9:03 gfredericks: Borkdude: into gives you a vector back; keep in mind what you're doing is one of the operations on vectors that is inefficient

9:04 Borkdude: gfredericks: I see

9:04 gfredericks: I never needed this btw, just wondering

9:06 chouser: The main difference is concat returns a lazy seq instead of a vector.

9:06 Borkdude: good point

9:07 chouser: if you wanted a lazy seq, you'd probably be better off with concat of take and drop, though it might be interesting to measure and find out

9:12 espeed: I'm having issues with clj-http not setting JSON form params properly -- I posted the details to SO http://stackoverflow.com/questions/10470643/why-isnt-clojures-clj-http-sending-the-json-form-params-properly -- any ideas?

9:28 gfredericks: espeed: why would you expect it to send escaped json?

9:28 espeed: what you're showing there is what I would expect it to do

9:37 daniel: ,(range 0 63 9)

9:37 clojurebot: (0 9 18 27 36 ...)

9:37 daniel: erm, doh

9:37 anyway, why doesn't this include 63?

9:37 36, 45, 54, 63????

9:37 i suppose it's up to and not including the second argument

9:38 michaelr525: yes, says so in the docs

9:39 daniel: is there a reason for it though? seems logical to define a range between two points including those points

9:41 AimHere: Well if you start counting at 0, then this way means (count (range n)) is n; also it matches the usual C-style for... loop idiom

9:41 daniel: ok, thanks

9:50 gfredericks: daniel: I've seen that style in a few different languages

9:51 Borkdude: daniel: same in python

9:53 daniel: from a python 'repl': >>> range(0,63,9)

9:53 [0, 9, 18, 27, 36, 45, 54]

9:53 gfredericks: &(take 8 (iterate (partial + 9) 0))

9:53 lazybot: ⇒ (0 9 18 27 36 45 54 63)

9:56 jonaskoelker: daniel: I think scala has both forms, Haskell has only endpoints-included

9:56 gfredericks: ruby/coffeescript have a range syntax that lets you do either...does python have that?

9:57 jonaskoelker: yes, you use the ",1+" argument separator if you want both endpoints ;-)

9:57 gfredericks: :P

9:58 jonaskoelker: alternatively, you can use the "_range=range; def range(x, y, z): return _range(x, y+1, z)" preprocessor pragma :D

9:59 gfredericks: that couldn't possibly break anything

9:59 jonaskoelker: nah

10:00 well, in a _real_ language I'm sure you could do some clever macrobatics

10:00 ;) [assert me.loves(python)]

10:00 antoineB: hello

10:00 Borkdude: would be very confusing, since slicing also works 'exclusively': [0,1,2,3,4,5][0:2] => [0,1]

10:00 jonaskoelker: Borkdude: have slices use range underneath

10:01 problem solved (or made worse, depending on perspective)

10:01 hello, antoineB

10:01 antoineB: i can build function using number of arguments make distinctions, could i use some sort of precondition?

10:01 Borkdude: jonaskoelker: yes, "nice" solution =)

10:02 antoineB you can use "dispatch on arty"

10:02 arity, stupid spelling correction

10:02 * gfredericks imagines Arty is some guy who works at a deli

10:02 antoineB: i have (defn ([x y] ...) ([x] ...))

10:03 jonaskoelker: antoineB: there seems to be a name missing

10:03 Borkdude: antoineB insert a name after defn

10:03 jonaskoelker: (defn foo ([x] x) ([x y] y))

10:03 antoineB: i would had (defn ([x y :when (= y 12)] ...) ([x] ...))

10:04 ... mean any code you want

10:04 Borkdude: antoineB: pattern matching?

10:04 gfredericks: oooh predicate dispatch

10:04 jonaskoelker: ah, similar to haskell's pattern match guards

10:04 antoineB: yes

10:04 jonaskoelker: more used to scala

10:04 espeed: gfredericks: This patch says, "If :content-type is set to :json, then :form-params is turned to a json string and set as the :body" https://github.com/dakrone/clj-http/pull/52

10:04 daniel: lol ",1+" argument separator

10:04 Borkdude: antoineB: hmm, there is some library for it https://github.com/clojure/core.match

10:04 jonaskoelker: =)

10:05 <--- smartass

10:05 gfredericks: espeed: my interpretation of that is consistent with what you're seeing

10:05 Borkdude: never used it though

10:06 gfredericks: espeed: I expect you don't need it escaped

10:06 jonaskoelker: how does arity dispatch work? java method-name overloading?

10:07 * gfredericks guesses probably so

10:07 jonaskoelker: oh, wait, noh, IFn doesn't have infinitely many methods

10:07 gfredericks: jonaskoelker: it has up to 20ish I think

10:07 jonaskoelker: so... unless you can only do it for up to some language-... oh

10:08 so you can't do (defn foo ([x] x) ([a b ... z] z))?

10:08 (if ish = 5)

10:08 gfredericks: jonaskoelker: try it

10:08 jonaskoelker: but... that would be empirical =)

10:08 gfredericks: well I don't know what it does and I want to

10:09 jonaskoelker: CompilerException java.lang.RuntimeException: Can't specify more than 20 params, compiling:(NO_SOURCE_PATH:14)

10:09 antoineB: Borkdude: thanks, but i will stay with arity for now, i am new to clojure

10:10 what is the diference between [a b] '(a b) ?

10:10 jonaskoelker: one is a vector, the other a list

10:10 also, the list contains 'a and 'b (two symbols), whereas the vector contains whatever a and b evaluate to

10:10 &(let [a 1 b 2] [a b])

10:10 lazybot: ⇒ [1 2]

10:11 jonaskoelker: &(let [a 1 b 2] '(a b))

10:11 lazybot: ⇒ (a b)

10:11 wmealing_: antoineB, many operations work on both.

10:11 but they are different.

10:11 jonaskoelker: (= (list 1 2) (vector 1 2))

10:11 &(= (list 1 2) (vector 1 2))

10:11 lazybot: ⇒ true

10:11 jonaskoelker: &(= '(1 2) [1 2])

10:11 lazybot: ⇒ true

10:13 antoineB: &(= '(2 3) [(+ 1 1) (+ 1 2)])

10:13 lazybot: ⇒ true

10:13 antoineB: &(= '((+ 1 1) (+ 1 2)) [2 3])

10:13 lazybot: ⇒ false

10:13 antoineB: ok

10:13 wmealing_: ,(sequential? [1 2 3])

10:13 clojurebot: true

10:14 wmealing_: ,(sequential? '(1 2 3))

10:14 clojurebot: true

10:14 jonaskoelker: (intstance? java.util.Collection ())

10:14 &(intstance? java.util.Collection ())

10:14 lazybot: java.lang.RuntimeException: Unable to resolve symbol: intstance? in this context

10:14 jonaskoelker: &(instance? java.util.Collection ())

10:14 lazybot: ⇒ true

10:14 jonaskoelker: &(instance? java.util.Collection [])

10:14 lazybot: ⇒ true

10:14 jonaskoelker: ,(counted? [])

10:14 clojurebot: true

10:14 jonaskoelker: ,(counted? ())

10:14 clojurebot: true

10:14 jonaskoelker: o_O

10:14 ,(counted? (list 1 2 3))

10:14 clojurebot: true

10:15 jonaskoelker: ,(counted (iterate (inc 0)))

10:15 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: counted in this context, compiling:(NO_SOURCE_PATH:0)>

10:15 jonaskoelker: ,(counted? (iterate (inc 0)))

10:15 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core$iterate>

10:15 jonaskoelker: ,(counted? (iterate inc 0))

10:15 clojurebot: false

10:15 wmealing_: ,(class? (list 1 2 3))

10:15 clojurebot: false

10:15 jonaskoelker: ,(class? class?)

10:15 clojurebot: false

10:15 jonaskoelker: :-)

10:15 wmealing_: :P

10:16 antoineB: is there a macro that take a sequence and expand it exemple: it take '(a b) and return a b

10:17 jonaskoelker: a b isn't a value

10:17 there are macros which embed the elements of one list in another, in the context of producing a syntax tree

10:17 well, macro-stuff

10:17 `(list 1 2 ~@(list 3 4))

10:18 &`(list 1 2 ~@(list 3 4))

10:18 lazybot: ⇒ (clojure.core/list 1 2 3 4)

10:18 antoineB: i have a function that return a sequence and i want proceed this sequence using matchin erity in another function

10:19 is it possible?

10:19 jonaskoelker: ,(apply (fn [x y] (+ x y)) (map inc [1 2))

10:19 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )>

10:19 jonaskoelker: ,(apply (fn [x y] (+ x y)) (map inc [1 2]))

10:19 clojurebot: 5

10:19 jonaskoelker: like this?

10:20 (apply + (list 1 2 3 4))

10:20 antoineB: how works apply? is it loop through the result of (map ...) ?

10:20 jonaskoelker: ,(apply + (list 1 2 3 4))

10:20 clojurebot: 10

10:21 jonaskoelker: (apply f (list a b c)) ~ (f a b c)

10:21 ,(apply + (cons 1 (cons 2 ())))

10:21 clojurebot: 3

10:22 jonaskoelker: i.e. it applies the function, using the elements of the list as the arguments

10:22 antoineB: &(apply (fn [a b c] (+ a (* b c)) [1 2 3])

10:22 lazybot: java.lang.RuntimeException: EOF while reading, starting at line 1

10:22 gfredericks: $google github gfredericks misquote

10:22 lazybot: [fredericksgary/misquote · GitHub] https://github.com/fredericksgary/misquote

10:22 jonaskoelker: &(apply (fn [a b c] (+ a (* b c)) [1 2 3])))

10:22 lazybot: clojure.lang.ArityException: Wrong number of args (1) passed to: core$apply

10:22 jonaskoelker: &(apply (fn [a b c] (+ a (* b c))) [1 2 3]))

10:22 lazybot: ⇒ 7

10:22 gfredericks: ^that library gives you unquoting without the other backtick stuff

10:23 jonaskoelker: I should get an IRC client with parenthesis highlighting :-)

10:23 [yes, I know, emacs...]

10:24 antoineB: &(apply (fn ([a b c] (+ a (* b c))) ([a b] (+ a b))) [1 2 3]))

10:24 lazybot: ⇒ 7

10:24 antoineB: &(apply (fn ([a b c] (+ a (* b c))) ([a b] (+ a b))) [1 2]))

10:24 lazybot: ⇒ 3

10:26 antoineB: jonaskoelker: thank you apply is the function i need

10:26 jonaskoelker: most welcome :)

10:26 I was thinking about ClojureQL---wouldn't CloQL be a more... c'loquial name? =)

10:29 wmealing_: boom tish

10:29 jonaskoelker: no laughter? Is everyone really so cloj-minded towards (my) puns?

10:29 =)

10:29 wmealing_: oh i got it

10:29 jonaskoelker: [sorry]

10:29 wmealing_: :)

10:29 it was just really bad

10:29 i love it.

10:30 jonaskoelker: yay, a bad pun buddy :)

10:39 btw, hickey mentioned something about running clojure backwards in a talk on blip.tv; does anyone know what that was about?

10:45 antoineB: how to loop through a list?

10:46 tmciver: antoineB: You're probably looking for the map function.

10:47 ,(doc map)

10:47 clojurebot: "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & ...]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."

10:47 tmciver: ,(map #(+ 1 %) [1 2 3 4 5])

10:47 clojurebot: (2 3 4 5 6)

10:48 antoineB: ,(doc reduce)

10:48 clojurebot: "([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i...

10:48 Robermann-mob: hi, anyone had success in using a web REPL from an ipad ?

10:49 antoineB: ,(reduce + ["a" "b" "c" "d"])

10:49 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number>

10:49 wmealing_: sounds way too trendy for me.

10:49 antoineB: ,(reduce concat ["a" "b" "c" "d"])

10:49 clojurebot: (\a \b \c \d)

10:50 antoineB: ,(reduce .append ["a" "b" "c" "d"])

10:50 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: .append in this context, compiling:(NO_SOURCE_PATH:0)>

10:50 antoineB: ,(reduce .concat ["a" "b" "c" "d"])

10:50 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: .concat in this context, compiling:(NO_SOURCE_PATH:0)>

10:50 Robermann-mob: clojurebot: your-message

10:50 clojurebot: excusez-moi

10:51 pandeiro: ,(reduce str ["a" "b" "c" "d"])

10:51 tmciver: antoineB: reduce is also a good one for operating on a collection but really only if you need to 'accumulate' some kind of result as you go.

10:51 clojurebot: "abcd"

10:52 wmealing_: is there a good way to do IPC between clojure instances ?

10:52 antoineB: tmciver: thank you

10:52 wmealing_: i've been thinking 0MQ

10:52 but i'm not convinced yet.

10:53 tmciver: pandeiro: I'd prefer apply there ##(apply str ["a" "b" "c" "d"])

10:53 lazybot: ⇒ "abcd"

10:53 pandeiro: tmciver: sure, i just thought antoineB was trying to do that... but i'm curious what's the advantage of using apply?

10:54 i guess you just do one (str ...) whereas with reduce you do n-1?

10:54 tmciver: pandeiro: I just think apply is more apt there. I only use reduce to accumulate a result.

10:54 wmealing_: i think i ask all the wrong questions.

10:56 pandeiro: tmciver: i'm actually very bad at understanding reduce fns... i'm trying to sort out a noir problem and the trail goes cold for me at a reduce i don't understand

10:57 tmciver: pandeiro: dito for me too, actually. I haven't had much occasion to use reduce :(

10:58 pandeiro: i think for more visual people recursion and some high order fns are just not as easy to reason about

11:00 antoineB: ,(reduce (fn [a b c] (* a (+ b c)) [1 2 3 4])

11:00 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

11:00 tmciver: antoineB: for reduce the function must take only two args.

11:01 antoineB: tmciver: that is i want to check

11:01 for me i din't see any difference between apply and reduce (expect the number of arguments)

11:01 pandeiro: ...and the reduce can optionally take an initial value to use instead of the first item in the seq

11:02 antoineB: i see apply as like 'this fn needs x args and i have a seq of x things'

11:03 wootsan: How could I use Java's (>>>) unsigned right shift operator from Clojure?

11:03 antoineB: ok

11:03 jweiss: I'd like to be able to write (def x (something [(println "hi") (println "there")]) so that the forms inside the literal list are not evaluated until the list is consumed. sort of like lazy-seq but each item is separate. does something like this already exist?

11:04 i'm writing a data-driven test harness, i don't want test data to be evaluated until runtime, but i also don't want to have to wrap every piece of data in (fn [] ...)

11:05 i could write a macro to do it for me, but thought there may already be one. :)

11:11 LauJensen: In lein/project.clj, how do I boost the heap size?

11:12 cancel that, I got it :jvm-opts ["-Xmx1g" "-server"]

11:16 raek: jweiss: one way to do it is (lazy-cat [(println "hi")] [(println "there")])

11:17 but a macro like this would perhaps be more ideal: (lazy-literal-seq (println "hi") (println "there")) --> (lazy-seq (cons (println "hi") (lazy-seq (cons (println "there") nil))))

11:23 jweiss: raek, thanks - I think lazy-cat might do it

11:24 oh wait, but i don't want them concatenated

11:24 i think i can just borrow lazy-cat's impl and leave off the "concat" :)

11:41 dnolen: mmarczyk: ping

11:53 Borkdude: or (map println ["hi" "there"])

11:53 since map returns a lazy seq

11:56 antoineB: (doc str)

11:56 clojurebot: "([] [x] [x & ys]); With no args, returns the empty string. With one arg x, returns x.toString(). (str nil) returns the empty string. With more than one arg, returns the concatenation of the str values of the args."

12:02 Borkdude: (+ 1 2 3)

12:02 clojurebot: *suffusion of yellow*

12:02 mdeboard: &(source +)

12:02 lazybot: java.lang.RuntimeException: Unable to resolve symbol: source in this context

12:02 mdeboard: &(clojure.repl/source +)

12:02 lazybot: ⇒ Source not found nil

12:02 Borkdude: ,(source +)

12:02 clojurebot: Source not found

12:03 Borkdude: ?

12:03 mdeboard: &(clojure.repl/source str)

12:03 lazybot: ⇒ Source not found nil

12:03 Borkdude: ,(+ 1 2 3)

12:03 clojurebot: 6

12:09 Fullmoon: I can't figure out how to tell lein to always use clj 1.4.0 - specific JVM options would be a bonus as well

12:12 wmealing_: i havn't done it but someone above said in projects.clj :jvm-opts ["-Xmx1g" "-server"]

12:13 and do you mean, for your project, or for lein itself ?

12:17 winkywooster: can anyone point out examples of customizing the repl, such as always using pprint?

12:18 Fullmoon: wmealing_: lein itself, when I just use "lein repl" for example, outside of a project

12:18 wmealing_: that, i dont know.

12:19 i imagine perhaps you could set it up in the lein script

12:19 xeqi: Fullmoon: what version of lein are you using?

12:20 nm, its just not something lein is setup to do

12:22 gf3: _ato: Hai?

12:27 raek: Fullmoon: you can't control the version used in "lein repl" outside a project.

12:27 Fullmoon: create a scratch project and specify the version in the project.clj file

13:33 muhoo: i guess nobody has made an extension to noir's wrap-exceptions function that sends an email with a stacktrace yet

13:36 if i make a custom exception handler, i hope there a way to replace noir's wrap-exceptions without actually having to patch noir

13:49 pandeiro: muhoo: what ns is wrap-exceptions in?

13:49 dakrone: espeed: I've seen your issue, I'll look at it, have to get on a plane now, check {:save-request? true} for more debug output in the meantime

13:49 pandeiro: nm found it

14:10 EvanK: The Clojure talk on sequences listed in the Clojure podcast on iTunes and on the Screencasts page are both only 8 seconds long.

14:10 cshell: When writing clojure tests, what is the convention for the namespace of the tests themselves? Is it the same as the namespace being tested or something built on it?

14:12 fliebel: What do you use for RSS feeds? Just clj-http + clojure.data.xml? Some Java Mammoth? Or something made for the job?

14:12 EvanK: iTunes itself. I subscribed through the store and downloaded the lecture.

14:19 wmealing_: apparently, there isnt much to know on sequences.

14:19 gfredericks: cshell: I always map foo.bar.baz to foo.test.bar.baz

14:20 at least assuming the project is called foo

14:20 I guess if the project is foo.bar then foo.bar.baz => foo.bar.test.baz

14:20 EvanK: wmealing_: Oh? I thought they were pretty important.

14:20 wmealing_: :)

14:23 kzar: How can I add a delay in Clojurescript? (Like Thread/sleep)

14:23 dnolen: kzar: there's no such thing.

14:24 kzar: if you want to run something later, call js/setTimeout

14:24 cshell: gfredericks: thanks, that's what seems to be working for me - having it in the same ns seems to cause it problems

14:25 gfredericks: cshell: yeah two files with the same namespace will freak out the namespace-loader-thingy

14:25 kzar: dnolen: ah right, hmm I did try that but I think I've gone wrong somewhere. (let [sound (js/Audio. "notification-beep.wav")] (dotimes [n 5] (js/setTimeout (.play sound), (* n 1000)))

14:26 (Was hoping it to play the sound once every second for 5 seconds)

14:26 gfredericks: kzar: probably you want #(.play sound)

14:26 so that it is a function

14:27 the way you have it it calls (.play sound) and then passes the return value from that to setTimeout

14:27 meiji11: is there anything like a distinct-by function? as in, if I provide a predicate to group the elements of a sequence into equivalence classes, the 'distinct-by' function will return a sequence where each class is represented once, provided it appeared in the original?

14:28 gfredericks: meiji11: (comp (partial map first) vals group-by)

14:28 dnolen: kzar: (js/setInterval #(.play sound) 1000)

14:29 gfredericks: meiji11: maybe :)

14:29 meiji11: thanks gfredericks.

14:29 dnolen: kzar: if you only want it to run 5 times you need to call setTimeout again from the thunk.

14:29 meiji11: why I didn't come across group-by sooner.

14:29 didn't I *

14:29 gfredericks: meiji11: wait I don't think the code I gave does anything meaningful

14:29 but I didn't quite understand what you were wanting anyhow

14:30 kzar: gfredericks, dnolen: thanks

14:30 meiji11: well.. I wanted to filter out elements in a sequence that are equal under some predicate, and retain only the first element of each eqv. class in the original order.

14:30 I guess.

14:31 gfredericks: oh that might actually be what it does

14:31 I retract my "doesn't do anything meaningful" claim

14:31 meiji11: yeah, group-by is definitely the right idea.

14:31 gfredericks: &((comp (partial map first) vals group-by) #(rem % 4) (range 99))

14:31 lazybot: ⇒ (0 1 2 3)

14:32 dnolen: (defn play-sound [s n] (when-not (zero? n) (.play s) (js/setTimeout #(play-sound s (dec n)) 1000)))

14:32 kzar: ^

14:32 gfredericks: &((comp (partial map first) vals group-by) #(first (str %)) (range 99))

14:32 lazybot: ⇒ (0 1 2 3 4 5 6 7 8 9)

14:32 fliebel: Is there something like xpath for clojure.data.xml? Having a huge record tree is not all that useful.

14:33 gfredericks: meiji11: though if you have a large dataset there would be more efficient ways to do it

14:35 kzar: (I can't believe how well Clojurescript and Clojurescript one work, when I tried playing a sound first time it just worked. Really cool, that with the new book that just came out has given me a kick up the arse to carry on learning Clojure again.)

14:35 meiji11: I'm not too concerned about that just yet. :)

14:36 cshell: clojure script one has a book?

14:36 kzar: cshell: Sorry I meant the new Clojure book

14:36 cshell: Ah, clojure programming?

14:37 hcumberdale: hi ;)

14:37 https://www.refheap.com/paste/2610

14:38 works for single requests, multiple requests throw (80%) "java.io.IOException: Pipe not connected" exceptions

14:38 what to do? (locking .... ?

14:39 kzar: With clojurescript one can you connect to the repl using swank or do you have to use the console based repl?

14:40 dnolen: kzar: no support for swank, but it's easy to get inferior lisp working.

14:40 kzar: dnolen: ok

14:40 (think I saw that in the video come to think of it)

14:40 dnolen: kzar: inferior lisp just needs a command to run at the shell and your good to go.

14:41 kzar: (setq inferior-lisp-program "...")

14:42 kzar: Would you not need to change your .emacs for each new project though?

14:44 dnolen: kzar: so make a command call run-cljs which sets it then calls it

14:44 kzar: actually sorry, you want run-lisp

14:45 kzar: ok

14:45 dnolen: kzar: https://gist.github.com/2623705

14:45 kzar: so just replace that with the command for starting the CLJS-one REPL

14:46 EvanK: Who's in charge of the screencasts?

14:54 faust45: any one around who manage clojure google group list?

15:21 fliebel: huh, the Clojure website just showed me a wikispaces add

15:23 kzar: fliebel: Sure I heard someone talk about that ages back

15:28 dnolen: I got it working thanks, commented on your gist with what I used. Had to tweak the script/repl file though to get the path right

15:29 dnolen: kzar: good to hear

15:29 mmarczyk: ping

15:38 pandeiro: what's the latest 'release' of cljs and where would i find that info besides searching the mailing list?

15:39 dnolen: pandeiro: r1011

15:40 pandeiro: easiest way to get it is to just use lein cljsbuild

15:41 pandeiro: dnolen: wait but then lein-cljsbuild would have to keep up as well, right? i'm using ibdknox's cljs-template for working with noir/cljs

15:41 just wondering if that info is made available anywhere other than the mailing list... say on clojure.org somewhere? or the official clojurescript repo?

15:42 xeqi: https://oss.sonatype.org/content/repositories/releases/org/clojure/clojurescript/ ?

15:44 dnolen: pandeiro: or http://search.maven.org/#search%7Cga%7C1%7Cclojurescript

15:45 pandeiro: cool thanks i'll bookmark those

15:45 xeqi: ah, forgot they get premoted

15:45 dnolen: pandeiro: lein-cljsbuild does have to keep up, would be nice to be able to pick a particular release.

15:45 pandeiro: a lot of people are using master since things are moving along very quickly these days.

15:46 pandeiro: dnolen: yeah i am thinking about lifting that part out of cljs-one, so i can use master instead of a jar

15:46 (the lein github bit)

15:47 yah but then i look at the src here |6

15:47 https://github.com/brentonashworth/one/blob/master/src/leiningen/git_deps.clj

15:48 ...and jar seems a lot easier

15:49 dnolen: pandeiro: people aren't doing that to track CLJS master

15:50 pandeiro: doing what, jar or using the lein git repo from cljs one? i am still looking for the right workflow, spend a lot of time debugging the env still

15:55 dnolen: pandeiro: https://github.com/clojure/clojurescript/wiki/lein-cljsbuild

15:56 pandeiro: dnolen: ahh gotcha, didn't realize lein-cljsbuild had that integrated. cheers.

15:57 still a lot of yak shaving ey, having to specify all of that for every new little throwaway project

15:58 dnolen: pandeiro: not much different Clojure and it scales.

15:58 pandeiro: not much different from I mean.

15:59 pandeiro: for little things, I just collect them inot one project with differnt subdirs inside.

16:00 pandeiro: dnolen: that's an idea, yeah... but then why not just use the convention that the person has CLOJURESCRIPT_HOME set?

16:01 dnolen: pandeiro: I don't follow, I don't use CLOJURESCRIPT_HOME. I'd only expct CLJS lang or compiler hackers to bother with that.

16:01 pandeiro: dnolen: when i started working with cljs, i was using cljs-watch, which just expected that env variable to be set

16:01 dnolen: pandeiro: yes it was yucky

16:01 pandeiro: then you only need one canonical cljs repo, keep it updated

16:02 so it's better to have to have a local cljs in every project?

16:02 dnolen: pandeiro: 90k jar.

16:02 pandeiro: right but then it's a jar, not master

16:02 dnolen: there are more important things to care about.

16:05 pandeiro: at some point in the future there'll be a very solid release - and you won't need to bother tracking master. I personally don't miss the cljs-watch days at all.

16:07 Raynes: It's hard being around during the early days of a project of the scale of ClojureScript.

16:08 It's not like they can just release after every change, but damn it, you sure want them to.

16:23 gfredericks: Raynes: what would be the consequences if they did?

16:23 hcumberdale: damn software ;(

16:24 Raynes: gfredericks: They'd get tired of doing it eventually and move to Africa.

16:24 gfredericks: I see

16:24 xeqi: but, but, post deploy hook

16:25 gfredericks: xeqi: but, but, africa

16:34 pandeiro: anyone know an elementary macros tutorial for beginners?

16:36 Raynes: muhoo: Yoohoo.

16:37 mdeboard: pandeiro: The only decent one I've seen is in the Clojure Programming book tbh

16:38 muhoo: Raynes: yo

16:38 Raynes: muhoo: Before I release refheap.el, got anything that should be done?

16:39 faust45: if i need in loop assign elements to hash map, how i can do this?

16:39 muhoo: nah, works fine to me after i changed to www.refheap.com

16:40 Raynes: it would be good to get that assoc out of there and move that logic server-side, but it'd mean an api change, and i'm slammed at the moment, doing heroic battle with jquery ui and css :-(

16:40 Raynes: muhoo: I don't think a mode association would be appropriate for the server side. It would be specific to Emacs.

16:41 pandeiro: mdeboard: cool, i look at it

16:44 Raynes: muhoo: 0.0.2 released

16:50 amalloy: pandeiro: i kinda feel like macros are one of those things you just have to absorb gradually. let it go (1) magic i don't even see the point of (2) okay, i can see why you'd want that (3) neat, i think i know how that works (4) hey, i bet i could do that too! (5) actually that was a dumb place for a macro, i'll just use a function

16:55 hcumberdale: java.lang.ClassCastException: java.lang.Long cannot be cast to [Ljava.awt.image.BufferedImageOp;

16:55 trying (defn gen-thumbnail "returns input stream to image" [url x y]

16:55 (let [in (javax.imageio.ImageIO/read (as-url url))

16:55 out (org.imgscalr.Scalr/resize in x y)]

16:56 API: resize(BufferedImage src, int targetWidth, int targetHeight, BufferedImageOp... ops)

16:57 pandeiro: amalloy: i read your post http://amalloy.hubpages.com/hub/Clojure-macro-writing-macros - which is great - but i am not at stage 4 yet

16:58 amalloy: yeah, that's definitely not a general-macro tutorial; it was specifically for metamacros

16:58 Raynes: And IIRC was written because he worked at hubpages and they wanted him to write crap on it.

16:58 ;P

16:58 pandeiro: haha yeah specifically the second section was helpful

16:59 cshell: how do i set javac options in leinengen? I'm trying :jvm-opts "-target 7" but it's not picking it up - still saying it's trying to compile to -source 1.5

17:00 mmarczyk: dnolen: pong

17:00 pandeiro: right now i would like to use clojure.tools.macro/name-with-attributes to make noir's defpartial able to take a docstring, and i understand what defpartial is doing, but i don't see where the args to name-with-attributes should be coming from

17:01 mmarczyk: dnolen: looking over your commits now -- very cool -- somehow next on a list just got a huge speedup :-)

17:02 cshell: Ah, figured it out by finally finding the page with all the options: http://bit.ly/J7E5xC - the answer is :javac-options [:target "7"]

17:03 dnolen: mmarczyk: heh yes :) call seq on cons, list very cheap.

17:04 amalloy: pandeiro: (defmacro defpage [& args] (let [[name & opts] (apply name-with-attributes args)] `(old-defpage-impl ~name ~@opts))), or some such

17:04 dnolen: mmarczyk: I tweaked protocols mask logic so we don't generate so many partitions

17:04 mmarczyk: dnolen: ah yes, I was going to say thanks for that :-)

17:04 dnolen: I actually remember realizing that was nonsense somewhere along the way, then leaving it in to see if multiple partitions will be created properly... apparently I forgot again :-(

17:04 technomancy: is there a way in clojurescript to get actual js/this without having the compiler change it into this$?

17:04 dnolen: mmarczyk: also after some more playing around I think benching with node.js is a bad idea.

17:05 mmarczyk: you should test with v8 directly, I also recommend testing with JavaScriptCore for sanity checking

17:05 technomancy: (js* "this")

17:05 technomancy: dnolen: thanks

17:05 mmarczyk: technomancy: see also this-as

17:06 technomancy: (this-as self (do-stuff self))

17:06 dnolen: technomancy: yeah this-as probably better, (js* ...)

17:07 only in dire cases.

17:07 mmarczyk: I also optimized default cases

17:07 mmarczyk: dnolen: I've been using v8 and SpiderMonkey for tests, I'll wire it up for for benchmarking

17:07 dnolen: mmarczyk: they were paying.

17:07 mmarczyk: ok cool

17:07 mmarczyk: dnolen: I've seen some *weird* results on node recently -- e.g. I've got a patch lying around which seems to speed up satisfies?

17:08 dnolen: 60ms -> 45ms on some huge number of runs

17:08 cemerick: since we're on the subject of cljs noob questions: is there any hope of bridging vectors (or lists) to arrays, so that I can avoid wrapping things in js/Array, etc?

17:08 mmarczyk: dnolen: but actually causes a hit on first/rest -- um, what?

17:08 dnolen: so, I don't really know what to think about it.

17:08 dnolen: mmarczyk: yeah I'm not sure what the deal is with node, they may tweak the VM settings a lot.

17:08 cemerick: mmm, that's probably a stupid question, actually

17:09 dnolen: mmarczyk: another big boost coming soon for idiomatic CLJS

17:10 mmarczyk: direct dispatch to rest fns

17:10 mmarczyk: dnolen: https://github.com/michalmarczyk/clojurescript/tree/or-free-satisfies

17:10 dnolen: *fantastic*

17:10 !

17:10 dnolen: mmarczyk: can you point me to the relevant change?

17:11 cemerick: something more than into-array?

17:11 mmarczyk: dnolen: sure, https://github.com/michalmarczyk/clojurescript/commit/ef872be54fef3833decc245dcbfed4c3aa10e421

17:12 dnolen: or in that position gets compiled into a function call -- if ((function () {...})()) ...

17:12 dnolen: mmarczyk: yeah that kind of stuff is nice for code readability

17:12 mmarczyk: but doesn't matter in the end.

17:12 mmarczyk: lambdas get lifted by GClosure

17:13 hcumberdale: I do not understand the java interop

17:13 for variable argument lists

17:13 mmarczyk: dnolen: ok, good to know

17:13 dnolen: mmarczyk: anytime you have a function to preserve expression semantics GClosure will optimize it away.

17:14 cemerick: dnolen: No. Ignore the Q. I'm just coping with not fundamentally caring about the interop issues in the case of cljs, so I'm being sloppy.

17:14 dnolen: mmarczyk: this is why the perf diff between simple and advanced is so big sometimes.

17:14 mmarczyk: so GClosure basically allows us to get away with having a recursive decent compiler :-)

17:14 dnolen: mmarczyk: yep

17:16 mmarczyk: check this out, on JSC rest fn optimization is only slightly slower than accessing arguments object it looks like :)

17:18 mmarczyk: dnolen: hah :-)

17:22 dnolen: well, this is marvellous -- should be a tremendous boon for idiomatic cljs

17:23 dnolen: mmarczyk: and on v8 we can call rest fn 1e6 times in ~90ms instead of ~1100ms

17:23 mmarczyk: dnolen: shall we say a noticeable improvement? ;-)

17:24 dnolen: so basically what I want to know now is when are you going to merge this in :-D

17:24 dnolen: now

17:25 mmarczyk: well that sounds like a great time

17:26 dnolen: rest fn optimization now in master

17:27 mmarczyk: :-)

17:27 wootsan: I tried marking a def with ^:const, but clojure screams at me that I "can't embed object in code, maybe print-dup not defined". What does this mean?

17:29 dnolen: mmarczyk: I've been wanting to optimize that an incredibly long time.

17:29 mmarczyk: but we needed a fast satisfies? first :)

17:29 mmarczyk: dnolen: :-)

17:30 dnolen: well that is going to be a *huge* win :-)

17:34 dnolen: I'll need to go and get some work done on a rather pressing project tonight; later though (tomorrow, I guess) I'll be putting together a benchmark runner -- 12x speed improvements on fundamental operations should be measured & tracked properly :-)

17:34 brainproxy: dnolen: I'm getting close to having something truly useable with node-clojurescript ... going to start porting over the tooling from the coffee-script library for wrapping around the core build routine, and expose command line operations

17:35 pandeiro: amalloy: cheers, that makes sense

17:36 brainproxy: cemerick: your pomegranate turned out to be very, very useful in the context of making cljs and nodejs runtime work well together

17:37 Raynes: Would anyone care if refheap's browserid authentication got replaced with github authentication?

17:37 cemerick: brainproxy: That's surprising, but sounds like a nifty use case. :-)

17:38 Raynes: whoa, that had a short lifespan. Where are you getting the github auth from?

17:38 Raynes: cemerick: What had a short lifespan?

17:38 brainproxy: cemerick: :) it allows cljs :require and nodejs/require to both work well

17:38 cemerick: the browserid thing

17:39 Raynes: cemerick: I'm simply entertaining other options. People keep complaining about browserid.

17:39 dnolen: brainproxy: nice!

17:39 mmarczyk: cool thanks for your all you help w/ this stuff.

17:39 brainproxy: cemerick: i.e. i needed a way to modify classpath at runtime, on the clj side of node-clojurescript

17:39 Raynes: cemerick: All two of the people who use konkeror can't sign in!

17:40 mmarczyk: dnolen: not at all, thanks for all of your time and insight and very much looking forward to working on this a lot more

17:40 brainproxy: anyone know a good resource for learning lein ... keep in mind I'm also trying to get my head around java, maven, et al. at the same time

17:40 cemerick: Raynes: I'm contemplating using https://github.com/fernandezpablo85/scribe-java/ for oauth in friend.

17:41 pandeiro: brainproxy: `lein help tutorial` you did already?

17:41 mmarczyk: brainproxy: README + the docs directory in the repo -- *really* good documentation

17:41 brainproxy: pandeiro: not yet, more like trying to just understand how it all fits together

17:42 Raynes: cemerick: I don't like scribe. It invented it's own request type, so if you want to write a library for an oauth API, you have to use its special http client thingy.

17:42 brainproxy: but I guess experimentation and the docs directory as mmarczyk suggested will be the way to go

17:44 cemerick: Raynes: Good point. That said, it already supports so many (and it so widely used — thus maybe ~= reliable) that I'd be happy enough with it for a first cut.

17:44 There can certainly be more than one oauth workflow in the world.

17:45 Raynes: Oh how I hate oauth.

17:45 cemerick: heh, course, there's no github API impl :-P

17:46 Raynes: cemerick: You should rewrite refheap to use couchdb.

17:46 cemerick: Anyway, the list that *is* there is impressive enough that I can't really ignore it.

17:46 https://github.com/fernandezpablo85/scribe-java/tree/master/src/main/java/org/scribe/builder/api

17:47 Raynes: That's two couch mentions from you in the same afternoon. Wassup?

17:47 Raynes: *shrug*

17:47 Just considering other options.

17:47 People seem to think I'm retarded for using mongodb, so obviously I must be doing something at least slightly wrong.

17:47 ibdknox: there's absolutely nothing wrong with mongo

17:48 Raynes: Cool.

17:49 cemerick: there's absolutely nothing wrong with mysql, either.

17:49 ibdknox: definitely. They're all viable tools

17:49 Licenser: there was something wrong with mongo so - they refused to make it sparc compatible :(

17:49 Raynes: Man, nobody uses solaris. Go away.

17:49 ibdknox: hrmpf, #python isn't being helpful

17:49 Licenser: Raynes I do!

17:50 also solaris != sparc

17:50 cemerick: ibdknox: I was mostly trolling. There's a great deal wrong with both mongo and mysql, but yes, people can make just about anything work given enough effort and conditioning.

17:51 ibdknox: cemerick: I dunno, it's all "right tool for the job", yeah? Engineers seem to be completely irrational when it comes to DB choices

17:51 rather, data persistence choices

17:51 which is funny to me

17:51 Raynes: ibdknox: Well, to be fair, my decision to use mongo in refheap was "I know how to use congomongo. Let's go."

17:51 cemerick: Sure, but all things being equal, there are reasonable defaults.

17:52 I think it'd be hard to make a good case that mysql is preferable to postgres, for example.

17:52 ibdknox: brehaut: you're the resident pythoner. Is there a python equivalent to in-ns in for the python repl?

17:52 cemerick: I agree, I knew you were trolling on that point :p

17:53 brehaut: ive forgotten what in-ns does

17:53 (doc in-ns)

17:53 clojurebot: "([name]); Sets *ns* to the namespace named by the symbol, creating it if needed."

17:53 brehaut: nope

17:53 ibdknox: brehaut: I want my code to eval in a specific context

17:53 seriously?

17:53 brehaut: well

17:53 theres not a commonly used trick

17:53 ibdknox: that's dumb

17:54 brehaut: the eval functions let you pass in locals and globals

17:54 ibdknox: is there a way to get the locals from a module?

17:54 brehaut: bound to be

17:55 dir(module) would work

17:55 but you are never supposed to rely on its behavior

17:55 (even though that behavior hasnt changed noticably in the 12 years ive used python)

17:55 ibdknox: python's AST stuff is so nice, but its facilities for actually executing code are terrible

17:56 brehaut: yeah, you might find you have to do a bunch of munging

17:57 ibdknox: meh. Ok. Hackery it is. Thanks brehaut

17:57 brehaut: no worries. i hope my advice is ok ;)

18:16 pandeiro: ,(let [args '(1 2 3 4)] (take (dec (count args)) args))

18:16 clojurebot: (1 2 3)

18:17 pandeiro: ,(let [args '(1 2 3 4)] (pop args))

18:17 clojurebot: (2 3 4)

18:17 pandeiro: ,(let [args '(1 2 3 4)] (pop (vec args)))

18:17 clojurebot: [1 2 3]

18:33 dnolen: k I think apply will be the next CLJS perf victim. Seems like a near 10X speed bump is possible there as well.

18:33 amalloy: &(doc butlast) ;; pandeiro

18:33 lazybot: ⇒ "([coll]); Return a seq of all but the last item in coll, in linear time"

18:37 pandeiro: amalloy: that's it, thanks... still working on defpartial :-/

18:42 zanes: So, I'm very new to Clojure and am trying to get started with a new project.

18:42 All I have is a single ns declaration that requires a few libraries.

18:42 When I C-c C-k to compile the file I get a bunch of errors of the form:

18:43 Warning: *format-str* not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic *format-str* or change the name.

18:43 Then the compilation errors out.

18:43 Is this a problem with the library I'm using?

18:46 brehaut: zanes: are you using clojure-contrib ?

18:46 zanes: Not that I know of.

18:46 brehaut: what libraries are you using?

18:47 because pre clojure 1.3 vars were dynamic by default.

18:47 they need to be annotated specifically in 1.3+

18:47 zanes: twitter-api and clj-oauth.

18:48 Looks like clj-oauth is the offender.

18:48 brehaut: looks like it

18:49 last release was feb last year

18:49 wheres Raynes

18:49 im sure he was complaining about oauth recently

18:49 zanes: perhaps have a look at oauth-clj ?

18:50 cemerick: shouldn't everyone always be complaining about oauth?

18:50 brehaut: haha

18:50 zanes: Haha

18:50 brehaut: probably

18:50 i was just thinking that if he had suffered under it recently, he might know the least bad library to use

18:51 unless friend is relevant here?

18:53 how did i not know that use allowed :as

18:55 (dec brehaut)

18:55 lazybot: You can't adjust your own karma.

18:55 brehaut: ,(print "(dec brehaut)")

18:55 clojurebot: (dec brehaut)

18:55 lazybot: ⇒ 6

18:55 brehaut: thanks clojurebot

18:55 zanes: brehaut: Not relevant. I'm just talking to the twitter API.

18:56 I'm excited about friend, though. Hope to use it for something else.

19:04 devn: ,(print "(inc devn)")

19:04 clojurebot: (inc devn)

19:04 lazybot: ⇒ 3

19:04 devn: ,(print "(inc devn)")

19:04 clojurebot: (inc devn)

19:04 lazybot: ⇒ 4

19:05 devn: brehaut: heh brehaut

19:05 brehaut: its pretty poor form to use that trick to inc yourself :P

19:05 devn: i didn't believe it worked :)

19:06 (read-string "(inc brehaut)")

19:06 ,(print (read-string "(inc brehaut)"))

19:06 clojurebot: (inc brehaut)

19:06 lazybot: ⇒ 7

19:06 brehaut: lol

19:06 thanks

19:06 devn: :)

19:13 lazybot: I feel so violated.

19:14 * devn sends lazybot to a house of religious worship to spend the rest of his/her days

19:25 zanes: Speaking of libraries, it appears that parsley is the least painful pure-Clojure parser generator?

19:31 devn: zanes: there are a few options

19:32 https://github.com/youngnh/parsatron

19:32 zanes: devn: I wa slooking at parsley, or potentially just ANTLR.

19:33 Should I not be alarmed if the project is still on Clojure 1.2.0?

19:33 devn: zanes: looks like you have some commits on it

19:34 zanes: Which? Parsley?

19:34 devn: yeah, is that right or just a coincidence?

19:34 https://github.com/cgrand/parsley/network

19:34 zanes: I submitted a pull request to bring it up to Clojure 1.4.0.

19:34 Or what I think will bring it up to 1.4. I'm just getting started with Clojure.

19:34 devn: laurent has work to get it to 1.3

19:35 perhaps you should submit your patches to him?

19:35 * devn wonders why there's all the forking and not a lot of merging

19:35 zanes: Yeah, unclear.

19:36 I get the impression it's not exactly being actively maintained. : )

19:36 ibdknox: none of cgrand's libs really are last I saw

19:36 devn: yeah :(

19:36 reason #10 to not use enlive

19:37 it's funny, because laurent has a dozen commits that arent submitted back to cgrand

19:37 cgrand has a commit which is a couple months old

19:38 why the crazy divergence?

19:38 zanes: Yeah. parsley was simply the parser generator that seemed easiest to port to 1.4.0.

19:38 devn: Not only that, but he branches away several times without any merges back.

19:39 yoklov: maybe they were bad ideas?

19:39 devn: if they're bad ideas, delete them

19:40 yoklov: oh, yeah, that's probably the thing to do

19:40 devn: im not the most organized guy ever though so i can see how they might be hanging out there

19:40 zanes: I mean, they just appear to be patches to maintain compatability with recent versions of Clojure.

19:40 yoklov: i do that a lot but i'm not very good at git, nor am i very organized

19:40 devn: zanes: idk, fwiw my advice is to just act like you own it

19:40 release to clojars, etc.

19:41 make your fork the good fork

19:41 leave mediocrity behind

19:41 yoklov: (the branch without returning, not the maintaining compat. w/ clojure versions)

19:41 zanes: Yeah. That makes sense. Just trying to be a good citizen with the pull request.

19:42 devn: zanes: yeah i understand -- he should too though if he's not addressing your requests in a timely fashion

19:43 _KY_: If I want multiple binding in

19:43 If I want multiple binding in "for"

19:44 I do (for [ [x y] [[1 2] [3 4] ]...., right?

19:45 ,(for [[x y] [[1 2] [3 4]] (print x y))

19:45 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )>

19:45 _KY_: ,(for [[x y] [[1 2] [3 4]]] (print x y))

19:45 clojurebot: (1 23 4nil nil)

19:46 _KY_: It doesn't seem to bind correctly if I have variables in place of 1,2,3,4...

20:01 mdeboard: &(clojure.repl/source if-let)

20:01 lazybot: ⇒ Source not found nil

20:02 brehaut: (source if-let)

20:02 huh. i thought that had some magic applied to it

20:03 mdeboard: trying to write an if-let for emacs :P

20:04 mega_: should not be to hard

20:06 dgrnbrg: hello clojurians

20:06 i have a weird issue w/ reevaluating namespaces in the same repl

20:06 I am :useing a namespace which redefines a lot of clojure primitives, like not=, =, >, <, +, -

20:07 when I reevaluate the unit tests for that namespaces, it fails on the ns macro, saying that not= is already defined in that namespace.

20:07 What is going on?

20:08 brehaut: i dont really know what im talking about here, but have you done a refer-clojure in the test ns?

20:08 dgrnbrg: brehaut: I have not

20:09 I want to use most of clojure's symbols, except for the ones I'm redefining

20:09 amalloy: ~source if-let

20:09 dgrnbrg: like algo.numeric-tower

20:10 brehaut: im pretty sure you can specify which core vars you want to refer

20:11 dgrnbrg: brehaut: do you know what the syntax is for doing that?

20:11 amalloy: (:refer-clojure :as core :exclude [+ - ...]), iirc

20:11 then you still have access to them under core/+

20:12 dgrnbrg: so that would just exclude those few symbols?

20:12 brehaut: go with what amalloy suggests; i only know about the feature in theory

20:12 amalloy: but really, just read ##(doc refer), and apply whatever the syntax is; refer-clojure takes the same args

20:12 lazybot: ⇒ "([ns-sym & filters]); refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symb... https://www.refheap.com/paste/2618

20:12 dgrnbrg: Actually, I don't think that's the problem

20:13 The root error is:

20:13 not= already refers to: #'myns.math/not= in namespace #'myns.test.math

20:14 I have multiple :use clauses in the ns macro

20:14 could that cause a problem

20:15 It appears to be related to the fact that it's re-using the symbol

20:16 And it's only happening for not=, not for any of the other vars (which are defined earlier in the source file)

20:18 gfredericks: dgrnbrg: you've excluded not= from clojure.core?

20:18 dgrnbrg: gfredericks: I referred clojure.core to clj

20:19 gfredericks: oh gotcha

20:19 dgrnbrg: it doesn't want to re-refer the same var

20:19 because it's already been defined

20:20 I'll be back in a moment to discuss it, but the bus just arrived at a rest stop

20:34 wkmanire: Good evening

20:34 :)

20:56 mebaran151: can a lein checkout override a project plugin?

20:56 I'm trying to debug my Windows issues with lein-cljsbuild and play with all the cool new toys

20:58 emezeske: mebaran151: I am not aware of a way to do that (although I don't claim to know for certain that it can't be done)

20:59 rhc: what does it mean when I get "Evaluation aborted" in the repl?

21:00 dreish: The form being evaluated threw an exception.

21:01 rhc: ah, ok, thanks dreish

21:02 strange, when i ran it a second time i got a stack trace. bit more useful :)

21:02 gfredericks: rhc: it's messing with you

21:03 mebaran151: emezeske: ah thanks, btw do you have any ideas what could npe'ing on the repl tasks; it looks like an eval-in-project issue

21:05 emezeske: mebaran151: Hard to say; I'd probably look at the leiningen code indicated in the exception to see what it's doing at that point

21:07 mebaran151: it looks like it's swallowing an exception and trying to parse out an exit code

21:07 emezeske: mebaran151: Is an exception thrown if you leave out the "trampoline"? The repl won't work right without it, but it should start

21:07 mebaran151: which apparently doesn't exist

21:08 emezeske: not using trampoline won't let me start it: gives an error that all repl tasks must be started from trampoline

21:08 emezeske: mebaran151: Derp, I forgot I added that check :)

21:09 I wonder if other trampoline tasks work? Like "lein trampoline run" ?

21:10 mebaran151: there might be an error in my setup too: is there a good example cljsbuild project that I coudl clone just to test and see if it's just some nonsense on my part setting up the build

21:10 emezeske: mebaran151: https://github.com/emezeske/lein-cljsbuild/tree/master/example-projects/simple

21:10 err

21:10 Yeah, that should work for e.g. "lein trampoline cljsbuild repl-rhino"

21:11 mebaran151: hmm, emezeske good call: lein trampoline repl also blew up

21:11 nybbles: whats the best way to make it so that a macro is syntax-highlighted as a keyword in clojure-mode? i.e. i want defconstrainderecord from trammel to be syntax-highlighted

21:11 mebaran151: I've been having trampoline issues with lein on windows anyway: thought I'd solved them but it seems like they need more thwacking

21:11 emezeske: mebaran151: Doh :/

21:15 mebaran151: it looks like the task actually starts, which is the weirdest part; I would have thought with trampolining, once the task was running, everything was setup alright

21:16 emezeske: mebaran151: Is this lein 1.7?

21:21 uvtc: Is it ok to have both ~/bin/lein and ~/bin/lein2 , and to use them both? Or will they interfere with eachother?

21:21 mebaran151: emezeske: I'm trying to get lein 2.0 running :/

21:22 uvtc: Actually, I meant, "hi #clojure", then the rest. :)

21:22 gfredericks: uvtc: I'm 98% sure it's fine

21:22 emezeske: uvtc: Yeah, I have that same setup going and it's just fine

21:23 mebaran151: Ah

21:23 uvtc: thanks :)

21:23 Oh, shoot. Actually, I just checked the lein2.0.0-preview3 release announcement, and it says "Note that this does not conflict in any way with Leiningen 1.x; you can

21:23 keep the two of them installed side-by-side."

21:25 * mebaran151 hates cmd file debugging

21:25 mebaran151: I might try and port the whole launcher script to a nice saner language like powershell

21:25 but now that I'm reading how trampoline works, it's pretty trippy, what with generating a script file to then try and call

21:26 emezeske: mebaran151: For troubleshooting, I definitely recommend taking a look at that generated script, and running it by itself

21:29 mebaran151: emezeske: I'm checking it right now

21:29 uvtc: The lein 2 preview 3 release announcement (<http://groups.google.com/group/clojure/browse_thread/thread/91079a531ee1f1c8#>) says "Highlights include the ability to show a full dependency tree a la "mvn

21:29 dependency:tree"". How do I tell lein to show me that?

21:31 gfredericks: uvtc: try `lein pom` then `mvn dependency:tree`

21:31 ....if you have maven installed

21:31 uvtc: gfredericks, Ah, I see. You've got to have maven installed. Thank you.

21:31 * gfredericks doesn't understand how lein works without maven installed

21:32 xeqi: uvtc: `lein deps :tree`

21:32 uvtc: Well, I'm guessing lein installs what it needs on its own, but I have no mvn command available on my system.

21:32 xeqi, thanks!

21:33 gfredericks: is that a lein2 thing?

21:33 uvtc: xeqi, `lein help deps` doesn't mention anything about that.

21:33 amalloy: gfredericks: yes

21:33 also, the lein standalone jar includes a copy of maven

21:33 xeqi: feel free to make an issue and we'll see if we can git to it for preview4 or 5

21:34 gfredericks: amalloy: you have explained two things in a row

21:34 amalloy: does "yes" ever count as explaining something?

21:34 gfredericks: hmm

21:34 yes

21:35 brainproxy: is the idea with string-print in clojurescript to output a string and have a line break ( \n ) automatically appended, or to just send the bare string to stdout?

21:37 reason i ask is that in the nodejs.cljs that ships with clojurescript string-print is pointing at sys.puts, but the latter is deprecated

21:37 and I'm wondering whether it would be better to point string-print at console.log

21:37 or process.stdout.write

21:38 console.log appends \n

21:38 process.stdout.write does not

21:38 mebaran151: emezeske: in proper trampolining, do you know what is supposed to be passed to the -main function?

21:39 uvtc: xeqi, created an issue. Thanks.

21:41 ForSpareParts: can anyone point me to good (newbie) resources for building data structures in clojure?

21:42 Almost all my experience so far is in imperative languages, but I've done some haskell, too -- I'm looking for something like the user data types in haskell, any good idiomatic way to build composite data structures.

21:44 brehaut: the default choice in clojure is to not define your own data type; just use maps and vectors

21:44 later on you might find something like defrecord useful, but you can safely ignore it for now

21:45 yoklov: blargh

21:45 amalloy: i don't remember who said it, but i like the suggestion to regard defrecord as an "advanced feature"

21:45 yoklov: mod works different in clojure and clojurescript

21:45 :/

21:46 and if it were fixed it would be slower :(

21:46 brehaut: i think the number of records ive defined in real programs could be counted on one hand

21:46 ForSpareParts: OK. So, what's the right way to organize data together? Just make a map containing several types of data?

21:47 brehaut: yes. keywords make convenient keys

21:47 amalloy: yeah, more or less. maps for "object-y" things, vectors for lists

21:47 (or seqs for lists. i don't mean to imply there's some reason to use vectors specifically)

21:50 ForSpareParts: OK. Thanks!

21:52 yoklov: vectors are more idiomatic imo

21:52 mebaran151: emezeske: I'm not sure if the trampoline is supposed to pass itself as an argument in the generated bat file

21:56 amalloy: yoklov: that's a silly opinion imo. i mean, if you're typing them in by hand, sure; but in real life you use whatever list-analogue makes most sense for your need. probably that winds up being a lazy-seq more often than a vector, but i don't actually know

21:58 * gfredericks adds flatland/useful to his project.clj

22:00 uvtc: gfredericks, I was just looking at flatland/useful. There appears to be a lot of good stuff in there.

22:00 mebaran151: anybody know if technomancy is around? I'd like to confirm one or two things before I mail him a patch

22:00 yoklov: amalloy: i primarially meant if you're typing by hand, all other things being equal. And yeah it's silly but usually fast random access is better than what lists/seqs offer

22:00 technomancy: mebaran151: briefly. what's up?

22:01 yoklov: at least for what i end up doing

22:02 technomancy: uvtc: thanks for opening that issue; would you be up for submitting a patch?

22:02 mebaran151: technomancy: I think I found the actual heart of the trampoline bug, but just to confirm, when a task trampolines, it creates a bat that re passes the entire command string (including the trampoline part) to leiningen/-main

22:02 technomancy: mebaran151: more or less

22:03 uvtc: technomancy, sure. I only just learning Clojure, but I can submit a pull request for a doc patch. :)

22:03 technomancy: I don't know if the thing it creates should be considered a bat or just a file full of commands

22:03 uvtc: s/I only/I'm only/

22:03 technomancy: uvtc: we don't discriminate =)

22:03 mebaran151: and if you pass -main a string like "trampoline repl" it would construe that as a single command right?

22:04 technomancy: mebaran151: depends on the context, I think, but that could be the case

22:05 mebaran151: anyway, I think I misdiagnosed my trampoline issue previous: it was less that the wrong path was being taken and more that \"%*\" expanded to "all commands in a single string"

22:06 technomancy: yeah, quoting in this context is fraught with peril

22:06 so easy to get wrong

22:06 mebaran151: oh man, tell me about it :)

22:07 btw, is there any particular reason the repl task would timeout if launched from a trampoline?

22:19 sweet it looks like cljs repl is working now. thanks for the help technomany; I suppose I just resubmit a patch with my updated fixes?

22:29 technomancy: mebaran151: that'd be great; thanks

22:29 the repl might time out if it expects there to be a leiningen process and a project process present, since trampoline means there's only one process

22:33 mebaran151: technomancy: ah okay, I just wanted to make sure I wasn't breaking anything else while fixing something, heh

22:37 uvtc: technomancy, I issued a pull-request for that doc patch (lein deps), but it went and created a new issue. I think I forgot to include "#562" my the commit message.

22:38 (I mean, I think that's what I was *supposed* to do. :) )

Logging service provided by n01se.net