#clojure log - Jun 03 2011

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

0:02 jean-philippe: you can check for common elements between 2 sets with their intersection (using clojure.set.intersection). If the intersection is not empty, the 2 sets have elements in common

0:06 bdesham: jean-philippe: the problem is that I've got a vector and I want to see if any elements are duplicated in the vector, including in sets within the vector

0:09 jean-philippe: bdesham: the quick trick would be to see if the sum of the counts of the individual sets is equal to the count of the union of all the sets

0:09 bdesham: ,(count #{})

0:09 clojurebot: 0

0:10 bdesham: ,(count #{#{}})

0:10 clojurebot: 1

0:10 bdesham: jean-philippe: I might be able to make that work

0:11 jean-philippe: bdesham: this should flatten deeply nested sets as long as there are no duplicate elements: https://gist.github.com/1005858

0:13 bdesham: it's quite rough, and you need to (use 'clojure.set) to get union and intersection, but it should give you a starting point

0:15 bdesham: jean-philippe: thanks!

0:18 rcfox: Hey guys, I have a rather newbie question. I'm trying to extend a Java class, and the .class is in the 'classes' directory, which is in my classpath. However, when I try to compile my new class, I get java.lang.ClassNotFoundException.

0:20 Is there anything I might be missing? Both classes are in the default namespace, if that makes a difference.

0:23 Doh, I just realized that the classes should go under classes/java/lang.

4:39 newbnumber1: hi there, I'm new to clojure, and I've been looking around for a guide to getting started with clojure web programming. It's a bit confusing. Most links seem to point to compojure, but it seems to be a fast-moving target. Is there a de-facto "this is the starting point for newbs" concerning clojure web development?

4:44 Vinzent: newbnumber1, checkout wiki on the github page of compojure

4:45 thorwil: newbnumber1: there's no de-facto starting point. common choices are compojure or moustache, enlive and/or hiccup

4:47 gko: Regarding SLIME with CL and Clojure: is it still either or? (CVS for CL, ELPA for Clojure

4:47 )

4:49 apsvx: newbnumber1: i think this: http://brehaut.net/blog/2011/ring_introduction is very good introduction

4:54 ordnungswidrig: How can I determine which protocols an instance extends? "extenders" goes the other way round.

4:55 fcek: newbnumber1: i started with http://mmcgrana.github.com/2010/07/develop-deploy-clojure-web-applications.html

4:55 but apsvx link looks good

5:08 raek: newbnumber1: I would recommend the official readme for Ring - the underlying library of most clojure web apps - and its spec: https://github.com/mmcgrana/ring and https://github.com/mmcgrana/ring/blob/master/SPEC

5:15 on top of Ring, you use a routing library (Compojure or Moustache) to choose among handlers based on URL and HTTP method and HTML generating libraries (Hiccup or Enlive) to generate the bodies of the responses

5:16 be aware that Compojure has changed quite a lot, so if you look at an example, make sure you check which version it is for

5:18 newbnumber1: reading through these links now, thanks guys :) yes, some tutorials I've seen confused me greatly, but it was compojure that had changed

5:19 raek: newbnumber1: the compojure wiki is probably the most up to date tutorial: https://github.com/weavejester/compojure/wiki

7:07 bendlas: hey

7:08 does anybody use eshell with zsh here?

7:23 LeNsTR: bendlas: use 'M-x ansi-term' instead esheel

7:23 works with zsh pretty well

7:54 bendlas: LeNsTR: thanks

7:54 LeNsTR: ^^

7:55 bendlas: I know, but I like the feel of eshell a bit better

7:56 zsh works pretty fine with it too, except it doesn't read my .zshrc

8:18 mec: Is it possible to memoize a local recursive function?

8:18 fliebel: mec: local?

8:18 mec: inside a let

8:19 fliebel: mec: I see no reason you can't do (let [f (memoize (fn [])))?

8:21 ilyak: https://github.com/alamar/clojure-xml-stream Here is my "stateless" stream XML parser

8:21 to declaratively parse huge XML files (larger than memory) into a lazy sequence of entities

8:22 mec: fliebel: something like (let [f (memoize (fn f [] (f ...)))), it wont memoize the inner calls

8:27 opqdonut: (fn f [] ...) ?

8:27 (let [f (memoize (fn [arg] (foo (f ...))))) will actually work

8:27 using recur inside the fn won't

8:27 (s/work/memoize/g)

8:29 mec: ,(let [fib (memoize (fn [n] (if (<= n 1) n (+ (fib (dec n)) (fib (- n 2))))))] (fib 10))

8:29 clojurebot: java.lang.Exception: Unable to resolve symbol: fib in this context

8:29 mec: opqdonut: doesnt allow that

8:30 and this way isnt actually memoized: #(let [fib (memoize (fn fib [n] (if (<= n 1) n (+ (fib (dec n)) (fib (- n 2))))))] (fib 20))

8:32 fliebel: mec: I see no reason you can do##(let [fib (memoize (fn [n] (if (<= n 1) n (+ (#'fib (dec n)) (#'fib (- n 2))))))] (fib 10))

8:32 sexpbot: java.lang.Exception: Unable to resolve var: fib in this context

8:33 fliebel: ... need a break

8:33 opqdonut: mec: hmm, letfn should work, right?

8:34 (my bad)

8:34 fliebel: opqdonut: But then you can;t memoize

8:34 opqdonut: ah, right

8:34 gah

8:34 Dranik: hi all

8:34 mec: I'm not sure this is possible

8:34 maybe i'll have to memoize by hand

8:34 fliebel: mec: wait, I have an idea!

8:36 Dranik: I have a macro defaction (https://gist.github.com/1006270). It expands to a runnable code -- but only if I run that expanded code manually. When I try it running using this macro -- it fails

8:36 can anyone have a look at it?

8:37 (macroexpand-1 '(defaction myaction [id post] (println "abc"))) expands to

8:37 (clojure.core/defn myaction [{session :session, {post :post, id :id} :params}] (println "abc"))

8:37 which is runnable if u jast paste it and run

8:37 fliebel: &(let [fib (fn [f n] (if (<= n 1) n (+ (f f (dec n)) (f f (- n 2)))))] (fib (memoize fib) 10))

8:37 sexpbot: ⟹ 55

8:37 Dranik: but calling (clojure.core/defn myaction [{session :session, {post :post, id :id} :params}] (println "abc")) doesn't work

8:38 fliebel: Dranik: Error message?

8:39 mec: fliebel: ah nice

8:39 fliebel: mec: No, but-ugly, but it works :)

8:39 mec: smells like Y combinator

8:39 Dranik: fliebel: Unable to resolve symbol: :post in this context

8:40 which is really weird bcs :post is just a keyword

8:40 chouser: heh

8:40 fliebel: mec: Y combinator? I suck at understanding, or wikipedia sucks at explaining.

8:40 chouser: Dranik: ues (keyword p) instead of (symbol ":" p)

8:41 we need to do something about that

8:41 a keyword is not the same as a symbol that starts with :

8:41 fliebel: chouser: About what? Ruby guys who confuse keyword and symbol?

8:41 Dranik: chouser: thanks, that was helpful

8:43 chouser: fliebel: no, about keywords and symbols that when printed and then read end up different than when they started

8:43 perhaps (symbol ":foo") should print as |:foo|, for example.

8:44 fliebel: chouser: Maybe invalid and unreadable symbols should throw an error?

8:44 chouser: right, another fine option.

8:44 fliebel: &(symbol "(")

8:44 sexpbot: ⟹ (

8:45 * chouser goes back to slumming it in JS-land

8:45 chouser: JavaScript doesn't have problems distinguishing between keywords and symbols.

8:46 fliebel: chouser: Does it even distinguish between anything?

8:46 chouser: nope! :-D

8:50 1 + "2" == "12" // just what I wanted!

8:53 cemerick: my favorite is:

8:53 Chousuke: It's most fun is when you do something silly like window["foo"] = 5; foo + 5 :P

8:53 cemerick: var a = {}; a[{c:5}] = 10; a[{d:6}] == 10 // whee!

8:54 fliebel: cemerick: How does that work?

8:55 cemerick: fliebel: javascript objects look up values based on the .toString() value of the key provided. Objects' .toString defaults to "[object Object]", so they all hash to the same entry.

8:56 IIRC

8:56 bhenry: i need the best way to pad a single digit number with a 0. begins as int ends as string.

8:56 i.e. 9 => 09 but 10 => 10

8:57 cemerick: ,(format "%02d" 9) ;<< bhenry

8:57 clojurebot: "09"

8:58 fliebel: &(format "%02d" 100)

8:58 sexpbot: ⟹ "100"

8:58 bhenry: cemerick: thank you

8:58 perfect

9:09 mec: fliebel: think theres any good way to abstract out this method of memoization?

9:11 Vinzent: I have a problem with vision (https://github.com/nakkaya/vision). When calling query-frame (e.g. (query-frame (capture-from-cap 0))), java process "exited abnormally with code 134". Any ideas how to overcome it?

9:27 ordnungswidrig: I try to extend a procotol at runtime. However reify is a macro, any ideas besides "eval"?

9:28 clgv: mec: just skip using that anonymous function and use defn since fib has enough logic to be standalone

9:28 Vinzent: ordnungswidrig, you can use extend to extend the protocol

9:29 ordnungswidrig: Vinzent: correct. I want to reify an existing instance not a type.

9:35 stuartsierra: You can't add or change methods of an instance on the JVM.

9:37 ordnungswidrig: stuartsierra: I'm fine with a new instance that implement another protocol "on top", say like (reify instance-of-A B (method-in-b [arg] )) which will return an instance that implements A and B

9:38 stuartsierra: Like a wrapper.

9:40 ordnungswidrig: exactly, in the end I want to build a delegate which takes list of delegates implementing an number of protocols. the wrapper shall then implement all of the procotols and delegate the method invokations to all delegates which implement the invoked method. the results shall be collected into a seq. i.e. the wrapper shall "map" the invokation over the handlers

9:46 hmm, extending an instance at runtime is hard. however, at the time when I want to extend the instance I know all method implementations. So I can relax to problem to "given a list of instances,build a instancen implementing all protocols implemented by all instances where the invokation of any method m defined in any protocol is (fn [_ & args] (map #(apply m % args) instances))

9:47 So I can reduce that to applying reify at runtime...

10:46 clgv: I have a map of maps that might refer to each other via keys and I want to update the map by replacing the keys with the reference to the map belonging to the key. in general this means building a directed acyclic graph

10:48 the only way to accomplish this goal seems to be to perform a topological sorting with respect to the referencing relation

10:56 gfrlog: could you do duck-typing in a static language by having every object implicitely implement an interface for each method it defines, and allow function arguments to specify a list of interfaces, one for each method it plans to call?

10:57 TimMc: gfrlog: ew

10:57 gfrlog: TimMc: whyso?

10:57 TimMc: I'm assuming all this happens under the covers

10:58 TimMc: gfrlog: What's to say that Foo.grovel() and Bar.grovel() are semantically interchangeable?

10:59 gfrlog: TimMc: nothing, that's the downside to duck-typing generally. I'm trying to get some static-checking out of it, so at least you know that your object can grovel

11:02 stuartsierra: Doesn't Java allow something like that? e.g. public foo(List<? implements Bar> bars)

11:03 gfrlog: stuartsierra: I'm not following :/ you have an argument bars of type List?

11:04 stuartsierra: nevermind

11:05 gfrlog: okay.

11:07 stuartsierra: "Structural" type systems, where the type of a thing is defined by its capabilities, are sort of like that.

11:07 As opposed to "Nominal" type systems like in Java.

11:08 gfrlog: Ah hah -- something to google. Just what I wanted. @unironic

11:16 bendlas: technomancy: is it possible, that slamhound chokes on clojure.contrib.core/-?>

11:16 specifically on the \?

11:33 technomancy: bendlas: totally possible; maybe open an issue?

11:40 bendlas: technomancy: can do that

11:49 technomancy: https://github.com/technomancy/slamhound/issues/8

11:49 technomancy: thanks

11:50 shame; I just cut a release yestorday

11:50 bendlas: on another note: is it intended, that when i do `lein plugin install marginalia 0.5.1` e.g. from my home dir

11:50 that it installs its deps in ~/lib/dev/*.jar

11:51 technomancy: hmm; no that's also a bug; could you report another issue?

11:51 bendlas: k

11:57 chewbranca: technomancy: hey man, sorry I didn't make it back last night, got caught up on some stuff and didn't have time to drive back down south

11:58 offby1: we ate your brownie.

11:58 chewbranca: I missed out on brownies? doh..

11:58 bendlas: https://github.com/technomancy/leiningen/issues/209

12:04 technomancy: chewbranca: ah no worries

12:05 chewbranca: technomancy: yeah was bad timing, had that meeting scheduled for weds originally but had to reschedule due to my car being in the shop on weds :/

12:05 technomancy: did I miss anything interesting?

12:06 technomancy: chewbranca: it was pretty low-key, but we had a cool demo of hiredman's pattern matching lib

12:06 TimMc: technomancy: What part of the country are you in?

12:07 chewbranca: technomancy: ahhh interesting

12:07 technomancy: TimMc: seattle

12:07 TimMc: Ah, OK.

12:07 Oh right, seajure.

12:10 offby1: ah, "hiredman". I meant to ask what his real name was :)

12:33 timvisher: hey all

12:33 seancorfield__: mornin'

12:33 * seancorfield__ listening to doug lea at scala days

12:34 technomancy: offby1: is this your friend you mentioned? https://github.com/paxan

12:34 ~guards

12:34 clojurebot: SEIZE HIM!

12:34 timvisher: i'm trying to figure out how to use destructuring to get at the keys of a map inside a map, i.e. {:foo {:bar "bar" :biz "biz"}}

12:34 dnolen: seancorfield__: cool, what's he talking about?

12:34 seancorfield__: dnolen: all flavors of parallelism, from hardware to explicit concurrent ADTs

12:35 hiredman: timvisher: you can't, destructure needs to know the keys to bind the values to names, you cannot do the reverse

12:35 dnolen: seancorfield__: interesting, got a favorite talk thus far?

12:36 seancorfield__: nah, lots of academic stuff... interesting from a theory p.o.v. but nothing really grabbed me yesterday

12:36 timvisher: unless i'm misunderstanding you, i might have worded myself wrong. I'm looking for something like {:keys [bar biz] {:keys [foo]}}

12:36 i don't mind having to specify the names explicitly

12:36 i just can't figure out the nesting

12:36 seancorfield__: my take away was "implicit (type conversion) is very very powerful but introduces all sorts of problems"

12:36 timvisher: someone told me how to do this before

12:36 i just can't remember how

12:37 hiredman: seancorfield__: shocking

12:37 timvisher: i could always use multiple lets

12:38 hiredman: seancorfield__: you should grab the mic and call on the people of scaladays to rise as one and throw off the shackles of complexity

12:39 raek: timvisher: (let [m {:a {:b 1}}, {{b :b} :a} m] b)

12:39 the inner destructuring can be written with the {:keys [b]} shortcut (well, in this case it wasn't much shorter...)

12:40 timvisher: that! exactly. :)

12:40 * timvisher really needs to sit down with destructuring for a week and get familiar with it

12:40 raek: binding form (symbol or destructuring) to the left and key to the right...

12:40 seancorfield__: hiredman: lol... i feel like i'm back at university doing CS264

12:41 in fact, one talk yesterday specifically referred to CS264

12:41 (but i'm british and we don't label courses like that)

12:42 doug's talking about concurrent collection libraries using CAS under the hood and self-healing algorithms to maintain internal consistency

12:42 dnolen: seancorfield__: hammurabi seemed interesting, but I find it humorous that writing 2X-4X the Scala to is improvement over the Jess Lisp syntax.

12:43 seancorfield__: dnolen: yeah, mario showed the jess example in his talk and complained about duplication of rules in the lisp code

12:43 his preso was pretty good tho' but reinforced what i don't like about scala :)

12:46 there's definitely some phenomenal work being done in the scala community but there's so much complexity behind the scenes... these two days are making me much more comfortable with choosing clojure for most of our future work at World Singles

12:47 rlb: The empty? docs request (seq x) rather than (not (empty? x)). What about the converse? i.e. (if (empty? x) ...)

12:49 seancorfield__: rlb: not sure what you're asking...?

12:49 ,(doc empty?)

12:49 clojurebot: "([coll]); Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not (empty? x))"

12:49 rlb: Is (if (empty? ) ...) considered idomatic?

12:50 (if (empty? x) ...)

12:50 seancorfield__: ah, because the docs indicate (not (empty? x)) is not idiomatic?

12:50 rlb: right

12:50 just curious -- trying to adjust to clojure's seq semantics...

12:50 seancorfield__: i think it's just indicating the complement pair is (empty? x) and (seq x) so you should avoid (not ...)

12:51 rlb: makes sense -- just wanted to check.

12:51 thx

13:02 seancorfield__: keynote is over... off to sessions now... may be back on and off during the day

13:05 astoddard: ,(clojure-version)

13:05 clojurebot: "1.2.0"

13:06 astoddard: ,(sort [5.0 2.0 Double/NaN 3.0])

13:06 clojurebot: (2.0 5.0 NaN 3.0)

13:10 dnolen: in a time when people thump the ground about static types yet don't understand the theory of Prolog are sad times indeed ...

13:17 astoddard: ,(sort [5.0 2.0 Double/NaN 3.0])

13:17 clojurebot: (2.0 5.0 NaN 3.0)

13:18 astoddard: Is the above behavior of sort with NaNs present likely to remain in 1.3?

13:22 rlb: Couldn't figure out why things weren't working -- took a while to notice that I'd typed `(foo ,bar) rather than `(foo ~bar).

13:23 ataggart: Thrdb: http://dev.clojure.org/jira/browse/CLJ-738

13:24 rlb: ^

13:24 ok, Im gonna stop typing until I've had my coffee

13:36 Dranik: is there any tutorial on writing a leiningen plugin?

13:37 seancorfield__: Dranik: https://github.com/technomancy/leiningen/blob/master/PLUGINS.md

13:37 Dranik: thanks

13:50 aaelony: hi - I realize a few things have moved around in contrib. Where are the most up to date docs for the most stable contrib API ?

13:51 ataggart: old clojure-contrib is stable for 1.2

13:51 aaelony: link ?

13:51 ataggart: to what?

13:51 aaelony: I'm looking for contrib that works with clojure 1.2.1

13:52 a doc link

13:52 manutter: aaelony: have you looked at clojuredocs.org?

13:52 ataggart: http://clojure.github.com/clojure-contrib/

13:52 https://github.com/clojure/clojure-contrib/commits/master

13:52 manutter: (um, or the official site too, I guess ... )

13:53 aaelony: yes, I am confused because there is assembla, clojure.org, and there is github, but they are diffs

13:53 stuartsierra: Assembla is dead and gone.

13:53 aaelony: ok

13:53 i guess its not always clear (to me) which doc links are stale (dead or gone)...

13:54 TimMc: stuartsierra: Dead, but not gone. :-(

13:54 stuartsierra: clojure.org has conceptual documentation. clojure.github.com has full API docs for every core function/macro.

13:54 TimMc: It is still there to confuse newcomers.

13:54 stuartsierra: Noted. Will raise with Core.

13:54 aaelony: I'll check out clojure.github.com for the full API

13:54 ataggart: aaelony: contrib readme is here https://github.com/clojure/clojure-contrib/blob/master/README.md

13:54 aaelony: thanks

13:55 TimMc: stuartsierra: Wait, maybe not... I can't find the old stuff anymore.

13:56 stuartsierra: Yeah, http://www.assembla.com/spaces/clojure/wiki is still there but points to dev.clojure.org on every page.

13:56 aaelony: for example, if I want to use something that reads json files with clojure 1.2.1, do I use clojure.data.json or do i use clojure.contrib.json?

13:57 stuartsierra: Both will work. Only clojure.data.json will be continued in the future.

13:57 aaelony: thnks

13:58 if I choose clojure.data.json, do I put [org.clojure/data.json "0.1.0"] in my project.clj ?

13:59 ataggart: aaelony: bear in mind the new contrib stuff may be dependent on features of 1.3, and the old contrib stuff may be dependent on deprecatd features in 1.3

13:59 aaelony: ataggart: yes, this is what I am getting at

13:59 stuartsierra: aaelony: yes

13:59 aaelony: thanks

13:59 stuartsierra: ataggart: Most of new contrib should still work in 1.2, though there are a couple exceptions.

14:00 ataggart: stuartsierra: true, just wanted to put out that caveat.

14:00 stuartsierra: yes

14:00 ataggart: it's an awkward time for someone to begin working with contrib

14:01 stuartsierra: contrib has always been awkward, but I think we're finally on the right track now

14:01 ataggart: yes, once 1.3 is released things will be smoother

14:01 though with the number of breaking changes, calling it 1.3 is a bit of a misnomer

14:02 stuartsierra: There's still a possibility it will be called 2.0.

14:02 aaelony: well, for example, I have been using contrib for some while but things are changing and I need to update some code. It would be nice to know the things that need to change and how they relate to explicit versions of clojure and contrib

14:03 ataggart: read the readme I linked to

14:03 ilyak: Is there something like a catalog of clojure libraries? How does one discover libraries for his needs? Is there a place where this topic is discussed?

14:04 aaelony: ataggart: saw that

14:04 ilyak: clojure maillist seems to be about everything and nothing

14:04 technomancy: stuartsierra: it's interesting to me that 1.3 closely follows scala 2.8, which caused much bemoaning of the fact that they didn't name it 3.0.

14:04 ataggart: semantic versioning is a Good Thing

14:04 stuartsierra: technomancy: People will complain in either case. We did a poll and it was a perfectly even split.

14:04 ataggart: ilyak: same way people find most libs: google

14:05 ilyak: clojuredocs might be a good plac to search too

14:05 http://clojuredocs.org/libs

14:05 hmm, thought there were more libs there

14:05 technomancy: stuartsierra: well in the case of scala 2.8 is was the maintainers who were the most regretful

14:05 manutter: clojure toolbox?

14:06 http://www.clojure-toolbox.com/

14:06 ilyak: ^

14:06 stuartsierra: I personally want to call it 2.0, but it's not my decision.

14:07 hiredman: this is how I look for libraries: 1. clojure libraries are generally crappy wrappers around java libs 2. look for java libs 3. write my own

14:07 ilyak: Okay, thanks

14:07 ataggart: hiredman: and then release them to compete in the marketplace of libs, right? ;)

14:07 hiredman: ataggart: depends

14:08 stuartsierra: I agree with hiredman.

14:08 * stuartsierra ducks out for a few

14:08 ataggart: writing good libraries for other people's possible usecases is Hard

14:09 says the guy whose crappy api tiggered the contrib modularity

14:10 technomancy: ataggart: well writing good libraries is especially hard if you don't control the version number.

14:10 ataggart: true dat

14:10 technomancy: it's easy enough to bump the major version and move on with life =)

14:11 hiredman: ataggart: it is, but, for example, some of the existing pattern matching libraries for clojure do things like wrap bodies in fns which breaks recur, obviously a non-starter

14:11 ataggart: which I think was also an issue in clojure itself somewhere

14:12 hiredman: ataggart: oh, sure, very easy for macros to do

14:13 but if you have pattern matching you want it to be foundational, which it cannot be if it breaks fundamental parts of the language

14:15 ataggart: It'd be nice if there was a better way to froment peer review of code other than just putting up a message in google groups

14:15 s/froment/foment

14:15 sexpbot: <ataggart> It'd be nice if there was a better way to foment peer review of code other than just putting up a message in google groups

14:16 hiredman: there is some arg parsing library we were looking at to use at work, which generates a nice help message, and then if you ask for help unconditionally calls System/exit

14:16 which is useless for long running processes

14:17 so we rolled our own, and ours is pretty nice, but part of our closed code base unfortunately

14:17 astoddard: ataggart: I looked at the jira link for the NaN <= bug. The issue with sort is very related but still different to me. Unless the comparator is NaN aware (not just ultimately using <) a NaN containing collection is unsortable.

14:17 hiredman: (you can specify a set of valid sets of args, and seperately a map of validator functions for each flag)

14:18 ataggart: astoddard: Double NaNs are sorted as largest Double.

14:18 hiredman: what lib is that?

14:18 the one that sucks, I mean

14:18 hiredman: clargon maybe

14:20 dnolen: hiredman: yeah wrapping bodies in fns is about structure sharing, it's something I'll have to deal w/ eventually as well ... supporting recur will be tricky.

14:20 * stuartsierra returns

14:21 hiredman: we have a long running process, and a shell script that acts as a dumb client, the shell script just passes args to the long running process, so calling System/exit is no good

14:43 rlb: Is there anything like __LINE__ to parallel *file*?

14:43 i.e. like __FILE__ __LINE__ in C?

14:44 stuartsierra: There's a LINE var in the compiler somewhere. It's not directly exposed but you can get at it.

14:44 hiredman: ,@clojure.lang.Compiler/LINE

14:44 clojurebot: 0

14:44 stuartsierra: that

14:44 hiredman: well, it is public

14:45 rlb: OK, thanks -- just wanted something for some quick, temporary debug messages.

14:59 Is it acceptable to use defmacro to create a local macro within a function?

15:00 stuartsierra: no

15:00 Clojure doesn't have local macros (yet).

15:00 rlb: so is macrolet the right thing to use?

15:00 stuartsierra: If there were a macrolet, yes.

15:01 rlb: (via clojure-contrib.macro-utils)

15:01 mrBliss: or tools.macro: https://github.com/clojure/tools.macro/blob/master/src/main/clojure/clojure/tools/macro.clj#L202

15:01 stuartsierra: That will work in most cases, but it's not a complete solution.

15:01 rlb: ok, thanks -- I don't have to have it, of course. I'll probably just leave it off for now.

15:02 stuartsierra: http://dev.clojure.org/display/design/letmacro

15:05 mrBliss: ,(letfn [(f [& args] (if (zero? (first args)) (second args) (recur (dec (first args)) (inc (second args)))))] (f 3 4))

15:05 clojurebot: java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 1 args, got: 2

15:05 mrBliss: It seems that one cannot recur when using a variable number of arguments

15:06 hiredman: you can, you have to box your args though

15:06 args is a seq, so if you recur to args you have to pass something seq-like (list or vector or seq)

15:07 mrBliss: hiredman: thanks

15:19 rlb: Is there a way to stop ` from qualifying symbol names? I just want the list (= x y), not (clojure.core/= x y).

15:20 The context is wrt a test assertion, i.e. `(... (pprint-str '(= ~x ~y)))

15:20 stuartsierra: ~'x will do it

15:20 clojurebot: 2009:Jan:29:16:03:17 <hiredman> I call Xiphojura

15:21 rlb: Ah, of course; thanks.

15:25 aav_away: $seen lpetit

15:25 sexpbot: lpetit was last seen quitting 1 week and 2 days ago.

16:17 Dranik: how to check the equality of strings?

16:18 manutter: ,(.compareToIgnoreCase "foo" "bar")

16:18 clojurebot: 4

16:18 manutter: ok, that's a bit different than I expected

16:18 ataggart: ,(= "foo" "bar")

16:18 clojurebot: false

16:18 manutter: ,(= "foo" "foo")

16:18 clojurebot: true

16:19 manutter: ,(> "foo" "bar")

16:19 clojurebot: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number

16:19 manutter: ,(.compareTo "bar" "foo")

16:19 clojurebot: -4

16:20 Dranik: manutter: thanks

16:20 manutter: So plain old = works for equality, but you have to use .compareTo or .compareToIgnoreCase for > or <

16:20 Dranik: anytime

16:20 Dranik: manutter: does the = call native java "equal" method?

16:20 manutter: I just did this for one of the 4clojure probs :)

16:20 Not sure what the = does

16:21 dnolen: ,(doc =)

16:21 clojurebot: "([x] [x y] [x y & more]); Equality. Returns true if x equals y, false if not. Same as Java x.equals(y) except it also works for nil, and compares numbers and collections in a type-independent manner. Clojure's immutable data structures define equals() (and thus =) as a value, not an identity, comparison."

16:21 manutter: ~botsnack

16:21 clojurebot: Thanks, but I prefer chocolate

16:21 manutter: ~chocolate

16:22 clojurebot: Titim gan éirí ort.

16:22 manutter: Ha!

16:22 dnolen: ~pizza

16:22 clojurebot: No entiendo

17:33 arohner: is there a good way to determine how much memory an object is using?

17:33 stuartsierra: arohner: Only with a JVM profiler.

17:54 arohner: stuartsierra: http://sizeof.sourceforge.net/

17:56 stuartsierra: cool

19:24 duck1123: can anyone tell me where clojure.contrib.duck-streams/pwd went?

19:24 I hate trying to track down the new locations of missing functions

19:25 hiredman: duck1123: it was most like decided to be junk and not promoted to other places when the rest of duckstreams was

19:26 https://github.com/richhickey/clojure-contrib/blob/061f3d5b45657a89faa335ffa2bb80819f2e6918/src/main/clojure/clojure/contrib/duck_streams.clj#L270

19:26 it's not really 'pwd'

19:26 technomancy: duck1123: (System/getProperty "user.dir")

19:26 hiredman: it is "the value of the mutable system property 'user.dir'"

19:27 aavram: yes, i think the refactorings are good, but there is a real sense of "who moved my cheese?

19:27 "

19:27 duck1123: Okay. I'm trying to fix up aleph for 1.3 and couldn't find that one. Glad I don't need another dep

19:28 technomancy: aavram: well the whole point of contrib was "we don't know if this is good yet."

19:28 aavram: i understand

19:28 TimMc: technomancy: reminds me of javax.*

19:28 technomancy: the problem was there was a genuine need for a standard library, and contrib was used as that even though that wasn't what it was intended for

19:29 duck1123: I definitely believe that when it's all done and moved it'll be good. It's just a pain right now

19:29 * technomancy did his part; newly generated lein projects do not depend upon contrib by default

19:30 duck1123: I went through all of the dependencies in my project last weekend and removed every trace of c.c 1.2

19:30 TimMc: I'm not familiar with the details of this refactoring -- has there been any effort to make a consistent API for code that needs to be compatible with both 1.2 and 1.3?

19:31 aavram: maybe it would be good to have lein give warnings like: "you are using libs a and b. if you use lib-a version 1.0 you need to use lib-b version 1.1" or something

19:31 hiredman: clojure.core is largely the same, contrib is the big change

19:32 duck1123: also minor issues like dynamics, and potemkin doesn't work when you pass it a symbol

19:32 hiredman: potemkin?

19:33 duck1123: it's a lib that is used in aleph and lamina. It's essentially compojure's old immegrate

19:33 hiredman: ugh

19:33 duck1123: but on a fn by fn level

19:33 hiredman: digusting, glad it's broken

19:33 duck1123: never been a fan myself honestly

20:45 lpetit: hello

20:47 scottj: que pachuca por toluca

20:47 lpetit: I've a very basic ring question : based on some handler logic, I'd like to serve a success file or a failure file. Those files would be in my webapp, for example at <webappContextProvidedByTomcat>/someSubdir/success and <webappContextProvidedByTomcat>/someSubdir/error

20:49 In "basic" JEE, I know how to do this: I call request.getContext() to get the "http://&lt;server>:<port>/&lt;webappContextProvidedByTomcat>" part of the URL (parts on which my webapp will have, of course, no control). And my handler can just add the webapp-relative part: /someSubdir/succes

20:49 I don't know how to do this with Ring :-(

20:55 scottj: does this work (-> request :servlet-request .getContextPath)

20:56 ring ml thread "Accessing HttpServletRequest object in the request-map" idk

20:58 lpetit: scottj: I'll see, thanks. I was working right from the SPEC document, and didn't know about these specific keys added by the adapter

21:01 Guest2285: is there a way to ignore a line break in multiline strings in clojure

21:02 scottj: Guest2285: don't think so

21:03 Guest2285: such as in python if you have a newline immediately following the \ character in a multiline string the newline gets ignored?

21:25 rahulkmr: What's the idiomatic way to do byte io in clojure? I can wrap Java streams for one

21:26 brehaut: rahulkmr: have you looked at the clojure.java.io module?

21:27 rahulkmr: What are the IOFactory docs it talks about?

21:28 Usage: (input-stream x & opts)

21:28 And I can't find explanation for & opts

21:28 oh got it

21:28 :append and :encoding

21:31 In clojure.java.io make-* and * function seem to be saying the same thing. For eg. output-stream and make-output-stream. Just that output-stream has bigger docs

21:33 brehaut: rahulkmr: im no expert but i think you probably use the non-make versions most of the time

21:35 rahulkmr: basicly the idiomatic way is to use the io utilities where possible, but otherwise you just do java IO

21:35 rahulkmr: Yep. got it output-stream uses make-output-stream https://gist.github.com/1007447

21:36 gotta love clojure.repl.source

21:36 offby1: do I _gotta_?

21:36 * offby1 pouts

21:37 brehaut: source is pretty great but apropos still wins for my favorite repl util

21:38 rahulkmr: Yes. apropos is great but I do a lot of (use..) in repl. My ns are polluted like anything

21:40 quizme: if I do a (doseq) on a clojurql query that operates on millions of rows, will that put the whole seq into memory? I want to just work the seq one item at a time, then have the jvm garbage collect along the way. how do i do that?

21:40 brehaut: quizme: look at dorun: it doesnt hold the head and returns nil

21:41 actually, doseq also doesnt hold the head and returns nil

21:43 quizme: brehaut ok so doseq should do the trick i guess, thanks.

Logging service provided by n01se.net