#clojure log - Jul 22 2011

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

0:27 ckirkendall: logout

0:44 scottj: Scriptor: just any announcement

1:48 ahriman`: íó ÷å

1:50 http://paste.org.ru/?7jn3ae i can add record, but link like localhost:8080/post?content=ddd&title=222 doesn't work. it adds record but all of properties are NIL

2:46 amalloy: technomancy: going to be a busy few days/weeks fielding questions about getting started with clojure, looks like

2:47 since you are foolish enough to maintain emacs (and lein? but i guess the new wave won't really care)

4:13 fliebel: Does ClojureScript do web workers?

4:18 vijaykiran: Hi All, is there a function that will take a list of fns and an arg and return the list of fn(arg)s ?

4:19 e.g. (somefn '(fn1 fn2 fn3) arg) = '(fn1(arg) fn2(arg) fn3(arg))

4:19 brehaut: ,(map #(% 1) [inc dec])

4:19 clojurebot: (2 0)

4:19 brehaut: ,((juxt inc dec) 1)

4:19 clojurebot: [2 0]

4:20 vijaykiran: brehaut: cool thanks!

4:21 brehaut: vijaykiran: the map version is definately lazy; i dont _think_ the juxt version is

4:23 vijaykiran: brehaut: ok, I didn't think of map like that - this is 'code is data' at work - right ?

4:24 brehaut: right

4:24 juxt is a special case of map really

4:24 (although its not implemented as such)

4:25 vijaykiran: ok.. also, I have another quick question - (prbly emacs/my setup) when I C-c C-k a file with an fn that has a doc string, (doc thatFn) isn't printing the docstring .. any idea what might be wrong ?

4:26 brehaut: i'll leave that for someone else

4:27 dsantiago: Have you use'd it into your namespace at the repl?

4:27 opqdonut: no, this is not "code is data" at work

4:27 this is merely "functional programming" at work

4:27 kumarshantanu: vijaykiran: are you connected to the swank-server through SLIME?

4:29 vijaykiran: yes I use slime-connect, c-c c-k the file, I can use use the function call it but the (doc thatfn) won't print the string

4:33 if I type [in slime-repl] (defn blah [] "some docstring") \n (doc blah) it just prints nil (Apart form the fn name and the args)

4:34 dsantiago: Ah, there's the problem.

4:34 The doc string should come before the arg list vector.

4:34 opqdonut: common mistake :)

4:35 * vijaykiran snaps the head

4:36 vijaykiran: ok that was super dumb of me - thanks guys :-) I was fooled by how the doc prints the out put first args then string

4:51 sakuradzukamori: ÷¸÷¸

5:12 fliebel: Wait, did I just ask a question and leave? I guess I'm to busy rebooting. The question was about concurrency in ClojureScript.

5:19 lnostdal-laptop: no one has answered it yet, fliebel

5:20 fliebel: lnostdal-laptop: Okay, that's good and bad :)

5:36 raek: cool, the video is up: http://blip.tv/clojure/rich-hickey-unveils-clojurescript-5399498

6:00 hiredman: clojurebot: ping

6:00 clojurebot: PONG!

6:00 hiredman: jesus, I have to ignore lazybot now too?

6:03 fliebel: hiredman: Has he spammed you, eaten your lunch, or killed a friend?

6:03 hiredman: fliebel: lazybot really need to tell me that clojurebot responded 493 milliseconds after my ping

6:04 fliebel: hiredman: *blush* that's my fault even.

6:04 hiredman: well, it's not going to bug me again

6:05 fliebel: hiredman: Raynes said sexpbot would change name weekly, starting from now :P Something about iTunes gift cards IIRC.

6:06 hiredman: great

6:07 fliebel: hiredman: That was a joke, I hope. But in all seriousness, I did not write that plugin to annoy people, and it's not like anyone is actually using it.

6:08 I could ask them to disable it if it bothers you.

6:10 vijaykiran: I found the root cause of my docstring The Joy of Clojure puts the doc string *after* the arg list vector ..

6:11 fliebel: ~logs

6:11 clojurebot: logs is http://clojure-log.n01se.net/

6:11 ahriman`: ÷¸÷¸

6:11 vijaykiran: not sure if any one has the book handy - on page 131 - (defn manip-map [f ks m] "Takes a function..

8:08 puffnfresh: hey everyone, I'm having a hard time defining macros in my ClojureScript

8:08 anybody had any luck?

8:09 I've currently got: (ns a.core (:require-macros [a.macros :as macros]))

8:10 but when I try to reference the macro with (macros/m 1 2 3) - ClojureScript compiles it as a function call

8:14 looks like I just got it working

8:19 clgv: puffnfresh: can you post a gist?

8:19 puffnfresh: sure, will do in a second

8:27 clgv: https://gist.github.com/1099350

8:27 Scriptor: hmm, trying to do require in the clojurescript repl gives me "Use of undeclared var cljs.user/require"

8:28 clgv: puffnfresh: hmm looks about right. so you should have (println "Hello!") in main

8:29 puffnfresh: yeah, that code works :)

8:29 mjg123: Scriptor: I've got a similar trouble, "Use of undeclared Var cljs.user/doc"

8:30 clgv: puffnfresh: so which does not and how does it fail?

8:31 Scriptor: mjg123: yep, I get the same problem when I try to use doc

8:32 mjg123: hrmmm

8:32 puffnfresh: clgv: sorry, it's fine now

8:32 not sure how I got it working

8:32 but that code works

8:33 clgv: puffnfresh: maybe you forgot syntax-quote in your previous implementation of the macro

8:35 woah. replacing defstruct by defrecord made my program slower - that's not what it is supposed to :/

8:37 hsuh: i've been getting http://pastebin.com/7C8QFr7A every few days, sometimes weeks.. what could i do about it ?

8:39 clgv: hsuh: first search for the first occurence of one of your clojure files in the stacktrace. it might be hidden in the cause of this exception or in the cause of the cause and so on

8:40 hsuh: isn't that the stacktrace of there is something else to look at? only lists java files

8:40 (clojure source files)

8:41 clgv: check if the exception has a cause

8:42 e.g. (print-stack-trace (.getCause *e))

8:42 hsuh: hm. and if i'm not running a repl?

8:42 should i put the code you pasted on the top level of my app ?

8:42 clgv: wrap a try-catch-block around it

8:42 hsuh: so the next time it happens..

8:42 ok

8:45 i'll try that.. tks

8:58 _ato: hsuh: interesting exception. reading the referenced bit of Keyword I would guess it's a race of some sort

8:59 maybe two threads interning the same keyword simultaneously

8:59 hsuh: _ato: yep, the other time folks told to Intern less :)

8:59 *told me to

9:01 _ato: that might be, but i don't understand how can user code do that...

9:01 (what triggers interning)

9:02 _ato: keywords are always interned, so calling (keyword "foo") or (read-str ":foo") would do it

9:02 hsuh: clgv: what does '*' do in (.getCause *e) ?

9:02 *mean

9:03 clgv: hsuh: it's just part of the name

9:03 hsuh: oh, right

9:03 clgv: hsuh: *e is the symbol where you can find the last exception in repl.

9:05 hsuh: but if i'm catching Exception e instead, then i should refer to 'e', not *e

9:05 clgv: hsuh: indeed

9:05 tufflax: *e is just convenient in the repl

9:05 also *1 is the last result of an evaluation, then there's *2 and *3 too. it's handy sometimes

9:05 hsuh: sure, really useful

9:09 _ato: ring calls keyword in some places.. i'm not sure what i should do about it...

9:09 mjg123: If I make a call using goog.net.XhrIo how do I extract the response body in the callback (see 1st code example at http://code.google.com/closure/library/docs/xhrio.html)

9:09 hsuh: detect and restart clojure seems pragmatc, and ugly

9:10 mjg123: The result of (.getResponseText (.target e)) is the getResponseText function - not the result of that function...

9:11 so I guess my question could also be: how can I execute a js-function in ClojureScript?

9:11 _ato: hsuh: I'm not too sure either. If you can work out what keyword is doing it you could just hold a global reference to it somewhere

9:11 ugly workaround

9:11 clgv: switching from defstruct to defrecord and not typhinting and/or switching from keyword-access to field-access (java-interop style) seems to degrade performance

9:13 _ato: whatever the underlying issue is in Clojure probably needs fixing. I'm not sure exactly how to do that though

9:13 stuartsierra: mjg123: Try (. (.target e) (getResponseText))

9:15 See "Host Interop" on https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure

9:15 Scriptor: any idea why a good amount of the core functions in repljs are missing?

9:16 hsuh: _ato: i'm on 1.2.0 ...

9:16 stuartsierra: Scriptor: we just haven't had time to implement them yet

9:16 mjg123: stuartsierra, thanks :)

9:16 Scriptor: stuartsierra: but these should be: doc, ns, use, join...

9:17 on the other hand, map, reduce, and filter are ther

9:17 stuartsierra: Well, "should" is relative. :)

9:17 `ns` is there. `use` is not and will not be.

9:17 Scriptor: ah

9:17 but still, there's no import or ns

9:18 stuartsierra: `ns` is defined in the compiler

9:18 `import` does not exist

9:20 Scriptor: when I try to do (require '[cljs.closure :as cljsc])

9:20 it gives an "undeclared var" exception

9:20 because it can't seem to find require

9:20 stuartsierra: `require` only exists in `ns`

9:21 Scriptor: stuartsierra: shouldn't it be available in the repl?

9:21 stuartsierra: maybe, but it's not right now

9:22 It would never work in compiled mode anyway.

9:22 Scriptor: well, it's the 3rd code sample on https://github.com/clojure/clojurescript/wiki/Quick-Start

9:23 stuartsierra: Scriptor: yes, that's a bug

9:23 in the docs

9:23 actually, no, that example is meant for the *Clojure* REPL, not ClojureScript.

9:24 Scriptor: sorry, emacs crashed

9:25 stuartsierra: So I just posted an update to that page. The `require ` example for building is meant to be run at the *Clojure* REPL, not ClojureScript.

9:26 Scriptor: ah! thanks, that makes much more sense

9:32 dnolen: stuartsierra: is there interest in require as a function? It's hard to play around w/ the Google Closure libs in the cljs REPL.

9:32 stuartsierra: I'd take a patch there

9:32 .

9:32 dnolen: stuartsierra: cool

9:36 stuartsierra: I imagine that no one sees a need for import in ClojureScript right? just require.

9:37 stuartsierra: Yeah, no `import`. `require` does double-duty in ClojureScript.

9:39 fliebel: Are there any sexy Clojure editors for Lion, significant advancements in VimClojure or other editor novelties?

9:39 stuartsierra: fliebel: Clojure was sexy before Lion. :)

9:41 adam_hinz: but lion makes everything sexier

9:50 jodaro: emacs is still sexy in lion

9:52 http://www.sublimetext.com/

9:52 played around with that a little

9:52 not really lion specific though, i guess

9:54 jcromartie: OK, Emacs topic: what's your favorite color-theme-*?

9:54 I'm partial to lighter ones

9:55 hsuh: light when room in bright, dark when room is dark

9:55 stuartsierra: I like Twilight, which is very dark. :)

9:56 jodaro: hmmm

9:56 clojure does in fact look pretty sexy in sublime

9:57 fliebel: jodaro: I can;t imagine sexy cross-platform apps.

9:58 jodaro: the thing is

9:58 it looks like emacs

9:58 aside from that minimap thing

9:58 and honestly i don't really want to see my code from 10k feet

9:59 probably means its time to split up your files if they are scrolling that much

9:59 hsuh: and there is a minimap for emacs if you wanted..

9:59 jcromartie: http://www.emacswiki.org/emacs/MiniMap

9:59 Emacs: it only does everything

10:00 jodaro: hah!

10:00 jcromartie: note that the Emacs feature was inspired by Sublime

10:00 jodaro: hadn't seen that

10:00 jcromartie: and then someone said "oh yeah, Emacs can do that"

10:00 jodaro: the emacs gnomes

10:00 jcromartie: pretty much

10:01 TimMc: jodaro: Clojure core has some epicly (sp.?) long files.

10:01 fliebel: Only emacs I know is m-c butterfly, or whatever.

10:01 TimMc: M-x

10:01 jodaro: fliebel: so yeah, the answer you seek: emacs.

10:02 Hodapp: I remember getting banned from a channel (no, not #emacs) once for saying "Emacs is a good operating system but it has a crappy text editor."

10:02 hsuh: but in my experience those cool looking hacks are almost never well implemented enough that you can take advantage, you have to start hacking elisp ...

10:03 jodaro: i mostly keep it simple

10:03 never got into those code folding things and whatnot

10:03 emacs in a Terminal is fine for me

10:03 on mac os

10:05 fliebel: I think I'd write all my code in Ia Writer, if I had enough iTunes credits. Pure zen, never mind visual clues and auto-everything.

10:06 jodaro: looking

10:06 oh

10:06 full screen totally plain?

10:07 jcromartie: fliebel: bah... minimalism is overrated

10:07 jodaro: lion has this new full screen mode

10:08 i just put my terminal into that

10:08 looks similar

10:08 in, uh, emacs.

10:09 auto markdown

10:11 stuartsierra: Aquamacs does full-screen in OSX too, pre-Lion.

10:24 ian__: (I'm new to cloure) I'm currently coding up a simple app that reads records out of a DB and displays them. There are many types of records and a few common fields in all (most) records. I'm thinking of using defrecord to define my data types and defprotocol to leverage the common fields. Is this a good idea? What are the trade-offs I'm making here instead of going with a pure map implementation?

10:24 Also I'm attempting to load these from the DB using clojure.contrib.sql. If I do define records, is there an easy way to load a map into a record that is retuned by the sql library?

10:25 stuartsierra: ian_: Start with plain maps, it's much easier for prototyping.

10:25 You don't need a protocol for data access.

10:26 ian__: okay, thanks

10:27 In my case, a protocol would simply help with type safety?

10:27 Which I don't really need when starting out

10:29 stuartsierra: Clojure is dynamically-typed. Safety is usually achieved through other means, such as pre/post assertions and unit testing.

10:30 ian__: makes sense. Thanks for the help!

10:31 stuartsierra: 'welcome.

10:35 metajack: during rich's clojurescript talk I heard him mention that he gave a talk on Google Closure. Is that talk online somewhere?

10:36 stuartsierra: metajack: sorry no, but it's the same as his JavaScript slides at the ClojureScript talk

10:37 metajack: ok. so at least I'll get to see some of it when that gets posted. I had to leave after the first 15 minutes the other day :(

10:38 stuartsierra: it's on blip.tv now

10:38 * metajack cheers

10:39 metajack: I really appreciate all the effort that goes into recording and posting these talks. Thanks.

10:39 stuartsierra: metajack: 'welcome! Thanks for watching.

10:54 clgv: does a class generated with defrecord have a working hashCode implementation that does not only return the reference?

10:55 stuartsierra: yes

10:55 clgv: hummm, damn that was the last idea that might have explained the strange behavior

10:56 stuartsierra: `deftype` does not do this

10:58 clgv: I switched from former defstruct to defrecord. what pitfalls could there be that degrade performance by 2/3

11:00 stuartsierra: defrecords should be faster than defstructs for plain field access.

11:00 Check for reflection warnings.

11:02 clgv: yeah. I switched from keyword-access to field-access and already checked for reflection warnings

11:04 so using defrecords in sets should work fine as well

11:09 stuartsierra: (.field record) and (:field record) should be nearly equal in performance.

11:10 clgv: I have narrowed it down to the function were performance degrades but can't really tell where there might be a problem

11:11 there are no reflection warnings

11:11 Scriptor: clgv: hmm, can you paste a gist of the code?

11:12 clgv: but if I can exclude the contains? on the set with the defrecord from the suspicious parts, thats fine.

11:12 Scriptor: not really, since it has a lot of dependencies of functions that I would have to paste as well.

11:13 I try to measure time consumption of its blocks now

11:16 Scriptor: can gclosure take in .html files and check for js code inside <script> tags?

11:17 that way ^:export wouldn't be necessary, right?

11:18 stuartsierra: Scriptor: not that I know of

11:24 clgv: stuartsierra: is it possible that I run into an auto-boxing issue when I switch from defstruct to defrecord? that could explain the performance degrade

11:36 gfrlog: is there a better way to create my own Exception class than to create a separate (ns) with (:gen-class)?

11:37 chouser: gfrlog: consider not making your own class

11:37 but no

11:38 gfrlog: chouser: okay, so how should I catch specific kinds of exceptions then?

11:38 chouser: to make your own Exception class you must use Java or gen-class (might not need a separate ns)

11:38 gfrlog: I have a web-app with a rather deep call stack, and I want to return a particular status/message if a particular thing goes wrong

11:39 the only other way I know of to deal with it is to use a generic Exception and check the message with a regex :|

11:39 or find an appropriate exception class in a library somewhere...

11:40 chouser: you want an exception that carries a Clojure map so you can stuff whatever data in there you need, and check for it later

11:40 gfrlog: chouser: that sounds like a nice pattern. Does clojure have something for that?

11:40 chouser: there's one of those in the old contrib. c.c.condition, I think.

11:40 clgv: given a set (def s #{ (Node. 1) (Node. 2}) in Clojure 1.2.1 with (defrecord [node-id]) - when I do (conj s (Node. 3)) the defrecord is added as normal map! is that intended behavior?

11:40 chouser: I don't know if there's on in the new contrib scheme or not.

11:41 gfrlog: chouser: checking it out

11:42 hugod: gfrlog: there is also https://github.com/scgilardi/slingshot

11:42 gfrlog: hugod: I'm glad I asked

11:42 pjstadig: slingshot is the new hotness

11:43 gfrlog: what a coincidence! my next question was "what is the new hotness?"

11:45 clgv: if I do (def n3 (Node. 3)) in advance and then (conj s n3) it works like it should

11:48 besides: is there a way to detect boxing and unboxing?

11:48 Vinzent: hm, will slingshot or something similar be included in 1.3? (as a standard mechanism or optional lib)

11:49 no_mind: Is there a way to output tidy html using enlive ?

11:56 scgilardi: Vinzent: there has been discussion of how to make error reporting more convenient over the years. nothing has gelled enough yet to become part of clojure. slingshot is something simple that I think adds good value and works in a way that is a strict superset of the current try and throw behavior. using any of the maven-based tools for bringing in dependencies (e.g., leiningen) makes this an easy optional install right now for cloj

12:00 Vinzent: scgilardi, understood. But, imo, it'd very handy to have it in standard lib, so anyone can just quickly require it and use, and, moreover, it's imortant to have only one "extended try" lib to avoid confusion while reading other's code

12:03 gfrlog: Vinzent: no confusion -- in the next one name the macros throw++ and try++

12:04 continue as needed

12:05 Vinzent: lol

12:05 technomancy: Vinzent: the goal is eventually if it's good enough it could replace try/throw

12:05 but we won't know how good it is until we try it out in lots of scenarios

12:07 Vinzent: technomancy, ok, it sounds reasonable

12:09 clgv: can I only typehint primitve types in a defrecord statement? I want to typehint another defrecord's class there

12:18 edoloughlin: I have a set of websocket connection objects (coming from Webbit) and I want to have more than one way of looking them up. I'm worried about assigning them to multiple maps. Will I get copies which can get stale because Webbit will only be updating one of them?

12:19 dnolen: ClojureScript is fun!

12:29 timvisher: hey all

12:29 are update-in and assoc-in not part of the official seq api?

12:29 they're not mentioned on the Clojure Sequences page

12:30 TallAdam: does anyone know the syntax for declaring a 'defrecord' that implements multiple protocols?

12:30 `fogus: RT @dnolen: ClojureScript is fun!

12:30 Whoops wrong window. ;-)

12:33 TallAdam: anyone? defrecord? multiple protocols?

12:34 dnolen: `fogus: heh :)

12:34 Vinzent: TallAdam, (defrecord Foo [...] AProtocol (impl [] ...) BProtocol (other [] ...)), no?

12:34 `fogus: (defrecord Foo [a b c] ISomething (bar [x] ...) ISomethingElse (baz [y] ...))

12:34 TallAdam: doesn't seem to be working for me

12:35 Vinzent: TallAdam, be aware of inheritance

12:36 `fogus: TallAdam: Do you have a snippet to show?

12:36 TallAdam: (defprotocol Fly (on-fly [this altitude]))

12:36 (defprotocol Land (on-land [this where]))

12:36 (defrecord Bird [colour]

12:36 Fly

12:36 (on-fly [this altitude] (str (:colour this) " bird flying at " altitude))

12:36 Land

12:36 (on-land [this where] (str (:colour this) " bird landing in " where)))

12:36 clojurebot: amalloy: therfor I return [previous] if rest is empty

12:36 TallAdam: then I do this in the repl:

12:36 (def b (Bird. "blue"))

12:36 Vinzent: TallAdam, please use paste.lisp.org or something like

12:36 TallAdam: (on-land b)

12:37 `fogus: on-land looks like it needs another arg

12:37 TallAdam: and it gives me: No single method: on_land of interface: twitter.callbacks.protocols.Land found for function: on-land of protocol: Land

12:37 `fogus: (on-land b :trashcan)

12:38 TallAdam: ok - I can't believe I was this stupid

12:38 time for a break

12:38 thanks guys

12:38 `fogus: np :-)

12:38 TallAdam: the error message is rather cryptic tho

12:39 thanks again

12:40 scgilardi: "no single method: on_land of interface" might be better expressed as "no method or multiple methods matching: on_land of interface"

12:40 matching -> match

12:44 `fogus: followed perhaps by "... taking 1 arg"

12:45 scgilardi: inc

12:50 clgv: I exchange one defstruct with one defrecord and my algorithm performance degrades by about 2/3. I touched nothing else except the definition and the creation function. any ideas what could be the problem?

12:51 hiredman: does your algorithm assoc in a lot of keys?

12:52 clgv: the algorithm gets objects of that defrecord and does not change them

12:53 the objects have some assoced data that is not in the defrecord definition - might access to this data be slower than in the defstruct version?

12:58 hiredman: clgv: how are you access the fields of the defrecord?

12:58 clgv: hiredman: like in the defstruct version before

12:58 hiredman: ok

12:58 how is that?

12:58 clgv: via keywords

12:59 hiredman: how via keywords?

12:59 clgv: (:attr rec)

12:59 hiredman: is this code eval'ed at the repl or aot compiled, or ?

12:59 clgv: I tried both. doesnt make any difference

13:00 hiredman: if you can isolate a little test case and pastebin it somewhere it would be interesting to look at

13:01 TimMc: Would (.attr rec) be faster?

13:01 hiredman: how often is the algorithm run? deos it have time for the jit to kick in?

13:04 clgv: hiredman: the subroutine that needs more time after the change is run about 17,000 times

13:05 hiredman: *shrug*

13:05 clgv: TimMc: yes it would. but (:attr rec) shouldnt be that much slower in a record than in a defstruct I guess

13:06 hiredman: clgv: example code illustrating the issue is good

13:07 clgv: hired: it's not that easy since there are dependencies to other code. 'll try to minimize

13:07 hiredman: sure

13:10 rhebus: what's a good way to convert a byte[] to a string? assuming the byte[] is ascii encoded. I have (apply str (map char (seq my-byte-array))) but is this idiomatic? is there a way that the encoding can be made more explicit?

13:10 \

13:10 hiredman: ,(String. (.getBytes "foo"))

13:10 clojurebot: "foo"

13:10 hiredman: learn to read java docs

13:11 rhebus: works a treat

13:11 i had forgotten that clojure strings are java strings

13:11 dnolen: clgv: have you tried to run a real profiling tool? VisualVM or YourKit?

13:12 clgv: dnolen: I have a macro for measuring the time via System/nanoTime

13:12 rhebus: so my problem was more fundamental than a failure to read documentation. but thanks for the advice.

13:12 hiredman: clgv: but a real profile tool shows you more than just time

13:12 it shows you what methods the time is spent in

13:13 clgv: hiredman: yes. I know exactly in which method the time is spent. I only dont know about the increase of time consumption

13:14 dnolen: clgv: but that method is clearly calling out to other fns, which of those fns take the most time?

13:14 hiredman: clgv: you may know at the clojure level what function the time is spent in, but that doesn't tell you where the time is spent in the clojure runtime or at the jvm level

13:15 clgv: hiredman: hm ok. maybe I run JVisualVM on it

13:16 dnolen: in both cases the only out-calling fn needs a similar amount of time. but the function itself needs more time

13:19 I am replacing the call now by a constant and some time consuming operation and check what happens in both cases

13:40 ok the isolation didnt exhibit the same behavior :(

13:40 err the function with the constant replacement

13:42 I'll try both cases with JVisualVM now

14:03 bortreb: what's the most clojure-y way to handle lots of optional paramaters? For example, a box in a 3D game. right now I'm doing something like (defn box

14:03 [& {name :name material :material color :color mass :mass friction :friction

14:03 texture :texture [l w h] :size [x y z] :position

14:03 :as user

14:03 :or

14:03 {:name "box" :material "Common/MatDefs/Misc/Unshaded.j3md"

14:03 :color ColorRGBA/Blue :texture false :size [1 1 1]

14:03 :position [0 0 0] :mass 5 :friction 0.1}}]

14:03 what would be better?

14:03 hiredman: the clojure way is to use a pastebin

14:03 Scriptor: was about to say that :p

14:03 bortreb: sorry about that

14:05 hiredman: I would think about if you want to actually call a function with all those parameters, or you want to have a datastructure that describes something and a function that interepts the datastructure

14:05 clgv: humm jvisualvm doesnt give me any good output. I dont see any namespace starting with clojure.lang in there...

14:06 hiredman: right, but what is the method all the time is spent in?

14:06 kumarshantanu: bortreb: Looks fine, but when you have so many args, consider passing a map that can have many k/v pairs -- or a record

14:06 you should also write a factory fn to create the record instance though

14:07 clgv: java.net.SocketINputStream.read() lol

14:07 thats from profiling I guess

14:07 Scriptor: kumarshantanu: that function does take a map, it's just destructured

14:07 bortreb: ok, I'm back --- https://gist.github.com/1100014

14:08 clgv: maybe JVisualVM has problems with jars

14:09 bortreb: If I just define it as in https://gist.github.com/1100017 and use only a map, then it seems like it would be really hard for other people to know how to use the function at the repl

14:09 clgv: I'll try again from lein repl

14:10 bortreb: and don't records need to have all their arguments filled in, and are inconvienent for just specifying a few?

14:10 kumarshantanu: Scriptor: IMHO passing a record is more manageable for too many args

14:10 hiredman: bortreb: that depends, clojure is a datastucture that gets passed to eval or compile and interpreted

14:11 it can be hard to figure out, but people deal with it :)

14:11 kumarshantanu: you can easily decouple validation of the args that way

14:13 bortreb: that makes sense if I use a factory function, thanks

14:14 clgv: hiredman: it works in repl :)

14:18 michaelbarton: exit

14:19 amalloy: using a record instead of a plain map seems silly to me

14:19 clgv: hiredman: hmm I found one odd thing. seq is called on my defrecord.

14:20 michaelbarton: Hello. I'm new to learn clojure and I have a beginners question.

14:21 hiredman: just about any call to map/filter/reduce/etc will cause seq to be called

14:21 michaelbarton: I'm trying to read each line from a file and then split that line.

14:21 I've been able to read each line from the file using line-seq

14:22 What is the best way to split a tab delimited string?

14:22 clgv: hiredman: yeah, I am aware of that, but I was not aware that it is used somewhere like that

14:22 amalloy: $javadoc String split

14:22 lazybot: http://download.oracle.com/javase/6/docs/api/java/lang/String.html#split(java.lang.String,%20int)

14:22 amalloy: &(doc clojure.string/split)

14:22 lazybot: ⇒ "([s re] [s re limit]); Splits string on a regular expression. Optional argument limit is the maximum number of splits. Not lazy. Returns vector of the splits."

14:23 michaelbarton: Thank you

14:23 Let me try this now

14:25 clgv: hiredman: so now the difficult task - how do I find these seq-calls...

14:26 hiredman: you have to trace the flow of your record through the code, I dunno have any good tools for that, just patience

14:28 clgv: hiredman: I only access those objects as maps or now as field access

14:28 hiredman: *shrug*

14:32 dnolen: clgv: have you pasted the problem fn?

14:32 clgv: dnolen: no. I couldnt minimize it without loosing the effect.

14:33 dnolen: but I now do see in JVisualVM that two of the 5 defrecords have frequent calls to their seq method

14:33 dnolen: clgv: is the problem fn large for some reason?

14:34 clgv: dnolen: no but it has various dependencies concerning its input and the one outcalling function

14:34 dnolen: and I am not entirely sure that it has to be exactly that function

14:39 michaelbarton: Got it!

14:39 Thank you

14:42 clgv: can I somehow intercept the seq-method of a defrecord to throw an exception to see where it was called?

14:43 stuartsierra: you could override clojure.lang.Seqable 'seq'

14:44 amalloy: stuartsierra: that doesn't work in defrecords, does it? since record already provides an impl

14:45 stuartsierra: you can still override it

14:45 Not generally recommended, but as an experiment...

14:45 amalloy: (defrecord Test [] clojure.lang.Seqable (seq [this] '(1))) ;; Duplicate method name&signature in class file user/Test

14:45 did this change in 1.3?

14:46 (i'm on 1.2)

14:46 clgv: I am on 1.2.1

14:47 I couldnt override equals on a defrecord

14:47 so I guess seq wont work

14:48 scgilardi: in a pinch you could change to an equivalent deftype where you can control everything

14:48 stuartsierra: oh

14:48 funny, I thought that worked.

14:49 amalloy: scgilardi: yeah, i was thinking about that too. it looks like defrecord is implemented as a macro on top of deftype, so you can just macroexpand it to get the equivalent deftype

14:50 change the bits you want, and voila

14:50 scgilardi: nice

14:50 clgv: scgilardi: but if there is some implementation detail of defrecord calling seq I will destroy that with the deftype.

14:50 amalloy: ah now I get it

14:51 &(-> '(deftype Node [id]) macroexpand-1 pprint)

14:51 lazybot: java.lang.Exception: Unable to resolve symbol: pprint in this context

14:51 clgv: &(-> '(deftype Node [id]) macroexpand-1 clojure.pprint/pprint)

14:52 lazybot: java.lang.ClassNotFoundException: clojure.pprint

14:52 clgv: &(-> '(deftype Node [id]) macroexpand-1)

14:52 lazybot: ⇒ (clojure.core/let [] (deftype* Node sandbox7610.Node [id] :implements []) (clojure.core/import sandbox7610.Node))

14:52 clgv: ups sorry

14:52 amalloy: how bizarre. deftype really is defined as `(let [] ...stuff...)

14:53 clgv: maybe that let is used when you specify more advanced stuff

14:53 amalloy: no, i was looking at the source

14:53 `(let []

14:53 ~(emit-deftype* name gname (vec hinted-fields) (vec interfaces) methods)

14:53 (import ~classname))

14:54 * tarcieri tries to get swank working again

14:54 hiredman: it maybe a hold over from something else, but I think it is because of different code generation for let vs. do

14:54 it is

14:55 clgv: hm ok I'll try to change seq withit to throw surgical exceptions from the inside ;)

14:55 amalloy: hiredman: yeah, i see commit 2ac93197 made that change explicitly, but i don't understand why. do you know what the difference in code generation is?

14:56 hiredman: do is special cased in the compiler in a few places

14:56 amalloy: oh, i see. i think the commit message explains it

14:57 hiredman: the compiler doesnn't compile do's as a unit, it pulls them apart and does each subform

14:58 amalloy: right, which as i understand it is usually helpful. but for defining classes i guess that exposes a race condition where the jvm might try to gc the class after definition but before anyone references it?

14:58 hiredman: I think it's the classloader

14:58 the subforms could be compiled with different classloaders

14:59 amalloy: hm. the commit message, for reference, is "prevent dynamic classes from being flushed before use"

14:59 hiredman: ah, yes

14:59 right, gc race

14:59 amalloy: that must have been a fun bug to track down

14:59 hiredman: because of the weakreference cache in dynamicclassloader

15:00 scgilardi: amalloy: was just thinking that

15:00 tarcieri: w00t, I can has repl

15:02 clgv: is there a free non-commercial version of the YourKit Java Profiler?

15:02 amalloy: clgv: there's an open-source license

15:02 clgv: amalloy: can I just download and use it by agreeing to this license?

15:02 amalloy: doubt it

15:03 scgilardi: you'll need a code from them

15:03 clgv: ok

15:03 amalloy: but someone who would surely know better than i do is google

15:04 kumarshantanu: clgv: they give free license to Open Source projects -- they ask you to put their HTML snippet in your project website though

15:04 tarcieri: ugh

15:04 chouser: amalloy: so, you didn't see my reply about prxml?

15:04 clgv: kumarshantanu: I have no public project with a website. currently it's my research project

15:04 amalloy: chouser: still nope

15:04 chouser: and now I've accidentally deleted the github message you sent me

15:05 amalloy: haha

15:05 kumarshantanu: clgv: send them a mail anyway - no harm I guess

15:05 amalloy: you are like some kind of github negative-expert

15:05 chouser: amalloy: ok, gist is: I hadn't looked at prxml before. It looks really convenient, and data.xml seems to me to be the right place for it.

15:06 amalloy: chouser: cool. how would you like me to submit the updated version?

15:07 chouser: well, data.xml deals in trees of Elements or sequences of Events

15:07 any chance you could rework prxml to produce a tree of Elements instead of text?

15:08 then people can use that tree with zip xml, zip filter, or emit it with (or without) indentation, etc.

15:08 amalloy: hm

15:08 chouser: that way the prxml code itself wouldn't have to deal with pretty prtinting, getting output encoding right, etc.

15:10 amalloy: ah, Elements are just records

15:11 so you want to reuse the existing emit/whatever functions in your data.xml, and turn prxml into a library for "turning vectors and maps into xml"

15:11 chouser: into xml elements

15:12 yes

15:13 amalloy: i like that idea. i'll take a look, but it should be pretty simple to make that transformation, and will get a lot of terrible code out of prxml

15:14 i suspect it will actually get almost all the code, period, out of prxml

15:15 clgv: hmm yourkit seems to be pretty awesome

15:24 ok got it: the hashCode implementation of defrecord is mapping over the seq call to create the hashCode

15:25 grumpytoad: hello... trying clojurescript but I get missing class sun.org.mozilla.javascript.internal.Context

15:25 is that an outdated rhino ?

15:25 clgv: so I should probably better switch to deftype and implement hashcode myself in a less time consuming way.

15:26 thanks all.

15:26 grumpytoad: hmm seems something to do with openjdk

15:27 dnolen: grumpytoad: I would stick w/ JDK 6.

15:27 ahriman`: one question pls

15:27 grumpytoad: it is jdk 6, just on linux with openjdk

15:28 stuartsierra: Yeah, OpenJDK is missing Rhino, or has it under a different name.

15:28 ahriman`: is there other way to do this? elegant and beatiful clojure-way ;). (defn n [map] (str "<tr><td>" (map :link) "<trr><td>" (map :href-content) )) (map #(n %) [firstRecord secondRecord thirdRecord])

15:28 dnolen: grumpytoad: hmm, I though the javascript stuff shipped w/ official jdk 6

15:28 grumpytoad: on os x I ran into the same problem w/ openjdk 7.

15:29 Scriptor: ahriman`: it's best to describe in words what you're trying to do first

15:29 grumpytoad: dnolen: ah ok, thx for the info

15:30 clojurescript looks really cool.. itching to give it a serious wack

15:31 ahriman`: Scriptor i want to do: get a sequence of maps (=records, something like records from database) and then iterate through this seq and wrap elements into corresponding piece of html.

15:32 the code above is a good way of doing this but i think that there exists more elegant way.

15:33 dnolen: ahriman`: use Hiccup or Enlive

15:33 ahriman`: dnolen im using Hiccup

15:33 but <tr><td> is a sample, not real.

15:34 hv: Would it make sense to have *cwd*, *home*, and *env* in the clojure.core namespace?

15:35 technomancy: hv: cwd doesn't make sense as the JVM can't change directories

15:35 home and env are easily accessible via (System/getenv)

15:36 hv: technomancy: well, I want them to be dynamic. (and *cwd*, too).

15:36 duncanm: hey technomancy - do you know what's the best way to get a stack trace in emacs?

15:36 technomancy: i turned on toggle-on-error, but the resulting buffer seems 'untouchable'

15:37 fliebel: Is there any Clojure support for Xcode?

15:37 hv: technomancy: even if java does not respect *cwd* and such, clojure, or at least just my own code can respect them.

15:38 dnolen: hv: such things will probably never make into core. But it doesn't mean you can't just define them yourself.

15:38 stuartsierra: *cwd* in core would be slightly misleading, since it wouldn't affect Java I/O methods.

15:39 duncanm: hi dnolen (swanodette?)

15:39 dnolen: duncanm: yes

15:39 duncanm: hey

15:40 hv: stuartsierra: well, how about having that there, and supporting *cwd* in clojure.java.io?

15:40 duncanm: dnolen: looks liek someone implemented my swing clojure IDE idea: https://github.com/arthuredelstein/clooj

15:40 dnolen: i've been busy with a new job, written jruby at work now, no time for clojure ;-(

15:40 dnolen: duncanm: oh yeah, clooj looks promising.

15:40 michaelbarton: If I have a class with an 'n' arity constructor how can I pass it a list with n elements to be used as the constructor arguments?

15:40 stuartsierra: hv: still misleading. clojure.java.io is a very thin wrapper over java.io.*

15:41 hv: will there be a clojure.io ?

15:41 duncanm: dnolen: but i did start learning some scala

15:41 hv: java io is really cumbersome, maybe clojure can fix [a subset of] that?

15:41 dnolen: duncanm: noooooooooooo, j/k

15:42 frou: hey dnolen → would you say the clojure tmbundle is largely done?

15:43 hv: also, will there be a clojurey wrapper around java.nio?

15:43 dnolen: hv: make a library that fits your notions of an elegant io lib. For bonus points make it work with ClojureScript. Then maybe you'll convince some people ;)

15:44 frou: largely stale more like it. but people seem to use it and I get few complaints, error reports, pull requests.

15:44 frou: did you intend to use it as your primary env at one point?

15:45 dnolen: frou: no just helping diversify the available editing environments.

15:46 frou: the only goal was to write it purely in Clojure to encourage contributions.

15:46 frou: alright, it's good that it's there

15:46 michaelbarton: Should I use the ~@ operator?

15:48 ahriman`: so what about my problem? :-(

15:48 dnolen: ahriman`: what's the issue, not sure I understand what you don't like.

15:48 kumarshantanu: Are defrecord and extend going to be part of ClojureScript?

15:49 stuartsierra: `extend` is there now.

15:49 defrecord is in the plan

15:49 kumarshantanu: stuartsierra: cool!

15:50 michaelbarton: Can use unquoting to expand a list into function arguments?

15:51 Eg. (Read. ~(split-line x))

15:51 stuartsierra: hv: Functional I/O is hard. Just ask Haskell. If someone comes up with a brilliant way to do it, there might be a clojure.io. But I haven't seen such a thing yet.

15:51 dnolen: michaelbarton: n arity in Java? you'll need to use an array.

15:53 Night-hacks: hi

15:53 grumpytoad: stuartsierra: +1 ... i think fork/join / mapreduce helps

15:53 michaelbarton: dnolen: The function has a fixed arity. I would like to split a list into the arguments rather than passing a single list containing the arguments.

15:54 * stuartsierra steps away

15:54 Night-hacks: is Clojure fully written in Java ?

15:54 Scriptor: Night-hacks: the compiler is

15:54 michaelbarton: dnolen: Sort of like destructuring to function arguments ...

15:55 scgilardi: michaelbarton: does this use of syntax-quote do it? `(MyClass. ~@my-list)

15:55 dnolen: michaelbarton: for Clojure code you have apply. For Java interop it's harder.

15:55 Night-hacks: Scriptor: and REPL too ?

15:55 hv: Night-hacks: see for your self: https://github.com/clojure/clojure/tree/master/src

15:55 scgilardi: michaelbarton: does this use of syntax quote do it? " `(MyClass. ~@my-list) "

15:56 dnolen: Night-hacks: Clojure is a mix of Java and Clojure. ClojureScript compiler is in Clojure and the rest is pure ClojureScript.

15:56 michaelbarton: sgilard: I still get a ctor error with that. Thank you though.

15:57 I only began playing with clojure this afternoon so I may be doing something stupid.

15:57 dnolen: michaelbarton: is MyClass a Java class with variable arity? yes or no?

15:58 amalloy: dnolen: whaaaatt, class with variable arity?

15:58 dnolen: sorry variable arity ctor

15:59 michaelbarton: dnolen: It's a record

15:59 Here's my very 'Newbie' code: https://gist.github.com/1100283

16:00 amalloy: michaelbarton: stop using records. just use a hashmap

16:00 michaelbarton: amalloy: I've reading the JoC at the same time and it recommends Records I think.

16:00 amalloy: records are an advanced feature that you don't need anywhere near as often as you think

16:00 michaelbarton: amalloy: OK

16:01 amalloy: Thank you

16:01 Any advice is appreciated.

16:01 amalloy: that said, your use of ~@ is also confused: it's only usable inside of backtick forms (`)

16:02 &(let [form '(a b c)] `(insert stuff like ~@form))

16:02 lazybot: ⇒ (clojure.core/insert clojure.core/stuff clojure.core/like a b c)

16:02 scgilardi: and only effective at (roughly) compile time

16:03 amalloy: scgilardi: well, not really true. i've found a few times when the simplest way to construct a list is with ` and ~@ rather than some complicated scheme of concats

16:04 (because, of course, it really resolves into a complicated scheme of concats but i don't have to be explicit about it)

16:04 scgilardi: good point. I was confused.

16:05 amalloy: michaelbarton: and i know you have other stuff to get used to, but try to get out of the habit of putting a single paren on each line

16:06 michaelbarton: amalloy: Oh really?

16:07 amalloy: as a sample taken completely at random of standard lisp formatting, see https://github.com/flatland/wakeful/blob/develop/src/wakeful/docs.clj#L22

16:07 dnolen: michaelbarton: https://gist.github.com/1100291

16:07 amalloy: dnolen: missed a spot

16:08 (in the formatting, that is)

16:08 frou: is there a tool that will format clojure source to a canonical style? I remember reading Go-lang had "gofmt"

16:08 michaelbarton: I see. The extra closing parenthesis don't need their own line.

16:08 Thank you.

16:08 This has been very useful.

16:09 amalloy: frou: emacs :P. it gets the indents right, but leaves it to you when to insert newlines (that can't really be automated)

16:10 dnolen: michaelbarton: records are cool, but they're a lot more difficult to work with. But they seem OOP-y so newcomers gravitate towards them.

16:11 * amalloy was one of those newcomers

16:11 _ulises: I gave records a try once or twice but realised that I was using them as maps anyway

16:12 they provide nice documentation though and a nice interface to things that are expected to be in those "maps"

16:12 michaelbarton: That's true. I come from an OOP background. I'm used to structs etc. in Java.

16:13 I'm looking at JoC now and it seems straight forward to deconstruct using :keys.

16:13 ... produce a map

16:21 DethStryke: I made some changes to ClojureScript so that the compiler creates paths in development mode that work in windows. https://gist.github.com/1099572 if anyone is interested.

16:21 stuartsierra: DethStryke: please submit a patch.

16:22 DethStryke: I don't have a signed paper yet. :(

16:22 stuartsierra: Well then...

16:23 DethStryke: I'll get one signed this weekend and mail it out.

16:23 stuartsierra: great!

16:23 DethStryke: I also don't know if it's a quality fix, or more of a bandaid. Still new to Clojure.

16:26 hv: is there a builtin for topologically sorting a hierarchy?

16:27 stuartsierra: DethStryke: That's fine. JIRA is a good place to get feedback on patches.

16:36 amalloy: chouser: should i fork data.xml and send a pull request, or get commit access to the real repo?

16:41 actually, looking at data.xml i don't see anyplace that comments can be used

16:48 michaelbarton: I have another beginner question. I can't seem to find what the ':' is used for. E.g. :none.

16:48 Is that like symbols in Ruby?

16:49 stuartsierra: `:foo` is a Keyword. Similar to a symbol in Ruby, yes.

16:49 mjg123: http://clojure.org/data_structures#Data%20Structures-Keywords

16:49 michaelbarton: Thank you

16:50 I see. Symbols mean something else in clojure though

16:51 stuartsierra: Yes. Clojure symbols have no leading colon, and they can be evaluated to return a value.

16:53 volton: Hi, is there a way to "unpack" a function so that its elements can be used as arguments to a function? Something like (list (unpack '(1 2 3 4)))

16:54 stuartsierra: volton: I think maybe you want `apply`

16:55 dnolen: ,(+ 1 2 3)

16:55 clojurebot: 6

16:55 dnolen: ,(apply + [1 2 3])

16:55 clojurebot: 6

17:03 arohner: I need to call a java method that takes an iterator as an argument. What's the best way to turn my seq into an iterator?

17:03 amalloy: &(doc iterator-seq)

17:03 lazybot: ⇒ "([iter]); Returns a seq on a java.util.Iterator. Note that most collections providing iterators implement Iterable and thus support seq directly."

17:03 amalloy: other way round, i guess. ##(seq-iterator)

17:03 lazybot: java.lang.Exception: Unable to resolve symbol: seq-iterator in this context

17:04 stuartsierra: arohner: Seqs are already java.lang.Iterable

17:04 So just call .iterator

17:04 arohner: stuartsierra: thanks

17:10 volton: stuartsierra: I don't think apply is what I need. The problem is the following: I have a call like (.setColor gfx (java.awt.Color. (mod xor 256) (mod xor 256) (mod xor 256))) and I want to replace the multiple calls to mod

17:11 for example by something like (map #(mod % 256) (replicate 3 xor))

17:12 stuartsierra: volton: are all the calls to `mod` the same? If so, just use a `let`

17:12 volton: stuartsierra: yes, so is using let idiomatic clojure?

17:12 stuartsierra: absolutely!

17:13 volton: So now I have something like (let [grey (mod xor 256)] (.setColor gfx (java.awt.Color. grey grey grey)))

17:13 stuartsierra: ok

17:13 volton: Is there a way around writing grey trice?

17:14 stuartsierra: Not really.

17:14 hv: volton: not a clean way. `new' is not a function

17:14 volton: aha! so this is why apply does not work!

17:14 hv: if it was, you could have used (apply new java.awt.Color (repeat 3 grey))

17:15 technomancy: if only IFn were a protocol =(

17:16 stuartsierra: technomancy: one day...

17:16 technomancy: stuartsierra: not on the JVM

17:16 stuartsierra: Why not?

17:17 technomancy: it interferes with hotspot inlining

17:17 hiredman: not fast enough, and protocols are on top of fns

17:17 technomancy: I asked rich about it at the emerginglangs conf because I hate the fact that regexes aren't IFn

17:17 hiredman: like, how could every fn call be compiled into another fn call?

17:17 solussd_: dumb question, I'm sure, can clojurescript be used client-side?

17:18 hiredman: solussd_: that seems to be the main target

17:18 technomancy: personally I would take IFn regexes over regexes that interop with java any day

17:18 stuartsierra: Well, nothing stopping you from implementing Regexes in pure Clojure :)

17:19 technomancy: apart from reader macros you mean?

17:19 stuartsierra: well that

17:19 technomancy: regexes that need interop are enough of an edge case that we don't need literals for them, we should save the literals for the more useful regexes

17:19 stuartsierra: Nothing stopping you from hacking the reader, either. :)

17:19 technomancy: nah, I'll wait for it to get rewritten in Clojure

17:20 hiredman: dude, have I got some code for you

17:20 technomancy: hiredman: oh that's right

17:20 stuartsierra: I think you could make a case for wrapping literal regexes in a container that implements IFn

17:20 hiredman: (but actually I guess you are better off starting with the reader from clojurescript)

17:20 technomancy: hiredman: ok, that's our next seajure hack project

17:20 oh, or that

17:21 hiredman: my reader needs to be updated now that deftype exists (and new 1.3 reader stuff)

17:22 volton: thanks guys, I learned a lot today :-)

17:23 jcromartie: how about just (re-fn #"foo")

17:24 (defn re-fn [re] (fn [s] (re-find re s)))

17:24 I know it's not an awesome reader macro :P

17:24 technomancy: something like 70% of my regex use is in conditionals: (when (#"tachyon" my-string) ...)

17:25 jcromartie: yeah

17:25 technomancy: so re-find or re-fn or whatever is just boilerplate

17:26 jcromartie: yup

17:28 arohner: technomancy: how many regexes do you use, to make it worthwhile? I have 80 in my 15k LoC here

17:30 technomancy: arohner: looks like about 50

17:30 arohner: technomancy: in how many lines?

17:31 technomancy: 12k

17:31 so a lot more common than multimethods or protocols

17:31 arohner: interesting. that sounds like a similar ratio

17:31 technomancy: about as common as sets, actually

17:31 and sets are more useful since they are already IFn

17:32 arohner: I have about as many set literals, but it feels like I use them a lot more

17:32 i.e. set code that is not literals

17:34 technomancy: regex ratio's a lot higher in test code: ~70 in 8kloc

17:35 dsantiago: How do you guys count your line of clojure?

17:36 arohner: dsantiago: in emacs, I'm using rgrep

17:36 michaelbarton: Thank you everyone for your help.

17:36 arohner: and wc -l

17:36 michaelbarton: It was very useful

17:36 technomancy: dsantiago: I trick sloccount into thinking it's CL

17:36 hiredman: only lines that have been folded over and rewritten at least 20 times

17:36 technomancy: clojurebot: sloccount is find $1 -name "*clj" | xargs cat > /tmp/sloc.lisp && sloccount /tmp/sloc.lisp

17:36 clojurebot: Alles klar

17:36 technomancy: it excludes commas, but not docstrings

17:37 still waiting for someone to write a clojure-aware line count that doesn't penalize documentation

17:37 hiredman: cloc --force-lang=lisp,clj .

17:37 technomancy: hiredman: aha

17:37 even better

17:38 arohner: that should be pretty straightforward using walk-namespaces, doc and source

17:38 technomancy: arohner: yeah, we should find someone who's looking for a clojure learning project and try to get them to write it. =)

17:38 arohner: :-)

17:41 metajack: What are people using for http client stuff in Clojure these days? I see lots of references to clj-http, most of which are 404s, and the clj-http in clojars appears to raise exceptions instead of returning things like {:status 403 …}

17:41 * technomancy realizes clj-http is a textbook case for slingshot

17:41 dsantiago: Thanks.

17:41 And were you guys saying there's a Clojure reader written in Clojure somewhere?

17:41 arohner: metajack: clj-http, use :throw-exceptions false

17:42 technomancy: metajack: clj-http is definitely the top contender

17:42 danlarkin's and my clojure-http-client is deprecated in favour of it

17:42 hiredman: is there a canonical github repo for clj-http anymore?

17:42 technomancy: of course there is always gnir: http://clojars.org/gnir

17:43 arohner: mmcgrana's?

17:43 metajack: the big clj-http blog posts has two that are both 404s now

17:43 but mmcgrana's seems to be where it's at

17:43 arohner: https://github.com/mmcgrana/clj-http

17:43 technomancy: arohner: IIRC it started as part of the now-defunct clj-sys project

17:43 metajack: arohner: that worked perfectly! i wonder why it's not the default

17:44 technomancy: what was clj-sys?

17:44 technomancy: metajack: I honestly don't know

17:44 it was described to me as "the apache project of clojure"

17:44 mmcgrana's is old

17:45 metajack: technomancy: reminds me of jungerl in erlang-world then

17:45 hiredman: "a collection of stuff we think is really cool, but are unable to get anyone outisde of ourselves interested in"

17:46 * gfrlog thinks that sounds like half of the things he likes

17:47 technomancy: hah; :dev-dependencies [[lein-multi "1.0.0"]]

17:47 :multi-deps {"1.1" [[org.clojure/clojure "1.1.0"]

17:47 [org.clojure/clojure-contrib "1.1.0"]]

17:47 "1.3" [[org.clojure/clojure "1.3.0-master-SNAPSHOT"]]}

17:47 daaaaaang it

17:47 what I meant to say was that http://www.morewords.com/word/cljsys/ is on the front page for results for clj-sys.

17:47 gfrlog: technomancy: that's a complicated password

17:48 technomancy: gfrlog: thank goodness for ssh-agent, amirite?

17:48 gfrlog: agreed.

17:48 amalloy: chouser: okay, so i threw away all of prxml and wrote a converter from prxml/hiccup format to data.xml format. not sure if i should send a pull request or what; let me know

17:58 volton: so.. another noob question... is this idiomatic Clojure? https://gist.github.com/1100521

17:59 arohner: volton: it's pretty good. I'd use a doto in there

18:02 amalloy: volton: new to java too?

18:02 volton: amalloy: no, does it seem that way? :-)

18:02 amalloy: well, you used java.awt.Frame, which has got to be a hundred years old by now

18:02 javax.swing.JFrame

18:03 volton: amalloy: oh I am just following the examples in Joy of Clojure

18:03 amalloy: huh

18:03 that's weird. i mean, awt still works, and swing is written on top of it

18:04 but you should generally try to use javax.swing.J* instead of java.awt.*

18:05 volton: well I guess their rationale is that they are using a java.awt.Graphics to draw stuff

18:05 and getGraphics() returns that even on swing, so why bother with swing

18:06 amalloy: meh. unconvincing; they probably just didn't want to get into the swing/awt gulf.

18:06 volton: amalloy: that's what I meant :-)

18:09 amalloy: anyway, volton, https://gist.github.com/1100537 is an example of rewriting with doto and ->

18:09 great tools for interop

18:10 volton: amalloy: Ha! That is very nice indeed. I posted my solution as a comment but yours is a lot nicer

18:12 amalloy: volton: github's parser mangles that a bit. you want to wrap the whole thing with ```...code...```

18:12 actually i guess i can do that myself, since you commented on my fork instead of your original

18:14 * gfrlog just somehow caused a SIGSEGV on IcedTea6

18:15 volton: alright, time to get some sleep

18:15 good night and thanks!

18:38 Raynes: How is one supposed to require node.js libraries in clojurescript when targeting to node.js?

18:38 'net', for example.

18:39 dakrone: look at the nodels.cljs example

18:39 Raynes: Oh, duh.

18:39 I for some reason thought it was less sophisticated than it actually is.

18:39 dakrone: Thank you, kind sir.

18:40 Your milk and cookies are on their way.

19:04 sjl: Is there a way to have Clojurescript watch foo.cljs and recompile it when it changes?

19:05 Raynes: clojurescript tooling isn't really that sophisticated at this point, given that it was announced two days ago.

19:05 amalloy: Raynes: yeah, did you see the question on SO about what the standard way to distribute a cljs app is?

19:06 sjl: Hmm. It's kind of painful doing it manually, and too slow to use something like kicker to run the script each time :\

19:06 Raynes: No, but haha anyways.

19:06 sjl: We've got some really cool ideas for cake that we're working on implementing. cake will support clojurescript in the probably not-so-distant future. Not sure about what leiningen plans to do.

19:07 sjl: Raynes: oh nice, using Cake with it would be perfect.

19:09 mjg123: no read-string in clojurescript?

19:10 so how to use clojure-literal as representation format in ajax calls?

19:18 sjl: hmm, when I call the following cljs function I get the correct elements back, but they don't fade out... (defn ^:export main [] (.fadeOut (jq "div")) (jq "div"))

19:26 dnolen_: sjl: are you compiling your code in advanced mode?

19:27 sjl: dnolen_: yes, because it doesn't seem to output to standard out otherwise :\

19:27 dnolen_: sjl: I'm pretty just jQuery is not compatible with advanced mode.

19:27 s/just/sure

19:27 lazybot: <dnolen_> sjl: I'm pretty sure jQuery is not compatible with advanced mode.

19:27 sjl: Oh. Well that's good to know.

19:31 dnolen_: sjl: http://code.google.com/p/closure-library/source/browse/trunk/closure/goog/demos/effects.html?spec=svn1075&r=1075

19:31 sjl: Google Closure library has pretty much everything jQuery can do and then some.

19:32 sjl: dnolen_: jquery UI as well?

19:32 dnolen_: sjl: only a matter of time before somebody a reasonable face on this stuff.

19:32 somebody puts

19:32 sjl: go wild, http://closure-library.googlecode.com/svn/docs/namespace_goog_ui.html

19:33 sjl: Mmm, learning a completely new framework for a weekend project... wasn't exactly in the plan.

19:34 Learning clojurescript itself is enough.

19:34 dnolen_: sjl: from what I understand jQuery is not written in a way that advanced mode can work w/, so might as well just give up on that now.

19:35 as a jQuery user, whatever, make something better.

19:44 Raynes: sjl: fwiw, the Closure library is very well documented and organized. Not much to learn.

19:45 sjl: Raynes: I believe it. Maybe I'll learn it in the future.

19:54 dnolen_: Raynes: persistent ClojureScript REPL can't come soon enuf :)

19:55 Raynes: dnolen_: :>

21:20 alandipert: dnolen and sjl google maintains an extern for jQuery

21:20 so it can survive advanced mode

21:21 see http://code.google.com/p/closure-compiler/source/browse/trunk/contrib/externs/

21:22 gclosure compiler doesn't automatically include those externs the way it does with the ecma/dom ones though, so use would entail some cljs.compile hacking and Closure book reading

21:22 dnolen_: alandipert: cool!

21:23 alandipert: is there any interest in a type fn for ClojureScript?

21:26 alandipert: dnolen_: there's interest in anything from clj.core that makes sense

21:26 * gfrlog is interested in big-int

21:27 alandipert: gfrlog: http://closure-library.googlecode.com/svn/docs/closure_goog_math_integer.js.html

21:28 gfrlog: alandipert: am I missing the arithmetic functions somewhere? Or is closure more than just a library?

21:29 alandipert: gfrlog: they're in the impl., for some reason not in the doc

21:30 gfrlog: oh okay

21:30 so is using closure with clojurescript the thing to do?

21:31 just to make spoken conversation difficult?

21:31 alandipert: we've been calling the google one gclosure (lib + compiler)

21:32 still confusing though :(

21:32 gfrlog: using them together could be glojure

21:32 which is fun since the two initial consonants are almost the same

23:10 tomoj: &(letfn [(k [& xs] (->> (iterate (partial * 1000) 1) (map * (reverse xs)) (reduce +)))] (k 18,869,726,156))

23:10 lazybot: ⇒ 18869726156

23:19 metajack: Is it just me or is clj-http not setting the Host header at all?

23:25 amalloy: &((fn [& xs] (reduce (+ (* 1000 %1) %2) 0 xs)) 18,869,726,156) ;; tomoj ?

23:25 lazybot: java.lang.Exception: Unable to resolve symbol: %1 in this context

23:25 amalloy: &((fn [& xs] (reduce #(+ (* 1000 %1) %2) 0 xs)) 18,869,726,156)

23:25 lazybot: ⇒ 18869726156

23:26 tomoj: cool

23:27 amalloy: wasn't sure if you were looking for a good way to do that, or just enjoying the cleverness of using , to read "formatted" numbers

23:29 tomoj: both

23:46 dnolen_: hmm anybody mess w/ macros in ClojureScript? So you just need to put the macros into their own ns, and in the ClojureScript source define :requires-macros ?

Logging service provided by n01se.net