#clojure logs

2011-10-03

00:00brehaut(this analogy doesnt really extend very well does it)
00:00ibdknoxlego technic was awesome
00:00cemerickbrehaut: technic is strint; cl-format is mindstorms
00:01ibdknoxhm
00:01cemerickthe old contrib is most hightly ranked :-(
00:04brehautwhoa, strint is cool. i fear i will lose my mind if i try to understand cl-format
00:04ibdknoxyeah cl-format seemed a bit crazy to me
00:04brehautcommon lisp right?
00:04ibdknoxbrehaut: link to strint?
00:04brehauthttps://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/strint.clj
00:05ibdknoxsweet
00:05jliwhat's mindstorms about cl-format? being able to include format strings in your format strings? :)
00:05jli(at least, I thought that was possible)
00:07jlihttp://www.gigamonkeys.com/book/a-few-format-recipes.html
00:07jliah, it's slowly coming back now
00:09jli(format nil "~r" 1234) ==> "one thousand two hundred thirty-four"
00:09jli(format nil "~@r" 1234) ==> "MCCXXXIV"
00:11jli(format nil "~{~a~#[~;, and ~:;, ~]~}" (list 1 2 3)) ==> "1, 2, and 3"
00:12jliwow, this is really starting to go off the deep end
00:12brehautjli: lets be honest, this is embeded apl isnt it
00:12jlibrehaut: yeah. I just projected all the chars down into ascii and added parens.
00:13brehautthought so
00:13jli"And there's more--I haven't mentioned the ~? directive, which can take snippets of control strings from the format arguments or the ~/ directive, which allows you to call an arbitrary function to handle the next format argument."
00:13jlithis is way worse than regexes
00:14jliLet's say you have a problem and you decide to use cl-format. Now, kill yourself.
00:14brehautim horrified that the blub paradox might extend to string interpolation functions
00:17jlibrehaut: how do you mean?
00:19jli(coincidentally, I queued up Beating the Averages in firefox earlier tonight and I'm getting to it now)
00:19amalloygood read. that's one of two articles that got me over the hump and actually learning lisp
00:20brehautjli: i cant actually explain it any better than that
00:20amalloybrehaut: i don't recognize the blub paradox. is it related to the lisp curse?
00:20brehautamalloy: its another PG thing; any language more expressive than the one you know (blub) looks like ridiculous gibberish
00:21amalloyah, that one
00:22amalloyi think he was talking about more like "pointless fluff" than "ridiculous gibberish", but i suppose it applies here too
00:22brehautconversely, i cant remember the lisp curse
00:22jlibrehaut: so you mean people who write their entire program in a single cl-format look down on us heathens trying to get by with strint etc.?
00:22amalloybrehaut: it's so easy to write an 80% solution in lisp that there are zillions of them, and no 100% solutions
00:23amalloyin blub, it's so hard to do anything at all that you get together a hundred people and eventually finish the 100%
00:23jliamalloy: haha. so basically, people inlining library code into their application?
00:23amalloywhich leads people to prefer blub
00:23brehautjli: well presumably there are people who have mastered cl-format and its clear and obvious to them, but to people like me with blub format functions, it looks unnecessarily complex
00:24amalloysomething like that. "there's a crappy library to do basically what i want, but it's missing N things; i'll just write my own"
00:24brehautamalloy: so its also the javascript curse :P
00:24dnolenamalloy: brehaut: I think it should be renamed to the JS curse.
00:24jlibrehaut: well, most of its capabilities seem useful. it just seems like write-once, read-never code
00:24dnolenNIH syndrome way less in Clojure land.
00:25brehautdnolen: yeah, one upon a time i would have called myself a javascript developer. these days i am not brave enough. thats a scary bad place
00:25technomancybrehaut: multiple major modes is still an unsolved problem for Emacs
00:26technomancyI am not sure it's worth the effort of implementing either
00:26brehauttechnomancy: if you dont have to use something like djangos template system i'd agree
00:26jliamalloy: anyway. yeah, PG. I think my poorly reconstructed road to lisp is roughly: watch The Matrix a lot -> read ESR's How To Become a Hacker -> read PG -> common lisp
00:26technomancybrehaut: yeah, I'm really glad I don't have to use Ruby's ERB
00:27technomancyI tried to write an emacs mode for it, but it was awful
00:27technomancyit's just the wrong problem to solve
00:27amalloyjli: the other one, for me, was http://www.defmacro.org/ramblings/lisp.html
00:28brehauttechnomancy: i just googled. that is about as far from a good idea as you could get
00:28brehauttechnomancy: why not just use PHP
00:31jlienlive didn't make sense to me until I learned css selectors
00:31jli(at least the parsing bits)
00:31brehautjli: ah yeah, without that foundation it would seem like crazy nonsense
00:32jliyeah. ":>" was pretty bewildering.
00:32brehautthats the chicken selector, it finds all the poultry and foul in your document
00:33jlifowl? ;)
00:33brehautjli: yeah sorry, and not pheasants. dunno why
00:33amalloyi wish there were something to find all the foul in your html
00:34ibdknoxme too
00:34ibdknoxlol
00:34amalloyit would either help you validate, or get you to use sexps instead
00:35brehautit would be nice if hiccup and enlive were more easily able to work together
00:36jliisn't it kind of bizarre that paul graham's site has the yahoo favicon still?
00:38amalloybrehaut: data.xml is probably a pretty good bridge for that
00:38amalloyamong other things it can convert hiccup vectors/etc to tag/attrs/content maps
00:39brehautoh yeah, that might do it
00:39amalloythat is the one feature i added to data.xml :P
00:39brehauthah
00:39brehauti need to work out if its how im using data.xml or if its a bug regarding escaping content in output text
00:39brehaut(in emit)
00:41brehautsorry bout the horrible english
00:41brehautits getting late i should go eat
00:41nappingThe irony is delicious - lisp is the most powerful language * programmers can't recognize languages more powerful than their own
00:42brehautnapping: haskell programmers agree ;)
00:43amalloybrehaut: looks like there's still no official release of data.xml, right?
00:44jlibrehaut: hm. I know some haskell - would you say it's more powerful? it has an interesting type system and is really expressive, but still no macros
00:44jliwell, not /no/ macrs, but you know what I mean
00:45brehautamalloy: actually, i think i was thinking of clojure.xml
00:45brehautjli, perhaps you should look up template haskell
00:45amalloyjli: lazy-everything and auto-currying get you a surprising part of the way towards macros
00:45nappingnot terribly unlike "no macros", though
00:46jlilazy everything makes a lot of control flow macros moot, I guess
00:46amalloybrehaut: my understanding is that template haskell is a hideous shambles
00:46brehautamalloy: haha yes :P
00:46brehautbut, its there
00:46brehautthe other thing that gets you a long way is the ghc compiler rewriting rules
00:46gienahsome of the template haskell tutorials suggest that its best to read On Lisp to figure it out
00:46brehautfrinstance, theres a rule that looks for map f $ map g l and rewrites it as map (f . g) l
00:48brehautalso, the type system does let you do some insane things, the c style printf but typesafe implementation is amazing
00:48brehaut(and frightening)
00:48brehautas is heterogenous lists (HList)
00:49jlibrehaut: I read some paper about implementing printf with continuations. is that how haskell printf works?
00:49jlibrehaut: also, HLists - ack! *google google*
00:49nappingyou'll say that after you find it too..
00:49jliis it based on existential types?
00:50brehautjli: the code is far more massive than i can fathom
00:50brehauthttp://hackage.haskell.org/package/HList
00:51nappingQuickCheck is a saner example
00:51brehautjli: i think its just typeclass magic (due to typeclasses being polymorphic on the return type of functions)
00:51brehautcombined with no parens for calls and curried functions
00:51brehauti guess it could be continuations… dunnoh
00:52jlibrehaut: what client are you using that keeps inserting unicode goodness?
00:53brehauterr, colloquay on a mac and me insisting on typographically ellipsis rather than three dots
00:53jlihaskell is a pretty fun place to play with pointlessness, what with $, ., flip, etc.
00:53jlibrehaut: oh, is it not auto-converting that?
00:53brehautjli: fogus informed me once that if i thought thahthaskell was good for PF, i needed to try cat
00:53jlihave you memorized the utf8 code point?
00:54brehautjli: i dont think so. opt+; is …
00:54jliah
00:56gienaha haskell type safe printf is described in section 4 of this paper: http://www.haskell.org/haskellwiki/Simonpj/Talk:FunWithTypeFuns
01:01jlimm, I need to spend some time with the git book. using mostly hg for months has wiped a lot of stuff.
01:47nappingto print some examples with results, can I avoid something like this (defmacro example [form] `(do (println (quote ~form)) (println ";=>" ~form)))
03:19Blktgood morning everyone
04:01kzaribdknox: Is there a way to access the request header / modify the response headers within defpage? Using middleware for some things seems over the top.
04:02kzaribdknox: (Sorry I meant to say, using Noir)
05:01justin`if I have a map that I need to update 3 seperate values in, in there a better way to do it than just (-> m (update-in [:x] inc) (update-in [:y] dec) (update-in [:z] fn)) ?
05:06mrh0057No but if you are going to do it a lot you can write your function to perform that operation.
05:42thorwiljustin`: perhaps you could do a for with [[:x inc] [:y dec] [:z fn]]
05:44amalloyit's not really possible with `for`. you can reduce, though
05:45amalloy&(reduce (fn [m k] (update-in m [k] inc)) {:x 1 :y 2 :z 3 :a 4} [:x :y :z])
05:45lazybot⇒ {:x 2, :y 3, :z 4, :a 4}
05:47kzarIs using .getBytes on a string idiomatic Clojure?
05:48raek_kzar: only if you supply the encoding parameter :)
05:48raek_kzar: what do you want to do?
05:50kzarraek: I'm trying to generate a HMAC-SHA512, I've got some of the way but figuring out the Java libraries is a puzzler
05:50kzarraek_: I was going from this example http://download.oracle.com/javase/1.4.2/docs/guide/security/jce/JCERefGuide.html#HmacEx
05:56raekkzar: ok, these algorithms operate on bytes (not chars) so you need to encode the string into a byte array (you can do this with (.getBytes string encoding) )
05:56raekbut what byte value(s) does a character have?
05:56raekthat completely depends on what encoding scheme you use
05:56kzarraek: I suppose it depnds on the encoding, hence the parameter
05:56kzarraek: Yea
05:57kzarraek: Is there a way to check encoding of a string?
05:57raekkzar: and that example is broken, since it will produce different hashes for the same string on different machines
05:57raekkzar: strings don't have encodings
05:58raekkzar: you can think of the connection between a byte array with, say, UTF-8 data and string as the conenction between a JPG stream and the picture you get on thescreen
05:59raeka picture can be stored in many formats
05:59raeklikewise can a piece of text be stored in many formats
06:00raekkzar: so to for the hash function to make sense, it must either take an encoding argument or hard-code a certain encoding
06:02raekso you might document the function like "Computes the HMAC-MD5 hash of the bytes acquired by encoding the string s using encoding e"
06:03kzarraek: How come the string doesn't have an encoding though, how does it store the piece of text?
06:05kzarraek: Also the doFinal method for the Mac object seems to return a byte array, but mapping char over it throws an exception I think because some of the numbers are too high / low. How can I convert it back?
06:06raekkzar: yes, String uses some kind of encoding internally (which happens to be UTF-16) but that is an implementation detail
06:07raekkzar: ok, so the algorithm outputs a byte array. what does it contain?
06:07raekif it's not text, then you should not try to make a string from it
06:08raekstrings on the JVM platform are for textual data only. there is no class for "byte strings" as in python3, for example
06:08raekonly byte arrays
06:09kzarraek: Right OK, fair enough. I do need a string rather than a byte array though, so what do I do?
06:10raekthat depends on which way you want to represent the bytes as a string
06:13raekif you are simply going to store this value in a file or send it over the network, OutputStream has a method that accepts byte arrays (so there's no reason to go from bytes to string back to bytes again in that case)
06:15kzarraek: Hmm I need to calculate the hmac-sha512 and then use it to check against the value they gave me. I'm not really sending the calculated value to a file or anything
06:16raekok, so you received a string?
06:16raekis it a hex string or something else?
06:17kzarraek: Yea, so I'm attempting to write this function that takes a message, key (, and encoding I guess) and returns the result. I'm going to then use that as a piece of Ring middlewear, I get a value in the header and I need to check that it's correct
06:17kzarraek: That way we know the request came from our guys
06:18raekhrm
06:19raekunfortunately HTTP does not specify which encoding the headers are in
06:19raekwhich means that ideally they should be treated as bytes and not characters (since we do not know the encoding)
06:20raekbut the servlet framework *will* decode the headers with some encoding scheme
06:21raekif you can guarantee that the header in question will only contain ASCII (for example by sending the data as hex or base64), maybe you could avoid this problem
06:25kzarraek: Hmm I think I'm probably more confused now
06:26raekkzar: much of what you have into interface with here is not encoding aware (which means that you get all kinds of nasty problems for non-ASCII text)
06:27raekkzar: is this header some sort of key?
06:28raekor is it a signature of the message?
06:28kzarraek: How do you mean? Well I look for a header like X-AUTH-HMAC or similar and then take that value and compare it to my calculated value
06:29raekok, and what is the input to the HMAC-MD5 function? the request body?
06:30kzarraek: Yea, I'm actually doing a SHA512 instead of MD5 though. That's just the closest example I found
06:30raekok
06:30raekso here's what I would do:
06:31raekmake sure that the body (which is text, I presume) is always encoded in UTF-8
06:32raeklet the X-AUTH-HMAC header value be encoded with base64
06:33raekso if you have the array [97 98 99], it will be transmitted as the ASCII string "YWJj" in the header
06:34raekthen when you receive the body (string decoded from body with UTF-8) and the header (base64 string), get the bytes from the body by encoding it in UTF-8 again (with getBytes)
06:34raekand de-base64 the header to get the bytes stored in it
06:35kzarraek: OK, I've found an example that shows you how to turn the digest into a string as well. That's working
06:35kzarraek: Main thing that confuses me now, how to turn a string key into a java.security.key
06:35raekthen you only have byte arrays which you can pass to the function and compare with java.util.Arrays.equals
06:38raekkzar: maybe you can use SecretKeySpec
06:38raekyou need to give that the byte array of the key
06:38kzarraek: ahh
06:38raek(which you can obtain by de-base64:ing the header string)
06:39raek(if you choose to implement my approach)
06:39kzarraek: Yea I think I'll do it your way becaues you seem to be quite clear on the different encodings. Actually how did you learn all that? I always fudge my way through this stuff
06:40raekkzar: I'm a Swede. I see the results from encoding errors by simply using my native language. :P
06:41kzaraha
06:41raekwell, it helps if you think of byte strings and character strings as icompatible types
06:41raek*in-
06:42raekand that somewhere a translation always has to be done
06:45kzarraek: Thanks for explaining all that, really helpful
06:46raekkzar: np. glad to help. :)
07:20ilyakIs there something like (let [foo (x) bar (y)] (body foo bar)), but which only evaluates body when foo and bar aren't null?
07:24ejacksonnested if-let
07:28michaelr525hello!
07:28BlafaselAnyone related to 4clojure? The only guy I know that is a contributor is US based (or at least: sleeping, in a timezone where it's pitch black now). Site's dead :( I don't want to get back to real work :)
07:29Blafasel502 bad gateway sounds like the backend process for cgi/fcgi or something died..
07:33ejacksonyeah, sounds like somebody needs to attend to a service
07:35BlafaselAh well.. Back to C# then it is.
07:35michaelr525Blafasel: i think amalloy_ is related to 4clojure, try poking him maybe
07:36michaelr525...and back to C# as well ;)
07:40michaelr525amalloy_: ^^
07:44Blafaselmichaelr525: He's the one that should sleep now :)
07:44michaelr525ah
07:44BlafaselI think. And the trailing _ seems to be the "I'm not here" marker :)
07:45Blafasel(ignoring that one could use /whois to check the away state)
07:49ilyakejackson: Thanks
07:49ilyakwhen-let did the trick
07:50ejacksoncool
07:53lnostdalany way to terminate the rogue thread created by an accidental send-off?
07:53lnostdala rogue*
07:57lnostdalns-unmap on the variable holding the agent didn't seem to work
08:25fdaoudgood morning
08:25fdaoudanyone else getting 502 Bad Gateway on 4clojure.com?
08:25zippy314yep
09:03tcrawleyThere seem to be a few testing frameworks for clojure to choose from. Does anyone here have a preference they'd like to share?
09:04ejacksonI use the standard test, but midje seems very popular
09:05fdaoud+1
09:07tcrawleyejackson: fdaoud: have either of you played with speclj? https://github.com/slagyr/speclj
09:07ejacksontcrawley: nope
09:08fdaoudI have not
09:09tcrawleyspeclj is attractive simply because I've done lots of rspec, but midje looks interesting
09:13fdaoudtcrawley: don't throw eggs at me-- I use Maven so having standard tests being executed within Maven test target is nice for me
09:14tcrawleyfdaoud: heh - my tests will be executed by maven as well - are you using https://github.com/talios/clojure-maven-plugin?
09:16fdaoudtcrawley: yes, and with this piece of configuration, mvn test works: https://gist.github.com/1259078
09:17fdaoudreload, I put the whole piece
09:18tcrawleyfdaoud: thanks!
09:18dbushenkowhat is the difference between fn and fn* ?
09:19fdaoudtcrawley: welcome
09:27jbwivhello all. Anyone here using Intellij Idea for clojure dev with the la clojure plugin?
09:27ArafangionHow does one get java programs to start faster?
09:27ArafangionWait, it was javac -version I was checking.
09:28Arafangionjava -version is only 10 or 20 times slower than python, that's not so bad.
09:28jbwivArafangion, you might read this article: http://blog.headius.com/2010/03/jruby-startup-time-tips.html. It's focused on Jruby, but would apply to any JVM lang
09:28Chousukeif you really need fast startup you can run a persistent jvm instance using eg. cake
09:28ArafangionThanks. :)
09:29ArafangionOoh, cake isn't neccessarily worksafe.
09:29Chousukeso basically it's just cheating by always running the jvm, but that might not be a bad solution
09:29Chousukeworksafe? :/
09:29ArafangionHow do I google "cake" and not get, you know, cakes?
09:29ArafangionChousuke: Lingerie cakes are result #4.
09:30Chousukegoogle clojure cake :P
09:30ArafangionOk. :)
09:30ArafangionAh, yep, that works. :)
09:30fdaoudmmm, cake.
09:30andrewcleggdoes "cake" mean something different outside the UK? what's a lingerie cake? I'd google it but I'm at work :-)
09:31Arafangionandrewclegg: I'm just going to hope it means "A cake in the shape of lingerie".
09:31redingerYeah, googling cake for me doesn't result in any lingerie. :)
09:32ArafangionWell, google is known to give different results depending on where you are.
09:32ArafangionJust checked it out, and interesting, nothing to do wiht cake.
09:33Arafangionwww.cakelingerie.com - not worksafe, but not exactly that outragious either, you'd do worse checking clothin advertisements. It's a website that 'congratulates you on your pregnancy'./
09:34andrewcleggaaaaaah :-)
09:35BlafaselWeird world in which this is not worksafe..
09:36ArafangionDepends on who is passing by behind you.
10:11ejacksonI'm having a problem getting the evaluation time of arguments to a macro correct
10:11ejacksoni've put up a gist https://gist.github.com/1259177
10:11ejacksonany explanation or help would be most appreciated :)
10:13ejacksoni'm unable to make the main argument available to the macro, very frustrating !
10:15TimMcChousuke, chouser: Remember yesterday's discussion about the possible inadvisability of automatic subvec-like behavior with (vec (seq some-vec))?
10:16TimMcChousuke, chouser: We just fixed a bug at work where String/substring and String/split held onto entire large documents even though we just wanted some small tokens -- which were then stored in a large in-memory hash table. Out of memory!
10:17fdaoudcrap. I was really enjoying 4clojure.com and now it's down :(
10:18TimMcfdaoud: amalloy will be at work in about 4 hours, I would hazard.
10:18Blafaselejackson: Disclaimer: I'm a lousy starter. Two questions: fm uses (symbol '=') ak uses 'and => Why the difference in quoting? More on topic: Why a macro? Couldn't it be a new method my-where taking a map and passing it on?
10:18jkkramerejackson: if ak is a macro, then (cql/where (ak {:a 6 :m 9})) should work, i think
10:19TimMcfdaoud: Or... based on his last timestamp in #4clojure, maybe 5 hours. >_<
10:19Blafaselfdaoud: Heh. Just created a beautiful (yeah.. well..) solution, tested it locally and it went down before i could submit my pascal triangle :)
10:19BlafaselTimMc: /whois him :)
10:20TimMcBlafasel: What about it?
10:21TimMcThe away timestamp means nothing without a time zone.
10:21fdaoudTimMc: thanks for the info
10:21ejacksonBlafasel: quoting, no reason actually. macro: I was having trouble avoiding the evalution of the equalities, so I just wanted the forms. I'll try again though.
10:22fdaoudBlafasel: how many problems solved you at?
10:22ejacksonjkkramer: Let me try that... thanks
10:22ejacksonmy head has been done in
10:22BlafaselTimMc: I was refering to "16:21:07 -!- idle : 0 days 4 hours 37 mins 7 secs [signon: Fri Sep 30 06:10:17 2011]"
10:22Blafaselfdaoud: No idea :)
10:22BlafaselNot a lot yet. 20? 30?
10:24TimMcBlafasel: Oh, cool. I just learned how to display that info.
10:31ejacksonBlafasel: OK, I tried as a function https://gist.github.com/1259177#gistcomment-53987
10:31BlafaselTo continue the stalking: It should be ~7:30 for him.. ;-p
10:31ejacksonits passed the predicate as the list, but it where just returns it
10:32ejacksoni don't understand why
10:36ejacksonits a function argument so it should be evaluated by the time the where macro sees it, so its should just be a list. Yet it treats it as it if something unrecognised... aaaarg
10:36Blafaselejackson: (defn better-where [p] (cql/where (ak p))) or (defn better-where2 [p] (apply cql/where (ak p))) won't work? Sorry if that's totally stupid?
10:36BlafaselI mean: Why the macro in the first place?
10:36ejacksonBlafasel: lemme try
10:37ejacksonBlafasel: Yeah, the macro, see my last mini rant about trying it a function, where just mocks it
10:38BlafaselUhm.
10:38gtrak~no, kancho $1 is <reply>javabot teleports silently behind $1, crouches and yells 'a thousand years of pain!'
10:38clojurebotAck. Ack.
10:38BlafaselWrapping it explicitly as a function? #(ak p)?
10:38ejacksonBlafasel: better-where2 doesn't work as where is a macro, so apply can't use it
10:39gtraksry clojurebot, wrong window
10:40ejacksonBlafasel: and better where is exactly the function I put in the comment, for some reason, which I don't understand, it doesn't work
10:40ejacksonlemme
10:40ejacksontry
10:40ejacksonthe
10:40ejacksonwrapping as a function
10:43theignoratican I make leiningen put the jar it builds in a dir?
10:52zippy314Does anybody know why sometime I get classes reported back as Ljavax instead of javax? Specifically working with java mail I'm getting: [Ljavax.mail.internet.InternetAddress as a class type.
10:53joegallothat's an array of InternetAddresses, i think
10:53twem2zippy314: see http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getName%28%29
10:54twem2its an array
10:55zippy314THanks, thats exactly right.
11:04jliamalloy_: I don't suppose you could bring 4clojure back up now? :)
11:04ejacksonwow, i didn't realise how popular that site is
11:07fdaoudjli: he's away
11:14jliejackson: I keep crashing it
11:14jlifdaoud: ah, oh wel
11:15ejacksongood work
11:15jli\o/
11:15lnostdalhm, i don't get this .. i got an app depending on a library, which in turn depends on hiccup-0.3.6.jar .. but looking in lib/ after a 'lein deps' in the app root folder shows hiccup-0.3.5.jar ...?
11:16joegallothe library and version that you're depending on would be helpful, if you're looking for diagnosis rather than commiseration :)
11:16lnostdalit's a local library here
11:17lnostdalit has :ring "0.3.11 and hiccup "0.3.6" in its :dependencies list (project.clj) .. if i run lein deps there it'll grab the right versions
11:17brcrthHi, what's the advantage of having anonymous functions? How I'll "call" the function when I need it?
11:17lnostdalbrcrth, http://en.wikipedia.org/wiki/Anonymous_function#Sorting
11:17joegallobrcth: you pass them around as arguments, or set them to local names in let, for instance
11:18brcrththanks :)
11:18joegalloso you'd call them like this (the-argument) or (the-name-that-i-let)
11:18joegallowhich is to say, just like other functions
11:20lnostdalthis doesn't make any sense .. grepping, "0.3.5" isn't mentioned anywhere
11:21kzarraek: What do you think? https://gist.github.com/1259359 It's not working right but I think it's nearly there
11:50TimMcfdaoud: 4clojure is up again, thanks to amcnamara
11:51raekkzar: I think you want to use this instead of the private sun classes (which are not guaranteed to be there): http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html
11:51raekkzar: [commons-codec "1.4"]
11:51fdaoudTimMc: thanks!
11:52gtrakI think contrib has a base64, no?
11:52raekkzar: and you want to decode the base64 string (not encode it).
11:53raekdecoding the base64 ASCII representation gives you the original bytes
11:53kzarraek: Silly me for taking an example at face value with no sanity check
11:53raek(but decoding bytes with a character encoding scheme gives you a string)
11:53raekso decode/encode has opposite types :)
11:54lnostdaldoes lein have some sort of verbose mode? .. so i can see why it's doing what it's doing?
11:54raekkzar: I would also split out conversion from string and base64 form to outside that function
11:54gtraklnostdal, what in particular is so unpredictable?
11:55raekit's not relevant for the hmac algorithm in what way the bytes were represented before it gets them
11:56raek(defn bytes-from-auth-header-value [base64-string] (Base64/decodeBase64 base64-string))
11:56lnostdalgtrak, i have project "B" which depends on ring 0.3.11 .. project "A" depends on project "B", but when i run 'lein deps' in context of project "A" it'll actually grab ring 0.3.8 for some reason not revealed
11:56raek(defn encode-in-utf-8 [string] (.getBytes string "UTF-8"))
11:57gtraklnostdal, for that, use lein pom to write a maven pom.xml, then use mvn dependencies:tree to see why it does what it does
11:57gtraknot sure if there's a native lein way to do that
11:58gtraklnostdal, then, once you find which dependency is pulling in the bad ring, you can add an exclusion to your project.clj
11:58raekkzar: also, you have a problem here: (.getBytes key)
11:59raekthis uses the platform default encoding. you'd better fix it to something non-changing (e.g. a constant "UTF-8")
12:00raekif the key is automatically generated, you should use the original byte array form (assuming it's avaiable)
12:01lnostdalok .. now i can't even get ring to build itself .. mvn install tries to pull stuff from some remote repository ...
12:02raekif you need to base it on a user-supplied string, you need to make sure that the path from the user to the .getBytes is encoding-aware (e.g. does not pass though a HTTP header)
12:02gtraklnostdal, huh?
12:02gtraklet maven do its thing
12:03lnostdalkinda makes local patching, well, hard
12:03gtrakwhat does?
12:03lnostdalit pulling stuff from clojars.org or whatever seemingly at random
12:03gtrakdon't actually use maven for building, just use it to build you a dependency graph
12:04gtrakto do that, it needs to download its own plugins, plus all the poms for all the dependencies
12:05gtraki think the command is actually mvn dependency:tree
12:27kzarraek: OK I think I've made those changes right, does using the = function to check if two byte arrays are equal work though?
12:27dnolenso now that we have Browser REPL, what about an iOS REPL ?
12:28raekkzar: no, = means "identical" for mutable thing, including arrays
12:28raekkzar: use (import 'java.util.Arrays) (Arrays/equals arr1 arr2)
12:29raekthis means "currently have the same value"
12:29lnostdalseems use of :main (in project.clj) and :gen-class was confusing lein/mvn (or me; whatever really.. *sigh*)
12:29dpritchett_is there a repl as cool as say iPython or irb+wirble yet?
12:29dpritchett_for clojure that is
12:31lnostdalemacs+slime, dpritchett_ ?
12:31dpritchett_I mean a no-dependencies repl
12:31lnostdalsure beats irb last time i tried that
12:32dpritchett_i like to work in vim with a REPL that i occasionally reload files with
12:32dpritchett_my two environments are vim + ipython/bpython and vim + irb
12:32lnostdalso you have a repl already then
12:32dpritchett_I have tried to love emacs a few times just because of clojure and it's never workedo ut
12:32dpritchett_lnostdal: Does the repl have line numbers, colorization, auto indents, etc?
12:32lnostdal..but if you want a cooler one i bet slime is cooler
12:32dpritchett_this is the kind of stuff i like about ipython/bpython
12:33dpritchett_plus bpython automatically supplies help text for whichever function i'm typing up at the moment
12:33lnostdalyes, except line numbers (does that even make sense in a repl?? -- i use buffers/files when stuff grow to, say, 5-6+ lines or so)
12:33lnostdalyup, it got that too
12:34gtrakdpritchett_, feel free to make an iclojure, I'd use it :-)
12:34dpritchett_so i could use slime purely for the repl and then do my actual editing in vim?
12:34dpritchett_how... odd
12:34dpritchett_i rather like the idea
12:35lnostdalmight as well switch to emacs full-time then .. it's not that hard .. and elisp is a lisp, so you get more lisp while coding a lisp
12:35dpritchett_woah woah woah
12:35lnostdal:>
12:35gtrakyo dog, i heard you like lisp, so I gave you a lisp so you can lisp while you lisp
12:35dpritchett_I ask for a slightly juiced up cljoure repl and you jump to "might as well switch to emacs full time"
12:35dpritchett_cmon now
12:36dpritchett_Maybe if I were a full time clojure programmer I would be interested, but vim has served me faithfully on many different stacks so far
12:36lnostdal*shrug* .. perhaps there are some middle ground type thing out there, i don't know
12:36dpritchett_i've tried viper etc. and they didn't feel right
12:36dpritchett_i guess i could always try again
12:36dpritchett_i really like the simplicity of great repl + unconnected text editor
12:37dnolendpritchett_: have you you looked at clooj? It the closest thing to something like Python's IDLE. It needs some work as far as syntax highlighting, but it has a lot of interesting features already.
12:37dpritchett_thank you dnolen, i will check it out
12:37dpritchett_IDLE is a big part of why i got into python to begin with
12:37dpritchett_its a great environment for playing around in
12:37dnolendpritchett_: clooj definitely fits the bill of staying of your way.
12:38dpritchett_looks like clooj is swing-based though, i do my clojure work on linux VMs and my desktop here is win7
12:38dpritchett_i foresee headaches down that path
12:38gtrakwhy's everyone hate on swing all the time?
12:38dnolendpritchett_: like it not understanding Linux/Windows conventions?
12:38dpritchett_i might try to run clooj on windows jsut to see how i like it
12:38dpritchett_yeah i would expect some of that dnolen
12:39dpritchett_I have nothing against swing gtrak, i just don't have a trustworthy java-speaking GUI handy
12:39Bronsadpritchett_: http://i.imgur.com/eFaUa.png
12:39Bronsaisnt this tempting enough? :>
12:39gtrakdpritchett_, like netbeans or idea? those are in swing
12:40dpritchett_ok, i guess i failed to accurately frame my problem
12:40dpritchett_i haev a tiny VPS, i work via putty and tmux, i like REPLs and vim
12:40gtrakdpritchett_, ah, you should do it locally and upload instead :-)
12:41dnolendpritchett_: why not vimclojure or slimv then?
12:41dpritchett_i havent really been back to vimclojure in a year or so, i remember trying 1.2 when it was finally released and it didn't sit well with me
12:41dpritchett_i haev never gotten slimv up and running, that's another thing to try
12:41dpritchett_I'm much better at this sort of thing than I was last October when vimclojure 1.2 came out
12:42dpritchett_perhaps I should just try everything one more time
12:42dpritchett_i still like having standalone repls
12:42dpritchett_i have built entire django sites with ipython in one pane and vim in the other this year
12:42dpritchett_and i really enjoyed that dynamic
12:43dpritchett_slimv looks al right though
12:43dnolendpritchett_: I never liked the Python REPL experience.
12:43gtrakipython was pretty nice, but eventually I just used eclipse for it all
12:43dpritchett_dnolen: Have you tried many of them? I'll admit that none of the python repls I've used were perfect
12:43dnolenreloading changes module w/ restarting everything was always a PITA
12:44kzarraek: OK I've made those changes, here's the test that fails https://github.com/kzar/ring-hmac-check/blob/master/test/ring/middleware/hmac_check_test.clj . I posted the full project this time - it's harder to post a small snippet after the refactor
12:44dpritchett_that is true, i hacked some init scripts into my .ipythonrc to reload my hottest modules with three-letter aliases
12:44dpritchett_and that only worked because my app was still fairly small
12:44dpritchett_and there are times when stopping and restarting the repl is necessary because i can't get rid of all of the objects from the last version of my class
12:44dpritchett_I can't fault you for finding that awkward; it is
12:45dpritchett_slimv seems like a good way to have my cake and eat it too
12:45dpritchett_considering how much mindshare swank has in this community
12:46gtrakit took me like 2 days to get effective on emacs and slime, but I don't have a vim habit to compare my effectiveness to
12:47dpritchett_i could certainly force myself to use emacs but it just seems silly to have my editor forced on me by a programming languages
12:47dpritchett_^language
12:47dpritchett_next thing you know people will be claiming they enjoy working in eclipse :P
12:48dpritchett_i'm rather susceptible to RSI which is another reason i avoid emacs... all of those key chords really hurt me after a day or two
12:48kzardpritchett_: There are a few articles about emacs + rsi about
12:48gtrakdpritchett_, first thing is to switch caps-lock to be your ctrl
12:48dpritchett_There'd have to be, eh?
12:49kzardpritchett_: I don't think there's causality. This book is worth reading by the way: http://www.amazon.co.uk/Mind-Body-Prescription-John-Sarno/dp/0446675156/
12:49dpritchett_I force myself to always use the opposite shift key from whichever key i'm modifying so that i don't have to hit two simultaneous keys with fingers ont he same hand
12:49dpritchett_i guess i need a right-capslock too
12:49dpritchett_kzar to be fair i was a rather avid gamer back then
12:49jkkrameror foot pedals ;)
12:49dpritchett_many causes to be sure
12:50dnolendpritchett_: I've been using Emacs for 7 years now, I hate doing any long Emacs sessions w/o my Kinesis.
12:50dpritchett_is that the thing technomancy strapped to his pants?
12:51kzardnolen: You should read that book as well, it's less fluffy than it sounds
12:52gtrakdnolen, which kinesis?
12:52dnolenKinesis Advantage
12:52gtrakso sexy, I haven't tried a keyboard like that yet
12:52dpritchett_i had one of those MS split keyboards a decade ago and i loved it
12:52gtrakbut i guess if this is my job for 50 years it's worth it
12:52dnolengtrak: the best part is that it lets you leverage your strongest fingers - your thumbs.
12:53dpritchett_+1 gtrak, i was just weighing the benefits of bringing my own $300 KB to work
12:53dnolenI've had my Kinesis for 5 years now. Rock solid.
12:53dnolencan't say that for much tech I own.
12:55dpritchett_Do you work from home?
12:55dpritchett_It'd be sad having a sweet keyboard at home or at the office and then not having one one the other side
12:57dnolendpritchett_: At one point I had two, work/home, but I gave my other to my brother who was having RSI trouble.
12:59rbransoni've taught myself how to type with my arms/hands at natural angles instead of bent, works great, even on a $10 keyboard
13:00dpritchett_What, like you have your arms nearly fully extended?
13:00gtrakyou don't rest your palms?
13:00dpritchett_I adjust the pitch of my keyboard regularly and slide my KB forward and back regularly to find a good spot
13:00dpritchett_sometimes I rest a wrist on a makeshift support
13:01dpritchett_Oh I forgot rbranson has a sit/stand desk
13:01dpritchett_That'd help
13:01rbransoninstead of bending at the wrist and aligning my fingers with the home keys
13:01rbransonmy fingers do a little bit more work and my wrists stay straight
13:02rbransoni was using natural keyboards for like 10 years though, don't feel much of a difference either way
13:03raek7away
13:03raekeh.
13:05dpritchett_Has anyone here played with clansi? Looks like a neat way to add colorization to any old command line clojure tool
13:05dpritchett_like say `cake repl`
13:05hiredmanI have
13:05dpritchett_have you hooked it into a repl? the clansi source is only 130 lines of clojure, i just need to figureo ut how to hook into it
13:05fdaouddpritchett_: just catching up.. fwiw I use vim and regular command-line repl, works fine. don't like emacs.
13:05hiredmanand I started to play with a repl that uses clojure.pprint and clansi for printing
13:06dpritchett_that sounds awesome hiredman
13:06hiredman*shrug*
13:06dpritchett_How'd you set up that repl?
13:06dpritchett_Just runtime invocations of pprint and clansi at startup?
13:06dpritchett_thanks fdaoud, that sounds like where i'm headed
13:06dpritchett_I have probably spent more time on clojure tools than on clojure programming... no one to blame but myself
13:07hiredmanI can tell
13:07dpritchett_maybe i should be a hardcore greenscreen guy instead of even trying to make myself happy with tools
13:08gtrakdpritchett_, yea focus on punchcards first
13:09dpritchett_most of the folks in my office are greybeards with punchcards and flowchart stencils and other cool stuff
13:09dpritchett_i learn a lot from them
13:14crazyFoxis there a naming convention for types defined with defrecord (or deftype or protocol for that matter)? Like, would i write (defrecord my-record-type ...) or rather (defrecord MyRecordType ...)?
13:15dnolencrazyFox: people tends to use Java naming conventions for protocols/types/records
13:17crazyFoxdnolen: ok. thank you.
13:20crazyFoxdnolen: does this also apply to the field/method names?
13:26jbwivI'm trying to build clojure-contrib and getting this output from mvn package (https://gist.github.com/60301f4a98dc666d8a4b). Any ideas how to solve?
13:28dnolencrazyFox: no fields and protocols fns should follow normal Lisp naming conventions.
13:32dnolenjbwiv: looks like your trying to build with 1.3.0, that probably won't work since some of those libs are not 1.3.0 compatible.
13:35dnolenjbwiv: you could probably make that work by building w/o tests.
13:37jbwivdnolen, ah, ok. what should I be using? 1.2?
13:37jbwivsorry...clojure newb here
13:38dnolenjbwiv: don't use monolithic contrib, it's deprecated.
13:38dnolenjbwiv: the most useful bits were already incorporated into 1.2.0
13:38jbwivdnolen, what's the best way of getting access to sql?
13:38jbwivthought that was in clojure-contrib
13:38dnolenjbwiv: https://github.com/clojure/java.jdbc
13:39jbwivdnolen, ok, thanks!
13:42dnolenno if only someone would implement all the Clojure persistent datastructures in C++ we could use them from V8, SpiderMonkey, JavaScriptCore ...
13:42dnolens/no/now
13:42seancorfieldorg.clojure/java.jdbc "0.0.6"
13:43gtrakdnolen, I think you need GC for this, yes?
13:43seancorfieldi need to push that up to 0.1.0 but there's a ticket i want to get in before then (resolving duplicate column names in a join)
13:43gtraksounds like a huge pain in the ass without GC
13:46gtrakI guess you can do smart pointers, but no circular references right?
13:51dnolengtrak: seems surmountable, http://code.google.com/p/jscocoa/wiki/GarbageCollection. I believe V8 has similar guidelines.
13:52gcvIs there any documentation on what exactly changed with exception handling between 1.2.1 and 1.3.0? I see some weird behavior where 1.3.0 chains an exception thrown from a Java library to a RuntimeException, which makes catch specificity impossible.
13:52gtrakI've done a little C++ and i'd be very very afraid
13:53dnolengtrak: well Node.js isn't.
13:53gtrakdnolen, you mean they have structurally shared data structures in node?
13:54dnolengtrak: no I mean they probably have to create C++ objects which are subject to GC there as well.
13:54gtraksure, java has a GC, too, but the data structures are written in java, not C++
13:54jbwivso I dropped back to 1.2 to compile clojure-contrib, because apparently the code I'm using requires that version of sql. I'm now getting this when building: https://gist.github.com/298cb5d4f6ef2a150b1a. Any ideas?
13:55kharrington1pretty sure the best way to do clojure data structures in C++ is to do it on top of Boost, then you can get GC for "free"
13:55gtrakkharrington1, not GC, reference-counted smart pointers
13:56gtrakit's a can of worms
13:57kharrington1mmm
13:57dnolenjbwiv: if you're using 1.2.1 there's no reason to build contrib from scratch.
13:57jbwivdnolen, so under 1.2.1, contrib is already there?
13:58dnolenjbwiv: no it's a separate jar, but just drop into your classpath
14:01jbwivdnolen, so, where would I find this jar? I don't see it after building 1.2.1
14:02dnolenjbwiv: contrib is not a part of 1.2.1. it's separate jar. And why do you need to build 1.2.1? It's also available for download.
14:03jbwivdnolen, ok, thanks. I typically like to download source zips and build them myself, but in the interest of time I'll just download the bins
14:04dnolenjbwiv: btw, what code are you using that requires the older SQL lib?
14:05jbwivdnolen, something another dev here wrote. may not require it, but I was getting "Could not locate clojure/contrib/sql__init.class or clojure/contrib/sql.clj on classpath" even after building java.jdbc
14:05jbwivso I presume it requires the older lib, but it is just as likely to be my setup
14:05dnolenjbwiv: because the namespace it's pointing as is wrong now.
14:05dnolens/as/at
14:05jbwivdnolen, ah, k
14:06dnolenjbwiv: it's probably worth considering the minor hassle moving to java.jdbc since it's actively maintained.
14:07jbwivdnolen, ok, thanks. in this particular case, I'm re-writing the code to ruby...but if it were staying clojure, i'd definitely follow your advice. I really appreciate the help
14:14gcvCould someone fill me in on the exact implications of the removal of checked exceptions in 1.3.0?
14:14gcvDoes every checked exception thrown by Java code get chained to a RuntimeException?
14:21dnolengcv: checked exception are a fiction from what I understand, http://tapestryjava.blogspot.com/2011/05/tragedy-of-checked-exceptions.html
14:24gcvdnolen: I totally agree that checked exceptions are broken by design, but something changed in Clojure between 1.2.1 and 1.3.0 — I call a Java method which defines a checked exception, but I can't catch it in Clojure 1.3.0. This used to work in 1.2.1. When I looked at the thrown exception closely, it turned into a RuntimeException with the original exception chained to it.
14:24gcvso I was hoping to understand the changes in 1.3.0 a little better — the changedoc has no details at all.
14:25TimMcI've heard some other people complaining about this too.
14:25dnolengcv: checked exceptions used to be supported I think? that's since been removed.
14:25technomancy"Checked exceptions are the TSA of software. So what if there's no evidence we're safer, at least we're inconvenienced." - http://twitter.com/#!/posco/status/116535658515939328
14:26gcvguys, I'm not disagreeing that checked exceptions suck :)
14:26TimMcdnolen: And are instead wrapped in RTEs?
14:26gcvI'm just trying to understand why catching an exception declared as checked in external Java code doesn't work.
14:26gcv(anymore)
14:26dnolenTimMc: I think so I don't understand the details of the change.
14:28TimMcNeither does anyone, as far as I can tell.
14:29TimMc"Clojure does not throw checked exceptions" <- OK...
14:29TimMcgcv: Experimentally, what does clojure throw?
14:30dnolengcv: bring the issue up on the mailing list, I'm sure someone has experienced this before.
14:30gcvdnolen: will do
14:31TimMcgcv: If you (throw (IllegalAccessException. "foo")), what does Java catch?
14:32gcvTimMc: no idea, I don't have any code which calls Clojure from Java
14:35pjstadiggcv: i think all exceptions are wrapped now into RuntimeExceptions
14:36amalloydnolen: i read your link, followed one of the comments to http://james-iry.blogspot.com/2010/08/on-removing-java-checked-exceptions-by.html - pretty remarkable abuse of the type system to get around checked exceptions
14:37gcvpjstadig: I hope not, because that means typed catch is now useless, which weakens Clojure's Java interop story.
14:37hiredmanpjstadig: are you sure about that?
14:39hiredmanI believe that is only if you are using reflection
14:39pjstadigno i'm not sure
14:39pjstadigi'm likely wrong
14:39hiredmanclojure's reflector rethrows as runtime exceptions to avoid having to declare thrown exceptions everywhere
14:40hiredman(in 1.3)
14:40crazyFoxis there any other way to resolve cyclic load dependencies than putting code into a different file?
14:40pjstadighttps://github.com/clojure/clojure/commit/8fda34e4c77cac079b711da59d5fe49b74605553
14:41crazyFoxpjstadig: u r talking to hiredman?
14:41pjstadigyeah i mean checked exceptions are a fiction (like has been mentioned) there's no reason to wrap them in the bytecode that clojure emits
14:41hiredmanright, but non-reflective calls still compile to normal java method calls, so exceptions bubbling out will not be caught and rethrown by the reflector
14:42pjstadig*wrap them in a RuntimeException
14:42hiredmanwell, the reason is the reflector is written in java, so it has to abide by the fiction
14:42hiredmanand if the reflector has to then so does the compiler etc
14:42pjstadigyeah
14:42hiredmanit ripples through the java codebase
14:43pjstadigright so i suppose anytime you cross that java barrier with clojure code, an exception thrown will get wrapped in Clojure's java code
14:43amalloyi guess the reflector couldn't be written in clojure because there are pieces of the runtime that depend on it? that's too bad
14:45crazyFoxcan declare be used to resolve cyclic load depedencies?
14:45dnolencrazyFox: no, you have to change your project structure
14:45raekcrazyFox: between vars in a namespace, yes. between namespaces, no.
14:46crazyFoxdealing with different namespaces so - ok ill change my files. not an ideal solution though.
14:46duck1123fixing load dependencies are a pain, but your project will be better for it anyway
14:47crazyFoxduck1123: what do u mean by "you project will be better for it anyway" (- maybe i dont quite understand bcause im not a native entlish speaker)
14:47raekthis is the result of some design decisions that makes it easy for macros to work the way they do (they can use any functions defined "so far" to do their job)
14:48crazyFoxyeah i see
14:48duck1123I'm just saying that if you have load dependency issues, it usually means you haven't thought out the structure of your project enough
14:49duck1123I've moved so many functions around just to stay one step ahead of that issue, and my project is better designed because of that
14:50amalloy(inc duck1123)
14:50lazybot⟹ 1
14:51amalloycyclic load dependencies recently gave me the choice of (a) dumping even more code into a "utils" file, or (b) breaking up that file into reasonable pieces
14:51amalloychose b, but the important thing was there's no (c) ignore the fact that your utils file is a mess
14:57crazyFoxduck1123: well i make my project structure up as i go along. so, yes its not thought out well so far :D
14:57ibdknoxNoir made it into the trending repo list on github :) https://github.com/explore
14:58dnolenibdknox: nice!
14:58ibdknoxI was actually very surprised people cared lol
14:59crazyFoxanyone aware of an editor thats has convenient functionality to help with cyclic load dependencies?
14:59gtrakcrazyFox, you mean like a compiler?
15:00crazyFoxgtrak: actually an ide
15:00gtrakif you try to compile your files and there's a cyclic dependency, it'll break
15:00gtrakisn't that enough?
15:02kijopenjdk is broken for the entire clojure or just clojsurescript ?
15:02crazyFoxit can be tedious. you could do nice things in an ide that automatically discovers cyclic load deps and e.g. suggest a solution (like which definitions have to move)
15:02technomancykij: just clojurescript
15:02kijthanks.
15:03TimMccrazyFox: If yo uneed IDE support for that, you *probably* need to work on your abstraction boundaries.
15:03dnolenkij: OpenJDK should be fixed for ClojureScript now.
15:03ibdknoxdnolen: when did that happen?
15:03dnolenibdknox: today
15:03ibdknoxdnolen: awesome :D
15:04dnolenClojureScript is now using a newer version of Rhino, Brenton has dropped some serious awesomeness.
15:04gtrakcrazyFox, if you don't write a ton of code all at once, you'll only have like one cyclic dependency to deal with at a time
15:04upwardindexDoes "leon upgrade" also upgrade plugins?
15:04ibdknoxupwardindex, no
15:04upwardindex"lein upgrade**
15:04dnolenibdknox: print doesn't trigger the print dialog, JS stack traces from Chrome / FF
15:04upwardindexibdknox: How do you upgrade plugins?
15:04crazyFoxTimMc: well as i said - i make it up as i go along. dont have a whole lot of experience so far neither with clojure nor "bigger" projects
15:05ibdknoxupwardindex: uninstall the old one and install the new version
15:05ibdknoxdnolen: yeah I saw those :)
15:05upwardindexibdknox: Ok, thank you!
15:05gtrakcrazyFox, i honestly can't think of a case where it'd be so bad that a tool is worth it
15:06gtraknow a general refactoring tool, I could get behind that
15:06gtraklike a 'change all references to this function when i move it' sort of thing
15:07technomancythere's a refactorer for Emacs
15:07technomancyit can do things like "arrowize this form"
15:08crazyFoxgtrak: yea but still. imagine an ide that tells u "definitions a b c are part of a cyclic load dep" - then u choose one of em, choose a file and the ide moves it automatically and adjusts all the ns forms. i think it wd be NICE
15:08gtrakcrazyFox, that's the point. I'm imagining it, and it looks silly
15:09gtrakplus, it's not terribly hard to avoid writing them in the first place
15:09ibdknoxcrazyFox: out of curiosity, what language are you coming from?
15:10crazyFoxidbknox: mainly c/java
15:10gtrakuse a forward declaration as a last resort
15:10ibdknoxcrazyFox: using primarily eclipse?
15:11crazyFoxgtrak: it might seem silly to some ppl, but it wd still help many i guess
15:11crazyFoxibdknox: lately yes
15:11ibdknoxgtrak: I think it honestly depends on how you "grew up" programming
15:11gtrakyea... I guess I had some C and C++ before java
15:13gtrakyou shouldn't write code like that in java, either, even though it lets you
15:13ibdknoxsure, but what's to teach you not to? lol
15:13crazyFox"code like that"?
15:13gtrakcircularly referenced stuff
15:14gtraktypes that know about each other, etc..
15:15gtrakcan't think of a case where that is the right choice
15:16gtrakibdknox, lots of good programming books out there
15:16ibdknoxgtrak: I think with types it's more obvious than it is with functions
15:16crazyFoxgtrak: agree. i just - have a lot to learn and so i just started my project and ill see where it takes me
15:18gtrakibdknox, with functions, wouldn't you be doing a mutual recursion by accident anyway?
15:18ibdknoxgtrak: groups of functions
15:18gtrakyou write a function that calls a function that calls you? seems like a stackoverflow
15:19ibdknoxgtrak: sorry didn't mean inside of a function
15:19ibdknoxI meant with a group of functions
15:19gtraklike how?
15:20ibdknoxThere are certainly logical groupings of functions where two files would depend on eachother
15:21crazyFoxgtrak: over time u add on function after the other. u think "this one belongs to ... THIS module". then u compile and see - "oops, doesnt work this way"
15:22gtraksure.. then you separate something out or add a forward declaration and it's fixed
15:22amalloygtrak``: (defn a/foo [] (b/bar)) (defn a/baz [] 1) (defn b/bar [] (a/baz))
15:22TimMccrazyFox: Often the answer is to have a common utility namespace or such.
15:23ibdknoxyeah. The fixes are usually straightforward :)
15:23crazyFoxyea. and an ide could help me with this.
15:23ibdknoxcrazyFox: well, I would argue that it's better to not have the IDE in this instance
15:23ibdknoxthere's value in learning how to think in a manner that organizes things cleanly
15:24technomancycrazyFox: slamhound does that, sorta
15:24technomancyit won't untangle circularity, but it will fix your ns forms to reflect what's on disk
15:24gtrakyou could also separate the names from implementations, which is what you do in C with .h's and .c's
15:24TimMcgtrak: ew
15:24gtrakwell, you could :-)
15:24ibdknoxhaha
15:24TimMcew
15:25crazyFoxtechnomancy: sorta :D. in my ideal ide this wd be done more automatically
15:25technomancycrazyFox: should be possible to trigger a recomputing of the ns form when you encounter a compilation error.
15:26gtrakyou could have an impl namespace that imports the vars
15:26technomancyjust a matter of someone hooking up the pieces
15:26gtrakthen binds itself onto the vars
15:26kzaribdknox: Is there a way to access request and response header from inside defpage?
15:26crazyFoxtechnomancy: do u plan to add functionality like "lein slamhound" -> slamhound replaces all the ns forms in all project files?
15:26kzaribdknox: Or just the full request / response
15:27ibdknoxkzar: you can set response headers by returning a map
15:27technomancycrazyFox: I have that implemented in elisp. it's really hard to implement in clojure.
15:27kzaribdknox: Sometimes I want to do things myself, middleware is the only way I found but it seems silly to use sometimes
15:27ibdknoxkzar, can you give me a case you think is silly?
15:27technomancyelisp lets you simultaneously treat code structurally and also as a string, but clojure doesn't
15:28crazyFoxgtrak: i dont understand. can u elaborate?
15:28gtrakit's a hair-brained scheme I just pulled out of my ass :-)
15:28crazyFoxoh. well then...
15:29kzaribdknox: Well if there's a one off reason to access something in the header / request in general. Or if likewise for response it seems like overkil to make middleware. Often it's fine don't get me wrong
15:29gtrakyou could have a namespace of function implementations that binds the implementations to the declaration vars on init
15:29gtrakthat way you'd have all the names of functions defined, but implementations separated
15:30gtraksort of like a dependency injection i guess
15:30amalloyibdknox, kzar: perhaps you want to reimplement whatismyip.com
15:30ibdknoxkzar: well I'm not sure what you're trying to do so it's a little harder for me to suggest the best method. There are a few different ways to get at the request. Pre-routes have full access. There's also the noir.request/ring-request function as of 1.2.0. Supplying response headers is just a matter of supplying a map as the return of your defpage. Take a look at what noir.response does
15:30amalloyone of your pages needs the client's IP address, but the rest don't
15:30gtrakI dont' recommend it as a a methodology, but just saying, it could be done
15:31ibdknoxamalloy: you can grab that from noir.request now :)
15:31amalloyibdknox: i assume you do this by adding a middleware that binds a var to the request?
15:31gtrakif all the names are declared in separate namespaces and decoupled from implementations, then you can't have circular references
15:31crazyFoxgtrak: u mean like a (declare <list all your functions>) in a separat (like header) file that u use in all the other files?
15:32gtrakyea something like that
15:32gtraka terrible terrible idea
15:32redingeribdknox: When are you coming back to Durham to present the Clojure meetup with all this Noir hotness? :)
15:32crazyFoxgtrak: y it does discourage a proper (layer) design
15:33amalloygtrak: an idea that doesn't even work. you can't declare outside of your current namespace
15:33crazyFoxthats even better. one less possibility to mess ^^
15:33amalloyand it's even more disgusting to write header.clj as: (ns foo) (declare myfn) (ns bar) (declare more-fns)
15:34jweiss,(map #(+ %1 ^{:my :meta}) [1 2 3])
15:34clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )>
15:34jweissthat is a misleading error message to me ^
15:34ibdknoxamalloy: yeah
15:34jweiss(i originally hit it copying metadata that already had a ^ into a with-meta form)
15:35ibdknoxredinger: haha I'm not sure yet. :)
15:35crazyFoxamalloy: i wonder how far bad style can be taken
15:36kzaribdknox: OK, so if I return a map instead of the body the map I return is the full response that's sent?
15:36gtrakamalloy, I think I said declare in one ns, bind in another
15:36ibdknoxkzar, well it's parts of it
15:37ibdknoxkzar, other parts will get added to it by middleware as it comes back out
15:37gtrakand i said it's totally a bad idea
15:37ibdknoxkzar, but yes
15:37kzaribdknox: OK gotya, thanks
15:37hiredman jweiss: misleading in what way? given the way the reader works it makes sense
15:37jweisshiredman: should users of clojure know how the internals of the reader work?
15:37hiredmanyes
15:38crazyFoxgtrak: i wont quote you on it
15:38ibdknoxlol
15:38ibdknoxno
15:38hiredmanabsolutely
15:38ibdknoxthat's the opposite of pragmatism
15:38kzaribdknox: BTW IMHO I think the new way to access a request is a bit ugly, might be better to just pass it as a parameter. Like I say it's just my opinion. Otherwise I really like Noir
15:38ibdknoxkzar: I think it is by far the 10% case, and so it was designed as such
15:39kzaribdknox: Hmm fair enough, at least there's a way when you need it
15:39ibdknoxkzar: yep :)
15:39kzaribdknox: Things like rails really limit you there, when you're doing anything more advanced. Like I was making a REST API and simple things where so hard without full access to request and response
15:39gtrakamalloy, yes it has downsides, but circular references is not one of them :-)
15:40jweisshiredman: while i agree it helps to know the internals, that should not be a requirement
15:40ibdknoxkzar: yeah, I agree. I think the default should be plain and simple, but you should be able to do the advanced stuff without needing to do crazy things :)
15:40jweissno consumer of a library is expected to know implementation details, just the contract
15:41amalloyjweiss: the contract is that ^{...} forms need to be attached to something?
15:41hiredmanjweiss: thats one of the huge benefits of clojure, the implementation, compared to most other languages is very simple
15:42jweissamalloy: yes, i know that, but i accidentally didn't do it and the error message was wrong
15:42hiredmanI would argue you should know the details of any language you use, and it's easier to do so with clojure
15:43jweissok, if the idea is that people want the reader to be simple and not give better error messages, i won't argue. but the error message here is wrong
15:43jweissthe delimiter is not unmatched.
15:43hiredmanit is
15:43hiredman^{} causes it to be unmatched
15:44jweissit is if you know the reader consumes the paren with the meta
15:44jweissand your mistake wasn't putting the ^ in there by accident in the first place
15:44sridhow do I set .innerHTML in clojurescript?
15:44sridor set any attr
15:45amalloyset!
15:46dnolensrid: you probably want to use something from google closure to do that if you're worried about cross browser issues.
15:50crazyFoxwhen i have a (defrecord MyDataType ...) in one file, do i :use, :import or :require it in another file?
15:51crazyFoxwell i can actually ask slamhound
15:52srid(.set! (. innerHTML content) (. innerHTML tab-content))
15:52srid-> TypeError: Cannot read property 'content' of undefined
15:52gtrakif you require, you'll have to qualify it by the alias
15:52gtrakcrazyFox^
15:52hiredmangtrak: no
15:52amalloysrid: args to . are backwards
15:52gfrederickswhere did clojure.contrib.json go for 1.3? I thought there was a clojure.data.json ns, but apparently not
15:52gfredericksgoogling doesn't help
15:52dnolencrazyFox: default ctor fns are provided for you in 1.3.0, in 1.2.0 you provide your own.
15:52hiredmancrazyFox: in 1.3 defrecord creates factory fns and you should use them
15:53sridamalloy: sure? http://java.dzone.com/articles/adventures-clojurescript says otherwise
15:53sridlooks like I should not have a space after .
15:53sridwith that, I get: TypeError: Object Nothing has no method 'set_BANG_'
15:53hiredmangfredericks: use cheshire
15:53hiredmanhttps://github.com/dakrone/cheshire
15:54gfrederickshiredman: okay I will try, thanks
15:54sridoops, I used .set! instead of set!
15:55duck1123gfredericks: data.json is at https://github.com/clojure/data.json
15:55gfredericksduck1123: thanks
15:55kzaribdknox: Oh, I meant to ask you. How does the mapping to static files in resources/public work?
15:55sriddnolen: not sure if closure has a wrapper for setting innerHTML
15:56dnolensrid: it does
15:56kzaribdknox: I couldn't figure it out, but I spotted a bug. If you're filename has spaces in they are escaped in a url to be %20, but then the translation doesn't decode it back to a space
15:57kzaribdknox: So it tries to open a filename of "dumb%20example.jpg" instead of "dumb example.jpg"
15:57hiredmancheshire is far superior to contrib's json handling
15:57sriddnolen: it has .setTextContent, but none for setting HTML content from what I can tell by reading http://closure-library.googlecode.com/svn/docs/closure_goog_dom_dom.js.html
15:58hiredmanround tripping through cheshire is faster than round tripping through clojure's printer/reader
15:58hiredman(which you can see from the nice table in the cheshire readme, data.json doesn't give any benchmarks, which is telling)
15:58dnolensrid: goog.dom.htmlToDocumentFragment
15:58gfrederickshiredman: in my case, development time is more important
15:59duck1123I might have to give cheshire a look then
15:59sriddnolen: hmm, ok. actually, it looks like I need to "move" a html chunk instead of copying it, else all the id's in it would become meaningless.
15:59sridall examples for tabbar does 'copy', but not 'move'
16:01ibdknoxkzar: is that with 1.2.0
16:04dakronehiredman: yea, I need to add benchmarks for data.json comparisons
16:05jbwivanyone here using intellij with la clojure?
16:05crazyFoxdnolen, hiredman: sorry, i dont understand yet. Using clojure 1.3.0. file A contains (defrecord MyDataType), file B creates instances of that type (via (MyDataType. ...)), file C contains a function that deals with those instances. How do i go about?
16:05jbwivI'm trying to inspect variable values in intellij when I hit a breakpoint, but watches don't seem to work
16:07dnolencrazyFox: import the ctor fns for those types into file C
16:09crazyFoxdnolen: what are ctor functions? what do they look like? or rather: is this explained somewhere?
16:10kzaribdknox: 1.1.1-SNAPSHOT
16:10jbwivwhat's the preferred way to debug clojure code? do any ides support debugging well?
16:11kzaribdknox: I'll upgrade and see what happens
16:13kzaribdknox: Yea, it happens with 1.2 as well
16:14S11001001crazyFox: http://dev.clojure.org/display/design/defrecord+improvements
16:16Raynesibdknox: I think you're right. My tolerance for Sublime's poor indention is quickly running out.
16:20kzarIs there something like re-seq that returns the context, the bits in between the matches? Or maybe something that returns the position of the matches
16:21kzarI need to do a regexp replace, but by giving a function the match as a parameter instead of replacing with a static string
16:21amalloykzar: clojure.string/replace takes a function
16:22amalloy&(clojure.string/replace "test" #"s" (fn [m] (str (char (inc (int (first m)))))))
16:22lazybot⇒ "tett"
16:22kzaramalloy: Schweet, that's exactly what I needed
16:23amalloyworst function definition ever there, btw. doing arithmetic on characters is such a pain :P
16:27crazyFoxS11001001: thank you! i will read and digest :)
16:34pyrso I have a locally deploy maven artifact
16:34pyrin $HOME/.m2/repository
16:35pyrwhen referencing it in my project.clj
16:35pyrit seems as though there's still an attempt to download from http repositories
16:36pyris that because i did not reference the artifact correctly
16:36pyror is it expected
16:42duck1123pyr: if it's a SNAPSHOT, it'll try to update it from time to time
16:53kzarHow can I make regexp match over new lines?
16:54TimMc&(clojure.string/replace "test" #"s" (comp str char inc int first))
16:54lazybot⇒ "tett"
16:54TimMckzar: DOTALL or MULTILINE or something
16:55TimMcYou have to use Pattern directly to do that, I think.
16:56amalloy$javadoc java.util.regex.Pattern
16:56lazybothttp://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html
16:58kzarTimMc: If the regexp literal is that class could I call a method on it to enable multi line matches?
16:58pyrduck1123: pb came from me
16:58TimMckzar: Looks to be immutable. There seems to be a way to enable those flags inline, though.
16:59TimMc,(re-seq #"_._" "a_\n_b")
16:59clojurebotnil
16:59TimMc,(re-seq #"(?s:_._)" "a_\n_b")
16:59clojurebot("_\n_")
17:00TimMc^ It's not pretty, but that's how to use Clojure's RE reader syntax and still get those flags.
17:00TimMcOr, do (Pattern. (str #"...") flags...)
17:00TimMcPattern/compile, rather
17:01kzarTimMc: I don't understand the ?s example, shouldn't it be ?m ?
17:02TimMcDOTALL allows . to match \n
17:02TimMcMULTILINE makes ^ and $ match line boundaries.
17:03duck1123it's a shame re-pattern doesn't accept flags
17:04kzarTimMc: Sweet I got that working, thanks
17:06TimMckzar: Word of warning: Pattern might not be smart enough to optimize that "global override" into a global flag.
17:06TimMcSo this approach could slow down your regexes, maybe.
17:06Blafaselhttp://pastebin.com/e0Py3ELe - What is leiningen trying to tell me?
17:06duck1123Is there a way to access the command history in CCW's repl views?
17:07ibdknoxBlafasel, looks like a Clojure version mismatch
17:07TimMcduck1123: Have you tried C-p and C-n?
17:07duck1123Blafasel: Most likely, you have a jar that was compiled against a different version than you're using
17:08duck1123TimMc: yep. (once I remembered that esc-p is not alt-p) didn't work
17:08Blafaselduck1123: ibdknox: This is a host that has never seen clojure before (micro instance from amazon). Other than the deps it didn't download anything.. Weird.
17:09duck1123Blafasel: one of your deps is going to have a bunch of class files in it, that's most likely the problem
17:10Blafaselduck1123: Checking. Thanks
17:10sridclojurescript's map doesn't work?
17:10srid(map #(...) (dom/getChildren (dom/getElement "maintab_content")) <- here the function was not invoked at all
17:11ibdknoxsrid, you're getting a node collection back, which isn't a seqable thing
17:11sridah
17:11sriddoseq, loop and seq didn't work, for that reason
17:11TimMcbecause mutable?
17:11chouserI think you and use primative-seq or something on it
17:11sridibdknox: so how do I "iterate" this node collection?
17:12ibdknoxsrid: use pinot ;)
17:12sridlater, maybe :-)
17:12chouser(prim-seq node-collection 0)
17:12ibdknoxsrid, or more seriously, you can either turn it into a collection using the array methods, implement ISeq on that type, or use what chouser said
17:13chousersrid: try prim-seq ^^^
17:14chouser(map #(...) (prim-seq (dom/getChildren ...)))
17:14chouser(map #(...) (prim-seq (dom/getChildren ...) 0))
17:14duck1123also, don't forget that map is lazy
17:14sridhmm, prim-seq doesn't see to work
17:14chouser:-(
17:15chouserI used it a bunch in traction. Not sure why.
17:15ibdknoxchouser, traction?
17:15chouserer, I mean, not sure why it wouldn't work for you.
17:16chouseribdknox: it's not documented or released: https://github.com/Chouser/talk-cljs/blob/master/src/traction.cljs
17:16Blafaselduck1123: Weird.. http://pastebin.com/24Cwh9Pe / except for clojure itself there's only the vimclojure server jar that contains .class files. And I'm pretty sure that very same thing worked on my other machine quite well.
17:18sridchouser: prim-seq worked with doseq, but not map!
17:18chousersrid: are you taking into account that map is lazy?
17:18srid*facepalm*
17:18srid,(dec srid)
17:18clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: srid in this context, compiling:(NO_SOURCE_PATH:0)>
17:26sridibdknox: i should probably take a look at pinox sooner, for right now i have the goog.ui.tabbar code in disparate locations (hiccup code to initialize html template, hiccup css includes, and cljs event handling)
17:29crazyFoxclojure 1.3.0: how do i import the record constructor functions? i tried (ns ... (:import myproject.myfile.map->MyRecord)), but this gives me a ClassNotFoundException
17:29brehautcrazyFox: use or require the namespace that defines it first
17:30dafrahi there
17:30dafrai've just tried swank, it's clojure 1.2
17:30dafrahow to use clojure 1.3 ?
17:31brehautcrazyFox: secondly, if you can provide utility functions (constructors, predicates etc) instead of requiring a namespace consumer to explicitly depend on the record type itself, thats better
17:33brehautdafra: i know basicly nothing about swank etc, but do you know of clojure-jack-in ?
17:33dafrabrehaut: i use clojure-jack-in, and it launches a 1.2.1 repl
17:33crazyFoxbrehaut: u mean like (ns ... (:use [myproj.myfile]) (:import myproj.myfile.map->MyRecord))? gives me the same exception
17:34brehautcrazyFox: where did you get the arrow from? leave that out
17:34raekdafra: change the clojure version in your project.clj file
17:34raekand run lein deps in the project dir
17:35dafra:dependencies [[org.clojure/clojure "1.3.0"]]
17:35dafraraek: but that did't help
17:35amalloybrehaut: i think that's correct in 1.3
17:35brehautamalloy: real? huh
17:35dafraraek: maybe rebooting emacs ? let's try
17:36brehautcompletely missed that change
17:36crazyFoxso what should my ns form look like?
17:36amalloyoh, it looks like my previous message got dropped though
17:36amalloycrazyFox: it's a plain old clojure function. just require/use it
17:36crazyFoxok, ill try that
17:36amalloybrehaut: in 1.3 (defrecord Foo []) has the side-effect of defining two additional functions, map->Foo and ->Foo
17:36sridwhy would a lamina channel be automatically closed?
17:36brehautoh right
17:37raekdafra: are you running clojure-jack-in while visiting a file or directory in the project?
17:37dafraraek: yes
17:37brehaut(inc amalloy)
17:37lazybot⟹ 16
17:37raekdafra: a listing of the files in your lib/ directory would also be helpful
17:37dafraraek: lein's lib ?
17:38crazyFoxamalloy: long journey comes to an end. Thank you!
17:38raekdafra: yes, the lib/ in the project directory
17:38brehautcrazyFox: sorry for leading you astray
17:39dafraraek: clojure 1.2.1 :)
17:39dafraraek: thanks, look like i know what to fix !
17:39raekand you have no other depencencies?
17:39crazyFoxbrehaut: no problem. after two hours of reading searching trying this was insubstantial
17:39dafraraek: not for now, jsut toynig with the ide
17:39raekyou shouldn't have 1.2.1 there if you specified 1.3.0 in the project.clj file... :/
17:40raekdafra: the lib/ directory is populated from what you put in the :dependencies thingy
17:41duck1123Do records always have a no-arg constructor? Or is that just in the cases I've been using them for?
17:41raekduck1123: they always take one argument per field
17:42raek(defrecord Foo [a b c]) must be constructed as (Foo. 1 2 3)
17:42dafraraek: I've copied clojure-1.3.0.jar into lib and the repl is 1.3 as expected
17:42raekdafra: but you shouldn't have to do that!
17:43dafraraek: how to tell lein that I want 1.3 ?
17:43raekdafra: are you sure you saved the project.clj file before you ran "lein deps" in the project directory?
17:43duck1123raek: Ok, In that case, I need to think about one of my libraries a bit more. :(
17:43dafrachanging the porject.clj wasnt enough
17:43dafraraek: lein deps ?? let's do it
17:44brehautdafra: porject.clj or project.clj?
17:44amalloyduck1123: you're on 1.3 now though, right?
17:44dafrabrehaut: right spelling (created by lein new)
17:45duck1123amalloy: yes
17:45brehautdafra: figured it probably was, but wanted to check
17:45amalloyduck1123: so you should be able to use (map->MyRecord {}) to get an "empty" version of a map
17:45amalloyer, record
17:45dafrabrehaut: could be, thanks
17:45raekdafra: if you change the dependencies you need to run lein deps to "apply the changes"
17:46dafraraek: just did lein deps, obviously better than copying by hand :)
17:46technomancyraek: (unless you set :checksum-deps true in project.clj or ~/.lein/init.clj)
17:46raekdafra: yeah, copying by hand is no fun for depencencies, dependencies of dependencies, dependencies of dependencies of dependencies, etc ;-)
17:48dafraraek: see you guys
17:49raekdafra: happy hacking :-)
17:56sridin clojurescript, (doseq [index [0 1 2 3 4]] ...) -> " doseq requires a vector for its binding" error
17:56sridi don't understand the error, as the deseq syntax looks alright
17:58sridthe doseq comes within a doto macro, if that matters
17:58ibdknoxthat matters
17:59sridah yes
18:13ibdknoxoh no's! Lazybot is gone
18:14gtrak,#(print "OH NO")
18:14clojurebot#<sandbox$eval27$fn__28 sandbox$eval27$fn__28@1dec77f>
18:14gtrak,(#(print "OH NO"))
18:14clojurebotOH NO
18:14ibdknox,(print "oh no :p")
18:14clojurebotoh no :p
18:14ibdknox# is unnecessary :)
18:14gtrakduh
18:15gtrakwe all have moments where we think something is a level less abstract than it is
18:15BlafaselThe whole machine is down, it seems
18:16Blafasel4clojure.com try-clojure.org and the guys that have a bouncer on that machine pinged out.
18:21ibdknoxhaha
18:22ibdknoxamalloy jinxed it talking about how he hasn't really had any issues with hosting
18:28wdouglasHey all, trying to get (floor(log_2 x)). Didn't want to loop recur so ended up using swap! but I don't really like it. Any better options for this?
18:28wdouglasFYI code is just:
18:28wdouglas(let
18:28wdouglas [a (atom 0)
18:28wdouglas b 30]
18:28wdouglas (while (> (bit-shift-right b @a) 0)
18:28wdouglas (swap! a inc))
18:28wdouglas @a)
18:28BlafaselWhat's wrong with Math/*?
18:29wdouglaslog base e/10
18:29wdouglasUnless I missed something
18:29wdouglasOr just do the log conversion do you mean?
18:30BlafaselDidn't know about the missing log, I meant both
18:31ibdknoxwhy didn't you want to use loop/recur?
18:32ibdknoxit'll be much more efficient than what you have right now
18:32hiredmanusing an atom for that there is dumb
18:32ibdknoxthough I'm with Blafasel, you can do that with normal math functions, can't use?
18:32ibdknoxyou*
18:32wdouglasHrm guess I could time it, was thinking the division is going to make the log base conversion a bit slower.
18:33Blafaselwdouglas: Depending on precision: http://everything2.com/title/log2%2528x%2529+%253D+log10%2528x%2529+%252B+ln%2528x%2529
18:33wdouglasI just thought the loop/recur was ugly for that
18:33hiredmanyou are wrong
18:33ibdknoxwdouglas, loop/recur was designed to solve problems like that
18:33ibdknoxlol
18:34wdouglasBlafasel: Oh nice on that top one.
18:34dabdhow can I construct a ratio from a string? For example from "13/17"
18:34wdouglasWell that's the way of it then. loop/recur it is. Thanks all =)
18:36dabdthe Ratio type does not seem to have a constructor or parser...
18:36hiredman,(/ 13 17)
18:36clojurebot13/17
18:37ibdknoxdabd: split the string, map Integer. over it and then do what hiredman did
18:37dabdok thx!
18:38dabdBut why there is a type without a constructor?
18:38brehautdabd: there is a constructor, its /
18:38dabdwell / works as a constructor obviously
18:38dabdyes
18:40ibdknoxI don't think I expected this:
18:40ibdknox,(/ 2)
18:40clojurebot1/2
18:40brehautibdknox: makes sense as a dual to ##(* 2)
18:41Blafasel,(doc /)
18:41clojurebot"([x] [x y] [x y & more]); If no denominators are supplied, returns 1/numerator, else returns numerator divided by all of the denominators."
18:41ibdknoxand doesn't when compared to +
18:41ibdknox,(+ 2)
18:41clojurebot2
18:41BlafaselSee the docs :)
18:41ibdknoxI know
18:41ibdknoxI was reading the source :p
18:41ibdknoxI meant more from a conceptual standpoint
18:41S11001001wdouglas: if you find loop distasteful, you may consider iterate
18:41ibdknoxI didn't expect it to work that way
18:42S11001001(weirdly enough, that exact phrase could also be used when talking about common lisp, though loop and iterate mean completely different things there :)
18:42brehautibdknox: i disagree; in all 3 cases, the unary implementation respects the identity value for the operation
18:43ibdknoxbrehaut, I just expected (/ 2) = 2
18:43brehautibdknox: consider in the context of the varargs imp: (/ 1 2) is 'really' (/ 1 1 2)
18:44brehaut(ibdknox i do get that its not necessarily obvious, but it seems correct to me)
18:45ibdknoxbrehaut, I don't follow your varargs argument
18:45brehautibdknox: / folds the varargs down; implicitly starting with the identity value for the operation
18:46ibdknoxno
18:46ibdknoxnot based on the source
18:46brehautibdknox: thats because its hand optimized to be fast
18:46brehautthe naive implementation would be (defn vararg-divide [& args) (reduce binary-divide 1 args))
18:46dabdI'd like to change all the values in a map and zipmap seems to do the job but I am concerned that 'keys' and 'vals' don't return the elements in the same order since maps have no order
18:47ibdknoxbrehaut, mm
18:47ibdknoxdabd, why are you concerned?
18:47dabdshould I use map instead and then into {} on the result?
18:47dabdibdknox: well maps have no order
18:47wdouglasS11001001: I didn't think about iterate at all. I'll see how that looks, thanks
18:48brehautibdknox: the one that really tripped me up is (< 1)
18:48ibdknoxdabd, maps don't guarantee order no matter which way you do it
18:48gtraka treemap does
18:48gtrakin javaland
18:48ibdknoxgtrak: the clojure {} map doesn't
18:49ibdknoxbrehaut, yeah... I still trip up on those sometimes
18:49brehautibdknox: i had to reprogram my brain; they aren't 'less than' etc
18:49hiredmankeys and vals will always return things in the order you want
18:49gtrakthere is a sorted-map
18:50hiredmanrich has guaranteed it
18:50brehautibdknox: but rather increasing sequence
18:50ibdknoxbrehaut, yeah, I liked technomancy's idea of renaming them to always decreasing
18:50gtrak,(source 'sorted-map)
18:50clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol>
18:50brehautibdknox: link?
18:50dabdok then (zipmap (keys m) (map my-fn vals)) should do the job
18:50brehautor was it irc?
18:50gtrak,(source sorted-map)
18:50clojurebotSource not found
18:50ibdknoxbrehaut, irc
18:50gtrak,(doc sorted-map)
18:50clojurebot"([& keyvals]); keyval => key val Returns a new sorted map with supplied mappings."
18:50dabdoops I meant ok then (zipmap (keys m) (map my-fn (vals m))) should do the job
18:51gtrak(into (sorted-map) existingMap)
18:51brehautibdknox: incidentally the doc string for < never mentions 'less than' only 'monotonically increasing order'
18:51dabddo I really need to use the sorted-map isn't zipmap on a hash-map enough?
18:52ibdknoxyou shouldn't use zipmap
18:52hiredmandabd: as I said, vals and keys will return things in an order that lines up keys with values
18:52hiredmanyou are good to go with zipmap
18:52dabdhiredman: thx
19:05dabdI am getting Java out of memory. I am using lein swank. Does anyone know how to increase heap space?
19:10technomancydabd: export JVM_OPTS=-Xmx1024m
19:10technomancyor :jvm-opts ["-Xmx1024m"] in project.clj if you want it to apply to everyone working on the project
19:12dabdtechnomancy: thx
19:32gtrak``dabd, use a profiler if you're not expecting that much data
19:34dabdgtrak: Not the case I need to read a 52MB file that contains a clojure map :-P. Some trick to memory map this file would be useful though
19:35hiredmansounds like a bad format decision
19:36hiredmanusing a single json or clojure map for large data dump is icky
19:37hiredmanyou end up needing something like a what do you call it, pullparser?
19:37hiredmanbetter to use small maps
19:54winkis there a better way to test for nil than (is (string/blank? (whatever)))?
19:55ibdknoxwink: hm?
19:55lynaghkAh, Chris, I was just looking to see if you were in here.
19:55lynaghkI've got a ClojureScript question for you
19:55ibdknoxlynaghk, shoot
19:56lynaghkI'm getting jsc_duplicate_input errors
19:56winkwell, testing that whatever returns nil for my given input
19:56lynaghkand saw that you ran into that stuff on your cljs-watch project.
19:56ibdknox,(doc nil?)
19:56clojurebot"([x]); Returns true if x is nil, false otherwise."
19:56ibdknoxlynaghk, ah, yes. It happens when a cljs file is both on the classpath and in the compilation path
19:57lynaghkWhat's the compilation path?
19:57ibdknoxhow are you running the cljs compiler?
19:57lynaghkI'm using cake
19:57lynaghkand just invoking a brief script
19:57ibdknoxwhat's the script do?
19:57lynaghk(closure/build ...)
19:58winkibdknox: hm, silly me. so it's a little about learning what's in core.
19:58ibdknoxthe compilation path is the first arg to build
19:58ibdknoxprobably "src/"
19:59lynaghkAh, so I should put my external cljs dependencies on the classpath (so that the compiler can find them), but when I'm actually compiling my own code should keep it out of the classpath?
20:00lynaghkI'm not sure if that makes sense, I must be missing something.
20:00ibdknoxlynaghk, basically yes
20:00lynaghkuh oh
20:00lynaghk= )
20:00ibdknoxso the way I fixed this for cljs-watch is by not including src/ in that jvm's classpath
20:00ibdknoxbut still including lib
20:01ibdknoxlynaghk: speaking of, out of curiosity, why aren't you using cljs-watch?
20:01lynaghkI shoved clojurescript support into my existing Rakefile-based toolchain
20:01lynaghkwhich handles HAML and SASS compilation
20:02lynaghkI've got a lot of stuff setup in those already, so I haven't switched to the Clojure analogs
20:04ibdknoxgotcha
20:04lynaghkJust as I was getting settled down with my auto-compiled minified CoffeeScript, ClojureScript gets released
20:04lynaghk= )
20:04ibdknoxI'm not sure you're going to be able to do this from Cake
20:05ibdknoxsince cake's JVM will definitely have src on the classpath
20:05lynaghkYou can config it out. I have src/clj, src/cljs
20:05ibdknoxah :)
20:08lynaghkyeah, all of this is a bit tricky
20:08lynaghkI've been meaning to sit down and try and figure it out
20:08lynaghkI just found out about the :foreign-libs option from Luke VanderHart's blog yesterday
20:09ibdknoxit didn't exist until about a week ago
20:09ibdknoxand wasn't merged in until this weekend I think
20:09ibdknoxthough really we shouldn't be packaging libs that are universal...
20:09lynaghkwhat do you mean?
20:09ibdknoxthey should be coming from a CDN
20:09lynaghkthings like jQuery?
20:10ibdknoxyeah, otherwise we're defeating the point of caching
20:10lynaghktrue, though you might save a lot of bytes from the dead-code elimination
20:11lynaghkplus, it's nice to have everything in one monolithic JS---I definitely try to send single HTML file visualizations to clients when I can
20:15lynaghkugh, D3 stops working with :optimizations :simple
20:15hiredmanclojurebot: ping?
20:15clojurebotPONG!
20:16lynaghkI need to sit down and hash out my clj replacement.
20:16ibdknoxlynaghk, I'm still on board to help with that :)
20:17lynaghkthanks
20:17lynaghkyeah, I've been letting it stew in my mind for a bit
20:17lynaghkspent the weekend reading up on SVG
20:17ibdknoxI've had *plenty* to do, so that's fine with me :)
20:18lynaghkheh
20:18lynaghkare you going to the Conj?
20:18gtrak``lynaghk, what's a clj replacement?
20:18ibdknoxI am indeed
20:18lynaghkgtrak`` I am thinking about implementing a visualization libary in Clojure(Script)
20:19ibdknoxgtrak``, he meant cljs replacement for D3
20:19lynaghkheavily-inspired by D3/Protovis
20:19gtrak``ah nice
20:19lynaghkibdknox, well we'll definitely have to grab a beer in November then
20:20ibdknoxlynaghk, sounds good :)
20:20gtrak``how about processing.js?
20:20lynaghkI haven't used it very much
20:20ibdknoxprocessing isn't data driven
20:20lynaghkor processing
20:21ibdknoxas an example, see th visualization section of the pinot readme: https://github.com/ibdknox/pinot
20:21lynaghkibdknox, what is keeping you so busy?
20:22ibdknoxwell, got Noir 1.2.0 out this weekend, started working on a SQL layer called Korma, and I have a couple secret projects in the works :)
20:22lynaghkWELL WELL
20:22lynaghkyeah, I saw that on HN
20:22lynaghkprops
20:23gtrak``do you run a consulting company or something?
20:23ibdknoxgtrak``, are you asking me?
20:23gtrak``yea
20:23ibdknoxnope :)
20:23gtrak``i saw you had a 'prototype your site in 2 weeks thing going' :-)
20:23lynaghkis anything about Korma online?
20:24ibdknoxlynaghk, not yet, I'll put something up in the next couple of days
20:24lynaghkI've been toying with ClojureQL a bit; I like the idea of actually using relational algebra with my databases.
20:24ibdknoxgtrak``, I'm currently under the employ of ReadyForZero :)
20:24gtrak``ah
20:24ibdknoxlynaghk, ClojureQL has some weirdness to it
20:25lynaghkyeah?
20:28ibdknoxthough my main motivation is actually I want it to handle relations for me
20:28ibdknoxand I think there's a much prettier language waiting to come out of it
20:29lynaghkI hope you mean that literally
20:29lynaghkand borrow heavily from the APL characterset
20:29ibdknoxlol
20:29ibdknox:p
20:31lynaghkWell that sounds interesting, I'll definitely look out for it
20:31lynaghkI'm not yet super into ClojureQL
20:31ibdknoxthe first implementation will just look like prettier sql though :)
20:31lynaghkuh oh, paved with good intentions right there
20:31lynaghkbe careful
20:31brehauti think clojureql is a good proof of concept
20:31ibdknoxsome of the SQL it generates hurts me
20:31chouseribdknox: as long as parts of a query are values that can be composed at runtime, I'll be interested. :-)
20:32ibdknoxchouser, they *definitely* are. tenant number 1 right there :)
20:33lynaghkDo you have any interest in implementing a 'lil DB in Clojure as well, instead of just compiling to SQL?
20:33lynaghkbecause then I can finally get my functional-relational-programming on.
20:33lynaghk(and compile it to JS)
20:33gtrak``lynaghk, isn't the point of a DB to be mutable?
20:34lynaghksure, in very constrained ways.
20:36ibdknoxerr, I meant tenet above. Don't mind the stupidity :)
20:37ibdknoxI'm not sure I'd want to implement a db
20:37ibdknoxsounds like work :p
20:37brehautibdknox: but you could get on the leading edge of the coSQL wave
20:38jlico?
20:38clojurebotcompilation is see compile
20:38hiredmanbroSQL
20:38lynaghkibdknox, maybe, but you could wave yoru hands and say it's all in-memory and just implement everything with table scans
20:38ibdknoxlol
20:38lynaghkmaybe I'll take a crack at it sometime
20:38ibdknoxI think fewer problems need databases
20:38brehautyeah, erik meijer
20:39lynaghkin all seriousness though, I really would like to find some implementations of FRP
20:39ibdknoxdatastores are often more correct I think
20:39brehaut's strange loop keynote is about how SQL and noSQL are duals
20:39brehautplease hold; finding the link
20:39brehauthttp://queue.acm.org/detail.cfm?id=1961297
20:40lynaghkbrehaut, does that mean we can easily get a lot of funding if we make a "primal sql".
20:40brehauthiredman: broSQL; the first choice in storage for low grade beer and grain spirits
20:41brehautlynaghk: thats gone over my head
20:41lynaghkeh, math joke.
20:42brehautI'm too stupid to understand math jokes
20:42lynaghksayith wikipedia: "Every linear programming problem, referred to as a primal problem, can be converted into a dual problem, which provides an upper bound to the optimal value of the primal problem."
20:42lynaghkOh, me too. I just try to get a few from each discipline so I can defend myself at cocktail parties.
20:43lynaghkThat paper looks interesting though, thanks for the link brehaut
20:43brehautlynaghk: see also https://github.com/strangeloop/2011-slides/blob/master/TOC.md
20:45lynaghkHmm, these conference organizers are on it
20:56vkurupxb
20:57vkurupoops. That was supposed to be C-xb :)
21:06shep-homeI evidently have 7 infinite recursion threads going from clojure-mode C-x C-e... any tips on how to stop them?
21:06seancorfieldhas anyone used Enlive with Clojure 1.3.0 successfully?
21:07seancorfieldi just tried the basic getting started example and got: NullPointerException net.cgrand.enlive-html/load-html-resource/fn--326 (enlive_html.clj:53)
21:08seancorfieldwhich is: (with-open [^java.io.Closeable stream stream]
21:09shep-homeAh, I got it - M-x slime-thread-kill
21:15seancorfieldbah... that means i can't use deftemplate since that relies on the same broken loading process
21:24jliyay, kernel.org is back
21:35buduhi
21:36buduis it normal that swank-clojure and 'lein repl' are still using clojure 1.3?
21:36buduor did i installed them unproperly?
21:37brehautbudu: I'm not a swank user, but aren't they dependent on the project.clj clojure dependancy?
21:37jli"still"?
21:37buduyes, but i'm talking about using them outside of a project
21:37budusorry for the lack of preciness
21:39budunobody is doing that it seems! ;-)
21:39gtrak``you can install it globally, and remove it from project.clj's. it's recommended now
21:39brehauti didn't even realize lein repl worked outside a project
21:49duck1123budu: which version are you using, I think the new one specifies 1.3
21:50duck1123although it might be multi dep
21:51duck1123hmm... it is multi dep, but 1.2 seems to be the default
22:11mcoffbyonehi, what is the proper way to write a ?function?macro that takes a method name as an argument? I got this (defn metfun [method] (eval `(~method "string")))
22:12mcoffbyoneit is called (metfun 'toUpperCase) -> "STRING"
22:24duck1123(defn metfun [f] (f "string"))
22:24duck1123it's that easy
22:25duck1123although, I'm not sure how well that works with interop
22:26duck1123(defmacro metfun [f] `(~f "string"))
22:41ibdknox what is the correct way to specify compatibility with clojure version >= 1.2.1 for a lib?
22:42brehautibdknox: I'm using [1.2.1],[1.3.0] in necessary evil, but i think something like [1.2.1) is available too
22:42ibdknoxah, that works. Thanks :)
22:43mcoffbyonethank you duck1123, do you know why/if macros should be prefered over eval for such simple cases?
22:45glob157anyone use hadoop in here with clj ?
22:46brehautmcoffbyone: the trite answer is that macros are idiomatic and eval is not
22:47brehautmcoffbyone: macros are part of the standard compilation process; eval fires up the compiler for each call. you could cache the result, but thats more work compared to letting a macro reduce down to the underlying behavior once
22:49ibdknoxglob157: sadly I do not, but just as a heads up, you're more likely to get an answer if you ask the question you really want the answer to
22:50mcoffbyonebrehaut: does this mean that the output of a macro is in no way different from code forms?
22:50brehautmcoffbyone: exactly
22:51mcoffbyoneand is (name some-symbol) like eval?
22:51brehautno
22:51brehautname is just a function
22:51brehautthat works on strings and clojure.lang.Named instances, of which symbols and keywords are instances
22:52mcoffbyoneI got it it happens after the compilation so it is not some run-time introsepction
22:52ibdknoxas a general rule of thumb eval is evil outside of developer tooling, and even then there are often other solutions
22:52brehautmcoffbyone: huh?
22:53mcoffbyoneI thougt (name) is inspecting the name of a symbol at runtime
22:54mcoffbyonebut the name is already an instance so it can have just a property with its name
22:54mcoffbyoneargh the symbol not the nam is an instance
22:54brehautmcoffbyone: yes; its just a function
22:54brehaut,(name (symbol "foo"))
22:54clojurebot"foo"
22:55ibdknoxif it were a macro this would work:
22:55ibdknox,(name foo)
22:55clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0)>
22:57brehautmcoffbyone: just to underscore how uncommon eval is in clojure code, clojure/core.clj is 6500 lines long and a quick grep has "(eval" occuring 4 times (once in the definition of eval)
22:57brehautand thats a piece of code that you might expect to find a lot of evals
22:58mcoffbyone:)
23:00brehautibdknox: http://docs.codehaus.org/display/MAVEN/Dependency+Mediation+and+Conflict+Resolution#DependencyMediationandConflictResolution-DependencyVersionRanges
23:00ibdknoxbrehaut: ah, thanks
23:01brehautibdknox: rather than cargo culting the crap i scrabbled together
23:01brehautsorry it took so long to find; i had a google fail
23:01ibdknoxtechnically I think the [1.2.1],[1.3.0] is the correct one
23:01ibdknoxsince I can't guarantee there won't be breaking changes in the future of clojure
23:01ibdknoxlol
23:02brehautthats what i guessed too :)
23:02amalloybrehaut: core.clj contains two actual uses of eval, fwiw
23:02ibdknoxamalloy: I was trying to think up an example outside of creating a new execution context where eval should ever be used, can you think of any?
23:03brehautibdknox: whenever you want the old hands on #clojure to yell at you :P
23:03ibdknoxlol
23:03amalloymaybe if you've decided life is no longer worth living
23:04brehautamalloy: if thats the case, why just eval when theres PHP
23:04ibdknoxlol
23:04amalloyibdknox: eval: death by stoning
23:05amalloyphp: self-mutilation
23:05amalloyer, brehaut: ^
23:05brehauti'll defer to your experience in this matter
23:05brehautits been years since i cut myself
23:05ibdknoxhaha
23:06ibdknoxlisten. PHP used to be all there was... unless you wanted to use perl.
23:06brehautibdknox: there was asp with vbscript
23:07ibdknoxhah
23:07brehaut(a language that appeared in the mid 90s on a 32 bit platform and by default has 16 bit signed ints)
23:08ibdknoxmakes sense to me :p
23:08brehautif you think that explicit return is a dumb idea, it has explicit return by assigning to the function name (but not subs; subs cant return anything)
23:08amalloybrehaut: how else would you implement a number with 16 sign bits? perfect for describing n-dimensional hypercubes
23:09brehauthaha
23:10brehautamalloy: http://xkcd.com/37/
23:14khaliGis it educational to read through clojure source code, amalloy?
23:14ibdknoxkhaliG: very
23:14brehautdespite not being amalloy, its education for me
23:14amalloywhoa, since when am i the authority on that?
23:15brehautkhaliG: do you know about the source function?
23:15duck1123you're probably going to find a couple of weird things, but generally it's a good place to look
23:15khaliGsince it seems you've read it :)
23:16amalloykhaliG: well, i'm armed with an OS that has grep built in :P
23:16amalloyi think it depends on whether you mean clojure source in general, or the source of clojure. both have a wealth of information, but especially in the latter case you need to be careful; there's a lot of stuff in core.clj that is not "good" code; it's there because the language is being built as you go
23:17brehautkhaliG: the clj source is a bit more readable and enlightening than the java source, which is pretty weird looking and does some amazingly clver tricks to get around certain limitations in java
23:18lynaghkIbdknox, do you know offhand what the Closure compiler does in simple mode?
23:19lynaghkin particular, does it just concatenate and run everything in the compilation path?
23:19ibdknoxmunges local names, concats
23:19lynaghkIs there a designated entry point / namespace that gets run?
23:19ibdknoxno
23:19ibdknoxcode at the top level will be run
23:19lynaghkof all namespaces
23:19ibdknoxyup
23:20lynaghkah
23:20lynaghkthat's what I was afraid of
23:20lynaghk=)
23:20gtrak``why?
23:20clojurebotwhy not?
23:20duck1123then you can create a -main somewhere and point lein to it for lein run
23:20ibdknoxadvanced mode will do the same
23:20lynaghkokay, that's good to know
23:21lynaghkI've been just hacking around the build system for the past few weeks
23:21lynaghkI need to get things all ship-shape
23:21lynaghkI might put together a this-is-how-to-do-it repo
23:21lynaghkit = ClojureScript + Clojure macros + external JS libs
23:21duck1123well, lein new <projectname> should get you most of the way there
23:22duck1123nvm
23:22lynaghkoh, this is for ClojureScript
23:22gtrak``too bad no lein for cljs
23:24ibdknoxwell
23:24ibdknoxwhen lein 2.0 comes out
23:24ibdknoxI'll do some fun things for CLJS in it
23:24lynaghkis 2.0 going to have persistent JVM support?
23:24lynaghkbecause that is the main reason I am using Cake
23:25lynaghkLein seems to have a lot more community backing though
23:27ibdknoxnot that I know of
23:27ibdknoxthe main thing is that it will use 1.3
23:27lynaghkah
23:28ibdknoxwhich is necessary for me to do cljs as a plugin
23:28lynaghkyou are going to integrate your watcher?
23:28ibdknoxthat would make sense
23:28ibdknoxI think
23:29lynaghkyeah, I think people would find it pretty helpful.
23:30glob157any clojure dojos on the east coast any time soon ?
23:30lynaghkthat's the main reason cake is nice though, because cljs changes are instantanous
23:30glob157i need to get my skills up
23:30lynaghkthat + the livereload browser plugin, though my understanding is that ClojureScript has some kind of Browser REPL now
23:30lynaghkwhich does all this stuff automagically for you