#clojure log - Sep 30 2012

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

0:03 cjfrisz: mpan: You could certainly do that

0:03 mpan: I think capslock-to-esc in vim is a way better idea

0:04 Urthwhyte: Jj is my preference

0:04 Rarely typed and on home row

0:04 cjfrisz: Hmm

0:04 I'd have to try that one out

0:04 mpan: wait, huh?

0:05 you rebound J to ctrl?

0:05 does that not break everything else you want to do?

0:05 cjfrisz: I think he meant for vim

0:05 Wait...

0:05 No, still think that might be a good idea

0:06 Urthwhyte: Depending on what your repeat is set to, jj works

0:06 Let let check the line

0:09 inoremap jj <Esc>

0:16 davejacobs: i'm having session problems in compojure. i'm using the compojure.handler/site macro to wrap my routes, and my understanding is that that should provide the correct binding for session inside defroutes

0:17 why am i getting "Unable to resolve symbol: session" inside defroutes?

0:19 it seems like the ways in which the session is handled have changed so the docs aren't easy to follow

0:21 duck1123: Does anyone know how in waltz I can trigger an event, but only if the state machine is in a set of states? (connection opened state)

0:24 I wonder if I should just build up a queue of pending events that'll fire as soon as the connection is back in an idle state

0:27 cjfrisz: I think I might be too proud of the piece of code I just wrote

0:27 No, not too proud

0:27 Just gloating about it too much

0:27 Cuz it's a really awesome piece of code

0:27 duck1123: link?

0:27 clojurebot: your link is dead

0:33 cjfrisz: It's probably not going to make sense out of context, but here goes: http://pastebin.com/xLdCQgxN

0:33 It's really more what it does, which needs a blog post to explain

0:38 duck1123: that looks like a function you'd be really happy once it works right

0:39 now it's probably time to break it down

1:30 mpan: &(disj [0 1 2 3] 1 2)

1:30 lazybot: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.IPersistentSet

1:31 mpan: whoops

2:15 spoon16: best template language to use with noir? does everyone agree re: hiccup?

2:16 Raynes: Whatever is best for the problem you're solving.

2:16 Hiccup, Enlive, Mustache, etc.

2:17 Mustache and Enlive are good choices for when you have designers working on your html that don't know Clojure. It's also nice if you like keeping your html and Clojure separate.

2:17 Hiccup is the best option for in-code html generation.

2:18 I'm personally a fan of mustache.

2:20 spoon16: I see

2:20 I'll take a look, that sounds nice… I like using hiccup for generating partials

2:20 but not the templates

2:23 Raynes do you have any examples of actually using mustache on any of your github projects that I could look at/

2:29 Raynes: spoon16: refheap uses it exclusively for templating.

2:29 Not going to say it is a canonical example though. My templates are due for a bit of a cleanup. ;)

2:30 https://github.com/Raynes/refheap

2:30 spoon16: got it

2:30 thanks

4:44 ciccillo: ciao

4:44 !list

8:48 cemerick: jonasen: In case you hadn't seen it: http://groups.google.com/group/clojure-dev/browse_thread/thread/a5242f3365149326

8:56 jonasen: cemerick: I did see it. BTW, my post to the clojure-tools ml seems to be stuck in moderation

8:57 cemerick: jonasen: I green-lighted you right after you sent it. It showed up in my inbox…?

8:58 jonasen: hmm... I don't see it at https://groups.google.com/forum/#!forum/clojure-tools

8:58 cemerick: huh, so it isn't

9:00 piranha: eh... so guys can somebody tell me how do you manage data in clojurescript? I mean if you have semi-complex application, which fetches some data from server and then combines with data from user, and needs to show it in various ways. I don't want to put it in DOM, so I could go with some atoms. But having too much atoms is not really nice, is it? If I have like hundred similar objects, should this be one atom? Or maybe single atom for all dat

9:00 a? And then some system to notify those who subscribed about updates?

9:01 cemerick: jonasen: feel free to resend

9:04 jonasen: cemerick: I wrote it with the google groups web interface so I don't have it anymore.. I'll just rewrite it then.

9:05 cemerick: jonasen: in that case, it may yet show up; I've seen latencies up to 2 days through the web interface

9:06 jonasen: I can forward your email back to you…

9:07 jonasen: cemerick: Please do, and I'll resend it immediately

9:07 cemerick: sent

9:10 jonasen: Ok, it arrived to google groups.. Thanks cemerick!

9:52 raek_: jonasen: fyi, I received two mail from you via the clojure-tools list, one yesterday and one today

10:23 bonega: piranha: I would go for atoms. The granularity depends on the logical context/performance needs

10:25 piranha: bonega: sure, I'm just thinking that I have to manage them somehow so I'm seeking if there is any work was done in this direction

10:25 I'm also wondering if having one single big atom will hurt performance too much

10:27 bonega: Well, one of the reasons for using multiple atoms are non-stalling writes

10:27 in clojurescript I think we still only have one thread

10:28 But I'm not well versed in clojurescript internals...

10:28 er..

10:28 hum

10:29 I see we are not talking about refs

10:44 piranha: bonega: well, there is one thread, so there can't be any race conditions, hehe

10:45 or whatever :)

11:35 devth: i'm trying to format a collection as a string (using map and string join) but need to know if i'm on the last item in the collection. is there an idiomatic way to do that?

11:37 zamaterian: @find lamda

11:37 @find lambda

12:13 SrPx: The lein vimclojure command stopped working... I've installed lein-tarsier and used it once, but now it won't work. http://pastebin.com/iBjveurv any idea?

12:34 nvm got it

12:35 benny__: SrPx, what is that for a command? my ubuntu packaged lein doesnt have it

12:36 SrPx: lein vimclojure if I understood runs a vimclojure server (?) or something that magically enables clojure repl and stuff on vim

13:03 Anyone has an idea what this means? java.io.FileNotFoundException: Could not locate clj_webdriver__init.class or clj_webdriver.clj on classpath: at clojure.lang.RT.load (RT.java:432)

13:05 I have added [clj-webdriver "0.5.1"] to my project. restarted "lein vimclojure". it even downloaded clj-webdriver. but calling (require 'clj-webdriver) makes this error show

13:06 xeqi: SrPx: did you want (require 'clj-webdriver.taxi) ?

13:07 SrPx: xeqi: actually I have tried (use 'clj-webdriver.taxi), (use 'clj-webdriver), same with require, and other combinations, and it did not work. I tried again just after asking and it miraculously worked.

13:08 (?) but thanks

13:33 edengler2: Howdy, having some issues using unquote-splicing and map. Basically, trying to figure out why it appears map does a check for an even number of arguments before unquote-splicing is applied, ie, why `[:client {~@[1 2 3 4]}] fails, yet `[:client {~@[1 2 3 4]}] and `[:client {~@[1 2 3 4]}] and `[:client {~@[1 2 3 4]}] all work

13:33 The docs all seem to indicate that unquote-splicing in a map should lead to a (apply hash-map ...) construct.

13:33 Whoops, ,my examples failed to copy, give me a sec

13:34 ... why `[:client {~@[1 2] ~@[3 4]}] and `[:client {~@[1] ~@[2 3 4]}] and `[:client {~@[1 2 3 4] ~@[]}] all work

13:37 raek: ,'`[:client {~@[1 2 3 4]}]

13:37 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Map literal must contain an even number of forms>

13:37 raek: ,'`[:client (~@[1 2 3 4])]

13:37 clojurebot: (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list :client) (clojure.core/list (clojure.core/seq (clojure.core/concat [1 2 3 4]))))))

13:38 raek: edengler2: the error comes from the reader.

13:39 or wait...

13:39 ,'[:client (~@[1 2 3 4])]

13:39 clojurebot: [:client ((clojure.core/unquote-splicing [1 2 3 4]))]

13:39 raek: ,'[:client {~@[1 2 3 4] :dummy}]

13:39 clojurebot: [:client {(clojure.core/unquote-splicing [1 2 3 4]) :dummy}]

13:41 raek: edengler2: I think the reader first reads the syntax quoted expression and then transforms it. But in your case the "inner" expression is not valid

13:41 edengler2: I guess I am asking the question why the reader is doing a check for even number of arguments before full macro expansion?

13:42 ChongLi: it's eager?

13:42 raek: for ordinary macro expansion that's definitely the case

13:42 edengler2: It looks if I can fake it out by providing an additional dummy unquote-splicing, but it seems odd

13:42 raek: a macro is implemented as a function that take and return clojure data

13:43 reading is just one way to construct that data

13:43 so a workaround in your case could be `[:client (hash-map ~@[1 2 3 4])]

13:43 edengler2: For example, I do get a bad mapping if I provide an odd number of elements for the mapping (ie, there is an additional post-check), `[:client {~@[1 2] ~@[3]}]. I would have thought only this check would be done.

13:45 For the workaround, I was thinking of `[:client {~@[1 2] ~@[]}], ie, add an extra expansion for the reader, but adds no new entries to the eventual expansion

13:45 raek: the problem is that the macro expander needs valid clojure data structures as its input

13:46 ,[:client {~@[1 2] ~@[]}]

13:46 clojurebot: #<IllegalStateException java.lang.IllegalStateException: Attempting to call unbound fn: #'clojure.core/unquote-splicing>

13:46 raek: ,'[:client {~@[1 2] ~@[]}]

13:46 clojurebot: [:client {(clojure.core/unquote-splicing [1 2]) (clojure.core/unquote-splicing [])}]

13:46 edengler2: Ok, so I guess adding the extra dummy entry is the way to go

13:47 raek: I would go with `[:client (hash-map ~@[1 2 3 4])]. In that case the intermediate forms make sense too

13:47 ,'[:client (hash-map ~@[1 2 3 4])]

13:47 clojurebot: [:client (hash-map (clojure.core/unquote-splicing [1 2 3 4]))]

13:49 raek: or perhaps you could simply do this: `[:client ~{1 2 3 4}]

13:50 edengler2: Unfortunately, `[:client (hash-map ~@[1 2 3 4])] doesn't end up at the same spot, my entry of `[:client {~@[1 2 3 4] ~@[]}] ends up with [:client {1 2, 3 4}] rather than [:client (clojure.core/hash-map 1 2 3 4)]

13:50 raek: what do you mean by "end up at the same spot"?

13:51 edengler2: Ie, equivalent to `[:client {1 2 3 4}]

13:51 raek: {1 2, 3 4} means the same thing as (clojure.core/hash-map 1 2 3 4) when evaluated

13:52 edengler2: Will give it a try, but all of this is interacting with other libraries for XML and JSON

13:53 raek: edengler2: how is the "1 2 3 4" data represented when you receive it in your case?

13:53 edengler2: Ie, the other libraries are processing the output of the above expansion, and looks like they do not like the clojure.core/hash-map

13:53 raek: ah, you are generating data and not code?

13:53 edengler2: For example, in one place I am trying to generate attributes that depend if they exist.

13:53 hfaafb: code is data!

13:54 :p

13:54 raek: edengler2: I think it would be even simpler to just build the map before you splice it in

13:55 edengler2: raek: Possibly, Any, thanks for the help!

13:55 raek: like `[:client ~(...code that builds the map...)], possibly using (into {} (for ...)) or (zipmap ...)

14:00 Sgeo: Would it be a bad idea to use Hiccup for non-HTML?

14:01 I saw somewhere that it has issues generating arbitrary XML?

14:01 augustl: Sgeo: iirc it has special knowledge of some HTML tags, not sure if that's configurable

14:01 Sgeo: Something about namespaces IIRC

14:01 I should note that I know little about XML

14:03 augustl: I'd imagine you could support that in hiccup quite easily

14:03 something like [:nynamespace :tagname {:attrs "here"} "contents here"]

14:08 yankov: is there a fast way to concat seq's elements into one string? apply str works slow if you got big list

14:13 Frozenlock: yankov: clojure.string/join perhaps

14:14 yankov: ,(time (clojure.string/join (range 10)))

14:14 clojurebot: "Elapsed time: 0.171213 msecs"

14:14 "0123456789"

14:14 yankov: (time (apply str (range 10)) )

14:14 oops

14:14 ,(time (apply str (range 10)) )

14:14 clojurebot: "Elapsed time: 0.144494 msecs"

14:14 "0123456789"

14:15 yankov: looks like join is even slower a bit

14:19 Frozenlock: Indeed. I get in the 0.0X msecs when using it with string directly though. Btw, what kind of performance are you looking for?

14:27 xeqi: ,(time (let [x (StringBuilder.)] (doseq [s (range 10)] (.append x (str s))) (.toString x)))

14:27 clojurebot: "Elapsed time: 0.301244 msecs"

14:27 "0123456789"

14:27 xeqi: heh, not that timing with clojurebot is accurate

14:48 Moses_: Hi, I'm looking for an open source web app example with a good test suite. I want to learn how to properly write tests for web apps in clojure. Anyone know of any projects that could be used for this?

14:49 _ulises: Moses_: what level of testing are you after?

14:50 Moses_: you may want to look at the tests for clj-webdriver

14:50 Moses_: if you're using noir, you can look at the util.test namespace as it has many useful functions there for testing

14:50 Moses_: Wow, okay thank you _ulises

14:50 I'm using Compojure, think that util.test is still releveant?

14:51 _ulises: Moses_: in any case, depending on the level of testing you're after, most webdev libraries deal with functions that return a map with the response, so it's a case of checking those maps for what you want

14:51 Moses_: indeed

14:51 weavejester: Moses_: There's ring-mock for creating request maps

14:51 xeqi: Moses_: I created kerodon for clojars's test suite

14:52 SrPx: So, in clojure, can I create a function with 2 separed definitions, in a way that (foo obj_1) and (foo obj_2) will return 2 different values?

14:52 Moses_: Thank you weavejester and xequi, I'll check those out

14:53 _ulises: SrPx: I don't know but I wouldn't think so

14:54 xeqi: SrPx: maybe multimethods or protocols

14:54 SrPx: Well I need a 'character' class, and a (image my-char-instance) that will return the character's image. What is the clojure linguistic approach to this?

14:55 Moses_: I know you can do this (defn ([x] &body) ([x y] &body)) but I don't know if that's what you mean SrPx

14:55 SrPx: Would the instance of the character be a simple hash with {:type "character"} and image a function inside it like {image my-f} ?

14:55 _ulises: SrPx: I was about to suggest multimethods

14:55 SrPx: if that's the case, you can dispatch on :type

14:55 SrPx: what is :type ?

14:56 Can I dispatch in other things ? Like the value of a key

14:56 _ulises: SrPx: yes, that's what I meant by :type

14:56 SrPx: remember that keywords are functions

15:00 SrPx: Just compiled the line 4, (derive :square :shape), got an error, http://o7.no/R54Hm0 , any idea ?

15:01 java.lang.AssertionError: Assert failed: (namespace parent)

15:01 assert failed, namespace parent? hm

15:01 gfredericks: SrPx: maybe you can only derive namespaced keywords?

15:01 e.g. (derive ::square ::shape)

15:02 * gfredericks is pretty sure that sounds right

15:02 SrPx: :: ?

15:02 _ulises: SrPx: this is what I meant by :type and multimethods https://www.refheap.com/paste/5399

15:02 gfredericks: SrPx: ##::foo

15:02 SrPx: ##(identity ::foo)

15:02 lazybot: ⇒ :clojure.core/foo

15:02 gfredericks: it expands into a namespaced keyword in the current namespace

15:02 so you could also type out :my.ns/foo if you wanted to

15:03 SrPx: ##(identify ::foo) ?

15:03 lazybot: java.lang.RuntimeException: Unable to resolve symbol: identify in this context

15:03 SrPx: ##?

15:04 ##::foo

15:04 gfredericks: ## just triggers lazybot

15:04 SrPx: ##(identify ::foo)

15:04 lazybot: java.lang.RuntimeException: Unable to resolve symbol: identify in this context

15:04 SrPx: why it does not work with me

15:04 xeqi: ## = inline lazybot eval, & = standalone lazybot eval

15:04 gfredericks: you're using identify instead of identity

15:04 SrPx: ohh sorry

15:04 gfredericks: ,::foo

15:04 clojurebot: :sandbox/foo

15:09 SrPx: ,(isa? java.util.HashMap ::collection)

15:09 clojurebot: false

15:13 SrPx: _ulises: I dont get it, (defmulti foo :type) ? :type ? Was not it supposed to be a function ?

15:13 Oh wait

15:13 keywords are functions that work on hashes right

15:14 _ulises: SrPx: exactly :)

15:14 SrPx: I get it now! Great!

15:15 Actually this is awesome, thanks!

15:15 _ulises: SrPx: you can have any function you want instead of :type

15:15 SrPx: as long as you have matching values instead of :image and :character

15:16 SrPx: using class as dispatch function will give you the type dispatch you'd expect in Java for instance

15:16 SrPx: _ulises: so this does not even need derive etc

15:16 _ulises: sorry, using class? What?

15:17 _ulises: ##(class "foo")

15:17 lazybot: ⇒ java.lang.String

15:17 _ulises: SrPx: that ^^^^

15:18 SrPx: so you mean I can .. hmm like, make like, (defmulti inverse class) (defmethod inverse java.lang.String [] ...) to extend java types?

15:19 _ulises: SrPx: not extend java types, but dispatch based on them

15:19 SrPx: hmm but why?

15:19 _ulises: SrPx: that's what you wanted to do originally?

15:19 SrPx: I mean, that was your original question

15:20 SrPx: on a second read, you weren't asking specifically about java types

15:20 SrPx: but that's the usual answer "have a Type1 and a Type2 and then overload based on that" etc.

15:20 SrPx: I see!

15:23 Should I use keywords, symbols or strings to define the type of my object? {:type :character}, {:type "character"}, etc?

15:24 gfredericks: using namespaced keywords gives you the derive functionality you were looking for earlier

15:24 otherwise regular keywords are probably fine

15:25 if there's any chance this 'type' will be mixing around in other systems then namespacing is safer

15:29 SrPx: Hmm

15:30 OK, thank you very much.

15:30 Unrelated question, is it possible to make a macro such as $test becomes (foo test)? This would be an reader macro, right? I know clojure does not have those, but I have heard it is possible to implement with some hacking

15:30 a reader*

15:32 gfredericks: SrPx: I'm not sure what the essence of what you're describing is. it's the '$' expanding, so that $bar becomes (foo bar)?

15:33 SrPx: Yes, specifially, I'd want $something to expand to a function that would select a html element with id=#something

15:33 gfredericks: well with a few more characters you could do ($ :something), but that just sidesteps the question

15:34 SrPx: I know, I'm fine with ($ :something). Just wondering if it would be possible

15:34 gfredericks: I think the only way to get that kind of concision is if you wrapped your whole code in a (regular) macro that did the replacement; e.g. with-dollar-selectors

15:39 SrPx: Hmm I see.

15:40 gfredericks: that's the main limitation of macros; you can do damn near anything, but it has to start with a parenthetical s-expression

15:54 SrPx: Why it does not provide a reader macro?

15:54 They are so powerful

15:54 gfredericks: fear of messy syntax?

15:54 SrPx: Clojure would be perfect with them

15:55 but you should not deny power to the programmer, it is the fundamental of the lisp spirit

15:55 ):

15:56 gfredericks: what about libraries?

15:56 SrPx: what?

15:56 clojurebot: What is meta

15:56 gfredericks: you could get two libraries that both define the same reader macro

15:57 SrPx: Libraries should be discouraged to use them, but you should allow the programmer to define it for personal use if he wants to

15:57 libraries can define the same macro anyway, right?

15:57 gfredericks: no they're always defined in namespaces

15:58 casion: there is one thing I've learned from using C a lot… if you allow people to do something, even if you strongly advise against it, they will do it

15:58 and they will do it a lot

15:58 and they will defend their right to do it

15:58 and everyone fucking hates it

15:58 including, eventually, the person who did it

15:58 gfredericks: :)

16:00 casion: SrPx: http://clojure-log.n01se.net/date/2008-11-06.html

16:01 starting at 18:39

16:02 gfredericks: casion: (you can link directly to the 18:39)

16:02 casion: gfredericks: oh…

16:02 i hate websites that have things like that essentially hidden :|

16:03 steven123: posted a question on stackoverflow: why do bindings in REPL not work? http://bit.ly/TX6NKJ

16:03 casion: when will people learn that not everyone uses a mouse to browse the web

16:03 steven123: can anybody help?

16:09 SrPx: I'm so sad reading that log

16:09 AWizzArd: rhickey: I don't want to convince anyone that reader macros are a good idea in general. But I think that you can't forsee everything, and people might come into situations where 1 or 2 reader macros are really helpful

16:09 To be honest I would live of reader macros for building my own syntax on top of lisp

16:10 I've chosen clojure over cl for many reasons, but the lack of reader macro thing really hurts me ):

16:11 I don't see why you couldn't implement namespace stuff over reader macros, also

16:11 mpan: clojure convinced me to try a lisp outside an academic context with its interop

16:13 gfredericks: SrPx: because once you have to specify the namespace of your reader macro you lose all the concision

16:13 SrPx: it is awesome but having to write ($ "#myid") instead of $myid all around, for example, is a huge difference to be honest

16:14 gfredericks: chouser had an interesting idea though

16:14 SrPx: gfredericks: I dont understand it well, if you can define a macro for ($ something), why cant you define a reader macro for strings starting with $? $something

16:15 gfredericks: oh hmm...what if you could do (ns foo (:reader-macros [some.lib/$ :as $])), and then it would only apply for your namespace

16:20 SrPx: something like that, I'm not sure, but I'm positive it's possible

16:21 it is the same thing in essence, just that it is a string preceding a symbol, instead of the first string in a s-expression

16:23 yankov: ,(count ( time (map str (range 10000))))

16:23 clojurebot: "Elapsed time: 0.05503 msecs"

16:23 10000

16:24 spoon16: /reload style

16:24 yankov: ,(count ( time (apply str (map str (range 10000)))))

16:24 clojurebot: "Elapsed time: 33.012849 msecs"

16:24 38890

16:24 yankov: seriously.. is there a way to make the second one faster?

16:24 gfredericks: yankov: the first one doesn't do anything

16:25 that's why it's so fast

16:25 ivan: can you not write some macro that turns every symbol that starts with $ into two forms?

16:25 yankov: gfredericks: ah..

16:25 gfredericks: ivan: yeah but he'd need a top-level macro call

16:25 ivan: right

16:25 gfredericks: ,(time (count (map str (range 10000))))

16:25 clojurebot: "Elapsed time: 23.317793 msecs"

16:25 10000

16:26 gfredericks: 94% of naive clojure benchmarking just times a noop :)

16:26 yankov: hm..

16:27 anyway, there should be a way to use something instead of apply str. the thing is that server needs to convert seq into a one string before sending it to a client

16:28 and that ends up being kinda slow. like 1.5k op/sec for a list of 600 elements

16:28 xeqi: ,(count (time (let [x (StringBuilder.)] (doseq [s (range 10000)] (.append x s)) (.toString x))))

16:28 clojurebot: "Elapsed time: 17.474309 msecs"

16:28 38890

16:28 gfredericks: xeqi: apply str already uses a stringbuilder

16:29 yankov: at the very least if you apply str you can get rid of the map str

16:29 yankov: does amount of arguments passed to str matter? maybe when I pass 600 args that makes it slow?

16:30 gfredericks: yankov: I wouldn't think so

16:31 yankov: hm, then it must be my map. in real code it's more complicated than just str

16:31 i just benchmarked it wrong

16:31 gfredericks: yankov: this is an http server? I wouldn't think you'd have to assemble a string before responding

16:31 yankov: gfredericks: not http. sort of custom protocol

16:32 gfredericks: even so you ought to be able to do streaming

16:33 yankov: gfredericks: makes sense. i tried to send a separate response for each elements but it was very slow. but again, i could be doing it wrong

16:34 will take a look, thanks

16:46 spoon16: stencile (https://github.com/davidsantiago/stencil) or clostache (https://github.com/fhd/clostache) for rendering mustache templates?

16:50 xeqi: refheap uses stencil, so I'd end up choosing it

16:52 SrPx: How are :keywords used as functions? I mean how is it possible? I have read something about that but I forgot

16:53 spoon16: but why did Raynes choose stencil for refheap… I can't really tell the difference between the two except that the author of stencil implies that performance was important during his development and he has done some profiling

16:53 I'm leaning towards stencil as well for that reason

16:53 ,(:test {: test "hello world"))

16:53 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Invalid token: :>

16:53 jondot`: seeing some new projects for android/clojure - anyone really doing this beyond just playing around?

16:54 spoon16: ,(:test {:test "hello world"))

16:54 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )>

16:54 spoon16: I'm terrible at using clojurebot

16:54 ,(:test {:test "hello world"})

16:54 clojurebot: "hello world"

16:56 spoon16: SrPx: keywords implement IFn with one argument (a map) and an optional second argument (a default value)

16:56 SrPx: For example (:mykey my-hash-map :none) means the same as (get my-hash-map :mykey :none)

16:56 SrPx: docs… http://clojure.org/data_structures#Data%20Structures-Keywords

16:57 SrPx: where is it implemented? hmm

16:57 IFn?

16:58 spoon16: IFn is the Java interface that identifies functions in clojure

16:58 anything that can be used in the operator position of a sexpression implements IFn

16:58 Keyword is the Java type implemented by all :keyword instances you use in Clojure

16:59 and Keyword implements IFn so it may be used as an operator

16:59 SrPx: see the code https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Keyword.java

17:07 nightfly_: spoon16: Yay, that explains a very confusing error message I was getting the other day.

17:07 jballanc: anyone know off-hand what repo/branch the Clojure+Lua work was in?

17:08 spoon16: nightfly_: cool, clojure makes way more sense if you spend the time to reference the github repo and really learn all the different data structures… I am still just beginning that process

17:34 nkoza: What's the simplest way to access a Java class instance protected field?

17:36 emezeske: nkoza: Maybe 'proxy ?

17:47 Raynes: spoon16: Performance. Stencil is the fastest spec compliant stencil implementation around.

17:47 gf3: My brain is failing me, what's the function to execute an arbitrary amount of expressions and only return the last one's value

17:47 (something x y z) ; z

17:47 Raynes: gfredericks: do

17:47 It isn't a function.

17:47 cjfrisz: gf3: do

17:47 gf3: Crap

17:47 Raynes: gf3, not gfredericks

17:48 cjfrisz: I know Raynes already answered...

17:48 gf3: Wrong channel


17:48 (Looking for Racket)

17:48 Raynes: lol

17:49 gf3: Just FYI, in Racket it's (begin)

17:50 evhan: gf3: I think it's `begin` in Racket.

17:50 gf3: AHEM

17:50 evhan: gf3: Ah, there you go.

17:58 nkoza: emezeske: you cant use "proxy" to access protected fields of the parent class :(

17:58 and I dont want to use AOT/gen-class

18:00 Raynes: nkoza: https://github.com/arohner/clj-wallhack/blob/master/src/wall/hack.clj#L15

18:01 Oh, fields. There is a function for that too below that one.

18:01 nkoza: Raynes: thanks

18:06 spoon16: you guys know of any other projects like wallhack but generally make reflection and exploration of objects simpler? I'm just looking at libraries that enrich the repl

18:11 kaoD: hi

18:34 what the hell is going on

18:34 ohpauleez: kaoD: It's called a netsplit

18:35 http://en.wikipedia.org/wiki/Netsplit

18:35 kaoD: hmm nevermind, those where "Excess Flood" messages

18:35 (completely missed it, but it's not a netplit)

18:41 alex_baranosky: does anyone know of a Clojure library for turning time durations into English (like "1 day", "2.34 days", etc)

18:42 gfredericks: "twoish days"

18:43 Raynes: alex_baranosky: lazybot has an implementation of that.

18:44 alex_baranosky: https://github.com/flatland/lazybot/blob/develop/src/lazybot/utilities.clj#L7

18:44 alex_baranosky: Raynes: thanks

18:46 firesofmay: Hi, can anyone tell me if we can run clojure on raspberry pi? Any idea?

18:46 gfredericks: man rhickey was all over the IRCs back in the day

18:46 mpan: firesofmay: pretty much the normal way

18:46 firesofmay: mpan, have you tried it?

18:47 mpan: no, but since you can get a regular linux distro on it, the rest of the steps are pretty much the same

18:47 firesofmay: mpan, I see.

18:47 spoon16: firesofmay: if you are running Debian on the Raspberry Pi you can 'sudo apt-get install openjdk-6-jre'

18:47 ivan: http://raspberrypi.stackexchange.com/questions/91/is-there-a-jdk-with-a-jit-compiler-available

18:47 mpan: I'm not aware of anything x86 specific along the line

18:47 so the same steps should work fine as they do on your regular computer

18:48 firesofmay: spoon16, mpan ivan I see. Thanks.

18:48 anyone hacked on raspberry pi here?

19:25 cjfrisz: Woo, finally published a blog post about how CTCO works

19:25 Now I don't have to feel guilty about never blogging

19:25 Plus I can write shorter updates about things I figure out how to optimize

19:26 dnolen: cjfrisz: cool!

19:28 ohpauleez: definitely cool

19:43 wei_: what's the most mature templating and event handling library for clojurescript?

19:57 one-luck: ok what now?

19:58 ohpauleez: wei_: What specifically are you looking to do?

20:01 most people use some mix of domina, enfocus, singult, crate, and jayq

20:03 wei_: I'm trying to listen to clicks on elements with a certain class. tried it with domina just now: (dom/listen! (dom/by-class "thumb") "click" thumb-clicked). but it results in Uncaught TypeError: Cannot call method 'call' of undefined

20:31 jcromartie: ,(count (time (apply str (range 1e5))))

20:31 clojurebot: "Elapsed time: 290.873695 msecs"

20:31 488890

20:32 jcromartie: just butting in, don't mind me

20:33 gfredericks: ,(->> 1e5 range (apply str) time count)

20:33 clojurebot: "Elapsed time: 221.043181 msecs"

20:33 488890

20:34 muhoo: jcromartie: you can pm the bot

20:35 cjfrisz: link?

20:35 cjfrisz: muhoo: http://www.chrisfrisz.com/blog/?p=234

20:54 wei_: solved my issue above. I had to import domina.events in addition to domina

20:54 err, require

21:30 n00b_: I'm currently looking for the source of the function applyTo - it's in clojure.core, but the definition isn't there and core does not import any other namespaces - how is this possible?

21:31 relevent link: http://code.google.com/p/clojure/source/browse/trunk/src/clj/clojure/core.clj

21:38 gert: has anyone tried to integrate Chas Emerick's Friend with a clojurescript app?

21:38 Raynes: n00b_: That's a Java method, not a Clojure function.

21:39 That is also not the right repository.

21:39 https://github.com/clojure/clojure

21:39 The code.google stuff is so old that it's kinda magical you found it and not the git repo.

21:40 brehaut: gert: cemerick might have ;)

21:42 n00b__: In the implementation of apply there is a fn applyTo - however when I look for it in core I find nothing, and no imports. How is this possible?/where does this fn come from?

21:42 cemerick: gert: ClojureScript is just a library in a browser as far as Friend is concerned.

21:43 gert: I know

21:43 :)

21:44 I'm trying to come up with a proper workflow/architecture for a clojurescript app + Chris Granger's Fetch + cemerick's Friend

21:44 xeqi: that does take some work

21:44 fetch + friend

21:45 gert: I think I'm close to getting something working, but it's a bit messy at the moment. I was just wondering if anyone else has done anything authentication-related in cljs

21:45 xeqi: gert: https://github.com/xeqi/friend-fetch-example has a working example, but I really need to get back and clean it a bit

21:46 gert: oh!

21:46 thanks xeqi, I'll check that tout

21:46 *out

21:46 xeqi: hmm, might make a good blog post too

21:47 cemerick: xeqi: that's a *really* hard way to do it

21:47 gert: I'm basically doing an xhr post request to a login url that gets intercepted by Friend. That part, and the authentication, works.

21:47 I just need to return a result

21:47 xeqi: ah, then fetch doesn't matter much in that case

21:47 ohpauleez: xeqi: If you're going to use fetch to authenticate, I suggest you replace it with Shoreleave's remotes

21:48 cemerick: gert: just make a request to a non-fetch URI in order to obtain an authenticated session, and then all of your RPC after that point with the same host will carry those credentials.

21:48 ohpauleez: to get CSRF protection and proper XSS handling

21:49 xeqi: ohpauleez: heh, I would look at shoreleave and cemerick's ring-remote; not a particular fan of noir/fetch, that was just a one off

21:49 gert: xeqi: I'm using fetch with Compojure

21:49 it's trivial to replace the noir defpage with a route that calls call-remote

21:50 it'd be easy to remove any dependency on noir or compojure from fetch

21:50 cemerick: gert: doing so would leave you with shoreleave remotes, essentially.

21:50 (AFAICT, I never used fetch myself)

21:51 gert: cemerick: ohpauleez: I guess it's time for me to have a closer look at Shoreleave. :)

21:51 ohpauleez: xeqi: Ahh gotcha. I actually have a few key issues with Noir, but I haven't sat down to rework some ideas I have

21:51 gert: Enjoy the rabbit hole!

21:52 In all honesty, the code is pretty straight forward - it really is all the grunt work you'd end up doing for a decent CLJS app

21:53 gert: ohpauleez: cheers! it's been a joy so far. I'll see how far I get with Shoreleave. this is the beginning of a fairly complex client side app and it's all very exciting. :)

21:53 ohpauleez: gert: Awesome to hear it! I've had a blast working on CLJS stuff and a lot of success. I have some pretty interesting metrics to share at the Conj

21:54 Raynes: ohpauleez: What are the key issues?

21:54 ohpauleez: Raynes: With?

21:54 Noir?

21:54 clojurebot: noir is great

21:54 Raynes: You said you have some key issues with Noir. Just curious what they are.

21:55 gert: ohpauleez: awesome! if I wasn't all the way in New Zealand I'd go to Conj. Or if my startup had the funds to send me. Maybe next year. :)

21:56 ohpauleez: ahh yeah - so i think the pieces you've pulled out into other libs lib-noir and the other one for looking across classpath stuff are awesome. It opens up the door for using metadata on functions rather than stateful atom bashing

21:56 really

21:56 I just don't want a macro for my functions, I want real functions. And the style of using an atom gets the job done, but I'm not sure it's totally needed

21:57 that said, I really haven't dug deeper

21:57 xeqi: ohpauleez: did you ever publish the todoMVC example mentioned on http://www.pauldee.org/blog/2012/production-clojurescript/ ?

21:57 ohpauleez: or tried my hand at it, so please take it with a huge grain of salt

21:57 Raynes: ohpauleez: I agree regarding the statefulness of noir. But once you pull that away, you get compojure. So, I've just been using compojure and lib-noir lately.

21:57 ohpauleez: xeqi: No, but there is a decent demo linked from Shoreleave's github

21:58 Raynes: ahhh cool. That was my thought at well. And I think you could still auto build routes via reflection on metadata, I'm not sure if that's a good idea or not

21:59 cjfrisz: Anybody else amused that the "call for presentations" is still up on the Conj site?

21:59 And also dying for a comprehensive list of who all is speaking and about what?

21:59 xeqi: cjfrisz: not surprised; was told the list of presentations should have been up at the end of last week

22:00 ohpauleez: cjfrisz: side note - great blog post

22:00 SegFaultAX: What's lib-noir?

22:00 Raynes: xeqi: I was told that it was put up next week. The Doctor doesn't usually lie about these things.

22:00 $google lib-noir

22:00 lazybot: [noir-clojure/lib-noir · GitHub] https://github.com/noir-clojure/lib-noir

22:01 cjfrisz: ohpauleez: Thanks! I really appreciate feedback.

22:04 xeqi: Raynes: but rule 1...

22:05 duck1123: don't wander off

22:05 xeqi: the other rule number one

22:05 duck1123: sorry, wrong Doctor

22:06 ohpauleez: What is rule number one? I'm trying to remember

22:06 InternetFriends: now you're going to die

22:06 xeqi: ohpauleez: http://tardis.wikia.com/wiki/The_Doctor%27s_Rules

22:07 duck1123: Eleven's rule #1 is "the doctor lies"

22:07 ohpauleez: Ahh yes, the doctor lies

22:08 the only one I remember is the last one, "Time is not the boss of you"

22:09 duck1123: ahh, speaking of... I need to go watch the new one still. night all

22:24 jkdufair: would anyone have any idea why a sequence i've obtained via a jdbc query would not cause the body of my map fn to execute but can be materialized via doseq?

22:25 ohpauleez: map is lazy, and nothing is forcing its execution

22:25 jkdufair: ah!

22:25 ohpauleez: when you doseq, you realize the entire sequence, making the map (and map fn) happen

22:25 jkdufair: didn't know map was lazy

22:25 thank you!

22:25 ohpauleez: totally welcome!

22:27 jkdufair: heh. read right past "lazy" in (doc map)

22:28 cjfrisz: Well, I'll be

22:28 I somehow never noticed that, either

22:29 jkdufair: also, args are all passed by ref, yes?

22:30 ohpauleez: jkdufair: reduce is lazy too, as are things like keep, remove, etc

22:31 jkdufair: super. makes total sense. i just hadn't realized my seq yet and couldn't figure out why my damn debug stmts weren't happening

22:31 Scriptor: ohpauleez: how is reduce lazy?

22:31 ohpauleez: jkdufair: you can always force realization if you need to bring everything into ram

22:32 jkdufair: no i actually don't

22:32 ohpauleez: Scriptor: I'm almost certain it is, no?

22:32 casion: I don't think reduce is

22:32 Scriptor: ohpauleez: it can't be, because it doesn't always return a lazy seq

22:32 ohpauleez: Ohh right

22:32 duh

22:32 Scriptor: reductions is lazy, however

22:37 jkdufair: ohpauleez: you broke thru a 2 day logjam i had. whew. i love clojure

22:37 mpan: yea, I got hit really hard by that recently

22:38 casion: speaking of logjams… after all the screwing around with clojure.xml, clojure.zip, clojure.data.zip/xml, clojure.data.xml

22:38 mpan: but I figure, it's the sort of wall you run into once, and in the future you remember to consider it

22:38 casion: the answer was to just use enlive

22:38 which seems to work correctly and very easly

22:38 mpan: what did you want to do?

22:38 casion: parse, modify and render xml

22:38 mpan: I think I'm gonna need to generate xml tomorrow or the day after

22:39 jkdufair: i'm rather enjoying enlive

22:39 casion: spent 4 days working on it, searching, searching irc logs and asking questions in here

22:39 jkdufair: my app is primarily a web scraper and enlive makes things very straightforward

22:40 mpan: wait, how does enlive help you with taking in xml?

22:40 casion: mpan: it has xml-resource

22:40 which uses the sax parser

22:40 mpan: but nicer than using sax directly, I hope?

22:40 casion: same as clojure.xml iirc

22:40 yes

22:40 mpan: awesome thanks

22:40 casion: the biggest benefit is that it has xpath-like element referencing

22:41 with css syntax

22:41 AND it renders properly

22:41 which clojure.xml does not do

22:41 mpan: wait, which part doesn't it?

22:41 should I use that and not clojure.xml, then?

22:42 casion: clojure.xml does not render properly

22:42 mpan: render as in?

22:42 casion: it has issues with whitespace and character entities

22:42 render, print, emit

22:42 mpan: ok

22:42 thanks

22:42 casion: the process of tree -> xml

22:43 enlive doesn't support xml namespaces though

22:43 but that's not an issue for me

23:07 spoon16: does hiccup support namespaced attributes on output?

Logging service provided by n01se.net