#clojure logs

2011-07-22

00:27ckirkendalllogout
00:44scottjScriptor: just any announcement
01:48ahriman`íó ÷å
01:50ahriman`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
02:46amalloytechnomancy: going to be a busy few days/weeks fielding questions about getting started with clojure, looks like
02:47amalloysince you are foolish enough to maintain emacs (and lein? but i guess the new wave won't really care)
04:13fliebelDoes ClojureScript do web workers?
04:18vijaykiranHi All, is there a function that will take a list of fns and an arg and return the list of fn(arg)s ?
04:19vijaykirane.g. (somefn '(fn1 fn2 fn3) arg) = '(fn1(arg) fn2(arg) fn3(arg))
04:19brehaut,(map #(% 1) [inc dec])
04:19clojurebot(2 0)
04:19brehaut,((juxt inc dec) 1)
04:19clojurebot[2 0]
04:20vijaykiranbrehaut: cool thanks!
04:21brehautvijaykiran: the map version is definately lazy; i dont _think_ the juxt version is
04:23vijaykiranbrehaut: ok, I didn't think of map like that - this is 'code is data' at work - right ?
04:24brehautright
04:24brehautjuxt is a special case of map really
04:24brehaut(although its not implemented as such)
04:25vijaykiranok.. 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 ?
04:26brehauti'll leave that for someone else
04:27dsantiagoHave you use'd it into your namespace at the repl?
04:27opqdonutno, this is not "code is data" at work
04:27opqdonutthis is merely "functional programming" at work
04:27kumarshantanuvijaykiran: are you connected to the swank-server through SLIME?
04:29vijaykiranyes 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
04:33vijaykiranif I type [in slime-repl] (defn blah [] "some docstring") \n (doc blah) it just prints nil (Apart form the fn name and the args)
04:34dsantiagoAh, there's the problem.
04:34dsantiagoThe doc string should come before the arg list vector.
04:34opqdonutcommon mistake :)
04:36vijaykiranok that was super dumb of me - thanks guys :-) I was fooled by how the doc prints the out put first args then string
04:51sakuradzukamori÷¸÷¸
05:12fliebelWait, did I just ask a question and leave? I guess I'm to busy rebooting. The question was about concurrency in ClojureScript.
05:19lnostdal-laptopno one has answered it yet, fliebel
05:20fliebellnostdal-laptop: Okay, that's good and bad :)
05:36raekcool, the video is up: http://blip.tv/clojure/rich-hickey-unveils-clojurescript-5399498
06:00hiredmanclojurebot: ping
06:00clojurebotPONG!
06:00hiredmanjesus, I have to ignore lazybot now too?
06:03fliebelhiredman: Has he spammed you, eaten your lunch, or killed a friend?
06:03hiredmanfliebel: lazybot really need to tell me that clojurebot responded 493 milliseconds after my ping
06:04fliebelhiredman: *blush* that's my fault even.
06:04hiredmanwell, it's not going to bug me again
06:05fliebelhiredman: Raynes said sexpbot would change name weekly, starting from now :P Something about iTunes gift cards IIRC.
06:06hiredmangreat
06:07fliebelhiredman: 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.
06:08fliebelI could ask them to disable it if it bothers you.
06:10vijaykiranI found the root cause of my docstring The Joy of Clojure puts the doc string *after* the arg list vector ..
06:11fliebel~logs
06:11clojurebotlogs is http://clojure-log.n01se.net/
06:11ahriman`÷¸÷¸
06:11vijaykirannot sure if any one has the book handy - on page 131 - (defn manip-map [f ks m] "Takes a function..
08:08puffnfreshhey everyone, I'm having a hard time defining macros in my ClojureScript
08:08puffnfreshanybody had any luck?
08:09puffnfreshI've currently got: (ns a.core (:require-macros [a.macros :as macros]))
08:10puffnfreshbut when I try to reference the macro with (macros/m 1 2 3) - ClojureScript compiles it as a function call
08:14puffnfreshlooks like I just got it working
08:19clgvpuffnfresh: can you post a gist?
08:19puffnfreshsure, will do in a second
08:27puffnfreshclgv: https://gist.github.com/1099350
08:27Scriptorhmm, trying to do require in the clojurescript repl gives me "Use of undeclared var cljs.user/require"
08:28clgvpuffnfresh: hmm looks about right. so you should have (println "Hello!") in main
08:29puffnfreshyeah, that code works :)
08:29mjg123Scriptor: I've got a similar trouble, "Use of undeclared Var cljs.user/doc"
08:30clgvpuffnfresh: so which does not and how does it fail?
08:31Scriptormjg123: yep, I get the same problem when I try to use doc
08:32mjg123hrmmm
08:32puffnfreshclgv: sorry, it's fine now
08:32puffnfreshnot sure how I got it working
08:32puffnfreshbut that code works
08:33clgvpuffnfresh: maybe you forgot syntax-quote in your previous implementation of the macro
08:35clgvwoah. replacing defstruct by defrecord made my program slower - that's not what it is supposed to :/
08:37hsuhi've been getting http://pastebin.com/7C8QFr7A every few days, sometimes weeks.. what could i do about it ?
08:39clgvhsuh: 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
08:40hsuhisn't that the stacktrace of there is something else to look at? only lists java files
08:40hsuh(clojure source files)
08:41clgvcheck if the exception has a cause
08:42clgve.g. (print-stack-trace (.getCause *e))
08:42hsuhhm. and if i'm not running a repl?
08:42hsuhshould i put the code you pasted on the top level of my app ?
08:42clgvwrap a try-catch-block around it
08:42hsuhso the next time it happens..
08:42hsuhok
08:45hsuhi'll try that.. tks
08:58_atohsuh: interesting exception. reading the referenced bit of Keyword I would guess it's a race of some sort
08:59_atomaybe two threads interning the same keyword simultaneously
08:59hsuh_ato: yep, the other time folks told to Intern less :)
08:59hsuh*told me to
09:01hsuh_ato: that might be, but i don't understand how can user code do that...
09:01hsuh(what triggers interning)
09:02_atokeywords are always interned, so calling (keyword "foo") or (read-str ":foo") would do it
09:02hsuhclgv: what does '*' do in (.getCause *e) ?
09:02hsuh*mean
09:03clgvhsuh: it's just part of the name
09:03hsuhoh, right
09:03clgvhsuh: *e is the symbol where you can find the last exception in repl.
09:05hsuhbut if i'm catching Exception e instead, then i should refer to 'e', not *e
09:05clgvhsuh: indeed
09:05tufflax*e is just convenient in the repl
09:05tufflaxalso *1 is the last result of an evaluation, then there's *2 and *3 too. it's handy sometimes
09:05hsuhsure, really useful
09:09hsuh_ato: ring calls keyword in some places.. i'm not sure what i should do about it...
09:09mjg123If 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)
09:09hsuhdetect and restart clojure seems pragmatc, and ugly
09:10mjg123The result of (.getResponseText (.target e)) is the getResponseText function - not the result of that function...
09:11mjg123so I guess my question could also be: how can I execute a js-function in ClojureScript?
09:11_atohsuh: 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
09:11_atougly workaround
09:11clgvswitching from defstruct to defrecord and not typhinting and/or switching from keyword-access to field-access (java-interop style) seems to degrade performance
09:13_atowhatever the underlying issue is in Clojure probably needs fixing. I'm not sure exactly how to do that though
09:13stuartsierramjg123: Try (. (.target e) (getResponseText))
09:15stuartsierraSee "Host Interop" on https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure
09:15Scriptorany idea why a good amount of the core functions in repljs are missing?
09:16hsuh_ato: i'm on 1.2.0 ...
09:16stuartsierraScriptor: we just haven't had time to implement them yet
09:16mjg123stuartsierra, thanks :)
09:16Scriptorstuartsierra: but these should be: doc, ns, use, join...
09:17Scriptoron the other hand, map, reduce, and filter are ther
09:17stuartsierraWell, "should" is relative. :)
09:17stuartsierra`ns` is there. `use` is not and will not be.
09:17Scriptorah
09:17Scriptorbut still, there's no import or ns
09:18stuartsierra`ns` is defined in the compiler
09:18stuartsierra`import` does not exist
09:20Scriptorwhen I try to do (require '[cljs.closure :as cljsc])
09:20Scriptorit gives an "undeclared var" exception
09:20Scriptorbecause it can't seem to find require
09:20stuartsierra`require` only exists in `ns`
09:21Scriptorstuartsierra: shouldn't it be available in the repl?
09:21stuartsierramaybe, but it's not right now
09:22stuartsierraIt would never work in compiled mode anyway.
09:22Scriptorwell, it's the 3rd code sample on https://github.com/clojure/clojurescript/wiki/Quick-Start
09:23stuartsierraScriptor: yes, that's a bug
09:23stuartsierrain the docs
09:23stuartsierraactually, no, that example is meant for the *Clojure* REPL, not ClojureScript.
09:24Scriptorsorry, emacs crashed
09:25stuartsierraSo I just posted an update to that page. The `require ` example for building is meant to be run at the *Clojure* REPL, not ClojureScript.
09:26Scriptorah! thanks, that makes much more sense
09:32dnolenstuartsierra: is there interest in require as a function? It's hard to play around w/ the Google Closure libs in the cljs REPL.
09:32stuartsierraI'd take a patch there
09:32stuartsierra.
09:32dnolenstuartsierra: cool
09:36dnolenstuartsierra: I imagine that no one sees a need for import in ClojureScript right? just require.
09:37stuartsierraYeah, no `import`. `require` does double-duty in ClojureScript.
09:39fliebelAre there any sexy Clojure editors for Lion, significant advancements in VimClojure or other editor novelties?
09:39stuartsierrafliebel: Clojure was sexy before Lion. :)
09:41adam_hinzbut lion makes everything sexier
09:50jodaroemacs is still sexy in lion
09:52jodarohttp://www.sublimetext.com/
09:52jodaroplayed around with that a little
09:52jodaronot really lion specific though, i guess
09:54jcromartieOK, Emacs topic: what's your favorite color-theme-*?
09:54jcromartieI'm partial to lighter ones
09:55hsuhlight when room in bright, dark when room is dark
09:55stuartsierraI like Twilight, which is very dark. :)
09:56jodarohmmm
09:56jodaroclojure does in fact look pretty sexy in sublime
09:57fliebeljodaro: I can;t imagine sexy cross-platform apps.
09:58jodarothe thing is
09:58jodaroit looks like emacs
09:58jodaroaside from that minimap thing
09:58jodaroand honestly i don't really want to see my code from 10k feet
09:59jodaroprobably means its time to split up your files if they are scrolling that much
09:59hsuhand there is a minimap for emacs if you wanted..
09:59jcromartiehttp://www.emacswiki.org/emacs/MiniMap
09:59jcromartieEmacs: it only does everything
10:00jodarohah!
10:00jcromartienote that the Emacs feature was inspired by Sublime
10:00jodarohadn't seen that
10:00jcromartieand then someone said "oh yeah, Emacs can do that"
10:00jodarothe emacs gnomes
10:00jcromartiepretty much
10:01TimMcjodaro: Clojure core has some epicly (sp.?) long files.
10:01fliebelOnly emacs I know is m-c butterfly, or whatever.
10:01TimMcM-x
10:01jodarofliebel: so yeah, the answer you seek: emacs.
10:02HodappI 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:02hsuhbut 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:03jodaroi mostly keep it simple
10:03jodaronever got into those code folding things and whatnot
10:03jodaroemacs in a Terminal is fine for me
10:03jodaroon mac os
10:05fliebelI 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:06jodarolooking
10:06jodarooh
10:06jodarofull screen totally plain?
10:07jcromartiefliebel: bah... minimalism is overrated
10:07jodarolion has this new full screen mode
10:08jodaroi just put my terminal into that
10:08jodarolooks similar
10:08jodaroin, uh, emacs.
10:09jodaroauto markdown
10:11stuartsierraAquamacs does full-screen in OSX too, pre-Lion.
10:24ian__(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:24ian__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:25stuartsierraian_: Start with plain maps, it's much easier for prototyping.
10:25stuartsierraYou don't need a protocol for data access.
10:26ian__okay, thanks
10:27ian__In my case, a protocol would simply help with type safety?
10:27ian__Which I don't really need when starting out
10:29stuartsierraClojure is dynamically-typed. Safety is usually achieved through other means, such as pre/post assertions and unit testing.
10:30ian__makes sense. Thanks for the help!
10:31stuartsierra'welcome.
10:35metajackduring rich's clojurescript talk I heard him mention that he gave a talk on Google Closure. Is that talk online somewhere?
10:36stuartsierrametajack: sorry no, but it's the same as his JavaScript slides at the ClojureScript talk
10:37metajackok. 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:38stuartsierrait's on blip.tv now
10:39metajackI really appreciate all the effort that goes into recording and posting these talks. Thanks.
10:39stuartsierrametajack: 'welcome! Thanks for watching.
10:54clgvdoes a class generated with defrecord have a working hashCode implementation that does not only return the reference?
10:55stuartsierrayes
10:55clgvhummm, damn that was the last idea that might have explained the strange behavior
10:56stuartsierra`deftype` does not do this
10:58clgvI switched from former defstruct to defrecord. what pitfalls could there be that degrade performance by 2/3
11:00stuartsierradefrecords should be faster than defstructs for plain field access.
11:00stuartsierraCheck for reflection warnings.
11:02clgvyeah. I switched from keyword-access to field-access and already checked for reflection warnings
11:04clgvso using defrecords in sets should work fine as well
11:09stuartsierra(.field record) and (:field record) should be nearly equal in performance.
11:10clgvI have narrowed it down to the function were performance degrades but can't really tell where there might be a problem
11:11clgvthere are no reflection warnings
11:11Scriptorclgv: hmm, can you paste a gist of the code?
11:12clgvbut if I can exclude the contains? on the set with the defrecord from the suspicious parts, thats fine.
11:12clgvScriptor: not really, since it has a lot of dependencies of functions that I would have to paste as well.
11:13clgvI try to measure time consumption of its blocks now
11:16Scriptorcan gclosure take in .html files and check for js code inside <script> tags?
11:17Scriptorthat way ^:export wouldn't be necessary, right?
11:18stuartsierraScriptor: not that I know of
11:24clgvstuartsierra: 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:36gfrlogis there a better way to create my own Exception class than to create a separate (ns) with (:gen-class)?
11:37chousergfrlog: consider not making your own class
11:37chouserbut no
11:38gfrlogchouser: okay, so how should I catch specific kinds of exceptions then?
11:38chouserto make your own Exception class you must use Java or gen-class (might not need a separate ns)
11:38gfrlogI 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:39gfrlogthe only other way I know of to deal with it is to use a generic Exception and check the message with a regex :|
11:39gfrlogor find an appropriate exception class in a library somewhere...
11:40chouseryou want an exception that carries a Clojure map so you can stuff whatever data in there you need, and check for it later
11:40gfrlogchouser: that sounds like a nice pattern. Does clojure have something for that?
11:40chouserthere's one of those in the old contrib. c.c.condition, I think.
11:40clgvgiven 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:40chouserI don't know if there's on in the new contrib scheme or not.
11:41gfrlogchouser: checking it out
11:42hugodgfrlog: there is also https://github.com/scgilardi/slingshot
11:42gfrloghugod: I'm glad I asked
11:42pjstadigslingshot is the new hotness
11:43gfrlogwhat a coincidence! my next question was "what is the new hotness?"
11:45clgvif I do (def n3 (Node. 3)) in advance and then (conj s n3) it works like it should
11:48clgvbesides: is there a way to detect boxing and unboxing?
11:48Vinzenthm, will slingshot or something similar be included in 1.3? (as a standard mechanism or optional lib)
11:49no_mindIs there a way to output tidy html using enlive ?
11:56scgilardiVinzent: 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:00Vinzentscgilardi, 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:03gfrlogVinzent: no confusion -- in the next one name the macros throw++ and try++
12:04gfrlogcontinue as needed
12:05Vinzentlol
12:05technomancyVinzent: the goal is eventually if it's good enough it could replace try/throw
12:05technomancybut we won't know how good it is until we try it out in lots of scenarios
12:07Vinzenttechnomancy, ok, it sounds reasonable
12:09clgvcan I only typehint primitve types in a defrecord statement? I want to typehint another defrecord's class there
12:18edoloughlinI 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:19dnolenClojureScript is fun!
12:29timvisherhey all
12:29timvisherare update-in and assoc-in not part of the official seq api?
12:29timvisherthey're not mentioned on the Clojure Sequences page
12:30TallAdamdoes anyone know the syntax for declaring a 'defrecord' that implements multiple protocols?
12:30`fogusRT @dnolen: ClojureScript is fun!
12:30`fogusWhoops wrong window. ;-)
12:33TallAdamanyone? defrecord? multiple protocols?
12:34dnolen`fogus: heh :)
12:34VinzentTallAdam, (defrecord Foo [...] AProtocol (impl [] ...) BProtocol (other [] ...)), no?
12:34`fogus(defrecord Foo [a b c] ISomething (bar [x] ...) ISomethingElse (baz [y] ...))
12:34TallAdamdoesn't seem to be working for me
12:35VinzentTallAdam, be aware of inheritance
12:36`fogusTallAdam: Do you have a snippet to show?
12:36TallAdam(defprotocol Fly (on-fly [this altitude]))
12:36TallAdam(defprotocol Land (on-land [this where]))
12:36TallAdam(defrecord Bird [colour]
12:36TallAdam Fly
12:36TallAdam (on-fly [this altitude] (str (:colour this) " bird flying at " altitude))
12:36TallAdam Land
12:36TallAdam (on-land [this where] (str (:colour this) " bird landing in " where)))
12:36clojurebotamalloy: therfor I return [previous] if rest is empty
12:36TallAdamthen I do this in the repl:
12:36TallAdam(def b (Bird. "blue"))
12:36VinzentTallAdam, please use paste.lisp.org or something like
12:36TallAdam(on-land b)
12:37`foguson-land looks like it needs another arg
12:37TallAdamand 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:38TallAdamok - I can't believe I was this stupid
12:38TallAdamtime for a break
12:38TallAdamthanks guys
12:38`fogusnp :-)
12:38TallAdamthe error message is rather cryptic tho
12:39TallAdamthanks again
12:40scgilardi"no single method: on_land of interface" might be better expressed as "no method or multiple methods matching: on_land of interface"
12:40scgilardimatching -> match
12:44`fogusfollowed perhaps by "... taking 1 arg"
12:45scgilardiinc
12:50clgvI 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:51hiredmandoes your algorithm assoc in a lot of keys?
12:52clgvthe algorithm gets objects of that defrecord and does not change them
12:53clgvthe 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:58hiredmanclgv: how are you access the fields of the defrecord?
12:58clgvhiredman: like in the defstruct version before
12:58hiredmanok
12:58hiredmanhow is that?
12:58clgvvia keywords
12:59hiredmanhow via keywords?
12:59clgv(:attr rec)
12:59hiredmanis this code eval'ed at the repl or aot compiled, or ?
12:59clgvI tried both. doesnt make any difference
13:00hiredmanif you can isolate a little test case and pastebin it somewhere it would be interesting to look at
13:01TimMcWould (.attr rec) be faster?
13:01hiredmanhow often is the algorithm run? deos it have time for the jit to kick in?
13:04clgvhiredman: the subroutine that needs more time after the change is run about 17,000 times
13:05hiredman*shrug*
13:05clgvTimMc: yes it would. but (:attr rec) shouldnt be that much slower in a record than in a defstruct I guess
13:06hiredmanclgv: example code illustrating the issue is good
13:07clgvhired: it's not that easy since there are dependencies to other code. 'll try to minimize
13:07hiredmansure
13:10rhebuswhat'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:10rhebus\
13:10hiredman,(String. (.getBytes "foo"))
13:10clojurebot"foo"
13:10hiredmanlearn to read java docs
13:11rhebusworks a treat
13:11rhebusi had forgotten that clojure strings are java strings
13:11dnolenclgv: have you tried to run a real profiling tool? VisualVM or YourKit?
13:12clgvdnolen: I have a macro for measuring the time via System/nanoTime
13:12rhebusso my problem was more fundamental than a failure to read documentation. but thanks for the advice.
13:12hiredmanclgv: but a real profile tool shows you more than just time
13:12hiredmanit shows you what methods the time is spent in
13:13clgvhiredman: yes. I know exactly in which method the time is spent. I only dont know about the increase of time consumption
13:14dnolenclgv: but that method is clearly calling out to other fns, which of those fns take the most time?
13:14hiredmanclgv: 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:15clgvhiredman: hm ok. maybe I run JVisualVM on it
13:16clgvdnolen: in both cases the only out-calling fn needs a similar amount of time. but the function itself needs more time
13:19clgvI am replacing the call now by a constant and some time consuming operation and check what happens in both cases
13:40clgvok the isolation didnt exhibit the same behavior :(
13:40clgverr the function with the constant replacement
13:42clgvI'll try both cases with JVisualVM now
14:03bortrebwhat'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:03bortreb [& {name :name material :material color :color mass :mass friction :friction
14:03bortreb texture :texture [l w h] :size [x y z] :position
14:03bortreb :as user
14:03bortreb:or
14:03bortreb{:name "box" :material "Common/MatDefs/Misc/Unshaded.j3md"
14:03bortreb :color ColorRGBA/Blue :texture false :size [1 1 1]
14:03bortreb :position [0 0 0] :mass 5 :friction 0.1}}]
14:03bortrebwhat would be better?
14:03hiredmanthe clojure way is to use a pastebin
14:03Scriptorwas about to say that :p
14:03bortrebsorry about that
14:05hiredmanI 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:05clgvhumm jvisualvm doesnt give me any good output. I dont see any namespace starting with clojure.lang in there...
14:06hiredmanright, but what is the method all the time is spent in?
14:06kumarshantanubortreb: Looks fine, but when you have so many args, consider passing a map that can have many k/v pairs -- or a record
14:06kumarshantanuyou should also write a factory fn to create the record instance though
14:07clgvjava.net.SocketINputStream.read() lol
14:07clgvthats from profiling I guess
14:07Scriptorkumarshantanu: that function does take a map, it's just destructured
14:07bortrebok, I'm back --- https://gist.github.com/1100014
14:08clgvmaybe JVisualVM has problems with jars
14:09bortrebIf 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:09clgvI'll try again from lein repl
14:10bortreband don't records need to have all their arguments filled in, and are inconvienent for just specifying a few?
14:10kumarshantanuScriptor: IMHO passing a record is more manageable for too many args
14:10hiredmanbortreb: that depends, clojure is a datastucture that gets passed to eval or compile and interpreted
14:11hiredmanit can be hard to figure out, but people deal with it :)
14:11kumarshantanuyou can easily decouple validation of the args that way
14:13bortrebthat makes sense if I use a factory function, thanks
14:14clgvhiredman: it works in repl :)
14:18michaelbartonexit
14:19amalloyusing a record instead of a plain map seems silly to me
14:19clgvhiredman: hmm I found one odd thing. seq is called on my defrecord.
14:20michaelbartonHello. I'm new to learn clojure and I have a beginners question.
14:21hiredmanjust about any call to map/filter/reduce/etc will cause seq to be called
14:21michaelbartonI'm trying to read each line from a file and then split that line.
14:21michaelbartonI've been able to read each line from the file using line-seq
14:22michaelbartonWhat is the best way to split a tab delimited string?
14:22clgvhiredman: yeah, I am aware of that, but I was not aware that it is used somewhere like that
14:22amalloy$javadoc String split
14:22lazybothttp://download.oracle.com/javase/6/docs/api/java/lang/String.html#split(java.lang.String,%20int)
14:22amalloy&(doc clojure.string/split)
14:22lazybot⇒ "([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:23michaelbartonThank you
14:23michaelbartonLet me try this now
14:25clgvhiredman: so now the difficult task - how do I find these seq-calls...
14:26hiredmanyou have to trace the flow of your record through the code, I dunno have any good tools for that, just patience
14:28clgvhiredman: I only access those objects as maps or now as field access
14:28hiredman*shrug*
14:32dnolenclgv: have you pasted the problem fn?
14:32clgvdnolen: no. I couldnt minimize it without loosing the effect.
14:33clgvdnolen: but I now do see in JVisualVM that two of the 5 defrecords have frequent calls to their seq method
14:33dnolenclgv: is the problem fn large for some reason?
14:34clgvdnolen: no but it has various dependencies concerning its input and the one outcalling function
14:34clgvdnolen: and I am not entirely sure that it has to be exactly that function
14:39michaelbartonGot it!
14:39michaelbartonThank you
14:42clgvcan I somehow intercept the seq-method of a defrecord to throw an exception to see where it was called?
14:43stuartsierrayou could override clojure.lang.Seqable 'seq'
14:44amalloystuartsierra: that doesn't work in defrecords, does it? since record already provides an impl
14:45stuartsierrayou can still override it
14:45stuartsierraNot generally recommended, but as an experiment...
14:45amalloy(defrecord Test [] clojure.lang.Seqable (seq [this] '(1))) ;; Duplicate method name&signature in class file user/Test
14:45amalloydid this change in 1.3?
14:46amalloy(i'm on 1.2)
14:46clgvI am on 1.2.1
14:47clgvI couldnt override equals on a defrecord
14:47clgvso I guess seq wont work
14:48scgilardiin a pinch you could change to an equivalent deftype where you can control everything
14:48stuartsierraoh
14:48stuartsierrafunny, I thought that worked.
14:49amalloyscgilardi: 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:50amalloychange the bits you want, and voila
14:50scgilardinice
14:50clgvscgilardi: but if there is some implementation detail of defrecord calling seq I will destroy that with the deftype.
14:50clgvamalloy: ah now I get it
14:51clgv&(-> '(deftype Node [id]) macroexpand-1 pprint)
14:51lazybotjava.lang.Exception: Unable to resolve symbol: pprint in this context
14:51clgv&(-> '(deftype Node [id]) macroexpand-1 clojure.pprint/pprint)
14:52lazybotjava.lang.ClassNotFoundException: clojure.pprint
14:52clgv&(-> '(deftype Node [id]) macroexpand-1)
14:52lazybot⇒ (clojure.core/let [] (deftype* Node sandbox7610.Node [id] :implements []) (clojure.core/import sandbox7610.Node))
14:52clgvups sorry
14:52amalloyhow bizarre. deftype really is defined as `(let [] ...stuff...)
14:53clgvmaybe that let is used when you specify more advanced stuff
14:53amalloyno, i was looking at the source
14:53amalloy`(let []
14:53amalloy ~(emit-deftype* name gname (vec hinted-fields) (vec interfaces) methods)
14:53amalloy (import ~classname))
14:54hiredmanit maybe a hold over from something else, but I think it is because of different code generation for let vs. do
14:54hiredmanit is
14:55clgvhm ok I'll try to change seq withit to throw surgical exceptions from the inside ;)
14:55amalloyhiredman: 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:56hiredmando is special cased in the compiler in a few places
14:56amalloyoh, i see. i think the commit message explains it
14:57hiredmanthe compiler doesnn't compile do's as a unit, it pulls them apart and does each subform
14:58amalloyright, 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:58hiredmanI think it's the classloader
14:58hiredmanthe subforms could be compiled with different classloaders
14:59amalloyhm. the commit message, for reference, is "prevent dynamic classes from being flushed before use"
14:59hiredmanah, yes
14:59hiredmanright, gc race
14:59amalloythat must have been a fun bug to track down
14:59hiredmanbecause of the weakreference cache in dynamicclassloader
15:00scgilardiamalloy: was just thinking that
15:00tarcieriw00t, I can has repl
15:02clgvis there a free non-commercial version of the YourKit Java Profiler?
15:02amalloyclgv: there's an open-source license
15:02clgvamalloy: can I just download and use it by agreeing to this license?
15:02amalloydoubt it
15:03scgilardiyou'll need a code from them
15:03clgvok
15:03amalloybut someone who would surely know better than i do is google
15:04kumarshantanuclgv: they give free license to Open Source projects -- they ask you to put their HTML snippet in your project website though
15:04tarcieriugh
15:04chouseramalloy: so, you didn't see my reply about prxml?
15:04clgvkumarshantanu: I have no public project with a website. currently it's my research project
15:04amalloychouser: still nope
15:04chouserand now I've accidentally deleted the github message you sent me
15:05amalloyhaha
15:05kumarshantanuclgv: send them a mail anyway - no harm I guess
15:05amalloyyou are like some kind of github negative-expert
15:05chouseramalloy: 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:06amalloychouser: cool. how would you like me to submit the updated version?
15:07chouserwell, data.xml deals in trees of Elements or sequences of Events
15:07chouserany chance you could rework prxml to produce a tree of Elements instead of text?
15:08chouserthen people can use that tree with zip xml, zip filter, or emit it with (or without) indentation, etc.
15:08amalloyhm
15:08chouserthat way the prxml code itself wouldn't have to deal with pretty prtinting, getting output encoding right, etc.
15:10amalloyah, Elements are just records
15:11amalloyso 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:11chouserinto xml elements
15:12chouseryes
15:13amalloyi 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:14amalloyi suspect it will actually get almost all the code, period, out of prxml
15:15clgvhmm yourkit seems to be pretty awesome
15:24clgvok got it: the hashCode implementation of defrecord is mapping over the seq call to create the hashCode
15:25grumpytoadhello... trying clojurescript but I get missing class sun.org.mozilla.javascript.internal.Context
15:25grumpytoadis that an outdated rhino ?
15:25clgvso I should probably better switch to deftype and implement hashcode myself in a less time consuming way.
15:26clgvthanks all.
15:26grumpytoadhmm seems something to do with openjdk
15:27dnolengrumpytoad: I would stick w/ JDK 6.
15:27ahriman`one question pls
15:27grumpytoadit is jdk 6, just on linux with openjdk
15:28stuartsierraYeah, OpenJDK is missing Rhino, or has it under a different name.
15:28ahriman`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:28dnolengrumpytoad: hmm, I though the javascript stuff shipped w/ official jdk 6
15:28dnolengrumpytoad: on os x I ran into the same problem w/ openjdk 7.
15:29Scriptorahriman`: it's best to describe in words what you're trying to do first
15:29grumpytoaddnolen: ah ok, thx for the info
15:30grumpytoadclojurescript looks really cool.. itching to give it a serious wack
15:31ahriman`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:32ahriman`the code above is a good way of doing this but i think that there exists more elegant way.
15:33dnolenahriman`: use Hiccup or Enlive
15:33ahriman`dnolen im using Hiccup
15:33ahriman`but <tr><td> is a sample, not real.
15:34hvWould it make sense to have *cwd*, *home*, and *env* in the clojure.core namespace?
15:35technomancyhv: cwd doesn't make sense as the JVM can't change directories
15:35technomancyhome and env are easily accessible via (System/getenv)
15:36hvtechnomancy: well, I want them to be dynamic. (and *cwd*, too).
15:36duncanmhey technomancy - do you know what's the best way to get a stack trace in emacs?
15:36duncanmtechnomancy: i turned on toggle-on-error, but the resulting buffer seems 'untouchable'
15:37fliebelIs there any Clojure support for Xcode?
15:37hvtechnomancy: even if java does not respect *cwd* and such, clojure, or at least just my own code can respect them.
15:38dnolenhv: such things will probably never make into core. But it doesn't mean you can't just define them yourself.
15:38stuartsierra*cwd* in core would be slightly misleading, since it wouldn't affect Java I/O methods.
15:39duncanmhi dnolen (swanodette?)
15:39dnolenduncanm: yes
15:39dnolenduncanm: hey
15:40hvstuartsierra: well, how about having that there, and supporting *cwd* in clojure.java.io?
15:40duncanmdnolen: looks liek someone implemented my swing clojure IDE idea: https://github.com/arthuredelstein/clooj
15:40duncanmdnolen: i've been busy with a new job, written jruby at work now, no time for clojure ;-(
15:40dnolenduncanm: oh yeah, clooj looks promising.
15:40michaelbartonIf 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:40stuartsierrahv: still misleading. clojure.java.io is a very thin wrapper over java.io.*
15:41hvwill there be a clojure.io ?
15:41duncanmdnolen: but i did start learning some scala
15:41hvjava io is really cumbersome, maybe clojure can fix [a subset of] that?
15:41dnolenduncanm: noooooooooooo, j/k
15:42frouhey dnolen → would you say the clojure tmbundle is largely done?
15:43hvalso, will there be a clojurey wrapper around java.nio?
15:43dnolenhv: 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:44dnolenfrou: largely stale more like it. but people seem to use it and I get few complaints, error reports, pull requests.
15:44froudid you intend to use it as your primary env at one point?
15:45dnolenfrou: no just helping diversify the available editing environments.
15:46dnolenfrou: the only goal was to write it purely in Clojure to encourage contributions.
15:46froualright, it's good that it's there
15:46michaelbartonShould I use the ~@ operator?
15:48ahriman`so what about my problem? :-(
15:48dnolenahriman`: what's the issue, not sure I understand what you don't like.
15:48kumarshantanuAre defrecord and extend going to be part of ClojureScript?
15:49stuartsierra`extend` is there now.
15:49stuartsierradefrecord is in the plan
15:49kumarshantanustuartsierra: cool!
15:50michaelbartonCan use unquoting to expand a list into function arguments?
15:51michaelbartonEg. (Read. ~(split-line x))
15:51stuartsierrahv: 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:51dnolenmichaelbarton: n arity in Java? you'll need to use an array.
15:53Night-hackshi
15:53grumpytoadstuartsierra: +1 ... i think fork/join / mapreduce helps
15:53michaelbartondnolen: 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:54Night-hacksis Clojure fully written in Java ?
15:54ScriptorNight-hacks: the compiler is
15:54michaelbartondnolen: Sort of like destructuring to function arguments ...
15:55scgilardimichaelbarton: does this use of syntax-quote do it? `(MyClass. ~@my-list)
15:55dnolenmichaelbarton: for Clojure code you have apply. For Java interop it's harder.
15:55Night-hacksScriptor: and REPL too ?
15:55hvNight-hacks: see for your self: https://github.com/clojure/clojure/tree/master/src
15:55scgilardimichaelbarton: does this use of syntax quote do it? " `(MyClass. ~@my-list) "
15:56dnolenNight-hacks: Clojure is a mix of Java and Clojure. ClojureScript compiler is in Clojure and the rest is pure ClojureScript.
15:56michaelbartonsgilard: I still get a ctor error with that. Thank you though.
15:57michaelbartonI only began playing with clojure this afternoon so I may be doing something stupid.
15:57dnolenmichaelbarton: is MyClass a Java class with variable arity? yes or no?
15:58amalloydnolen: whaaaatt, class with variable arity?
15:58dnolensorry variable arity ctor
15:59michaelbartondnolen: It's a record
15:59michaelbartonHere's my very 'Newbie' code: https://gist.github.com/1100283
16:00amalloymichaelbarton: stop using records. just use a hashmap
16:00michaelbartonamalloy: I've reading the JoC at the same time and it recommends Records I think.
16:00amalloyrecords are an advanced feature that you don't need anywhere near as often as you think
16:00michaelbartonamalloy: OK
16:01michaelbartonamalloy: Thank you
16:01michaelbartonAny advice is appreciated.
16:01amalloythat said, your use of ~@ is also confused: it's only usable inside of backtick forms (`)
16:02amalloy&(let [form '(a b c)] `(insert stuff like ~@form))
16:02lazybot⇒ (clojure.core/insert clojure.core/stuff clojure.core/like a b c)
16:02scgilardiand only effective at (roughly) compile time
16:03amalloyscgilardi: 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:04amalloy(because, of course, it really resolves into a complicated scheme of concats but i don't have to be explicit about it)
16:04scgilardigood point. I was confused.
16:05amalloymichaelbarton: 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:06michaelbartonamalloy: Oh really?
16:07amalloyas a sample taken completely at random of standard lisp formatting, see https://github.com/flatland/wakeful/blob/develop/src/wakeful/docs.clj#L22
16:07dnolenmichaelbarton: https://gist.github.com/1100291
16:07amalloydnolen: missed a spot
16:08amalloy(in the formatting, that is)
16:08frouis there a tool that will format clojure source to a canonical style? I remember reading Go-lang had "gofmt"
16:08michaelbartonI see. The extra closing parenthesis don't need their own line.
16:08michaelbartonThank you.
16:08michaelbartonThis has been very useful.
16:09amalloyfrou: emacs :P. it gets the indents right, but leaves it to you when to insert newlines (that can't really be automated)
16:10dnolenmichaelbarton: 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_ulisesI gave records a try once or twice but realised that I was using them as maps anyway
16:12_ulisesthey provide nice documentation though and a nice interface to things that are expected to be in those "maps"
16:12michaelbartonThat's true. I come from an OOP background. I'm used to structs etc. in Java.
16:13michaelbartonI'm looking at JoC now and it seems straight forward to deconstruct using :keys.
16:13michaelbarton... produce a map
16:21DethStrykeI 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:21stuartsierraDethStryke: please submit a patch.
16:22DethStrykeI don't have a signed paper yet. :(
16:22stuartsierraWell then...
16:23DethStrykeI'll get one signed this weekend and mail it out.
16:23stuartsierragreat!
16:23DethStrykeI also don't know if it's a quality fix, or more of a bandaid. Still new to Clojure.
16:26hvis there a builtin for topologically sorting a hierarchy?
16:27stuartsierraDethStryke: That's fine. JIRA is a good place to get feedback on patches.
16:36amalloychouser: should i fork data.xml and send a pull request, or get commit access to the real repo?
16:41amalloyactually, looking at data.xml i don't see anyplace that comments can be used
16:48michaelbartonI have another beginner question. I can't seem to find what the ':' is used for. E.g. :none.
16:48michaelbartonIs that like symbols in Ruby?
16:49stuartsierra`:foo` is a Keyword. Similar to a symbol in Ruby, yes.
16:49mjg123http://clojure.org/data_structures#Data%20Structures-Keywords
16:49michaelbartonThank you
16:50michaelbartonI see. Symbols mean something else in clojure though
16:51stuartsierraYes. Clojure symbols have no leading colon, and they can be evaluated to return a value.
16:53voltonHi, 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:54stuartsierravolton: I think maybe you want `apply`
16:55dnolen,(+ 1 2 3)
16:55clojurebot6
16:55dnolen,(apply + [1 2 3])
16:55clojurebot6
17:03arohnerI 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:03amalloy&(doc iterator-seq)
17:03lazybot⇒ "([iter]); Returns a seq on a java.util.Iterator. Note that most collections providing iterators implement Iterable and thus support seq directly."
17:03amalloyother way round, i guess. ##(seq-iterator)
17:03lazybotjava.lang.Exception: Unable to resolve symbol: seq-iterator in this context
17:04stuartsierraarohner: Seqs are already java.lang.Iterable
17:04stuartsierraSo just call .iterator
17:04arohnerstuartsierra: thanks
17:10voltonstuartsierra: 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:11voltonfor example by something like (map #(mod % 256) (replicate 3 xor))
17:12stuartsierravolton: are all the calls to `mod` the same? If so, just use a `let`
17:12voltonstuartsierra: yes, so is using let idiomatic clojure?
17:12stuartsierraabsolutely!
17:13voltonSo now I have something like (let [grey (mod xor 256)] (.setColor gfx (java.awt.Color. grey grey grey)))
17:13stuartsierraok
17:13voltonIs there a way around writing grey trice?
17:14stuartsierraNot really.
17:14hvvolton: not a clean way. `new' is not a function
17:14voltonaha! so this is why apply does not work!
17:14hvif it was, you could have used (apply new java.awt.Color (repeat 3 grey))
17:15technomancyif only IFn were a protocol =(
17:16stuartsierratechnomancy: one day...
17:16technomancystuartsierra: not on the JVM
17:16stuartsierraWhy not?
17:17technomancyit interferes with hotspot inlining
17:17hiredmannot fast enough, and protocols are on top of fns
17:17technomancyI asked rich about it at the emerginglangs conf because I hate the fact that regexes aren't IFn
17:17hiredmanlike, how could every fn call be compiled into another fn call?
17:17solussd_dumb question, I'm sure, can clojurescript be used client-side?
17:18hiredmansolussd_: that seems to be the main target
17:18technomancypersonally I would take IFn regexes over regexes that interop with java any day
17:18stuartsierraWell, nothing stopping you from implementing Regexes in pure Clojure :)
17:19technomancyapart from reader macros you mean?
17:19stuartsierrawell that
17:19technomancyregexes 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:19stuartsierraNothing stopping you from hacking the reader, either. :)
17:19technomancynah, I'll wait for it to get rewritten in Clojure
17:20hiredmandude, have I got some code for you
17:20technomancyhiredman: oh that's right
17:20stuartsierraI think you could make a case for wrapping literal regexes in a container that implements IFn
17:20hiredman(but actually I guess you are better off starting with the reader from clojurescript)
17:20technomancyhiredman: ok, that's our next seajure hack project
17:20technomancyoh, or that
17:21hiredmanmy reader needs to be updated now that deftype exists (and new 1.3 reader stuff)
17:22voltonthanks guys, I learned a lot today :-)
17:23jcromartiehow about just (re-fn #"foo")
17:24jcromartie(defn re-fn [re] (fn [s] (re-find re s)))
17:24jcromartieI know it's not an awesome reader macro :P
17:24technomancysomething like 70% of my regex use is in conditionals: (when (#"tachyon" my-string) ...)
17:25jcromartieyeah
17:25technomancyso re-find or re-fn or whatever is just boilerplate
17:26jcromartieyup
17:28arohnertechnomancy: how many regexes do you use, to make it worthwhile? I have 80 in my 15k LoC here
17:30technomancyarohner: looks like about 50
17:30arohnertechnomancy: in how many lines?
17:31technomancy12k
17:31technomancyso a lot more common than multimethods or protocols
17:31arohnerinteresting. that sounds like a similar ratio
17:31technomancyabout as common as sets, actually
17:31technomancyand sets are more useful since they are already IFn
17:32arohnerI have about as many set literals, but it feels like I use them a lot more
17:32arohneri.e. set code that is not literals
17:34technomancyregex ratio's a lot higher in test code: ~70 in 8kloc
17:35dsantiagoHow do you guys count your line of clojure?
17:36arohnerdsantiago: in emacs, I'm using rgrep
17:36michaelbartonThank you everyone for your help.
17:36arohnerand wc -l
17:36michaelbartonIt was very useful
17:36technomancydsantiago: I trick sloccount into thinking it's CL
17:36hiredmanonly lines that have been folded over and rewritten at least 20 times
17:36technomancyclojurebot: sloccount is find $1 -name "*clj" | xargs cat > /tmp/sloc.lisp && sloccount /tmp/sloc.lisp
17:36clojurebotAlles klar
17:36technomancyit excludes commas, but not docstrings
17:37technomancystill waiting for someone to write a clojure-aware line count that doesn't penalize documentation
17:37hiredmancloc --force-lang=lisp,clj .
17:37technomancyhiredman: aha
17:37technomancyeven better
17:38arohnerthat should be pretty straightforward using walk-namespaces, doc and source
17:38technomancyarohner: yeah, we should find someone who's looking for a clojure learning project and try to get them to write it. =)
17:38arohner:-)
17:41metajackWhat 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:41dsantiagoThanks.
17:41dsantiagoAnd were you guys saying there's a Clojure reader written in Clojure somewhere?
17:41arohnermetajack: clj-http, use :throw-exceptions false
17:42technomancymetajack: clj-http is definitely the top contender
17:42technomancydanlarkin's and my clojure-http-client is deprecated in favour of it
17:42hiredmanis there a canonical github repo for clj-http anymore?
17:42technomancyof course there is always gnir: http://clojars.org/gnir
17:43arohnermmcgrana's?
17:43metajackthe big clj-http blog posts has two that are both 404s now
17:43metajackbut mmcgrana's seems to be where it's at
17:43arohnerhttps://github.com/mmcgrana/clj-http
17:43technomancyarohner: IIRC it started as part of the now-defunct clj-sys project
17:43metajackarohner: that worked perfectly! i wonder why it's not the default
17:44metajacktechnomancy: what was clj-sys?
17:44technomancymetajack: I honestly don't know
17:44technomancyit was described to me as "the apache project of clojure"
17:44technomancymmcgrana's is old
17:45metajacktechnomancy: reminds me of jungerl in erlang-world then
17:45hiredman"a collection of stuff we think is really cool, but are unable to get anyone outisde of ourselves interested in"
17:47technomancyhah; :dev-dependencies [[lein-multi "1.0.0"]]
17:47technomancy :multi-deps {"1.1" [[org.clojure/clojure "1.1.0"]
17:47technomancy [org.clojure/clojure-contrib "1.1.0"]]
17:47technomancy "1.3" [[org.clojure/clojure "1.3.0-master-SNAPSHOT"]]}
17:47technomancydaaaaaang it
17:47technomancywhat I meant to say was that http://www.morewords.com/word/cljsys/ is on the front page for results for clj-sys.
17:47gfrlogtechnomancy: that's a complicated password
17:48technomancygfrlog: thank goodness for ssh-agent, amirite?
17:48gfrlogagreed.
17:48amalloychouser: 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:58voltonso.. another noob question... is this idiomatic Clojure? https://gist.github.com/1100521
17:59arohnervolton: it's pretty good. I'd use a doto in there
18:02amalloyvolton: new to java too?
18:02voltonamalloy: no, does it seem that way? :-)
18:02amalloywell, you used java.awt.Frame, which has got to be a hundred years old by now
18:02amalloyjavax.swing.JFrame
18:03voltonamalloy: oh I am just following the examples in Joy of Clojure
18:03amalloyhuh
18:03amalloythat's weird. i mean, awt still works, and swing is written on top of it
18:04amalloybut you should generally try to use javax.swing.J* instead of java.awt.*
18:05voltonwell I guess their rationale is that they are using a java.awt.Graphics to draw stuff
18:05voltonand getGraphics() returns that even on swing, so why bother with swing
18:06amalloymeh. unconvincing; they probably just didn't want to get into the swing/awt gulf.
18:06voltonamalloy: that's what I meant :-)
18:09amalloyanyway, volton, https://gist.github.com/1100537 is an example of rewriting with doto and ->
18:09amalloygreat tools for interop
18:10voltonamalloy: Ha! That is very nice indeed. I posted my solution as a comment but yours is a lot nicer
18:12amalloyvolton: github's parser mangles that a bit. you want to wrap the whole thing with ```...code...```
18:12amalloyactually i guess i can do that myself, since you commented on my fork instead of your original
18:15voltonalright, time to get some sleep
18:15voltongood night and thanks!
18:38RaynesHow is one supposed to require node.js libraries in clojurescript when targeting to node.js?
18:38Raynes'net', for example.
18:39dakronelook at the nodels.cljs example
18:39RaynesOh, duh.
18:39RaynesI for some reason thought it was less sophisticated than it actually is.
18:39Raynesdakrone: Thank you, kind sir.
18:40RaynesYour milk and cookies are on their way.
19:04sjlIs there a way to have Clojurescript watch foo.cljs and recompile it when it changes?
19:05Raynesclojurescript tooling isn't really that sophisticated at this point, given that it was announced two days ago.
19:05amalloyRaynes: yeah, did you see the question on SO about what the standard way to distribute a cljs app is?
19:06sjlHmm. It's kind of painful doing it manually, and too slow to use something like kicker to run the script each time :\
19:06RaynesNo, but haha anyways.
19:06Raynessjl: 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:07sjlRaynes: oh nice, using Cake with it would be perfect.
19:09mjg123no read-string in clojurescript?
19:10mjg123so how to use clojure-literal as representation format in ajax calls?
19:18sjlhmm, 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:26dnolen_sjl: are you compiling your code in advanced mode?
19:27sjldnolen_: yes, because it doesn't seem to output to standard out otherwise :\
19:27dnolen_sjl: I'm pretty just jQuery is not compatible with advanced mode.
19:27dnolen_s/just/sure
19:27lazybot<dnolen_> sjl: I'm pretty sure jQuery is not compatible with advanced mode.
19:27sjlOh. Well that's good to know.
19:31dnolen_sjl: http://code.google.com/p/closure-library/source/browse/trunk/closure/goog/demos/effects.html?spec=svn1075&amp;r=1075
19:31dnolen_sjl: Google Closure library has pretty much everything jQuery can do and then some.
19:32sjldnolen_: jquery UI as well?
19:32dnolen_sjl: only a matter of time before somebody a reasonable face on this stuff.
19:32dnolen_somebody puts
19:32dnolen_sjl: go wild, http://closure-library.googlecode.com/svn/docs/namespace_goog_ui.html
19:33sjlMmm, learning a completely new framework for a weekend project... wasn't exactly in the plan.
19:34sjlLearning clojurescript itself is enough.
19:34dnolen_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:35dnolen_as a jQuery user, whatever, make something better.
19:44Raynessjl: fwiw, the Closure library is very well documented and organized. Not much to learn.
19:45sjlRaynes: I believe it. Maybe I'll learn it in the future.
19:54dnolen_Raynes: persistent ClojureScript REPL can't come soon enuf :)
19:55Raynesdnolen_: :>
21:20alandipertdnolen and sjl google maintains an extern for jQuery
21:20alandipertso it can survive advanced mode
21:21alandipertsee http://code.google.com/p/closure-compiler/source/browse/trunk/contrib/externs/
21:22alandipertgclosure 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:22dnolen_alandipert: cool!
21:23dnolen_alandipert: is there any interest in a type fn for ClojureScript?
21:26alandipertdnolen_: there's interest in anything from clj.core that makes sense
21:27alandipertgfrlog: http://closure-library.googlecode.com/svn/docs/closure_goog_math_integer.js.html
21:28gfrlogalandipert: am I missing the arithmetic functions somewhere? Or is closure more than just a library?
21:29alandipertgfrlog: they're in the impl., for some reason not in the doc
21:30gfrlogoh okay
21:30gfrlogso is using closure with clojurescript the thing to do?
21:31gfrlogjust to make spoken conversation difficult?
21:31alandipertwe've been calling the google one gclosure (lib + compiler)
21:32alandipertstill confusing though :(
21:32gfrlogusing them together could be glojure
21:32gfrlogwhich is fun since the two initial consonants are almost the same
23:10tomoj&(letfn [(k [& xs] (->> (iterate (partial * 1000) 1) (map * (reverse xs)) (reduce +)))] (k 18,869,726,156))
23:10lazybot⇒ 18869726156
23:19metajackIs it just me or is clj-http not setting the Host header at all?
23:25amalloy&((fn [& xs] (reduce (+ (* 1000 %1) %2) 0 xs)) 18,869,726,156) ;; tomoj ?
23:25lazybotjava.lang.Exception: Unable to resolve symbol: %1 in this context
23:25amalloy&((fn [& xs] (reduce #(+ (* 1000 %1) %2) 0 xs)) 18,869,726,156)
23:25lazybot⇒ 18869726156
23:26tomojcool
23:27amalloywasn'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:29tomojboth
23:46dnolen_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 ?