2011-10-03
| 00:00 | brehaut | (this analogy doesnt really extend very well does it) |
| 00:00 | ibdknox | lego technic was awesome |
| 00:00 | cemerick | brehaut: technic is strint; cl-format is mindstorms |
| 00:01 | ibdknox | hm |
| 00:01 | cemerick | the old contrib is most hightly ranked :-( |
| 00:04 | brehaut | whoa, strint is cool. i fear i will lose my mind if i try to understand cl-format |
| 00:04 | ibdknox | yeah cl-format seemed a bit crazy to me |
| 00:04 | brehaut | common lisp right? |
| 00:04 | ibdknox | brehaut: link to strint? |
| 00:04 | brehaut | https://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/strint.clj |
| 00:05 | ibdknox | sweet |
| 00:05 | jli | what's mindstorms about cl-format? being able to include format strings in your format strings? :) |
| 00:05 | jli | (at least, I thought that was possible) |
| 00:07 | jli | http://www.gigamonkeys.com/book/a-few-format-recipes.html |
| 00:07 | jli | ah, it's slowly coming back now |
| 00:09 | jli | (format nil "~r" 1234) ==> "one thousand two hundred thirty-four" |
| 00:09 | jli | (format nil "~@r" 1234) ==> "MCCXXXIV" |
| 00:11 | jli | (format nil "~{~a~#[~;, and ~:;, ~]~}" (list 1 2 3)) ==> "1, 2, and 3" |
| 00:12 | jli | wow, this is really starting to go off the deep end |
| 00:12 | brehaut | jli: lets be honest, this is embeded apl isnt it |
| 00:12 | jli | brehaut: yeah. I just projected all the chars down into ascii and added parens. |
| 00:13 | brehaut | thought so |
| 00:13 | jli | "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:13 | jli | this is way worse than regexes |
| 00:14 | jli | Let's say you have a problem and you decide to use cl-format. Now, kill yourself. |
| 00:14 | brehaut | im horrified that the blub paradox might extend to string interpolation functions |
| 00:17 | jli | brehaut: how do you mean? |
| 00:19 | jli | (coincidentally, I queued up Beating the Averages in firefox earlier tonight and I'm getting to it now) |
| 00:19 | amalloy | good read. that's one of two articles that got me over the hump and actually learning lisp |
| 00:20 | brehaut | jli: i cant actually explain it any better than that |
| 00:20 | amalloy | brehaut: i don't recognize the blub paradox. is it related to the lisp curse? |
| 00:20 | brehaut | amalloy: its another PG thing; any language more expressive than the one you know (blub) looks like ridiculous gibberish |
| 00:21 | amalloy | ah, that one |
| 00:22 | amalloy | i think he was talking about more like "pointless fluff" than "ridiculous gibberish", but i suppose it applies here too |
| 00:22 | brehaut | conversely, i cant remember the lisp curse |
| 00:22 | jli | brehaut: 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:22 | amalloy | brehaut: it's so easy to write an 80% solution in lisp that there are zillions of them, and no 100% solutions |
| 00:23 | amalloy | in blub, it's so hard to do anything at all that you get together a hundred people and eventually finish the 100% |
| 00:23 | jli | amalloy: haha. so basically, people inlining library code into their application? |
| 00:23 | amalloy | which leads people to prefer blub |
| 00:23 | brehaut | jli: 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:24 | amalloy | something 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:24 | brehaut | amalloy: so its also the javascript curse :P |
| 00:24 | dnolen | amalloy: brehaut: I think it should be renamed to the JS curse. |
| 00:24 | jli | brehaut: well, most of its capabilities seem useful. it just seems like write-once, read-never code |
| 00:24 | dnolen | NIH syndrome way less in Clojure land. |
| 00:25 | brehaut | dnolen: 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:25 | technomancy | brehaut: multiple major modes is still an unsolved problem for Emacs |
| 00:26 | technomancy | I am not sure it's worth the effort of implementing either |
| 00:26 | brehaut | technomancy: if you dont have to use something like djangos template system i'd agree |
| 00:26 | jli | amalloy: 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:26 | technomancy | brehaut: yeah, I'm really glad I don't have to use Ruby's ERB |
| 00:27 | technomancy | I tried to write an emacs mode for it, but it was awful |
| 00:27 | technomancy | it's just the wrong problem to solve |
| 00:27 | amalloy | jli: the other one, for me, was http://www.defmacro.org/ramblings/lisp.html |
| 00:28 | brehaut | technomancy: i just googled. that is about as far from a good idea as you could get |
| 00:28 | brehaut | technomancy: why not just use PHP |
| 00:31 | jli | enlive didn't make sense to me until I learned css selectors |
| 00:31 | jli | (at least the parsing bits) |
| 00:31 | brehaut | jli: ah yeah, without that foundation it would seem like crazy nonsense |
| 00:32 | jli | yeah. ":>" was pretty bewildering. |
| 00:32 | brehaut | thats the chicken selector, it finds all the poultry and foul in your document |
| 00:33 | jli | fowl? ;) |
| 00:33 | brehaut | jli: yeah sorry, and not pheasants. dunno why |
| 00:33 | amalloy | i wish there were something to find all the foul in your html |
| 00:34 | ibdknox | me too |
| 00:34 | ibdknox | lol |
| 00:34 | amalloy | it would either help you validate, or get you to use sexps instead |
| 00:35 | brehaut | it would be nice if hiccup and enlive were more easily able to work together |
| 00:36 | jli | isn't it kind of bizarre that paul graham's site has the yahoo favicon still? |
| 00:38 | amalloy | brehaut: data.xml is probably a pretty good bridge for that |
| 00:38 | amalloy | among other things it can convert hiccup vectors/etc to tag/attrs/content maps |
| 00:39 | brehaut | oh yeah, that might do it |
| 00:39 | amalloy | that is the one feature i added to data.xml :P |
| 00:39 | brehaut | hah |
| 00:39 | brehaut | i need to work out if its how im using data.xml or if its a bug regarding escaping content in output text |
| 00:39 | brehaut | (in emit) |
| 00:41 | brehaut | sorry bout the horrible english |
| 00:41 | brehaut | its getting late i should go eat |
| 00:41 | napping | The irony is delicious - lisp is the most powerful language * programmers can't recognize languages more powerful than their own |
| 00:42 | brehaut | napping: haskell programmers agree ;) |
| 00:43 | amalloy | brehaut: looks like there's still no official release of data.xml, right? |
| 00:44 | jli | brehaut: 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:44 | jli | well, not /no/ macrs, but you know what I mean |
| 00:45 | brehaut | amalloy: actually, i think i was thinking of clojure.xml |
| 00:45 | brehaut | jli, perhaps you should look up template haskell |
| 00:45 | amalloy | jli: lazy-everything and auto-currying get you a surprising part of the way towards macros |
| 00:45 | napping | not terribly unlike "no macros", though |
| 00:46 | jli | lazy everything makes a lot of control flow macros moot, I guess |
| 00:46 | amalloy | brehaut: my understanding is that template haskell is a hideous shambles |
| 00:46 | brehaut | amalloy: haha yes :P |
| 00:46 | brehaut | but, its there |
| 00:46 | brehaut | the other thing that gets you a long way is the ghc compiler rewriting rules |
| 00:46 | gienah | some of the template haskell tutorials suggest that its best to read On Lisp to figure it out |
| 00:46 | brehaut | frinstance, theres a rule that looks for map f $ map g l and rewrites it as map (f . g) l |
| 00:48 | brehaut | also, the type system does let you do some insane things, the c style printf but typesafe implementation is amazing |
| 00:48 | brehaut | (and frightening) |
| 00:48 | brehaut | as is heterogenous lists (HList) |
| 00:49 | jli | brehaut: I read some paper about implementing printf with continuations. is that how haskell printf works? |
| 00:49 | jli | brehaut: also, HLists - ack! *google google* |
| 00:49 | napping | you'll say that after you find it too.. |
| 00:49 | jli | is it based on existential types? |
| 00:50 | brehaut | jli: the code is far more massive than i can fathom |
| 00:50 | brehaut | http://hackage.haskell.org/package/HList |
| 00:51 | napping | QuickCheck is a saner example |
| 00:51 | brehaut | jli: i think its just typeclass magic (due to typeclasses being polymorphic on the return type of functions) |
| 00:51 | brehaut | combined with no parens for calls and curried functions |
| 00:51 | brehaut | i guess it could be continuations… dunnoh |
| 00:52 | jli | brehaut: what client are you using that keeps inserting unicode goodness? |
| 00:53 | brehaut | err, colloquay on a mac and me insisting on typographically ellipsis rather than three dots |
| 00:53 | jli | haskell is a pretty fun place to play with pointlessness, what with $, ., flip, etc. |
| 00:53 | jli | brehaut: oh, is it not auto-converting that? |
| 00:53 | brehaut | jli: fogus informed me once that if i thought thahthaskell was good for PF, i needed to try cat |
| 00:53 | jli | have you memorized the utf8 code point? |
| 00:54 | brehaut | jli: i dont think so. opt+; is … |
| 00:54 | jli | ah |
| 00:56 | gienah | a haskell type safe printf is described in section 4 of this paper: http://www.haskell.org/haskellwiki/Simonpj/Talk:FunWithTypeFuns |
| 01:01 | jli | mm, I need to spend some time with the git book. using mostly hg for months has wiped a lot of stuff. |
| 01:47 | napping | to print some examples with results, can I avoid something like this (defmacro example [form] `(do (println (quote ~form)) (println ";=>" ~form))) |
| 03:19 | Blkt | good morning everyone |
| 04:01 | kzar | ibdknox: 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:02 | kzar | ibdknox: (Sorry I meant to say, using Noir) |
| 05:01 | justin` | 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:06 | mrh0057 | No but if you are going to do it a lot you can write your function to perform that operation. |
| 05:42 | thorwil | justin`: perhaps you could do a for with [[:x inc] [:y dec] [:z fn]] |
| 05:44 | amalloy | it's not really possible with `for`. you can reduce, though |
| 05:45 | amalloy | &(reduce (fn [m k] (update-in m [k] inc)) {:x 1 :y 2 :z 3 :a 4} [:x :y :z]) |
| 05:45 | lazybot | ⇒ {:x 2, :y 3, :z 4, :a 4} |
| 05:47 | kzar | Is using .getBytes on a string idiomatic Clojure? |
| 05:48 | raek_ | kzar: only if you supply the encoding parameter :) |
| 05:48 | raek_ | kzar: what do you want to do? |
| 05:50 | kzar | raek: 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:50 | kzar | raek_: I was going from this example http://download.oracle.com/javase/1.4.2/docs/guide/security/jce/JCERefGuide.html#HmacEx |
| 05:56 | raek | kzar: 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:56 | raek | but what byte value(s) does a character have? |
| 05:56 | raek | that completely depends on what encoding scheme you use |
| 05:56 | kzar | raek: I suppose it depnds on the encoding, hence the parameter |
| 05:56 | kzar | raek: Yea |
| 05:57 | kzar | raek: Is there a way to check encoding of a string? |
| 05:57 | raek | kzar: and that example is broken, since it will produce different hashes for the same string on different machines |
| 05:57 | raek | kzar: strings don't have encodings |
| 05:58 | raek | kzar: 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:59 | raek | a picture can be stored in many formats |
| 05:59 | raek | likewise can a piece of text be stored in many formats |
| 06:00 | raek | kzar: so to for the hash function to make sense, it must either take an encoding argument or hard-code a certain encoding |
| 06:02 | raek | so you might document the function like "Computes the HMAC-MD5 hash of the bytes acquired by encoding the string s using encoding e" |
| 06:03 | kzar | raek: How come the string doesn't have an encoding though, how does it store the piece of text? |
| 06:05 | kzar | raek: 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:06 | raek | kzar: yes, String uses some kind of encoding internally (which happens to be UTF-16) but that is an implementation detail |
| 06:07 | raek | kzar: ok, so the algorithm outputs a byte array. what does it contain? |
| 06:07 | raek | if it's not text, then you should not try to make a string from it |
| 06:08 | raek | strings on the JVM platform are for textual data only. there is no class for "byte strings" as in python3, for example |
| 06:08 | raek | only byte arrays |
| 06:09 | kzar | raek: Right OK, fair enough. I do need a string rather than a byte array though, so what do I do? |
| 06:10 | raek | that depends on which way you want to represent the bytes as a string |
| 06:13 | raek | if 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:15 | kzar | raek: 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:16 | raek | ok, so you received a string? |
| 06:16 | raek | is it a hex string or something else? |
| 06:17 | kzar | raek: 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:17 | kzar | raek: That way we know the request came from our guys |
| 06:18 | raek | hrm |
| 06:19 | raek | unfortunately HTTP does not specify which encoding the headers are in |
| 06:19 | raek | which means that ideally they should be treated as bytes and not characters (since we do not know the encoding) |
| 06:20 | raek | but the servlet framework *will* decode the headers with some encoding scheme |
| 06:21 | raek | if 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:25 | kzar | raek: Hmm I think I'm probably more confused now |
| 06:26 | raek | kzar: 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:27 | raek | kzar: is this header some sort of key? |
| 06:28 | raek | or is it a signature of the message? |
| 06:28 | kzar | raek: 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:29 | raek | ok, and what is the input to the HMAC-MD5 function? the request body? |
| 06:30 | kzar | raek: Yea, I'm actually doing a SHA512 instead of MD5 though. That's just the closest example I found |
| 06:30 | raek | ok |
| 06:30 | raek | so here's what I would do: |
| 06:31 | raek | make sure that the body (which is text, I presume) is always encoded in UTF-8 |
| 06:32 | raek | let the X-AUTH-HMAC header value be encoded with base64 |
| 06:33 | raek | so if you have the array [97 98 99], it will be transmitted as the ASCII string "YWJj" in the header |
| 06:34 | raek | then 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:34 | raek | and de-base64 the header to get the bytes stored in it |
| 06:35 | kzar | raek: OK, I've found an example that shows you how to turn the digest into a string as well. That's working |
| 06:35 | kzar | raek: Main thing that confuses me now, how to turn a string key into a java.security.key |
| 06:35 | raek | then you only have byte arrays which you can pass to the function and compare with java.util.Arrays.equals |
| 06:38 | raek | kzar: maybe you can use SecretKeySpec |
| 06:38 | raek | you need to give that the byte array of the key |
| 06:38 | kzar | raek: ahh |
| 06:38 | raek | (which you can obtain by de-base64:ing the header string) |
| 06:39 | raek | (if you choose to implement my approach) |
| 06:39 | kzar | raek: 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:40 | raek | kzar: I'm a Swede. I see the results from encoding errors by simply using my native language. :P |
| 06:41 | kzar | aha |
| 06:41 | raek | well, it helps if you think of byte strings and character strings as icompatible types |
| 06:41 | raek | *in- |
| 06:42 | raek | and that somewhere a translation always has to be done |
| 06:45 | kzar | raek: Thanks for explaining all that, really helpful |
| 06:46 | raek | kzar: np. glad to help. :) |
| 07:20 | ilyak | Is there something like (let [foo (x) bar (y)] (body foo bar)), but which only evaluates body when foo and bar aren't null? |
| 07:24 | ejackson | nested if-let |
| 07:28 | michaelr525 | hello! |
| 07:28 | Blafasel | Anyone 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:29 | Blafasel | 502 bad gateway sounds like the backend process for cgi/fcgi or something died.. |
| 07:33 | ejackson | yeah, sounds like somebody needs to attend to a service |
| 07:35 | Blafasel | Ah well.. Back to C# then it is. |
| 07:35 | michaelr525 | Blafasel: i think amalloy_ is related to 4clojure, try poking him maybe |
| 07:36 | michaelr525 | ...and back to C# as well ;) |
| 07:40 | michaelr525 | amalloy_: ^^ |
| 07:44 | Blafasel | michaelr525: He's the one that should sleep now :) |
| 07:44 | michaelr525 | ah |
| 07:44 | Blafasel | I think. And the trailing _ seems to be the "I'm not here" marker :) |
| 07:45 | Blafasel | (ignoring that one could use /whois to check the away state) |
| 07:49 | ilyak | ejackson: Thanks |
| 07:49 | ilyak | when-let did the trick |
| 07:50 | ejackson | cool |
| 07:53 | lnostdal | any way to terminate the rogue thread created by an accidental send-off? |
| 07:53 | lnostdal | a rogue* |
| 07:57 | lnostdal | ns-unmap on the variable holding the agent didn't seem to work |
| 08:25 | fdaoud | good morning |
| 08:25 | fdaoud | anyone else getting 502 Bad Gateway on 4clojure.com? |
| 08:25 | zippy314 | yep |
| 09:03 | tcrawley | There seem to be a few testing frameworks for clojure to choose from. Does anyone here have a preference they'd like to share? |
| 09:04 | ejackson | I use the standard test, but midje seems very popular |
| 09:05 | fdaoud | +1 |
| 09:07 | tcrawley | ejackson: fdaoud: have either of you played with speclj? https://github.com/slagyr/speclj |
| 09:07 | ejackson | tcrawley: nope |
| 09:08 | fdaoud | I have not |
| 09:09 | tcrawley | speclj is attractive simply because I've done lots of rspec, but midje looks interesting |
| 09:13 | fdaoud | tcrawley: don't throw eggs at me-- I use Maven so having standard tests being executed within Maven test target is nice for me |
| 09:14 | tcrawley | fdaoud: heh - my tests will be executed by maven as well - are you using https://github.com/talios/clojure-maven-plugin? |
| 09:16 | fdaoud | tcrawley: yes, and with this piece of configuration, mvn test works: https://gist.github.com/1259078 |
| 09:17 | fdaoud | reload, I put the whole piece |
| 09:18 | tcrawley | fdaoud: thanks! |
| 09:18 | dbushenko | what is the difference between fn and fn* ? |
| 09:19 | fdaoud | tcrawley: welcome |
| 09:27 | jbwiv | hello all. Anyone here using Intellij Idea for clojure dev with the la clojure plugin? |
| 09:27 | Arafangion | How does one get java programs to start faster? |
| 09:27 | Arafangion | Wait, it was javac -version I was checking. |
| 09:28 | Arafangion | java -version is only 10 or 20 times slower than python, that's not so bad. |
| 09:28 | jbwiv | Arafangion, 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:28 | Chousuke | if you really need fast startup you can run a persistent jvm instance using eg. cake |
| 09:28 | Arafangion | Thanks. :) |
| 09:29 | Arafangion | Ooh, cake isn't neccessarily worksafe. |
| 09:29 | Chousuke | so basically it's just cheating by always running the jvm, but that might not be a bad solution |
| 09:29 | Chousuke | worksafe? :/ |
| 09:29 | Arafangion | How do I google "cake" and not get, you know, cakes? |
| 09:29 | Arafangion | Chousuke: Lingerie cakes are result #4. |
| 09:30 | Chousuke | google clojure cake :P |
| 09:30 | Arafangion | Ok. :) |
| 09:30 | Arafangion | Ah, yep, that works. :) |
| 09:30 | fdaoud | mmm, cake. |
| 09:30 | andrewclegg | does "cake" mean something different outside the UK? what's a lingerie cake? I'd google it but I'm at work :-) |
| 09:31 | Arafangion | andrewclegg: I'm just going to hope it means "A cake in the shape of lingerie". |
| 09:31 | redinger | Yeah, googling cake for me doesn't result in any lingerie. :) |
| 09:32 | Arafangion | Well, google is known to give different results depending on where you are. |
| 09:32 | Arafangion | Just checked it out, and interesting, nothing to do wiht cake. |
| 09:33 | Arafangion | www.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:34 | andrewclegg | aaaaaah :-) |
| 09:35 | Blafasel | Weird world in which this is not worksafe.. |
| 09:36 | Arafangion | Depends on who is passing by behind you. |
| 10:11 | ejackson | I'm having a problem getting the evaluation time of arguments to a macro correct |
| 10:11 | ejackson | i've put up a gist https://gist.github.com/1259177 |
| 10:11 | ejackson | any explanation or help would be most appreciated :) |
| 10:13 | ejackson | i'm unable to make the main argument available to the macro, very frustrating ! |
| 10:15 | TimMc | Chousuke, chouser: Remember yesterday's discussion about the possible inadvisability of automatic subvec-like behavior with (vec (seq some-vec))? |
| 10:16 | TimMc | Chousuke, 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:17 | fdaoud | crap. I was really enjoying 4clojure.com and now it's down :( |
| 10:18 | TimMc | fdaoud: amalloy will be at work in about 4 hours, I would hazard. |
| 10:18 | Blafasel | ejackson: 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:18 | jkkramer | ejackson: if ak is a macro, then (cql/where (ak {:a 6 :m 9})) should work, i think |
| 10:19 | TimMc | fdaoud: Or... based on his last timestamp in #4clojure, maybe 5 hours. >_< |
| 10:19 | Blafasel | fdaoud: Heh. Just created a beautiful (yeah.. well..) solution, tested it locally and it went down before i could submit my pascal triangle :) |
| 10:19 | Blafasel | TimMc: /whois him :) |
| 10:20 | TimMc | Blafasel: What about it? |
| 10:21 | TimMc | The away timestamp means nothing without a time zone. |
| 10:21 | fdaoud | TimMc: thanks for the info |
| 10:21 | ejackson | Blafasel: 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:22 | fdaoud | Blafasel: how many problems solved you at? |
| 10:22 | ejackson | jkkramer: Let me try that... thanks |
| 10:22 | ejackson | my head has been done in |
| 10:22 | Blafasel | TimMc: 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:22 | Blafasel | fdaoud: No idea :) |
| 10:22 | Blafasel | Not a lot yet. 20? 30? |
| 10:24 | TimMc | Blafasel: Oh, cool. I just learned how to display that info. |
| 10:31 | ejackson | Blafasel: OK, I tried as a function https://gist.github.com/1259177#gistcomment-53987 |
| 10:31 | Blafasel | To continue the stalking: It should be ~7:30 for him.. ;-p |
| 10:31 | ejackson | its passed the predicate as the list, but it where just returns it |
| 10:32 | ejackson | i don't understand why |
| 10:36 | ejackson | its 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:36 | Blafasel | ejackson: (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:36 | Blafasel | I mean: Why the macro in the first place? |
| 10:36 | ejackson | Blafasel: lemme try |
| 10:37 | ejackson | Blafasel: Yeah, the macro, see my last mini rant about trying it a function, where just mocks it |
| 10:38 | Blafasel | Uhm. |
| 10:38 | gtrak | ~no, kancho $1 is <reply>javabot teleports silently behind $1, crouches and yells 'a thousand years of pain!' |
| 10:38 | clojurebot | Ack. Ack. |
| 10:38 | Blafasel | Wrapping it explicitly as a function? #(ak p)? |
| 10:38 | ejackson | Blafasel: better-where2 doesn't work as where is a macro, so apply can't use it |
| 10:39 | gtrak | sry clojurebot, wrong window |
| 10:40 | ejackson | Blafasel: 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:40 | ejackson | lemme |
| 10:40 | ejackson | try |
| 10:40 | ejackson | the |
| 10:40 | ejackson | wrapping as a function |
| 10:43 | theignorati | can I make leiningen put the jar it builds in a dir? |
| 10:52 | zippy314 | Does 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:53 | joegallo | that's an array of InternetAddresses, i think |
| 10:53 | twem2 | zippy314: see http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getName%28%29 |
| 10:54 | twem2 | its an array |
| 10:55 | zippy314 | THanks, thats exactly right. |
| 11:04 | jli | amalloy_: I don't suppose you could bring 4clojure back up now? :) |
| 11:04 | ejackson | wow, i didn't realise how popular that site is |
| 11:07 | fdaoud | jli: he's away |
| 11:14 | jli | ejackson: I keep crashing it |
| 11:14 | jli | fdaoud: ah, oh wel |
| 11:15 | ejackson | good work |
| 11:15 | jli | \o/ |
| 11:15 | lnostdal | hm, 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:16 | joegallo | the library and version that you're depending on would be helpful, if you're looking for diagnosis rather than commiseration :) |
| 11:16 | lnostdal | it's a local library here |
| 11:17 | lnostdal | it 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:17 | brcrth | Hi, what's the advantage of having anonymous functions? How I'll "call" the function when I need it? |
| 11:17 | lnostdal | brcrth, http://en.wikipedia.org/wiki/Anonymous_function#Sorting |
| 11:17 | joegallo | brcth: you pass them around as arguments, or set them to local names in let, for instance |
| 11:18 | brcrth | thanks :) |
| 11:18 | joegallo | so you'd call them like this (the-argument) or (the-name-that-i-let) |
| 11:18 | joegallo | which is to say, just like other functions |
| 11:20 | lnostdal | this doesn't make any sense .. grepping, "0.3.5" isn't mentioned anywhere |
| 11:21 | kzar | raek: What do you think? https://gist.github.com/1259359 It's not working right but I think it's nearly there |
| 11:50 | TimMc | fdaoud: 4clojure is up again, thanks to amcnamara |
| 11:51 | raek | kzar: 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:51 | raek | kzar: [commons-codec "1.4"] |
| 11:51 | fdaoud | TimMc: thanks! |
| 11:52 | gtrak | I think contrib has a base64, no? |
| 11:52 | raek | kzar: and you want to decode the base64 string (not encode it). |
| 11:53 | raek | decoding the base64 ASCII representation gives you the original bytes |
| 11:53 | kzar | raek: Silly me for taking an example at face value with no sanity check |
| 11:53 | raek | (but decoding bytes with a character encoding scheme gives you a string) |
| 11:53 | raek | so decode/encode has opposite types :) |
| 11:54 | lnostdal | does lein have some sort of verbose mode? .. so i can see why it's doing what it's doing? |
| 11:54 | raek | kzar: I would also split out conversion from string and base64 form to outside that function |
| 11:54 | gtrak | lnostdal, what in particular is so unpredictable? |
| 11:55 | raek | it's not relevant for the hmac algorithm in what way the bytes were represented before it gets them |
| 11:56 | raek | (defn bytes-from-auth-header-value [base64-string] (Base64/decodeBase64 base64-string)) |
| 11:56 | lnostdal | gtrak, 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:56 | raek | (defn encode-in-utf-8 [string] (.getBytes string "UTF-8")) |
| 11:57 | gtrak | lnostdal, 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:57 | gtrak | not sure if there's a native lein way to do that |
| 11:58 | gtrak | lnostdal, then, once you find which dependency is pulling in the bad ring, you can add an exclusion to your project.clj |
| 11:58 | raek | kzar: also, you have a problem here: (.getBytes key) |
| 11:59 | raek | this uses the platform default encoding. you'd better fix it to something non-changing (e.g. a constant "UTF-8") |
| 12:00 | raek | if the key is automatically generated, you should use the original byte array form (assuming it's avaiable) |
| 12:01 | lnostdal | ok .. now i can't even get ring to build itself .. mvn install tries to pull stuff from some remote repository ... |
| 12:02 | raek | if 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:02 | gtrak | lnostdal, huh? |
| 12:02 | gtrak | let maven do its thing |
| 12:03 | lnostdal | kinda makes local patching, well, hard |
| 12:03 | gtrak | what does? |
| 12:03 | lnostdal | it pulling stuff from clojars.org or whatever seemingly at random |
| 12:03 | gtrak | don't actually use maven for building, just use it to build you a dependency graph |
| 12:04 | gtrak | to do that, it needs to download its own plugins, plus all the poms for all the dependencies |
| 12:05 | gtrak | i think the command is actually mvn dependency:tree |
| 12:27 | kzar | raek: OK I think I've made those changes right, does using the = function to check if two byte arrays are equal work though? |
| 12:27 | dnolen | so now that we have Browser REPL, what about an iOS REPL ? |
| 12:28 | raek | kzar: no, = means "identical" for mutable thing, including arrays |
| 12:28 | raek | kzar: use (import 'java.util.Arrays) (Arrays/equals arr1 arr2) |
| 12:29 | raek | this means "currently have the same value" |
| 12:29 | lnostdal | seems use of :main (in project.clj) and :gen-class was confusing lein/mvn (or me; whatever really.. *sigh*) |
| 12:29 | dpritchett_ | is there a repl as cool as say iPython or irb+wirble yet? |
| 12:29 | dpritchett_ | for clojure that is |
| 12:31 | lnostdal | emacs+slime, dpritchett_ ? |
| 12:31 | dpritchett_ | I mean a no-dependencies repl |
| 12:31 | lnostdal | sure beats irb last time i tried that |
| 12:32 | dpritchett_ | i like to work in vim with a REPL that i occasionally reload files with |
| 12:32 | dpritchett_ | my two environments are vim + ipython/bpython and vim + irb |
| 12:32 | lnostdal | so you have a repl already then |
| 12:32 | dpritchett_ | I have tried to love emacs a few times just because of clojure and it's never workedo ut |
| 12:32 | dpritchett_ | lnostdal: Does the repl have line numbers, colorization, auto indents, etc? |
| 12:32 | lnostdal | ..but if you want a cooler one i bet slime is cooler |
| 12:32 | dpritchett_ | this is the kind of stuff i like about ipython/bpython |
| 12:33 | dpritchett_ | plus bpython automatically supplies help text for whichever function i'm typing up at the moment |
| 12:33 | lnostdal | yes, 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:33 | lnostdal | yup, it got that too |
| 12:34 | gtrak | dpritchett_, feel free to make an iclojure, I'd use it :-) |
| 12:34 | dpritchett_ | so i could use slime purely for the repl and then do my actual editing in vim? |
| 12:34 | dpritchett_ | how... odd |
| 12:34 | dpritchett_ | i rather like the idea |
| 12:35 | lnostdal | might 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:35 | dpritchett_ | woah woah woah |
| 12:35 | lnostdal | :> |
| 12:35 | gtrak | yo dog, i heard you like lisp, so I gave you a lisp so you can lisp while you lisp |
| 12:35 | dpritchett_ | I ask for a slightly juiced up cljoure repl and you jump to "might as well switch to emacs full time" |
| 12:35 | dpritchett_ | cmon now |
| 12:36 | dpritchett_ | 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:36 | lnostdal | *shrug* .. perhaps there are some middle ground type thing out there, i don't know |
| 12:36 | dpritchett_ | i've tried viper etc. and they didn't feel right |
| 12:36 | dpritchett_ | i guess i could always try again |
| 12:36 | dpritchett_ | i really like the simplicity of great repl + unconnected text editor |
| 12:37 | dnolen | dpritchett_: 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:37 | dpritchett_ | thank you dnolen, i will check it out |
| 12:37 | dpritchett_ | IDLE is a big part of why i got into python to begin with |
| 12:37 | dpritchett_ | its a great environment for playing around in |
| 12:37 | dnolen | dpritchett_: clooj definitely fits the bill of staying of your way. |
| 12:38 | dpritchett_ | looks like clooj is swing-based though, i do my clojure work on linux VMs and my desktop here is win7 |
| 12:38 | dpritchett_ | i foresee headaches down that path |
| 12:38 | gtrak | why's everyone hate on swing all the time? |
| 12:38 | dnolen | dpritchett_: like it not understanding Linux/Windows conventions? |
| 12:38 | dpritchett_ | i might try to run clooj on windows jsut to see how i like it |
| 12:38 | dpritchett_ | yeah i would expect some of that dnolen |
| 12:39 | dpritchett_ | I have nothing against swing gtrak, i just don't have a trustworthy java-speaking GUI handy |
| 12:39 | Bronsa | dpritchett_: http://i.imgur.com/eFaUa.png |
| 12:39 | Bronsa | isnt this tempting enough? :> |
| 12:39 | gtrak | dpritchett_, like netbeans or idea? those are in swing |
| 12:40 | dpritchett_ | ok, i guess i failed to accurately frame my problem |
| 12:40 | dpritchett_ | i haev a tiny VPS, i work via putty and tmux, i like REPLs and vim |
| 12:40 | gtrak | dpritchett_, ah, you should do it locally and upload instead :-) |
| 12:41 | dnolen | dpritchett_: why not vimclojure or slimv then? |
| 12:41 | dpritchett_ | 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:41 | dpritchett_ | i haev never gotten slimv up and running, that's another thing to try |
| 12:41 | dpritchett_ | I'm much better at this sort of thing than I was last October when vimclojure 1.2 came out |
| 12:42 | dpritchett_ | perhaps I should just try everything one more time |
| 12:42 | dpritchett_ | i still like having standalone repls |
| 12:42 | dpritchett_ | i have built entire django sites with ipython in one pane and vim in the other this year |
| 12:42 | dpritchett_ | and i really enjoyed that dynamic |
| 12:43 | dpritchett_ | slimv looks al right though |
| 12:43 | dnolen | dpritchett_: I never liked the Python REPL experience. |
| 12:43 | gtrak | ipython was pretty nice, but eventually I just used eclipse for it all |
| 12:43 | dpritchett_ | dnolen: Have you tried many of them? I'll admit that none of the python repls I've used were perfect |
| 12:43 | dnolen | reloading changes module w/ restarting everything was always a PITA |
| 12:44 | kzar | raek: 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:44 | dpritchett_ | that is true, i hacked some init scripts into my .ipythonrc to reload my hottest modules with three-letter aliases |
| 12:44 | dpritchett_ | and that only worked because my app was still fairly small |
| 12:44 | dpritchett_ | 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:44 | dpritchett_ | I can't fault you for finding that awkward; it is |
| 12:45 | dpritchett_ | slimv seems like a good way to have my cake and eat it too |
| 12:45 | dpritchett_ | considering how much mindshare swank has in this community |
| 12:46 | gtrak | it 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:47 | dpritchett_ | 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:47 | dpritchett_ | ^language |
| 12:47 | dpritchett_ | next thing you know people will be claiming they enjoy working in eclipse :P |
| 12:48 | dpritchett_ | 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:48 | kzar | dpritchett_: There are a few articles about emacs + rsi about |
| 12:48 | gtrak | dpritchett_, first thing is to switch caps-lock to be your ctrl |
| 12:48 | dpritchett_ | There'd have to be, eh? |
| 12:49 | kzar | dpritchett_: 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:49 | dpritchett_ | 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:49 | dpritchett_ | i guess i need a right-capslock too |
| 12:49 | dpritchett_ | kzar to be fair i was a rather avid gamer back then |
| 12:49 | jkkramer | or foot pedals ;) |
| 12:49 | dpritchett_ | many causes to be sure |
| 12:50 | dnolen | dpritchett_: I've been using Emacs for 7 years now, I hate doing any long Emacs sessions w/o my Kinesis. |
| 12:50 | dpritchett_ | is that the thing technomancy strapped to his pants? |
| 12:51 | kzar | dnolen: You should read that book as well, it's less fluffy than it sounds |
| 12:52 | gtrak | dnolen, which kinesis? |
| 12:52 | dnolen | Kinesis Advantage |
| 12:52 | gtrak | so sexy, I haven't tried a keyboard like that yet |
| 12:52 | dpritchett_ | i had one of those MS split keyboards a decade ago and i loved it |
| 12:52 | gtrak | but i guess if this is my job for 50 years it's worth it |
| 12:52 | dnolen | gtrak: the best part is that it lets you leverage your strongest fingers - your thumbs. |
| 12:53 | dpritchett_ | +1 gtrak, i was just weighing the benefits of bringing my own $300 KB to work |
| 12:53 | dnolen | I've had my Kinesis for 5 years now. Rock solid. |
| 12:53 | dnolen | can't say that for much tech I own. |
| 12:55 | dpritchett_ | Do you work from home? |
| 12:55 | dpritchett_ | It'd be sad having a sweet keyboard at home or at the office and then not having one one the other side |
| 12:57 | dnolen | dpritchett_: At one point I had two, work/home, but I gave my other to my brother who was having RSI trouble. |
| 12:59 | rbranson | i've taught myself how to type with my arms/hands at natural angles instead of bent, works great, even on a $10 keyboard |
| 13:00 | dpritchett_ | What, like you have your arms nearly fully extended? |
| 13:00 | gtrak | you don't rest your palms? |
| 13:00 | dpritchett_ | I adjust the pitch of my keyboard regularly and slide my KB forward and back regularly to find a good spot |
| 13:00 | dpritchett_ | sometimes I rest a wrist on a makeshift support |
| 13:01 | dpritchett_ | Oh I forgot rbranson has a sit/stand desk |
| 13:01 | dpritchett_ | That'd help |
| 13:01 | rbranson | instead of bending at the wrist and aligning my fingers with the home keys |
| 13:01 | rbranson | my fingers do a little bit more work and my wrists stay straight |
| 13:02 | rbranson | i was using natural keyboards for like 10 years though, don't feel much of a difference either way |
| 13:03 | raek | 7away |
| 13:03 | raek | eh. |
| 13:05 | dpritchett_ | Has anyone here played with clansi? Looks like a neat way to add colorization to any old command line clojure tool |
| 13:05 | dpritchett_ | like say `cake repl` |
| 13:05 | hiredman | I have |
| 13:05 | dpritchett_ | 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:05 | fdaoud | dpritchett_: just catching up.. fwiw I use vim and regular command-line repl, works fine. don't like emacs. |
| 13:05 | hiredman | and I started to play with a repl that uses clojure.pprint and clansi for printing |
| 13:06 | dpritchett_ | that sounds awesome hiredman |
| 13:06 | hiredman | *shrug* |
| 13:06 | dpritchett_ | How'd you set up that repl? |
| 13:06 | dpritchett_ | Just runtime invocations of pprint and clansi at startup? |
| 13:06 | dpritchett_ | thanks fdaoud, that sounds like where i'm headed |
| 13:06 | dpritchett_ | I have probably spent more time on clojure tools than on clojure programming... no one to blame but myself |
| 13:07 | hiredman | I can tell |
| 13:07 | dpritchett_ | maybe i should be a hardcore greenscreen guy instead of even trying to make myself happy with tools |
| 13:08 | gtrak | dpritchett_, yea focus on punchcards first |
| 13:09 | dpritchett_ | most of the folks in my office are greybeards with punchcards and flowchart stencils and other cool stuff |
| 13:09 | dpritchett_ | i learn a lot from them |
| 13:14 | crazyFox | is 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:15 | dnolen | crazyFox: people tends to use Java naming conventions for protocols/types/records |
| 13:17 | crazyFox | dnolen: ok. thank you. |
| 13:20 | crazyFox | dnolen: does this also apply to the field/method names? |
| 13:26 | jbwiv | I'm trying to build clojure-contrib and getting this output from mvn package (https://gist.github.com/60301f4a98dc666d8a4b). Any ideas how to solve? |
| 13:28 | dnolen | crazyFox: no fields and protocols fns should follow normal Lisp naming conventions. |
| 13:32 | dnolen | jbwiv: 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:35 | dnolen | jbwiv: you could probably make that work by building w/o tests. |
| 13:37 | jbwiv | dnolen, ah, ok. what should I be using? 1.2? |
| 13:37 | jbwiv | sorry...clojure newb here |
| 13:38 | dnolen | jbwiv: don't use monolithic contrib, it's deprecated. |
| 13:38 | dnolen | jbwiv: the most useful bits were already incorporated into 1.2.0 |
| 13:38 | jbwiv | dnolen, what's the best way of getting access to sql? |
| 13:38 | jbwiv | thought that was in clojure-contrib |
| 13:38 | dnolen | jbwiv: https://github.com/clojure/java.jdbc |
| 13:39 | jbwiv | dnolen, ok, thanks! |
| 13:42 | dnolen | no if only someone would implement all the Clojure persistent datastructures in C++ we could use them from V8, SpiderMonkey, JavaScriptCore ... |
| 13:42 | dnolen | s/no/now |
| 13:42 | seancorfield | org.clojure/java.jdbc "0.0.6" |
| 13:43 | gtrak | dnolen, I think you need GC for this, yes? |
| 13:43 | seancorfield | i 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:43 | gtrak | sounds like a huge pain in the ass without GC |
| 13:46 | gtrak | I guess you can do smart pointers, but no circular references right? |
| 13:51 | dnolen | gtrak: seems surmountable, http://code.google.com/p/jscocoa/wiki/GarbageCollection. I believe V8 has similar guidelines. |
| 13:52 | gcv | Is 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:52 | gtrak | I've done a little C++ and i'd be very very afraid |
| 13:53 | dnolen | gtrak: well Node.js isn't. |
| 13:53 | gtrak | dnolen, you mean they have structurally shared data structures in node? |
| 13:54 | dnolen | gtrak: no I mean they probably have to create C++ objects which are subject to GC there as well. |
| 13:54 | gtrak | sure, java has a GC, too, but the data structures are written in java, not C++ |
| 13:54 | jbwiv | so 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:55 | kharrington1 | pretty 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:55 | gtrak | kharrington1, not GC, reference-counted smart pointers |
| 13:56 | gtrak | it's a can of worms |
| 13:57 | kharrington1 | mmm |
| 13:57 | dnolen | jbwiv: if you're using 1.2.1 there's no reason to build contrib from scratch. |
| 13:57 | jbwiv | dnolen, so under 1.2.1, contrib is already there? |
| 13:58 | dnolen | jbwiv: no it's a separate jar, but just drop into your classpath |
| 14:01 | jbwiv | dnolen, so, where would I find this jar? I don't see it after building 1.2.1 |
| 14:02 | dnolen | jbwiv: 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:03 | jbwiv | dnolen, 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:04 | dnolen | jbwiv: btw, what code are you using that requires the older SQL lib? |
| 14:05 | jbwiv | dnolen, 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:05 | jbwiv | so I presume it requires the older lib, but it is just as likely to be my setup |
| 14:05 | dnolen | jbwiv: because the namespace it's pointing as is wrong now. |
| 14:05 | dnolen | s/as/at |
| 14:05 | jbwiv | dnolen, ah, k |
| 14:06 | dnolen | jbwiv: it's probably worth considering the minor hassle moving to java.jdbc since it's actively maintained. |
| 14:07 | jbwiv | dnolen, 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:14 | gcv | Could someone fill me in on the exact implications of the removal of checked exceptions in 1.3.0? |
| 14:14 | gcv | Does every checked exception thrown by Java code get chained to a RuntimeException? |
| 14:21 | dnolen | gcv: checked exception are a fiction from what I understand, http://tapestryjava.blogspot.com/2011/05/tragedy-of-checked-exceptions.html |
| 14:24 | gcv | dnolen: 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:24 | gcv | so I was hoping to understand the changes in 1.3.0 a little better — the changedoc has no details at all. |
| 14:25 | TimMc | I've heard some other people complaining about this too. |
| 14:25 | dnolen | gcv: checked exceptions used to be supported I think? that's since been removed. |
| 14:25 | technomancy | "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:26 | gcv | guys, I'm not disagreeing that checked exceptions suck :) |
| 14:26 | TimMc | dnolen: And are instead wrapped in RTEs? |
| 14:26 | gcv | I'm just trying to understand why catching an exception declared as checked in external Java code doesn't work. |
| 14:26 | gcv | (anymore) |
| 14:26 | dnolen | TimMc: I think so I don't understand the details of the change. |
| 14:28 | TimMc | Neither does anyone, as far as I can tell. |
| 14:29 | TimMc | "Clojure does not throw checked exceptions" <- OK... |
| 14:29 | TimMc | gcv: Experimentally, what does clojure throw? |
| 14:30 | dnolen | gcv: bring the issue up on the mailing list, I'm sure someone has experienced this before. |
| 14:30 | gcv | dnolen: will do |
| 14:31 | TimMc | gcv: If you (throw (IllegalAccessException. "foo")), what does Java catch? |
| 14:32 | gcv | TimMc: no idea, I don't have any code which calls Clojure from Java |
| 14:35 | pjstadig | gcv: i think all exceptions are wrapped now into RuntimeExceptions |
| 14:36 | amalloy | dnolen: 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:37 | gcv | pjstadig: I hope not, because that means typed catch is now useless, which weakens Clojure's Java interop story. |
| 14:37 | hiredman | pjstadig: are you sure about that? |
| 14:39 | hiredman | I believe that is only if you are using reflection |
| 14:39 | pjstadig | no i'm not sure |
| 14:39 | pjstadig | i'm likely wrong |
| 14:39 | hiredman | clojure's reflector rethrows as runtime exceptions to avoid having to declare thrown exceptions everywhere |
| 14:40 | hiredman | (in 1.3) |
| 14:40 | crazyFox | is there any other way to resolve cyclic load dependencies than putting code into a different file? |
| 14:40 | pjstadig | https://github.com/clojure/clojure/commit/8fda34e4c77cac079b711da59d5fe49b74605553 |
| 14:41 | crazyFox | pjstadig: u r talking to hiredman? |
| 14:41 | pjstadig | yeah 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:41 | hiredman | right, 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:42 | pjstadig | *wrap them in a RuntimeException |
| 14:42 | hiredman | well, the reason is the reflector is written in java, so it has to abide by the fiction |
| 14:42 | hiredman | and if the reflector has to then so does the compiler etc |
| 14:42 | pjstadig | yeah |
| 14:42 | hiredman | it ripples through the java codebase |
| 14:43 | pjstadig | right so i suppose anytime you cross that java barrier with clojure code, an exception thrown will get wrapped in Clojure's java code |
| 14:43 | amalloy | i 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:45 | crazyFox | can declare be used to resolve cyclic load depedencies? |
| 14:45 | dnolen | crazyFox: no, you have to change your project structure |
| 14:45 | raek | crazyFox: between vars in a namespace, yes. between namespaces, no. |
| 14:46 | crazyFox | dealing with different namespaces so - ok ill change my files. not an ideal solution though. |
| 14:46 | duck1123 | fixing load dependencies are a pain, but your project will be better for it anyway |
| 14:47 | crazyFox | duck1123: 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:47 | raek | this 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:48 | crazyFox | yeah i see |
| 14:48 | duck1123 | I'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:49 | duck1123 | I'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:50 | amalloy | (inc duck1123) |
| 14:50 | lazybot | ⟹ 1 |
| 14:51 | amalloy | cyclic 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:51 | amalloy | chose b, but the important thing was there's no (c) ignore the fact that your utils file is a mess |
| 14:57 | crazyFox | duck1123: well i make my project structure up as i go along. so, yes its not thought out well so far :D |
| 14:57 | ibdknox | Noir made it into the trending repo list on github :) https://github.com/explore |
| 14:58 | dnolen | ibdknox: nice! |
| 14:58 | ibdknox | I was actually very surprised people cared lol |
| 14:59 | crazyFox | anyone aware of an editor thats has convenient functionality to help with cyclic load dependencies? |
| 14:59 | gtrak | crazyFox, you mean like a compiler? |
| 15:00 | crazyFox | gtrak: actually an ide |
| 15:00 | gtrak | if you try to compile your files and there's a cyclic dependency, it'll break |
| 15:00 | gtrak | isn't that enough? |
| 15:02 | kij | openjdk is broken for the entire clojure or just clojsurescript ? |
| 15:02 | crazyFox | it 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:02 | technomancy | kij: just clojurescript |
| 15:02 | kij | thanks. |
| 15:03 | TimMc | crazyFox: If yo uneed IDE support for that, you *probably* need to work on your abstraction boundaries. |
| 15:03 | dnolen | kij: OpenJDK should be fixed for ClojureScript now. |
| 15:03 | ibdknox | dnolen: when did that happen? |
| 15:03 | dnolen | ibdknox: today |
| 15:03 | ibdknox | dnolen: awesome :D |
| 15:04 | dnolen | ClojureScript is now using a newer version of Rhino, Brenton has dropped some serious awesomeness. |
| 15:04 | gtrak | crazyFox, 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:04 | upwardindex | Does "leon upgrade" also upgrade plugins? |
| 15:04 | ibdknox | upwardindex, no |
| 15:04 | upwardindex | "lein upgrade** |
| 15:04 | dnolen | ibdknox: print doesn't trigger the print dialog, JS stack traces from Chrome / FF |
| 15:04 | upwardindex | ibdknox: How do you upgrade plugins? |
| 15:04 | crazyFox | TimMc: 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:05 | ibdknox | upwardindex: uninstall the old one and install the new version |
| 15:05 | ibdknox | dnolen: yeah I saw those :) |
| 15:05 | upwardindex | ibdknox: Ok, thank you! |
| 15:05 | gtrak | crazyFox, i honestly can't think of a case where it'd be so bad that a tool is worth it |
| 15:06 | gtrak | now a general refactoring tool, I could get behind that |
| 15:06 | gtrak | like a 'change all references to this function when i move it' sort of thing |
| 15:07 | technomancy | there's a refactorer for Emacs |
| 15:07 | technomancy | it can do things like "arrowize this form" |
| 15:08 | crazyFox | gtrak: 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:08 | gtrak | crazyFox, that's the point. I'm imagining it, and it looks silly |
| 15:09 | gtrak | plus, it's not terribly hard to avoid writing them in the first place |
| 15:09 | ibdknox | crazyFox: out of curiosity, what language are you coming from? |
| 15:10 | crazyFox | idbknox: mainly c/java |
| 15:10 | gtrak | use a forward declaration as a last resort |
| 15:10 | ibdknox | crazyFox: using primarily eclipse? |
| 15:11 | crazyFox | gtrak: it might seem silly to some ppl, but it wd still help many i guess |
| 15:11 | crazyFox | ibdknox: lately yes |
| 15:11 | ibdknox | gtrak: I think it honestly depends on how you "grew up" programming |
| 15:11 | gtrak | yea... I guess I had some C and C++ before java |
| 15:13 | gtrak | you shouldn't write code like that in java, either, even though it lets you |
| 15:13 | ibdknox | sure, but what's to teach you not to? lol |
| 15:13 | crazyFox | "code like that"? |
| 15:13 | gtrak | circularly referenced stuff |
| 15:14 | gtrak | types that know about each other, etc.. |
| 15:15 | gtrak | can't think of a case where that is the right choice |
| 15:16 | gtrak | ibdknox, lots of good programming books out there |
| 15:16 | ibdknox | gtrak: I think with types it's more obvious than it is with functions |
| 15:16 | crazyFox | gtrak: agree. i just - have a lot to learn and so i just started my project and ill see where it takes me |
| 15:18 | gtrak | ibdknox, with functions, wouldn't you be doing a mutual recursion by accident anyway? |
| 15:18 | ibdknox | gtrak: groups of functions |
| 15:18 | gtrak | you write a function that calls a function that calls you? seems like a stackoverflow |
| 15:19 | ibdknox | gtrak: sorry didn't mean inside of a function |
| 15:19 | ibdknox | I meant with a group of functions |
| 15:19 | gtrak | like how? |
| 15:20 | ibdknox | There are certainly logical groupings of functions where two files would depend on eachother |
| 15:21 | crazyFox | gtrak: 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:22 | gtrak | sure.. then you separate something out or add a forward declaration and it's fixed |
| 15:22 | amalloy | gtrak``: (defn a/foo [] (b/bar)) (defn a/baz [] 1) (defn b/bar [] (a/baz)) |
| 15:22 | TimMc | crazyFox: Often the answer is to have a common utility namespace or such. |
| 15:23 | ibdknox | yeah. The fixes are usually straightforward :) |
| 15:23 | crazyFox | yea. and an ide could help me with this. |
| 15:23 | ibdknox | crazyFox: well, I would argue that it's better to not have the IDE in this instance |
| 15:23 | ibdknox | there's value in learning how to think in a manner that organizes things cleanly |
| 15:24 | technomancy | crazyFox: slamhound does that, sorta |
| 15:24 | technomancy | it won't untangle circularity, but it will fix your ns forms to reflect what's on disk |
| 15:24 | gtrak | you could also separate the names from implementations, which is what you do in C with .h's and .c's |
| 15:24 | TimMc | gtrak: ew |
| 15:24 | gtrak | well, you could :-) |
| 15:24 | ibdknox | haha |
| 15:24 | TimMc | ew |
| 15:25 | crazyFox | technomancy: sorta :D. in my ideal ide this wd be done more automatically |
| 15:25 | technomancy | crazyFox: should be possible to trigger a recomputing of the ns form when you encounter a compilation error. |
| 15:26 | gtrak | you could have an impl namespace that imports the vars |
| 15:26 | technomancy | just a matter of someone hooking up the pieces |
| 15:26 | gtrak | then binds itself onto the vars |
| 15:26 | kzar | ibdknox: Is there a way to access request and response header from inside defpage? |
| 15:26 | crazyFox | technomancy: do u plan to add functionality like "lein slamhound" -> slamhound replaces all the ns forms in all project files? |
| 15:26 | kzar | ibdknox: Or just the full request / response |
| 15:27 | ibdknox | kzar: you can set response headers by returning a map |
| 15:27 | technomancy | crazyFox: I have that implemented in elisp. it's really hard to implement in clojure. |
| 15:27 | kzar | ibdknox: Sometimes I want to do things myself, middleware is the only way I found but it seems silly to use sometimes |
| 15:27 | ibdknox | kzar, can you give me a case you think is silly? |
| 15:27 | technomancy | elisp lets you simultaneously treat code structurally and also as a string, but clojure doesn't |
| 15:28 | crazyFox | gtrak: i dont understand. can u elaborate? |
| 15:28 | gtrak | it's a hair-brained scheme I just pulled out of my ass :-) |
| 15:28 | crazyFox | oh. well then... |
| 15:29 | kzar | ibdknox: 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:29 | gtrak | you could have a namespace of function implementations that binds the implementations to the declaration vars on init |
| 15:29 | gtrak | that way you'd have all the names of functions defined, but implementations separated |
| 15:30 | gtrak | sort of like a dependency injection i guess |
| 15:30 | amalloy | ibdknox, kzar: perhaps you want to reimplement whatismyip.com |
| 15:30 | ibdknox | kzar: 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:30 | amalloy | one of your pages needs the client's IP address, but the rest don't |
| 15:30 | gtrak | I dont' recommend it as a a methodology, but just saying, it could be done |
| 15:31 | ibdknox | amalloy: you can grab that from noir.request now :) |
| 15:31 | amalloy | ibdknox: i assume you do this by adding a middleware that binds a var to the request? |
| 15:31 | gtrak | if all the names are declared in separate namespaces and decoupled from implementations, then you can't have circular references |
| 15:31 | crazyFox | gtrak: u mean like a (declare <list all your functions>) in a separat (like header) file that u use in all the other files? |
| 15:32 | gtrak | yea something like that |
| 15:32 | gtrak | a terrible terrible idea |
| 15:32 | redinger | ibdknox: When are you coming back to Durham to present the Clojure meetup with all this Noir hotness? :) |
| 15:32 | crazyFox | gtrak: y it does discourage a proper (layer) design |
| 15:33 | amalloy | gtrak: an idea that doesn't even work. you can't declare outside of your current namespace |
| 15:33 | crazyFox | thats even better. one less possibility to mess ^^ |
| 15:33 | amalloy | and it's even more disgusting to write header.clj as: (ns foo) (declare myfn) (ns bar) (declare more-fns) |
| 15:34 | jweiss | ,(map #(+ %1 ^{:my :meta}) [1 2 3]) |
| 15:34 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )> |
| 15:34 | jweiss | that is a misleading error message to me ^ |
| 15:34 | ibdknox | amalloy: yeah |
| 15:34 | jweiss | (i originally hit it copying metadata that already had a ^ into a with-meta form) |
| 15:35 | ibdknox | redinger: haha I'm not sure yet. :) |
| 15:35 | crazyFox | amalloy: i wonder how far bad style can be taken |
| 15:36 | kzar | ibdknox: OK, so if I return a map instead of the body the map I return is the full response that's sent? |
| 15:36 | gtrak | amalloy, I think I said declare in one ns, bind in another |
| 15:36 | ibdknox | kzar, well it's parts of it |
| 15:37 | ibdknox | kzar, other parts will get added to it by middleware as it comes back out |
| 15:37 | gtrak | and i said it's totally a bad idea |
| 15:37 | ibdknox | kzar, but yes |
| 15:37 | kzar | ibdknox: OK gotya, thanks |
| 15:37 | hiredman | jweiss: misleading in what way? given the way the reader works it makes sense |
| 15:37 | jweiss | hiredman: should users of clojure know how the internals of the reader work? |
| 15:37 | hiredman | yes |
| 15:38 | crazyFox | gtrak: i wont quote you on it |
| 15:38 | ibdknox | lol |
| 15:38 | ibdknox | no |
| 15:38 | hiredman | absolutely |
| 15:38 | ibdknox | that's the opposite of pragmatism |
| 15:38 | kzar | ibdknox: 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:38 | ibdknox | kzar: I think it is by far the 10% case, and so it was designed as such |
| 15:39 | kzar | ibdknox: Hmm fair enough, at least there's a way when you need it |
| 15:39 | ibdknox | kzar: yep :) |
| 15:39 | kzar | ibdknox: 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:39 | gtrak | amalloy, yes it has downsides, but circular references is not one of them :-) |
| 15:40 | jweiss | hiredman: while i agree it helps to know the internals, that should not be a requirement |
| 15:40 | ibdknox | kzar: 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:40 | jweiss | no consumer of a library is expected to know implementation details, just the contract |
| 15:41 | amalloy | jweiss: the contract is that ^{...} forms need to be attached to something? |
| 15:41 | hiredman | jweiss: thats one of the huge benefits of clojure, the implementation, compared to most other languages is very simple |
| 15:42 | jweiss | amalloy: yes, i know that, but i accidentally didn't do it and the error message was wrong |
| 15:42 | hiredman | I would argue you should know the details of any language you use, and it's easier to do so with clojure |
| 15:43 | jweiss | ok, 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:43 | jweiss | the delimiter is not unmatched. |
| 15:43 | hiredman | it is |
| 15:43 | hiredman | ^{} causes it to be unmatched |
| 15:44 | jweiss | it is if you know the reader consumes the paren with the meta |
| 15:44 | jweiss | and your mistake wasn't putting the ^ in there by accident in the first place |
| 15:44 | srid | how do I set .innerHTML in clojurescript? |
| 15:44 | srid | or set any attr |
| 15:45 | amalloy | set! |
| 15:46 | dnolen | srid: you probably want to use something from google closure to do that if you're worried about cross browser issues. |
| 15:50 | crazyFox | when i have a (defrecord MyDataType ...) in one file, do i :use, :import or :require it in another file? |
| 15:51 | crazyFox | well i can actually ask slamhound |
| 15:52 | srid | (.set! (. innerHTML content) (. innerHTML tab-content)) |
| 15:52 | srid | -> TypeError: Cannot read property 'content' of undefined |
| 15:52 | gtrak | if you require, you'll have to qualify it by the alias |
| 15:52 | gtrak | crazyFox^ |
| 15:52 | hiredman | gtrak: no |
| 15:52 | amalloy | srid: args to . are backwards |
| 15:52 | gfredericks | where did clojure.contrib.json go for 1.3? I thought there was a clojure.data.json ns, but apparently not |
| 15:52 | gfredericks | googling doesn't help |
| 15:52 | dnolen | crazyFox: default ctor fns are provided for you in 1.3.0, in 1.2.0 you provide your own. |
| 15:52 | hiredman | crazyFox: in 1.3 defrecord creates factory fns and you should use them |
| 15:53 | srid | amalloy: sure? http://java.dzone.com/articles/adventures-clojurescript says otherwise |
| 15:53 | srid | looks like I should not have a space after . |
| 15:53 | srid | with that, I get: TypeError: Object Nothing has no method 'set_BANG_' |
| 15:53 | hiredman | gfredericks: use cheshire |
| 15:53 | hiredman | https://github.com/dakrone/cheshire |
| 15:54 | gfredericks | hiredman: okay I will try, thanks |
| 15:54 | srid | oops, I used .set! instead of set! |
| 15:55 | duck1123 | gfredericks: data.json is at https://github.com/clojure/data.json |
| 15:55 | gfredericks | duck1123: thanks |
| 15:55 | kzar | ibdknox: Oh, I meant to ask you. How does the mapping to static files in resources/public work? |
| 15:55 | srid | dnolen: not sure if closure has a wrapper for setting innerHTML |
| 15:56 | dnolen | srid: it does |
| 15:56 | kzar | ibdknox: 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:57 | kzar | ibdknox: So it tries to open a filename of "dumb%20example.jpg" instead of "dumb example.jpg" |
| 15:57 | hiredman | cheshire is far superior to contrib's json handling |
| 15:57 | srid | dnolen: 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:58 | hiredman | round tripping through cheshire is faster than round tripping through clojure's printer/reader |
| 15:58 | hiredman | (which you can see from the nice table in the cheshire readme, data.json doesn't give any benchmarks, which is telling) |
| 15:58 | dnolen | srid: goog.dom.htmlToDocumentFragment |
| 15:58 | gfredericks | hiredman: in my case, development time is more important |
| 15:59 | duck1123 | I might have to give cheshire a look then |
| 15:59 | srid | dnolen: 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:59 | srid | all examples for tabbar does 'copy', but not 'move' |
| 16:01 | ibdknox | kzar: is that with 1.2.0 |
| 16:04 | dakrone | hiredman: yea, I need to add benchmarks for data.json comparisons |
| 16:05 | jbwiv | anyone here using intellij with la clojure? |
| 16:05 | crazyFox | dnolen, 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:05 | jbwiv | I'm trying to inspect variable values in intellij when I hit a breakpoint, but watches don't seem to work |
| 16:07 | dnolen | crazyFox: import the ctor fns for those types into file C |
| 16:09 | crazyFox | dnolen: what are ctor functions? what do they look like? or rather: is this explained somewhere? |
| 16:10 | kzar | ibdknox: 1.1.1-SNAPSHOT |
| 16:10 | jbwiv | what's the preferred way to debug clojure code? do any ides support debugging well? |
| 16:11 | kzar | ibdknox: I'll upgrade and see what happens |
| 16:13 | kzar | ibdknox: Yea, it happens with 1.2 as well |
| 16:14 | S11001001 | crazyFox: http://dev.clojure.org/display/design/defrecord+improvements |
| 16:16 | Raynes | ibdknox: I think you're right. My tolerance for Sublime's poor indention is quickly running out. |
| 16:20 | kzar | Is 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:21 | kzar | I need to do a regexp replace, but by giving a function the match as a parameter instead of replacing with a static string |
| 16:21 | amalloy | kzar: clojure.string/replace takes a function |
| 16:22 | amalloy | &(clojure.string/replace "test" #"s" (fn [m] (str (char (inc (int (first m))))))) |
| 16:22 | lazybot | ⇒ "tett" |
| 16:22 | kzar | amalloy: Schweet, that's exactly what I needed |
| 16:23 | amalloy | worst function definition ever there, btw. doing arithmetic on characters is such a pain :P |
| 16:27 | crazyFox | S11001001: thank you! i will read and digest :) |
| 16:34 | pyr | so I have a locally deploy maven artifact |
| 16:34 | pyr | in $HOME/.m2/repository |
| 16:35 | pyr | when referencing it in my project.clj |
| 16:35 | pyr | it seems as though there's still an attempt to download from http repositories |
| 16:36 | pyr | is that because i did not reference the artifact correctly |
| 16:36 | pyr | or is it expected |
| 16:42 | duck1123 | pyr: if it's a SNAPSHOT, it'll try to update it from time to time |
| 16:53 | kzar | How can I make regexp match over new lines? |
| 16:54 | TimMc | &(clojure.string/replace "test" #"s" (comp str char inc int first)) |
| 16:54 | lazybot | ⇒ "tett" |
| 16:54 | TimMc | kzar: DOTALL or MULTILINE or something |
| 16:55 | TimMc | You have to use Pattern directly to do that, I think. |
| 16:56 | amalloy | $javadoc java.util.regex.Pattern |
| 16:56 | lazybot | http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html |
| 16:58 | kzar | TimMc: If the regexp literal is that class could I call a method on it to enable multi line matches? |
| 16:58 | pyr | duck1123: pb came from me |
| 16:58 | TimMc | kzar: Looks to be immutable. There seems to be a way to enable those flags inline, though. |
| 16:59 | TimMc | ,(re-seq #"_._" "a_\n_b") |
| 16:59 | clojurebot | nil |
| 16:59 | TimMc | ,(re-seq #"(?s:_._)" "a_\n_b") |
| 16:59 | clojurebot | ("_\n_") |
| 17:00 | TimMc | ^ It's not pretty, but that's how to use Clojure's RE reader syntax and still get those flags. |
| 17:00 | TimMc | Or, do (Pattern. (str #"...") flags...) |
| 17:00 | TimMc | Pattern/compile, rather |
| 17:01 | kzar | TimMc: I don't understand the ?s example, shouldn't it be ?m ? |
| 17:02 | TimMc | DOTALL allows . to match \n |
| 17:02 | TimMc | MULTILINE makes ^ and $ match line boundaries. |
| 17:03 | duck1123 | it's a shame re-pattern doesn't accept flags |
| 17:04 | kzar | TimMc: Sweet I got that working, thanks |
| 17:06 | TimMc | kzar: Word of warning: Pattern might not be smart enough to optimize that "global override" into a global flag. |
| 17:06 | TimMc | So this approach could slow down your regexes, maybe. |
| 17:06 | Blafasel | http://pastebin.com/e0Py3ELe - What is leiningen trying to tell me? |
| 17:06 | duck1123 | Is there a way to access the command history in CCW's repl views? |
| 17:07 | ibdknox | Blafasel, looks like a Clojure version mismatch |
| 17:07 | TimMc | duck1123: Have you tried C-p and C-n? |
| 17:07 | duck1123 | Blafasel: Most likely, you have a jar that was compiled against a different version than you're using |
| 17:08 | duck1123 | TimMc: yep. (once I remembered that esc-p is not alt-p) didn't work |
| 17:08 | Blafasel | duck1123: 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:09 | duck1123 | Blafasel: one of your deps is going to have a bunch of class files in it, that's most likely the problem |
| 17:10 | Blafasel | duck1123: Checking. Thanks |
| 17:10 | srid | clojurescript's map doesn't work? |
| 17:10 | srid | (map #(...) (dom/getChildren (dom/getElement "maintab_content")) <- here the function was not invoked at all |
| 17:11 | ibdknox | srid, you're getting a node collection back, which isn't a seqable thing |
| 17:11 | srid | ah |
| 17:11 | srid | doseq, loop and seq didn't work, for that reason |
| 17:11 | TimMc | because mutable? |
| 17:11 | chouser | I think you and use primative-seq or something on it |
| 17:11 | srid | ibdknox: so how do I "iterate" this node collection? |
| 17:12 | ibdknox | srid: use pinot ;) |
| 17:12 | srid | later, maybe :-) |
| 17:12 | chouser | (prim-seq node-collection 0) |
| 17:12 | ibdknox | srid, 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:13 | chouser | srid: try prim-seq ^^^ |
| 17:14 | chouser | (map #(...) (prim-seq (dom/getChildren ...))) |
| 17:14 | chouser | (map #(...) (prim-seq (dom/getChildren ...) 0)) |
| 17:14 | duck1123 | also, don't forget that map is lazy |
| 17:14 | srid | hmm, prim-seq doesn't see to work |
| 17:14 | chouser | :-( |
| 17:15 | chouser | I used it a bunch in traction. Not sure why. |
| 17:15 | ibdknox | chouser, traction? |
| 17:15 | chouser | er, I mean, not sure why it wouldn't work for you. |
| 17:16 | chouser | ibdknox: it's not documented or released: https://github.com/Chouser/talk-cljs/blob/master/src/traction.cljs |
| 17:16 | Blafasel | duck1123: 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:18 | srid | chouser: prim-seq worked with doseq, but not map! |
| 17:18 | chouser | srid: are you taking into account that map is lazy? |
| 17:18 | srid | *facepalm* |
| 17:18 | srid | ,(dec srid) |
| 17:18 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: srid in this context, compiling:(NO_SOURCE_PATH:0)> |
| 17:26 | srid | ibdknox: 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:29 | crazyFox | clojure 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:29 | brehaut | crazyFox: use or require the namespace that defines it first |
| 17:30 | dafra | hi there |
| 17:30 | dafra | i've just tried swank, it's clojure 1.2 |
| 17:30 | dafra | how to use clojure 1.3 ? |
| 17:31 | brehaut | crazyFox: 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:33 | brehaut | dafra: i know basicly nothing about swank etc, but do you know of clojure-jack-in ? |
| 17:33 | dafra | brehaut: i use clojure-jack-in, and it launches a 1.2.1 repl |
| 17:33 | crazyFox | brehaut: u mean like (ns ... (:use [myproj.myfile]) (:import myproj.myfile.map->MyRecord))? gives me the same exception |
| 17:34 | brehaut | crazyFox: where did you get the arrow from? leave that out |
| 17:34 | raek | dafra: change the clojure version in your project.clj file |
| 17:34 | raek | and run lein deps in the project dir |
| 17:35 | dafra | :dependencies [[org.clojure/clojure "1.3.0"]] |
| 17:35 | dafra | raek: but that did't help |
| 17:35 | amalloy | brehaut: i think that's correct in 1.3 |
| 17:35 | brehaut | amalloy: real? huh |
| 17:35 | dafra | raek: maybe rebooting emacs ? let's try |
| 17:36 | brehaut | completely missed that change |
| 17:36 | crazyFox | so what should my ns form look like? |
| 17:36 | amalloy | oh, it looks like my previous message got dropped though |
| 17:36 | amalloy | crazyFox: it's a plain old clojure function. just require/use it |
| 17:36 | crazyFox | ok, ill try that |
| 17:36 | amalloy | brehaut: in 1.3 (defrecord Foo []) has the side-effect of defining two additional functions, map->Foo and ->Foo |
| 17:36 | srid | why would a lamina channel be automatically closed? |
| 17:36 | brehaut | oh right |
| 17:37 | raek | dafra: are you running clojure-jack-in while visiting a file or directory in the project? |
| 17:37 | dafra | raek: yes |
| 17:37 | brehaut | (inc amalloy) |
| 17:37 | lazybot | ⟹ 16 |
| 17:37 | raek | dafra: a listing of the files in your lib/ directory would also be helpful |
| 17:37 | dafra | raek: lein's lib ? |
| 17:38 | crazyFox | amalloy: long journey comes to an end. Thank you! |
| 17:38 | raek | dafra: yes, the lib/ in the project directory |
| 17:38 | brehaut | crazyFox: sorry for leading you astray |
| 17:39 | dafra | raek: clojure 1.2.1 :) |
| 17:39 | dafra | raek: thanks, look like i know what to fix ! |
| 17:39 | raek | and you have no other depencencies? |
| 17:39 | crazyFox | brehaut: no problem. after two hours of reading searching trying this was insubstantial |
| 17:39 | dafra | raek: not for now, jsut toynig with the ide |
| 17:39 | raek | you shouldn't have 1.2.1 there if you specified 1.3.0 in the project.clj file... :/ |
| 17:40 | raek | dafra: the lib/ directory is populated from what you put in the :dependencies thingy |
| 17:41 | duck1123 | Do records always have a no-arg constructor? Or is that just in the cases I've been using them for? |
| 17:41 | raek | duck1123: they always take one argument per field |
| 17:42 | raek | (defrecord Foo [a b c]) must be constructed as (Foo. 1 2 3) |
| 17:42 | dafra | raek: I've copied clojure-1.3.0.jar into lib and the repl is 1.3 as expected |
| 17:42 | raek | dafra: but you shouldn't have to do that! |
| 17:43 | dafra | raek: how to tell lein that I want 1.3 ? |
| 17:43 | raek | dafra: are you sure you saved the project.clj file before you ran "lein deps" in the project directory? |
| 17:43 | duck1123 | raek: Ok, In that case, I need to think about one of my libraries a bit more. :( |
| 17:43 | dafra | changing the porject.clj wasnt enough |
| 17:43 | dafra | raek: lein deps ?? let's do it |
| 17:44 | brehaut | dafra: porject.clj or project.clj? |
| 17:44 | amalloy | duck1123: you're on 1.3 now though, right? |
| 17:44 | dafra | brehaut: right spelling (created by lein new) |
| 17:45 | duck1123 | amalloy: yes |
| 17:45 | brehaut | dafra: figured it probably was, but wanted to check |
| 17:45 | amalloy | duck1123: so you should be able to use (map->MyRecord {}) to get an "empty" version of a map |
| 17:45 | amalloy | er, record |
| 17:45 | dafra | brehaut: could be, thanks |
| 17:45 | raek | dafra: if you change the dependencies you need to run lein deps to "apply the changes" |
| 17:46 | dafra | raek: just did lein deps, obviously better than copying by hand :) |
| 17:46 | technomancy | raek: (unless you set :checksum-deps true in project.clj or ~/.lein/init.clj) |
| 17:46 | raek | dafra: yeah, copying by hand is no fun for depencencies, dependencies of dependencies, dependencies of dependencies of dependencies, etc ;-) |
| 17:48 | dafra | raek: see you guys |
| 17:49 | raek | dafra: happy hacking :-) |
| 17:56 | srid | in clojurescript, (doseq [index [0 1 2 3 4]] ...) -> " doseq requires a vector for its binding" error |
| 17:56 | srid | i don't understand the error, as the deseq syntax looks alright |
| 17:58 | srid | the doseq comes within a doto macro, if that matters |
| 17:58 | ibdknox | that matters |
| 17:59 | srid | ah yes |
| 18:13 | ibdknox | oh no's! Lazybot is gone |
| 18:14 | gtrak | ,#(print "OH NO") |
| 18:14 | clojurebot | #<sandbox$eval27$fn__28 sandbox$eval27$fn__28@1dec77f> |
| 18:14 | gtrak | ,(#(print "OH NO")) |
| 18:14 | clojurebot | OH NO |
| 18:14 | ibdknox | ,(print "oh no :p") |
| 18:14 | clojurebot | oh no :p |
| 18:14 | ibdknox | # is unnecessary :) |
| 18:14 | gtrak | duh |
| 18:15 | gtrak | we all have moments where we think something is a level less abstract than it is |
| 18:15 | Blafasel | The whole machine is down, it seems |
| 18:16 | Blafasel | 4clojure.com try-clojure.org and the guys that have a bouncer on that machine pinged out. |
| 18:21 | ibdknox | haha |
| 18:22 | ibdknox | amalloy jinxed it talking about how he hasn't really had any issues with hosting |
| 18:28 | wdouglas | Hey 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:28 | wdouglas | FYI code is just: |
| 18:28 | wdouglas | (let |
| 18:28 | wdouglas | [a (atom 0) |
| 18:28 | wdouglas | b 30] |
| 18:28 | wdouglas | (while (> (bit-shift-right b @a) 0) |
| 18:28 | wdouglas | (swap! a inc)) |
| 18:28 | wdouglas | @a) |
| 18:28 | Blafasel | What's wrong with Math/*? |
| 18:29 | wdouglas | log base e/10 |
| 18:29 | wdouglas | Unless I missed something |
| 18:29 | wdouglas | Or just do the log conversion do you mean? |
| 18:30 | Blafasel | Didn't know about the missing log, I meant both |
| 18:31 | ibdknox | why didn't you want to use loop/recur? |
| 18:32 | ibdknox | it'll be much more efficient than what you have right now |
| 18:32 | hiredman | using an atom for that there is dumb |
| 18:32 | ibdknox | though I'm with Blafasel, you can do that with normal math functions, can't use? |
| 18:32 | ibdknox | you* |
| 18:32 | wdouglas | Hrm guess I could time it, was thinking the division is going to make the log base conversion a bit slower. |
| 18:33 | Blafasel | wdouglas: Depending on precision: http://everything2.com/title/log2%2528x%2529+%253D+log10%2528x%2529+%252B+ln%2528x%2529 |
| 18:33 | wdouglas | I just thought the loop/recur was ugly for that |
| 18:33 | hiredman | you are wrong |
| 18:33 | ibdknox | wdouglas, loop/recur was designed to solve problems like that |
| 18:33 | ibdknox | lol |
| 18:34 | wdouglas | Blafasel: Oh nice on that top one. |
| 18:34 | dabd | how can I construct a ratio from a string? For example from "13/17" |
| 18:34 | wdouglas | Well that's the way of it then. loop/recur it is. Thanks all =) |
| 18:36 | dabd | the Ratio type does not seem to have a constructor or parser... |
| 18:36 | hiredman | ,(/ 13 17) |
| 18:36 | clojurebot | 13/17 |
| 18:37 | ibdknox | dabd: split the string, map Integer. over it and then do what hiredman did |
| 18:37 | dabd | ok thx! |
| 18:38 | dabd | But why there is a type without a constructor? |
| 18:38 | brehaut | dabd: there is a constructor, its / |
| 18:38 | dabd | well / works as a constructor obviously |
| 18:38 | dabd | yes |
| 18:40 | ibdknox | I don't think I expected this: |
| 18:40 | ibdknox | ,(/ 2) |
| 18:40 | clojurebot | 1/2 |
| 18:40 | brehaut | ibdknox: makes sense as a dual to ##(* 2) |
| 18:41 | Blafasel | ,(doc /) |
| 18:41 | clojurebot | "([x] [x y] [x y & more]); If no denominators are supplied, returns 1/numerator, else returns numerator divided by all of the denominators." |
| 18:41 | ibdknox | and doesn't when compared to + |
| 18:41 | ibdknox | ,(+ 2) |
| 18:41 | clojurebot | 2 |
| 18:41 | Blafasel | See the docs :) |
| 18:41 | ibdknox | I know |
| 18:41 | ibdknox | I was reading the source :p |
| 18:41 | ibdknox | I meant more from a conceptual standpoint |
| 18:41 | S11001001 | wdouglas: if you find loop distasteful, you may consider iterate |
| 18:41 | ibdknox | I didn't expect it to work that way |
| 18:42 | S11001001 | (weirdly enough, that exact phrase could also be used when talking about common lisp, though loop and iterate mean completely different things there :) |
| 18:42 | brehaut | ibdknox: i disagree; in all 3 cases, the unary implementation respects the identity value for the operation |
| 18:43 | ibdknox | brehaut, I just expected (/ 2) = 2 |
| 18:43 | brehaut | ibdknox: consider in the context of the varargs imp: (/ 1 2) is 'really' (/ 1 1 2) |
| 18:44 | brehaut | (ibdknox i do get that its not necessarily obvious, but it seems correct to me) |
| 18:45 | ibdknox | brehaut, I don't follow your varargs argument |
| 18:45 | brehaut | ibdknox: / folds the varargs down; implicitly starting with the identity value for the operation |
| 18:46 | ibdknox | no |
| 18:46 | ibdknox | not based on the source |
| 18:46 | brehaut | ibdknox: thats because its hand optimized to be fast |
| 18:46 | brehaut | the naive implementation would be (defn vararg-divide [& args) (reduce binary-divide 1 args)) |
| 18:46 | dabd | I'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:47 | ibdknox | brehaut, mm |
| 18:47 | ibdknox | dabd, why are you concerned? |
| 18:47 | dabd | should I use map instead and then into {} on the result? |
| 18:47 | dabd | ibdknox: well maps have no order |
| 18:47 | wdouglas | S11001001: I didn't think about iterate at all. I'll see how that looks, thanks |
| 18:48 | brehaut | ibdknox: the one that really tripped me up is (< 1) |
| 18:48 | ibdknox | dabd, maps don't guarantee order no matter which way you do it |
| 18:48 | gtrak | a treemap does |
| 18:48 | gtrak | in javaland |
| 18:48 | ibdknox | gtrak: the clojure {} map doesn't |
| 18:49 | ibdknox | brehaut, yeah... I still trip up on those sometimes |
| 18:49 | brehaut | ibdknox: i had to reprogram my brain; they aren't 'less than' etc |
| 18:49 | hiredman | keys and vals will always return things in the order you want |
| 18:49 | gtrak | there is a sorted-map |
| 18:50 | hiredman | rich has guaranteed it |
| 18:50 | brehaut | ibdknox: but rather increasing sequence |
| 18:50 | ibdknox | brehaut, yeah, I liked technomancy's idea of renaming them to always decreasing |
| 18:50 | gtrak | ,(source 'sorted-map) |
| 18:50 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol> |
| 18:50 | brehaut | ibdknox: link? |
| 18:50 | dabd | ok then (zipmap (keys m) (map my-fn vals)) should do the job |
| 18:50 | brehaut | or was it irc? |
| 18:50 | gtrak | ,(source sorted-map) |
| 18:50 | clojurebot | Source not found |
| 18:50 | ibdknox | brehaut, irc |
| 18:50 | gtrak | ,(doc sorted-map) |
| 18:50 | clojurebot | "([& keyvals]); keyval => key val Returns a new sorted map with supplied mappings." |
| 18:50 | dabd | oops I meant ok then (zipmap (keys m) (map my-fn (vals m))) should do the job |
| 18:51 | gtrak | (into (sorted-map) existingMap) |
| 18:51 | brehaut | ibdknox: incidentally the doc string for < never mentions 'less than' only 'monotonically increasing order' |
| 18:51 | dabd | do I really need to use the sorted-map isn't zipmap on a hash-map enough? |
| 18:52 | ibdknox | you shouldn't use zipmap |
| 18:52 | hiredman | dabd: as I said, vals and keys will return things in an order that lines up keys with values |
| 18:52 | hiredman | you are good to go with zipmap |
| 18:52 | dabd | hiredman: thx |
| 19:05 | dabd | I am getting Java out of memory. I am using lein swank. Does anyone know how to increase heap space? |
| 19:10 | technomancy | dabd: export JVM_OPTS=-Xmx1024m |
| 19:10 | technomancy | or :jvm-opts ["-Xmx1024m"] in project.clj if you want it to apply to everyone working on the project |
| 19:12 | dabd | technomancy: thx |
| 19:32 | gtrak`` | dabd, use a profiler if you're not expecting that much data |
| 19:34 | dabd | gtrak: 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:35 | hiredman | sounds like a bad format decision |
| 19:36 | hiredman | using a single json or clojure map for large data dump is icky |
| 19:37 | hiredman | you end up needing something like a what do you call it, pullparser? |
| 19:37 | hiredman | better to use small maps |
| 19:54 | wink | is there a better way to test for nil than (is (string/blank? (whatever)))? |
| 19:55 | ibdknox | wink: hm? |
| 19:55 | lynaghk | Ah, Chris, I was just looking to see if you were in here. |
| 19:55 | lynaghk | I've got a ClojureScript question for you |
| 19:55 | ibdknox | lynaghk, shoot |
| 19:56 | lynaghk | I'm getting jsc_duplicate_input errors |
| 19:56 | wink | well, testing that whatever returns nil for my given input |
| 19:56 | lynaghk | and saw that you ran into that stuff on your cljs-watch project. |
| 19:56 | ibdknox | ,(doc nil?) |
| 19:56 | clojurebot | "([x]); Returns true if x is nil, false otherwise." |
| 19:56 | ibdknox | lynaghk, ah, yes. It happens when a cljs file is both on the classpath and in the compilation path |
| 19:57 | lynaghk | What's the compilation path? |
| 19:57 | ibdknox | how are you running the cljs compiler? |
| 19:57 | lynaghk | I'm using cake |
| 19:57 | lynaghk | and just invoking a brief script |
| 19:57 | ibdknox | what's the script do? |
| 19:57 | lynaghk | (closure/build ...) |
| 19:58 | wink | ibdknox: hm, silly me. so it's a little about learning what's in core. |
| 19:58 | ibdknox | the compilation path is the first arg to build |
| 19:58 | ibdknox | probably "src/" |
| 19:59 | lynaghk | Ah, 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:00 | lynaghk | I'm not sure if that makes sense, I must be missing something. |
| 20:00 | ibdknox | lynaghk, basically yes |
| 20:00 | lynaghk | uh oh |
| 20:00 | lynaghk | = ) |
| 20:00 | ibdknox | so the way I fixed this for cljs-watch is by not including src/ in that jvm's classpath |
| 20:00 | ibdknox | but still including lib |
| 20:01 | ibdknox | lynaghk: speaking of, out of curiosity, why aren't you using cljs-watch? |
| 20:01 | lynaghk | I shoved clojurescript support into my existing Rakefile-based toolchain |
| 20:01 | lynaghk | which handles HAML and SASS compilation |
| 20:02 | lynaghk | I've got a lot of stuff setup in those already, so I haven't switched to the Clojure analogs |
| 20:04 | ibdknox | gotcha |
| 20:04 | lynaghk | Just as I was getting settled down with my auto-compiled minified CoffeeScript, ClojureScript gets released |
| 20:04 | lynaghk | = ) |
| 20:04 | ibdknox | I'm not sure you're going to be able to do this from Cake |
| 20:05 | ibdknox | since cake's JVM will definitely have src on the classpath |
| 20:05 | lynaghk | You can config it out. I have src/clj, src/cljs |
| 20:05 | ibdknox | ah :) |
| 20:08 | lynaghk | yeah, all of this is a bit tricky |
| 20:08 | lynaghk | I've been meaning to sit down and try and figure it out |
| 20:08 | lynaghk | I just found out about the :foreign-libs option from Luke VanderHart's blog yesterday |
| 20:09 | ibdknox | it didn't exist until about a week ago |
| 20:09 | ibdknox | and wasn't merged in until this weekend I think |
| 20:09 | ibdknox | though really we shouldn't be packaging libs that are universal... |
| 20:09 | lynaghk | what do you mean? |
| 20:09 | ibdknox | they should be coming from a CDN |
| 20:09 | lynaghk | things like jQuery? |
| 20:10 | ibdknox | yeah, otherwise we're defeating the point of caching |
| 20:10 | lynaghk | true, though you might save a lot of bytes from the dead-code elimination |
| 20:11 | lynaghk | plus, 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:15 | lynaghk | ugh, D3 stops working with :optimizations :simple |
| 20:15 | hiredman | clojurebot: ping? |
| 20:15 | clojurebot | PONG! |
| 20:16 | lynaghk | I need to sit down and hash out my clj replacement. |
| 20:16 | ibdknox | lynaghk, I'm still on board to help with that :) |
| 20:17 | lynaghk | thanks |
| 20:17 | lynaghk | yeah, I've been letting it stew in my mind for a bit |
| 20:17 | lynaghk | spent the weekend reading up on SVG |
| 20:17 | ibdknox | I've had *plenty* to do, so that's fine with me :) |
| 20:18 | lynaghk | heh |
| 20:18 | lynaghk | are you going to the Conj? |
| 20:18 | gtrak`` | lynaghk, what's a clj replacement? |
| 20:18 | ibdknox | I am indeed |
| 20:18 | lynaghk | gtrak`` I am thinking about implementing a visualization libary in Clojure(Script) |
| 20:19 | ibdknox | gtrak``, he meant cljs replacement for D3 |
| 20:19 | lynaghk | heavily-inspired by D3/Protovis |
| 20:19 | gtrak`` | ah nice |
| 20:19 | lynaghk | ibdknox, well we'll definitely have to grab a beer in November then |
| 20:20 | ibdknox | lynaghk, sounds good :) |
| 20:20 | gtrak`` | how about processing.js? |
| 20:20 | lynaghk | I haven't used it very much |
| 20:20 | ibdknox | processing isn't data driven |
| 20:20 | lynaghk | or processing |
| 20:21 | ibdknox | as an example, see th visualization section of the pinot readme: https://github.com/ibdknox/pinot |
| 20:21 | lynaghk | ibdknox, what is keeping you so busy? |
| 20:22 | ibdknox | well, 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:22 | lynaghk | WELL WELL |
| 20:22 | lynaghk | yeah, I saw that on HN |
| 20:22 | lynaghk | props |
| 20:23 | gtrak`` | do you run a consulting company or something? |
| 20:23 | ibdknox | gtrak``, are you asking me? |
| 20:23 | gtrak`` | yea |
| 20:23 | ibdknox | nope :) |
| 20:23 | gtrak`` | i saw you had a 'prototype your site in 2 weeks thing going' :-) |
| 20:23 | lynaghk | is anything about Korma online? |
| 20:24 | ibdknox | lynaghk, not yet, I'll put something up in the next couple of days |
| 20:24 | lynaghk | I've been toying with ClojureQL a bit; I like the idea of actually using relational algebra with my databases. |
| 20:24 | ibdknox | gtrak``, I'm currently under the employ of ReadyForZero :) |
| 20:24 | gtrak`` | ah |
| 20:24 | ibdknox | lynaghk, ClojureQL has some weirdness to it |
| 20:25 | lynaghk | yeah? |
| 20:28 | ibdknox | though my main motivation is actually I want it to handle relations for me |
| 20:28 | ibdknox | and I think there's a much prettier language waiting to come out of it |
| 20:29 | lynaghk | I hope you mean that literally |
| 20:29 | lynaghk | and borrow heavily from the APL characterset |
| 20:29 | ibdknox | lol |
| 20:29 | ibdknox | :p |
| 20:31 | lynaghk | Well that sounds interesting, I'll definitely look out for it |
| 20:31 | lynaghk | I'm not yet super into ClojureQL |
| 20:31 | ibdknox | the first implementation will just look like prettier sql though :) |
| 20:31 | lynaghk | uh oh, paved with good intentions right there |
| 20:31 | lynaghk | be careful |
| 20:31 | brehaut | i think clojureql is a good proof of concept |
| 20:31 | ibdknox | some of the SQL it generates hurts me |
| 20:31 | chouser | ibdknox: as long as parts of a query are values that can be composed at runtime, I'll be interested. :-) |
| 20:32 | ibdknox | chouser, they *definitely* are. tenant number 1 right there :) |
| 20:33 | lynaghk | Do you have any interest in implementing a 'lil DB in Clojure as well, instead of just compiling to SQL? |
| 20:33 | lynaghk | because then I can finally get my functional-relational-programming on. |
| 20:33 | lynaghk | (and compile it to JS) |
| 20:33 | gtrak`` | lynaghk, isn't the point of a DB to be mutable? |
| 20:34 | lynaghk | sure, in very constrained ways. |
| 20:36 | ibdknox | err, I meant tenet above. Don't mind the stupidity :) |
| 20:37 | ibdknox | I'm not sure I'd want to implement a db |
| 20:37 | ibdknox | sounds like work :p |
| 20:37 | brehaut | ibdknox: but you could get on the leading edge of the coSQL wave |
| 20:38 | jli | co? |
| 20:38 | clojurebot | compilation is see compile |
| 20:38 | hiredman | broSQL |
| 20:38 | lynaghk | ibdknox, maybe, but you could wave yoru hands and say it's all in-memory and just implement everything with table scans |
| 20:38 | ibdknox | lol |
| 20:38 | lynaghk | maybe I'll take a crack at it sometime |
| 20:38 | ibdknox | I think fewer problems need databases |
| 20:38 | brehaut | yeah, erik meijer |
| 20:39 | lynaghk | in all seriousness though, I really would like to find some implementations of FRP |
| 20:39 | ibdknox | datastores are often more correct I think |
| 20:39 | brehaut | 's strange loop keynote is about how SQL and noSQL are duals |
| 20:39 | brehaut | please hold; finding the link |
| 20:39 | brehaut | http://queue.acm.org/detail.cfm?id=1961297 |
| 20:40 | lynaghk | brehaut, does that mean we can easily get a lot of funding if we make a "primal sql". |
| 20:40 | brehaut | hiredman: broSQL; the first choice in storage for low grade beer and grain spirits |
| 20:41 | brehaut | lynaghk: thats gone over my head |
| 20:41 | lynaghk | eh, math joke. |
| 20:42 | brehaut | I'm too stupid to understand math jokes |
| 20:42 | lynaghk | sayith 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:42 | lynaghk | Oh, me too. I just try to get a few from each discipline so I can defend myself at cocktail parties. |
| 20:43 | lynaghk | That paper looks interesting though, thanks for the link brehaut |
| 20:43 | brehaut | lynaghk: see also https://github.com/strangeloop/2011-slides/blob/master/TOC.md |
| 20:45 | lynaghk | Hmm, these conference organizers are on it |
| 20:56 | vkurup | xb |
| 20:57 | vkurup | oops. That was supposed to be C-xb :) |
| 21:06 | shep-home | I evidently have 7 infinite recursion threads going from clojure-mode C-x C-e... any tips on how to stop them? |
| 21:06 | seancorfield | has anyone used Enlive with Clojure 1.3.0 successfully? |
| 21:07 | seancorfield | i just tried the basic getting started example and got: NullPointerException net.cgrand.enlive-html/load-html-resource/fn--326 (enlive_html.clj:53) |
| 21:08 | seancorfield | which is: (with-open [^java.io.Closeable stream stream] |
| 21:09 | shep-home | Ah, I got it - M-x slime-thread-kill |
| 21:15 | seancorfield | bah... that means i can't use deftemplate since that relies on the same broken loading process |
| 21:24 | jli | yay, kernel.org is back |
| 21:35 | budu | hi |
| 21:36 | budu | is it normal that swank-clojure and 'lein repl' are still using clojure 1.3? |
| 21:36 | budu | or did i installed them unproperly? |
| 21:37 | brehaut | budu: I'm not a swank user, but aren't they dependent on the project.clj clojure dependancy? |
| 21:37 | jli | "still"? |
| 21:37 | budu | yes, but i'm talking about using them outside of a project |
| 21:37 | budu | sorry for the lack of preciness |
| 21:39 | budu | nobody is doing that it seems! ;-) |
| 21:39 | gtrak`` | you can install it globally, and remove it from project.clj's. it's recommended now |
| 21:39 | brehaut | i didn't even realize lein repl worked outside a project |
| 21:49 | duck1123 | budu: which version are you using, I think the new one specifies 1.3 |
| 21:50 | duck1123 | although it might be multi dep |
| 21:51 | duck1123 | hmm... it is multi dep, but 1.2 seems to be the default |
| 22:11 | mcoffbyone | hi, 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:12 | mcoffbyone | it is called (metfun 'toUpperCase) -> "STRING" |
| 22:24 | duck1123 | (defn metfun [f] (f "string")) |
| 22:24 | duck1123 | it's that easy |
| 22:25 | duck1123 | although, I'm not sure how well that works with interop |
| 22:26 | duck1123 | (defmacro metfun [f] `(~f "string")) |
| 22:41 | ibdknox | what is the correct way to specify compatibility with clojure version >= 1.2.1 for a lib? |
| 22:42 | brehaut | ibdknox: I'm using [1.2.1],[1.3.0] in necessary evil, but i think something like [1.2.1) is available too |
| 22:42 | ibdknox | ah, that works. Thanks :) |
| 22:43 | mcoffbyone | thank you duck1123, do you know why/if macros should be prefered over eval for such simple cases? |
| 22:45 | glob157 | anyone use hadoop in here with clj ? |
| 22:46 | brehaut | mcoffbyone: the trite answer is that macros are idiomatic and eval is not |
| 22:47 | brehaut | mcoffbyone: 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:49 | ibdknox | glob157: 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:50 | mcoffbyone | brehaut: does this mean that the output of a macro is in no way different from code forms? |
| 22:50 | brehaut | mcoffbyone: exactly |
| 22:51 | mcoffbyone | and is (name some-symbol) like eval? |
| 22:51 | brehaut | no |
| 22:51 | brehaut | name is just a function |
| 22:51 | brehaut | that works on strings and clojure.lang.Named instances, of which symbols and keywords are instances |
| 22:52 | mcoffbyone | I got it it happens after the compilation so it is not some run-time introsepction |
| 22:52 | ibdknox | as a general rule of thumb eval is evil outside of developer tooling, and even then there are often other solutions |
| 22:52 | brehaut | mcoffbyone: huh? |
| 22:53 | mcoffbyone | I thougt (name) is inspecting the name of a symbol at runtime |
| 22:54 | mcoffbyone | but the name is already an instance so it can have just a property with its name |
| 22:54 | mcoffbyone | argh the symbol not the nam is an instance |
| 22:54 | brehaut | mcoffbyone: yes; its just a function |
| 22:54 | brehaut | ,(name (symbol "foo")) |
| 22:54 | clojurebot | "foo" |
| 22:55 | ibdknox | if it were a macro this would work: |
| 22:55 | ibdknox | ,(name foo) |
| 22:55 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: foo in this context, compiling:(NO_SOURCE_PATH:0)> |
| 22:57 | brehaut | mcoffbyone: 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:57 | brehaut | and thats a piece of code that you might expect to find a lot of evals |
| 22:58 | mcoffbyone | :) |
| 23:00 | brehaut | ibdknox: http://docs.codehaus.org/display/MAVEN/Dependency+Mediation+and+Conflict+Resolution#DependencyMediationandConflictResolution-DependencyVersionRanges |
| 23:00 | ibdknox | brehaut: ah, thanks |
| 23:01 | brehaut | ibdknox: rather than cargo culting the crap i scrabbled together |
| 23:01 | brehaut | sorry it took so long to find; i had a google fail |
| 23:01 | ibdknox | technically I think the [1.2.1],[1.3.0] is the correct one |
| 23:01 | ibdknox | since I can't guarantee there won't be breaking changes in the future of clojure |
| 23:01 | ibdknox | lol |
| 23:02 | brehaut | thats what i guessed too :) |
| 23:02 | amalloy | brehaut: core.clj contains two actual uses of eval, fwiw |
| 23:02 | ibdknox | amalloy: 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:03 | brehaut | ibdknox: whenever you want the old hands on #clojure to yell at you :P |
| 23:03 | ibdknox | lol |
| 23:03 | amalloy | maybe if you've decided life is no longer worth living |
| 23:04 | brehaut | amalloy: if thats the case, why just eval when theres PHP |
| 23:04 | ibdknox | lol |
| 23:04 | amalloy | ibdknox: eval: death by stoning |
| 23:05 | amalloy | php: self-mutilation |
| 23:05 | amalloy | er, brehaut: ^ |
| 23:05 | brehaut | i'll defer to your experience in this matter |
| 23:05 | brehaut | its been years since i cut myself |
| 23:05 | ibdknox | haha |
| 23:06 | ibdknox | listen. PHP used to be all there was... unless you wanted to use perl. |
| 23:06 | brehaut | ibdknox: there was asp with vbscript |
| 23:07 | ibdknox | hah |
| 23:07 | brehaut | (a language that appeared in the mid 90s on a 32 bit platform and by default has 16 bit signed ints) |
| 23:08 | ibdknox | makes sense to me :p |
| 23:08 | brehaut | if 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:08 | amalloy | brehaut: how else would you implement a number with 16 sign bits? perfect for describing n-dimensional hypercubes |
| 23:09 | brehaut | haha |
| 23:10 | brehaut | amalloy: http://xkcd.com/37/ |
| 23:14 | khaliG | is it educational to read through clojure source code, amalloy? |
| 23:14 | ibdknox | khaliG: very |
| 23:14 | brehaut | despite not being amalloy, its education for me |
| 23:14 | amalloy | whoa, since when am i the authority on that? |
| 23:15 | brehaut | khaliG: do you know about the source function? |
| 23:15 | duck1123 | you're probably going to find a couple of weird things, but generally it's a good place to look |
| 23:15 | khaliG | since it seems you've read it :) |
| 23:16 | amalloy | khaliG: well, i'm armed with an OS that has grep built in :P |
| 23:16 | amalloy | i 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:17 | brehaut | khaliG: 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:18 | lynaghk | Ibdknox, do you know offhand what the Closure compiler does in simple mode? |
| 23:19 | lynaghk | in particular, does it just concatenate and run everything in the compilation path? |
| 23:19 | ibdknox | munges local names, concats |
| 23:19 | lynaghk | Is there a designated entry point / namespace that gets run? |
| 23:19 | ibdknox | no |
| 23:19 | ibdknox | code at the top level will be run |
| 23:19 | lynaghk | of all namespaces |
| 23:19 | ibdknox | yup |
| 23:20 | lynaghk | ah |
| 23:20 | lynaghk | that's what I was afraid of |
| 23:20 | lynaghk | =) |
| 23:20 | gtrak`` | why? |
| 23:20 | clojurebot | why not? |
| 23:20 | duck1123 | then you can create a -main somewhere and point lein to it for lein run |
| 23:20 | ibdknox | advanced mode will do the same |
| 23:20 | lynaghk | okay, that's good to know |
| 23:21 | lynaghk | I've been just hacking around the build system for the past few weeks |
| 23:21 | lynaghk | I need to get things all ship-shape |
| 23:21 | lynaghk | I might put together a this-is-how-to-do-it repo |
| 23:21 | lynaghk | it = ClojureScript + Clojure macros + external JS libs |
| 23:21 | duck1123 | well, lein new <projectname> should get you most of the way there |
| 23:22 | duck1123 | nvm |
| 23:22 | lynaghk | oh, this is for ClojureScript |
| 23:22 | gtrak`` | too bad no lein for cljs |
| 23:24 | ibdknox | well |
| 23:24 | ibdknox | when lein 2.0 comes out |
| 23:24 | ibdknox | I'll do some fun things for CLJS in it |
| 23:24 | lynaghk | is 2.0 going to have persistent JVM support? |
| 23:24 | lynaghk | because that is the main reason I am using Cake |
| 23:25 | lynaghk | Lein seems to have a lot more community backing though |
| 23:27 | ibdknox | not that I know of |
| 23:27 | ibdknox | the main thing is that it will use 1.3 |
| 23:27 | lynaghk | ah |
| 23:28 | ibdknox | which is necessary for me to do cljs as a plugin |
| 23:28 | lynaghk | you are going to integrate your watcher? |
| 23:28 | ibdknox | that would make sense |
| 23:28 | ibdknox | I think |
| 23:29 | lynaghk | yeah, I think people would find it pretty helpful. |
| 23:30 | glob157 | any clojure dojos on the east coast any time soon ? |
| 23:30 | lynaghk | that's the main reason cake is nice though, because cljs changes are instantanous |
| 23:30 | glob157 | i need to get my skills up |
| 23:30 | lynaghk | that + the livereload browser plugin, though my understanding is that ClojureScript has some kind of Browser REPL now |
| 23:30 | lynaghk | which does all this stuff automagically for you |