#clojure log - Jan 14 2010

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

0:00 arohner: if I put a dorun around it, I see 12 prints, and then exception

0:00 if I take the dorun off, I see 0 prints, and then exception

0:00 hiredman: erm

0:00 arohner: yeah.

0:00 hiredman: how are you consuming the for?

0:00 arohner: I'll try to come up with a reproducing example

0:00 the for is returned by a function. I'm calling the function from the repl => the repl is consuming

0:01 hiredman: hmmm

0:02 I certainly cannot reproduce it

0:02 (for [x (range 13)] (if (= x 12) (throw (Exception.)) (prn x)))

0:04 oh!

0:04 are you using println or print?

0:04 arohner: println

0:04 hiredman: hmmm

0:05 thought it might be a flushing issue

0:05 arohner: I reproduced it using your example, moving the body into a separate function

0:05 lisppaste8: url

0:05 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

0:06 arohner pasted "weird println issue" at http://paste.lisp.org/display/93372

0:08 arohner: sigh.

0:08 it happens in slime, but not at the repl

0:08 not at the real console

0:08 it's a slime issue.

0:09 well, thanks for the help

0:31 yangsx1: Maybe this just happens to me. Projects using maven and thus leiningen sometimes make it difficult to work, because access to the central repos may fail, as is the case here in Beijing. Fortunately clojure and clojure-contrib havent moved to maven or lein to build themselves.

0:34 hiredman: you can add a repository you have more reliable access to

0:34 durka42: i can't seem to compile the latest contrib against the latest clojure

0:34 java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V

0:38 hiredman: works for me

0:39 yangsx: hiredman: thanks for the tip, but I even cannot make "lein-stable deps" finish itself (maybe a temporary problem with the release of clojure 1.1).

0:40 hiredman: yangsx: and the problem is you are unable to grap the jars from maven central?

0:40 grab

0:40 http://groups.google.com/group/tuscany-sca-chinese/browse_thread/thread/3113aebbcbe710b4

0:41 durka42: that works for me was for you

0:42 yangsx: hiredman: No, because "snapshot org.clojure:clojure-contrib:1.1.0-master-SNAPSHOT" could not be retrieved

0:42 hiredman: ah

0:42 durka42: hiredman: hmm. i'll clean out the dir and try again

0:44 hiredman: huh, now it worked

0:48 hiredman: it would be nice if someone figured out what that exception is

0:49 <init> is a constructor, (I)V means it takes an Integer and returns void

0:50 and restfn has a constructor with that signature

0:50 :|

1:53 optimizer: is there any chance a shell (like bash/zsh) written in clojure?

1:54 unfo-: optimizer, i was thinking about it myself ;) but that

1:54 's as far as it has gone

1:54 but dunno, haven't googled for it

2:30 G0SUB: what is the best way to convert a string to a stream and vice versa?

2:31 I am trying to download a zip file using an http client and I want to unzip it in-memory and get the unzipped string back.

2:34 replaca: G0SUB: I think you want StringReader or StringBufferInputStream

2:35 G0SUB: replaca: looking. thanks.

2:37 replaca: does that behave like a File? ZipFile can take only a file.

2:38 replaca: G0SUB: no, isn't there a way to zip a stream?

2:39 yeah, ZipInputStream

2:39 G0SUB: replaca: looking

2:41 replaca: OK, how do I convert a StringReader to an InputStream?

2:45 replaca: G0SUB: are you trying to read from the string or from the HTTP result?

2:45 G0SUB: replaca: yes

2:45 replaca: http result.

2:45 replaca: if you're getting zip back, you can't change it to a string cause it won't really be one

2:45 LauJensen: (slurp* url)

2:46 replaca: you'll have to get it as a byte stream from the http request

2:48 instead of calling slurp, just do (reader url) and pass the result to ZipInputStream and I think you'll be good to go

2:48 G0SUB: replaca: thanks. I am using c.c.http-agent, btw.

2:51 replaca: G0SUB: well http-agent has a stream function right on it: http://richhickey.github.com/clojure-contrib/http.agent-api.html#clojure.contrib.http.agent/stream

2:51 G0SUB: replaca: yeah, I think that should work.

2:52 replaca: thanks for the tips. I am really a Java n00b.

3:04 replaca: G0SUB: np.

3:09 G0SUB: replaca: I need a bit of help in writing a fn which reads a zip file from a stream and return an outputstream of uncompressed data.

3:25 replaca: G0SUB: so you absolutely need an inputstream? (an outputstream would be going back the other way)

3:25 or do you just need data?

3:26 G0SUB: replaca: If I get the unzipped data as a string, I am fine. the zip file will have only one file in it.

3:30 replaca: You're basically going to have to loop on that .read method in ZipInputStream and build up a stream

3:30 the part I'm not remembering now is how you decode the bytes into a String

3:30 G0SUB: hmm

3:31 replaca: I would just use loop..recur on the .read and then use (apply str (map bytes-to-str acc)))

3:32 where acc is the vector of read results from your loop and bytes-to-str is the func that converts the byte array to the string

3:32 I'd help more, but I really have to crash

3:32 G0SUB: replaca: how should I write bytes-to-str?

3:32 replaca: no problem. thanks a lot.

3:33 ah, (String. byte-array) works

3:34 replaca: Yeah, that should be OK as long s you don't try to run it in japan or anything

3:34 G0SUB: hehe

3:34 replaca: it'll barf if there's a difference between where you are and what you're reading

3:35 G0SUB: right, but my data is just ASCII

3:35 replaca: ok, I've given you the tools. Let me know how it goes!

3:35 yeah, you should be ok

3:35 G0SUB: replaca: yep. many thanks :)

3:35 replaca: goodnight!

4:11 Raynes: the-kenny: Ping.

4:40 lypanov: does running the AOT provide me with information such as misspelt function names in definitions that are called elsewhere like java does?

4:41 (as in, i have a method C() and three callers Cx() does AOT fail during compile as it can't find Cx()?)

4:41 s/three callers/& call/

4:42 Chousuke: method? you mean java method?

4:43 lypanov: Chousuke: both clojure "methods" defs.

4:43 LauJensen: lypanov: AOT compile to regular java class files, so for clojure functions you get that those kinds of errors

4:43 Chousuke: the compiler will complain if you refer to nonexisting vars or classes, but not methods. They are resolved at runtime using reflection (unless you use type hints)

4:43 lypanov: ah, cool. thx LauJensen!

4:43 eep.

4:44 maybe clojure is the wrong language for getting gwt going with :)

4:44 (am trying to decide between clojure and scala)

4:44 Chousuke: ,(foo 3) ; should fail during compile-time

4:44 clojurebot: java.lang.Exception: Unable to resolve symbol: foo in this context

4:44 lypanov: but i guess the dynamicness of clojure makes that impossible

4:44 Chousuke: what exactly is the problem?

4:45 lypanov: Chousuke: is the reflection path also taken when using AOT?

4:45 Chousuke: yes.

4:46 lypanov: if so, and thats part of the basics of clojure.

4:46 i can't imagine that its possible to generate java that gwt will accept.

4:46 as reflection is not allowed by gwt.

4:46 Chousuke: if you do (.someMethod x), you don't know the type of x

4:46 so it needs reflection

4:46 but you can avoid it with type-hinting, like (.someMethod #^MyClass x)

4:46 lypanov: *nod* and without type hinting it can't name mangle etc

4:48 Chousuke: Clojure has a var called *warn-on-reflection* that you can bind to true before evaluation

4:48 you can make code entirely non-reflective using that.

4:49 type hints are threaded through forms so usually you don't need them everywhere.

4:50 LauJensen: lypanov: try adding this to your main (set! *warn-on-reflection* true) and then compile. That'll give you a list of every single expression which needs a type-hint to rid the reflection

5:29 Raynes: the-kenny: ping-number-2.

7:00 lypanov: anyone around know the internals of clojure?

7:00 LauJensen / anyone else: how feasible do you think it is to generate java from clojure?

7:01 assuming i add type hints everywhere.

7:01 are there other dispatch types that java can't deal with?

7:01 LauJensen: Clojure compiles to bytecode, seamlessly integrated on the JVM - Its no problem

7:02 lypanov: LauJensen: i should add background, i'd like to generate java source, which is the input gwt needs.

7:02 LauJensen: Ah sorry

7:02 At present I think you'd be happier in Java for that purpose :)

7:02 lypanov: yes, but this is a long term project.

7:03 and the project tech, is the project. if you know what i mean.

7:03 trying to decide between scala or clojure as the source lang i use.

7:03 LauJensen: If you have some time I recommend producing a small prototype in both languages, then compare experience

7:23 lypanov: LauJensen: good idea. can't think of what exactly i should prototype though.

7:23 will learn more about clojure and give that some good thinking.

7:24 still not convinced that i'm looking for a dyn lang. more of a compiles-moan sorta guy.

7:25 (ruby from '99 till '04, then paid work forced a shift to java and i did ruby only in spare time, just made shift to ruby again for commercial work and realllly see the downsides to dyn and thinking more of scala)

7:25 (maybe its just that ruby sucks rather than dyn sucks)

7:34 LauJensen: lypanov: I had a fun (but dangerous thought), what if you wrote Clojure, compiled to bytecode and decompiled into Java (http://www.dmoz.org/Computers/Programming/Languages/Java/Development_Tools/Translators/Decompilers_and_Disassemblers/) ?

7:35 the-kenny: LauJensen: I tried that

7:35 lypanov: LauJensen: at least scala generates much bytecode that can't be decompiled.

7:35 the-kenny: It's almost readable, but good for searching for performance issues

7:35 lypanov: i guess its the same with clojure.

7:35 LauJensen: the-kenny: In this case it doesn't need to be readable, just passable to gwt

7:36 the-kenny: LauJensen: hm.. it uses much RT etc. I don't know if this would work

7:37 LauJensen: This discussion would probably be easier with c-in-c in place and Chouser or rhickey weighing in

7:37 forget 'possibly'

7:38 lypanov: c in c?

7:39 LauJensen: Clojure is being implemented in Clojure, so all you have to do is provide a bootstrap and compile to any language you want

7:41 lypanov: its now in java?

7:42 minimalistic bootstrapping is teh hard :)

7:42 maybe when chouser/rhickey are back they can weigh in.

7:42 i'm 100% certain many people are interested in this.

7:54 Raynes: the-kenny: Did you ever figure out the error you were getting in Slime when you tried to require something?

8:01 rhickey: lypanov: what do yuo want to do with the generated Java?

8:03 lypanov: rhickey: as input to gwt.

8:03 we're currently ruby/backend java/frontend. which is irritating. i'm slowly moving towards x/{backend,frontend}

8:03 rhickey: lypanov: you'd still run the risk of the GWT converter balking at something

8:03 lypanov: there is a scala -> gwt project already, but its very primitive.

8:04 rhickey: it depends what is generated. at least for scala its very hard as some generated bytecodes have no java equiv. eg throwing exceptions without a throws declaration.

8:05 and it has tail call opts, which use jumps. so this requires lots of fixups to the ast.

8:05 if clojure was easier / better matched, itwould make it a lot easier than doing the same for scala.

8:05 rhickey: lypanov: the lack of goto is definitely a problem with generating Java source

8:05 lypanov: otoh, clojure has the dyn side of things.

8:06 rhickey: lypanov: the dynamic aspect can go away with AOT and type hints

8:06 lypanov: rhickey: ast tree manips and break/continue usage fixes that, just lots of boring special case tree manip.

8:07 rhickey: lypanov: yes, and for Clojure that only occurs with recur

8:07 lypanov: rhickey: i'd like to have a unit tests -> produce type hinting.

8:07 to remove even the need for manual type hinting in actual source.

8:07 AWizzArd: what is bad about manual type hinting?

8:08 defn: all that reading! and typing!

8:08 AWizzArd: It's okay when the editor can hide/unhide the types.

8:08 Typing.. it takes just a few seconds. This is not what reduces the productivity of a good programmer.

8:08 defn: i was kidding, for the record...

8:09 AWizzArd: Reducing the complexity of multithreading is where Clojure helps. Typing #^String does not make me unproductive. Working with locks does.

8:10 Type inference is okay, but in that case we would need a function (get-inferred-type #'foo) which our editors can use.

8:11 lypanov: AWizzArd: thx for the input. type annotation scares me much less now.

8:17 Licenser: types are so much typeing?

8:18 Raynes: Typing is so much typing.

8:28 chouser: lypanov: I did once try to run the Java parts of Clojure through the gwt compiler.

8:28 I did so hoping to get PersistentHashMap in JS without hand-translating it.

8:29 but it really didn't go well at all. I don't remeber everything gwt complained about, but it was enough that I spent a couple weeks translating the collection classes by hand instead.

8:32 LauJensen: chouser: isnt this the case where c-in-c would really give lypanov some mileage?

8:33 chouser: only if there were a Java source back-end, and only if it produced Java source that gwt liked.

8:33 Chousuke: c-in-c will solve all your problems and cure cancer.

8:34 lypanov: chouser: depending on how much i can get to like clojure, i'm open to writing that.

8:34 is there a better beginners doc than http://java.ociweb.com/mark/clojure/article.html ?

8:35 djork: lypanov: I can bet you will like it very much

8:35 lypanov: i'm enjoying it :) but in case my research into things to read was flawed, prefer to ask.

8:35 djork: lypanov: it's a good article

8:35 but I would also recommend just reading the docs, as they detail most of the corners of the language very succinctly

8:35 cemerick: I pine for a clojure-friendly gwt. Regular web development sucks.

8:36 djork: I am trying to grok compojure right now

8:36 lypanov: cemerick: you do devel in which fallback is required, or interested in something pure clojure?

8:37 cemerick: lypanov: fallback?

8:37 djork: The docs are sparse (and scattered), but it's a nice little framework.

8:37 lypanov: cemerick: ajaxless version for ie6 / noscript lovers

8:37 cemerick: (as long as you stay away from the sexpr html generation, IMO)

8:37 lypanov: no, I could care less about that.

8:37 lypanov: cemerick: heard of pure.js?

8:37 cemerick: nope

8:38 * cemerick only does web development to irritate real web devs :-P

8:38 lypanov: http://beebole.com/pure/

8:38 we're using it here. with jquery.

8:39 it allows me to shove the designers html/css tarballs on line and make my code just hammer them into working functional apps.

8:39 now i'd just like to replace the js i'm currently doing that with, with clojure.

8:39 djork: cemerick: you're using Enlive, right?

8:40 cemerick: lypanov: eh, I'm not too concerned with separating js from html

8:40 djork: yes, badly

8:40 there's a ton of capability there, but I haven't grokked it yet (esp. template/snippet composition)

8:40 lypanov: cemerick: well, my concern is more separation of js/html from code.

8:41 as in, data vs pretty.

8:41 djork: yeah

8:41 hah

8:41 Enlive is really an amazing idea, I'm not sure if it's new or what

8:41 lypanov: ah

8:41 its the same idea

8:41 djork: it kind of turns the template idea on its head

8:41 lypanov: someone just released the same thing for rails also.

8:41 glad this is at last catching on

8:42 djork: I don't really see anything about "selector-based templating" in Google

8:42 cemerick: lypanov: yeah, looks like pure is the same as enlive, but driven by js

8:42 djork: except for enlive

8:42 lypanov: djork: gimme asec

8:42 cemerick: which means I immediately don't like it ;-)

8:42 djork: heh

8:42 ah, pure.js yeah I think I've seen that around

8:43 lypanov: djork / cemerick: http://github.com/jferris/effigy

8:44 cemerick: nice

8:44 djork: yay

8:44 yeah, templating languages suck primarily because they make editing such a hassle

8:44 lypanov: *nod*

8:44 djork: they break syntax highlighting and structured editing

8:45 I was really thrilled to find Enlive because I am trying to build a web dev environment for the iPhone.

8:45 And editing anything but well-structured HTML is nearly impossible with the approach I am taking...

8:45 lypanov: after doing non paired devel for 2 weeks with a designer i finally gave up and started to rewrite everything to use pure.js

8:45 productivity soared

8:45 djork: yeah

8:46 lypanov: ability to replace that js would a nice lang would just make it all so much nicer

8:46 djork: no more <%= @f.x { |y| y.bar } %>

8:46 LauJensen: lypanov: Had a look at Clojure script?

8:47 djork: scriptjure?

8:47 OK I have 10 minutes (self-imposed) to get compojure and enlive working

8:47 lypanov: reading.

8:47 djork: i think he refers to http://github.com/technomancy/clojure-contrib/tree/7ea70da82e42416864e2f97e3d314aced34af682/clojurescript

8:48 is that the one LauJensen?

8:48 cemerick: totally, totally OT, but: does it seem like a good idea to others that dates formatted for storage as strings should be converted to UTC (to avoid oddball daylight savings time rules, etc)?

8:48 LauJensen: lypanov: I think you'll find it under Chouser

8:48 lypanov: ah, another one. hehe

8:48 Licenser: Okay people :) I

8:48 #v

8:48 LauJensen: djork: I have a screencast showing you how to get going with Compojure+ClojureQL in about 10 minz, and another one showing of Enlive (2 actually)

8:48 Licenser: argh

8:48 esj: cemererick: is what I do.

8:49 djork: oh yeah? I'd love to see them

8:49 LauJensen: Then head over to www.bestinclass.dk -> click blog

8:49 lypanov: LauJensen: wantttttttt

8:50 * lypanov likes started by looking at real code

8:50 * lypanov clicks manically

8:50 lypanov: s/ed/ing/

8:50 djork: cemerick: absolutely, every time

8:50 there's no other way to store dates as strings as far as I am concerned

8:50 cemerick: OK, good to know.

8:50 Licenser: I've a question, I'm working on a bit game stuff in clojure and have the folowing situation, I've a 'game'-struct that holds all the unit structs. each update function gets the game and and 'id' for the unit passed to do the stuff with it it should do. Now I come to the points where the units should become 'inteligent' but passing every AI script the entire game map to update it sounds a bit of a overkill for me or is that a good idea?

8:50 cemerick: I've never really had to deal with dates before where I cared much.

8:51 djork: Licenser: passing a large object is never a problem because it's really passing a reference to that large object

8:51 internally

8:51 lypanov: um. who is chouser on http://github.com/richhickey/clojure-contrib/network ?

8:51 Licenser: djork: I know it's not a memory problem but just a thing of well niceness

8:51 djork: but generally, in functional programming, you want to pass everything a function needs to know about to it directly

8:52 another thing to consider is having AI functions that return the action that they think should happen

8:52 Licenser: If I have somehting like: (recharge-battery game unit-id engine-id ammount) I kind of feel it gets crouded

8:52 while it keeps nice and functional

8:52 djork: they take the game state, look at it, and say "move this here, move that there"

8:52 but without actually mutating the game state

8:53 spariev: Licenser: have you seen this paper http://portal.acm.org/citation.cfm?id=1176617.1176630

8:53 djork: that's really not too bad Licenser, and you can create macros and closures around things to keep it slim

8:53 Licenser: spariev: no

8:53 *nods* Also I am not compfora

8:53 djork: but that argument list looks totally sane

8:54 cemerick: lypanov: chouser is here :-)

8:54 Licenser: compfortable with allowing the AI to mutate the entire game - so I like the idea of returning 'what should happen' stuff

8:54 lypanov: cemerick: aye, saw him earlier just wondering based on LauJensen's reply where i can find his github fork

8:55 spariev: Licenser: not sure it's relevant to your problem, but it describes interesting patterns regarding to game ai imho

8:55 djork: "udvikling" is such a funny word to my English-speaking eyes :)

8:55 Chousuke: Licenser: you might be able to use a global binding to provide a read-only view of the game state

8:55 lypanov: duh... that would be Chouser with a C

8:55 djork: what does it mean, literally?

8:55 * lypanov makes another coffee

8:56 Chousuke: Licenser: eg (def *game*) then a macro (with-game-view @some-ref-holding-the-actual-state (charge-battery ...) ...)

8:56 Licenser: Chousuke: that is a good idea

8:56 Chousuke: though as usual, you'll need to be careful if you do threading

8:56 chouser: lypanov: you're looking for clojurescript? Did you find it? I'm afraid it's rather out of date now

8:57 lypanov: chouser: i found the repl but chrome doesn't like that at all.

8:57 chouser: just reading your c-in-c post. whats the status on that out of interest?

8:57 Licenser: hmm yea it is kind of complicated. So far (since all functions are internal and 'trusted') it is kind of easy I just pass them the game and the stuff they should change and the y do

8:58 djork: Licenser: in my very limited MUD game dev in Clojure I've found that passing the game state around is a good thing

8:58 Licenser: djork: *nods*

8:59 chouser: lypanov: ongoing. "master" branch of clojure has perhaps 90% of the features required for cinc.

9:00 Raynes: Yay! I think I got clj-apache-http into a reasonable state now. No more libs included in the github repo, and no more nasty ant build files. :D

9:00 And no more namespace with about 37 dots in it. :<

9:00 chouser: lypanov: huh, clojurescipt.n01se.net works fine for me in chromium on ubuntu. I'm a bit surprised -- haven't tried it in ages.

9:00 Licenser: what makes it kind of complicated that it's not going to be a actual game but should be kind of a library for simulating game combats

9:00 Raynes: Why do people do that anyway? Do people really enjoy typing org.this.that.overhere.overthere.overtherainbow?

9:02 LauJensen: Licenser: I wrapped JMonkeyEngine a while ago

9:02 chouser: Raynes: it's recommended by the Java docs, and guarantees no namespace clashes

9:03 cemerick: ...and is totally ignored by a lot of java libs :-/

9:03 Raynes: chouser: But this isn't a Java application. :|

9:03 cemerick: sorry, s/java/clojure

9:03 Chousuke: you should have at least two segments in your namespace, anyway :/

9:04 Licenser: ah LauJensen not a graphics library just something to calculate events, outcomes and things

9:04 cemerick: Raynes: distinct namespaces are good. 50 different libs claiming the "http-client" ns (or whatever) would not be good.

9:04 LauJensen: Licenser: JME is vast

9:04 djork: I like my namespace to be the name of the project

9:04 Chousuke: yeah. namespaces allow for better naming overall.

9:05 Raynes: I changed the ns to cljapachehttp. It was like 5 segments long. I suppose I can add another segment.

9:05 Licenser: I trust you but I want my own LauJensen :P

9:05 djork: naming an ns after the github project is close enough to unique for most purposes :)

9:05 unless you want to use two forks at once

9:05 :P

9:05 Chousuke: it's not like you need to type the full org.whatever.foo very often

9:05 Raynes: I've just seen lots of projects where the ns was just the project name, so I figured that was a good option.

9:06 chouser: Raynes: there are definitely some people advocating that

9:06 * djork raises hand

9:06 chouser: I'm not fully convinced either way.

9:06 Raynes: chouser: Leiningen does it, so I figured it would be good.

9:06 Chousuke: Raynes: I think it causes problems in some cases, because the class for the namespace will end up in the default package

9:06 djork: hmm

9:07 cemerick: It's a bad path to take, on all but the most superficial criteria.

9:08 Raynes: I suppose I'll add another segment or two, but what it was originally was a bit obscene.

9:08 Licenser: well thank you all for the input I'll play around a bit more :)

9:08 chouser: cemerick: technomancy has argued that it has cause major upheaval when the maintenance of a lib has moved from one "site" to another, requiring all users of the lib to switch from org.foo.magiclib to com.bar.magiclib

9:09 Chousuke: chouser: well, that's not really needed :P

9:09 chouser: my response to that was -- if it's actually the same lib, why not leave the name alone?

9:09 Chousuke: right

9:09 cemerick: chouser: that's a good point, but *choosing* a proper ns is totally orthogonal to *having* a useful ns to begin with.

9:11 chouser: so far I haven't named many public non-contrib clojure libs. But for example, I'm insufficiently arrogant to claim "clojure-jna" as a top-level name, so I'm happy I didn't have to come up with something more creative and could just call it net.n01se.clojure-jna

9:11 Chousuke: if you have more than two segments it'll also be easier to differentiate forks.

9:11 which might not be needed that often, but it's an advantage nonetheless

9:15 Raynes: I'll also point out that the original namespace didn't really make much sense in the first place, which is one of the reasons I changed it.

9:17 chouser: Raynes: fwiw, it's taken me many many months to be acclimated to the deep and nearly-empty directory trees required by java and clojure for projects named this way.

9:17 I guess I am used to it now though. ...doesn't anger me the way it did once. :-)

9:18 Raynes: chouser: That is annoying, but it's the name that didn't really make sense.

9:18 cemerick: If you're managing a large and diverse codebase (or interrelated set of codebases), it's simply the only way to cope. We end up having 3-6 segments depending on the project, etc.

9:21 Raynes: I changed it back to what it was originally. I guess the author owns the twinql.com domain. That was what had me a little confused.

9:25 I'm just trying to get clojure-twitter and all of it's dependencies fixed up and on clojars. Going good so far.

9:27 djork: for(Object o=null;;o=new Object[]{o});

9:27 chouser: djork: ew

9:27 djork: crashes the JVM in a very inelegant way

9:28 not graceful

9:28 :) just for fun (saw it on Reddit)

9:28 brb

9:29 chouser: (loop [o nil] (recur (to-array [o])))

9:29 there, much better.

9:31 cemerick: Raynes: don't let us push you around any :-) If you think it needs a different ns, that's your call.

9:32 Raynes: cemerick: Naw. It's the authors call. ;)

9:32 * jcromartie was djork... not hiding behind anonymity

9:32 cemerick: Raynes: sounded like you were forking

9:32 jcromartie: all of you professionals use your real names :)

9:33 Raynes: cemerick: I am.

9:33 cemerick: Raynes: then whether a new ns is used is your call, IMO

9:33 Raynes: It's better that it keeps it's old name anyway. I imagine there is some code out there using this besides clj-oauth (which I'll be migrating to leiningen as well)

9:34 Good point, but still, this way people don't have to change their code if they pull it off clojars.

9:35 Plus, you guys have given a good argument for multi-segmented namespaces.

9:37 spariev: why could code like (pmap #(* % %) (range 0 10)) work fine in lein repl, but throw java.util.concurrent.RejectedExecutionException in slime when connected to lein swank server ?

9:37 i'm using 1.1.0-master-SNAPSHOT

9:38 here's full commands for swank / repl as seen in ps - http://pastebin.com/m65144fcc

9:39 (clojure-version) shows "1.1.0-master-SNAPSHOT" in both cases

9:41 bpattison: I need to call a Java function that takes a double array, how do I great a double array of a given size in clojure?

9:41 double[] adfGeoTransform = new double[6];

9:41 poDataset.GetGeoTransform(adfGeoTransform);

9:42 mjt0229: does that method modify the array as a side-effect?

9:42 the-kenny: bpattison: double-array should be the function

9:42 mjt0229: I was wondering recently how Clojure handles Java interop for java methods that have side-effects.

9:43 the-kenny: ,(double-array [1 2 3])

9:43 clojurebot: #<double[] [D@1669fc6>

9:43 Chousuke: ,(make-array Double/TYPE 6)

9:43 clojurebot: #<double[] [D@2fab89>

9:43 bpattison: the-kenny: excellent. thanks!

9:43 {newbie}: What do you guys think about point free clojure?

9:43 the-kenny: mjt0229: "Normal" Java datatypes are mutable like in every java program

9:43 mjt0229: Oh, of course.

9:44 Chousuke: {newbie}: useful sometimes, but not as idiomatic as in haskell.

9:44 mjt0229: I ran across an API that expects me to pass in an empty Set, which it would fill on my behalf with the information that I wanted.

9:44 {newbie}: Chousuke: isn't point free a bit bad for someone who want to profile

9:45 mjt0229: I guess the point is that you can pass in a sorted set or a hash set, depending on what you're interested in.

9:45 {newbie}: each "method" individuali?

9:45 Chousuke: {newbie}: may be? I don't know.

9:45 {newbie}: individually?

9:45 mjt0229: But I wouldn't do it that way, at least not without returning the set after I was done with it.

9:45 Chousuke: mjt0229: you can't pass in one of the persistent set types though.

9:45 mjt0229: since they don't support mutation

9:46 mjt0229: Right, it would have to be (.fill obj (HashSet.))

9:46 Chousuke: yeah.

9:46 mjt0229: Well, that doesn't retain a reference, but you get the idea.

9:46 the-kenny: (let [myset (HashSet.)] (.fill obj myset) myset) would work :)

9:46 mjt0229: indeed.

9:46 Raynes: the-kenny: Did you ever figure out that error you were getting with swank around the first whenever you tried to use/require something?

9:46 the-kenny: Raynes: Yes

9:47 It had something to do with my init-file

9:47 after I removed it, everything worked fine

9:47 Chousuke: or even better, finish it with (set myset) to get a persistent set :)

9:47 the-kenny: (the only thing it modified was some *vars*

9:48 Raynes: the-kenny: Just asking because I had the same problem earlier and asked on the mailing list. It has something to do with *warn-on-reflecting* being set to true. Setting it to false fixes it.

9:48 the-kenny: Raynes: Yeah, that was one of the vars I was setting

9:48 Raynes: reflection*

9:48 the-kenny: A very very strange error

9:49 Raynes: the-kenny: I believe somebody has figured out the cause of the error. Hopefully.

9:51 http://github.com/ztellman/swank-clojure/commit/1f79e9312650bb41b541d8c601382ac22900939c

9:53 the-kenny: uhh that's awesome

9:54 chouser: The MEAP is up, so you can read the first 4 chapters, plus more as we write them. http://joyofclojure.com/

9:56 * rhickey buys it

9:57 * Raynes can't afford it.

9:57 * the-kenny is thinking about buying it

9:57 chouser: rhickey: did Manning not contact you for technical review?

9:58 rhickey: chouser: nope

9:58 chouser: hmph. That's silly.

10:03 cemerick: this is funny: http://github.com/Scriptor/pharen

10:06 jcromartie: hah

10:07 obligatory mention: http://github.com/jcromartie/objclj

10:07 needs some love

10:07 and maybe a better name

10:08 cemerick: insanity :-)

10:09 cburroughs: chouser, Yesterday you suggested I use LinkedBlockingQueue and ThreadPoolExecutor instead of trying to be overly complicated. I just wanted to let you know it appears to have worked out well

10:10 spariev_: pmap work in slime if run via M-x swank-clojure-project or just M-x slime, only behaving strange in lein swank server

10:10 chouser: cburroughs: great, thanks for the update.

10:11 jcromartie: cool!

10:13 stuartsierra: ~log

10:13 clojurebot: see logs

10:13 stuartsierra: ~logs

10:13 clojurebot: logs is http://clojure-log.n01se.net/

10:13 chouser: jcromartie: I think someone else has done something similar (without the Objective-C aspirations), though I'm not finding it now.

10:16 defn: jcromartie: pharen is awesome lol

10:16 jcromartie: defn: I guess so? Why are you telling me? :P

10:16 rhickey: 'maenadic' - fancy

10:16 stuartsierra: Returning from yesterday; double-argument dispatch with protocols http://paste.lisp.org/+2015

10:16 jcromartie: but yes pharen looks awesome

10:16 stuartsierra: rhickey: is that what we you talking about Tuesday evening?

10:17 defn: defmacro: you posted the link

10:17 err jcromartie you posted the link

10:18 jcromartie: I pasted a link to my own lisp-to-C project, cemerick pasted pharen

10:18 defn: ah, my mistake

10:18 what's the lisp-to-C named?

10:19 cemerick: I wouldn't say awesome...scary is more like it.

10:19 IMO, of course :-)

10:19 defn: cemerick: i think we're all on the same page there

10:19 it's novel and cool though

10:20 cemerick: novel, for sure. Perhaps I'm feeling curmudgenly today.

10:20 defn: i know i am

10:22 chouser: I hadn't considered it before, but ... a PHP backend for cinc might actually be pretty popular.

10:22 * chouser cringes slightly.

10:22 stuartsierra: does PHP have bytecode?

10:22 chouser: beats me

10:24 cemerick: that's the whole point of zend, right? Have a JIT in the background to speed things up?

10:24 jcromartie: I had a friend that tried to convince me that Perl was bytecode-compiled and ran on a VM

10:25 chouser: jcromartie: perl6? :-)

10:25 jcromartie: his argument was that any interpreted language that is parsed into a tree structure and run by an interpreter counts as bytecode and a vm, where the C data structures are "bytecode"

10:25 yeah

10:26 chouser: oh, I see. "compiled" and "vm" *maybe*, but to me bytecode implies serialized.

10:26 jcromartie: http://php.net/manual/en/book.bcompiler.php

10:28 rhickey: stuartsierra: kind of. I think the complex-parts protocol complicates things - it's ok to just have implementation-aware code use :r and :i, and to not try to normalize other numbers as complexes. Also, putting add-number and add-complex into the same protocol implies a closed-ness that doesn't exist - you could instead have adding-long and adding-complex etc protocols, obviously an open set

10:30 stuartsierra: but yes, the fundamental trick is (add anX aY) -> (add-X aY anX)

10:30 chouser: I need to read that, but I did something probably similar for finger trees

10:31 * Raynes can think of 10 thousand uses for clj-apache-http and is happy he moved it to Leiningen. :D

10:32 chouser: appending one tree on another requires different code for each combination of node/deepnode

10:33 rhickey: protocols let you do double-dispatch without the type-intrusion of the visitor pattern

10:34 chouser: chapter 2 is a doozy

10:34 stuartsierra: rhickey: Cool, thanks. I was playing with several ideas at once, that's how complex-parts got in there.

10:34 chouser: rhickey: :-/ yeah. I think it's going to get trimmed back a bit before we're done.

10:34 stuartsierra: And I was thinking that adding-* should be separate protocols.

10:35 rhickey: chouser: I'm sure what-goes-where will be more evident when you have all of your material in hand

10:36 i have to admit the early infix example made me cringe a bit

10:38 chouser: at our current rate for pages-per-section, we'll overshoot our page goal by quite a bit. Hopefully that means will be able to toss out all the least valuable content and end up with something very solid.

10:38 cemerick: rhickey: on the php project page, you mean?

10:38 rhickey: cemerick: no, in Joy of Clojure

10:39 cemerick: oh, right

10:39 lypanov: chouser: do you think i should wait on the js conversion project until you get to 99% c-in-c or should i get into it now in case its needed to shape c-in-c?

10:39 chouser: lypanov: what are your plans for a js conversion project?

10:40 lypanov: chouser: basically, plug clojure via java source gen into gwt.

10:41 Raynes: user> (two + 2) => 4

10:41 :D

10:41 I def'd two as + and unmapped +.

10:41 :>

10:41 spariev_: oh, I have finally fixed my error with pmap - turned out I used old 1.0.0 version of lein-swank, and new 1.1.0 works just fine

10:46 chouser: lypanov: it will be much easier to reach a useful stable state after cinc, but I expect some things could be done now to get there sooner.

10:48 lypanov: for example, it would be interesting to have a maps-and-vectors version of Clojure's compiler analysis tree (AST?)

10:49 if you could build such a thing that rhickey signed off on, then you could start work on code to convert that to java sources, code that you ought to be able to drop in to cinc once it's all done.

10:59 mjt0229: What's the proper type hint for an array? appending a '[]' doesn't appear to work.

11:00 chouser: depends a bit. what type of object is in the array?

11:01 mjt0229: Let's assume its a Java object, not a primitive.

11:01 It's an object defined in a Java library, whose api returns (inexplicably) an array rather than a list.

11:01 chouser: #^objects

11:02 oh. if it's being returned to you, why do you need to hint it?

11:02 mjt0229: I'm binding it in a let form to a name.

11:03 chouser: you only need a hint if you're going to use it in a way that can take advantage of that hint

11:04 angerman: Ohh as we are on the Array thing. That usually has that strange [D... or so look. How much would it break if clojure would internally translate Object[] into the correct type-hint?

11:04 mjt0229: I've set *warn-on-reflection* and my access via aget is reflecting. I think I can restructure the loop so I don't need to use aget.

11:04 yeah, in Java it looks like [LString, I think.

11:06 chouser: mjt0229: 'aget' itself should require reflection. You might need to hint what 'aget' returns.

11:06 mjt0229: ah.

11:07 chouser: "shouldn't"

11:07 mjt0229: that indeed does appear to be where the reflection is occurring, but there wasn't a binding there, so I didn't know how to place a type hint in that form (it's just a few nested calls)

11:07 defn: mmm partition -- mutually exclusive and exhaustive

11:08 chouser: #^String (aget a x) ; should work

11:08 mjt0229: if you're playing with type hints, you might find repl-utils expression-info helpful.

11:09 (expression-info '(let [a #^ints map] (aget a 1))) ;=> {:class int, :primitive? true}

11:09 mjt0229: Cool, I'll take a look.

11:09 chouser: (expression-info '(let [a #^"[Ljava.lang.String;" map] (aget a 1))) ;=> {:class java.lang.Object, :primitive? false}

11:09 mjt0229: So, you can place type hints alongside any method invocation?

11:10 ie, (println #^String (first ["foo" "bar"]))

11:10 that's not a great example, but I'm just trying to show the syntax in a little context

11:11 chouser: yes but with a pile of caveats. :-)

11:11 mjt0229: for what it's worth, I was using a counting loop over the array, but I was able to switch it to a simple list comprehension and get the type hints correct.

11:11 Which has improved the readability of the code, not surprisingly.

11:12 chouser: :-)

11:19 * Raynes wishes he had the cash to buy chouser's book.

11:19 Raynes: I'll probably have to wait until the first of the month for any loose cash. :\

11:22 chouser: Raynes: Manning runs deals occsionally, sometimes as much as half-off. When they tell us they're going to do that, I generally remember to tweet it.

11:22 lypanov: LauJensen: (i speak dutch, so... yeah, irony). man.... my wife won't let me use clojure anymore as your page says it gives 10-25x more "fart" :(

11:22 Raynes: chouser: Cool. I'll follow you.

11:23 * lypanov does the same

11:23 * lypanov can't decide between the two manning books :(

11:24 Raynes: Two?

11:24 LauJensen: hehe

11:24 lypanov: I didn't know that the woman where in control in Holland :)

11:25 lypanov: LauJensen: she vetoed my request for more power.

11:25 LauJensen: haha

11:25 chouser: Raynes: there's also http://tinyurl.com/clojureinaction

11:26 Raynes: Oh dear.

11:26 jcromartie: Clojure Inaction

11:26 lypanov: but inaction only has 3 chaps and joy has 4. so joy is obviously superior.

11:26 jcromartie: sounds demotivating

11:26 lypanov: hehe

11:26 jcromartie: I've had quite a good amount of Clojure inaction lately.

11:27 Raynes: lypanov: Joy also looks like it is going to cover more than the other one.

11:27 lypanov: i'll prob just end up buying both, in action has some neat sounding sections on hadoop.

11:27 Raynes: Such as protocols and types.

11:27 lypanov: Raynes: aye, in action is more practical.

11:28 i usually use such books as ref and bed side reading so for me all depends on writing style. as in, how fast i can read it without interruptions stopping me.

11:28 Raynes: I'll get Joy first, because chouser is awesome, and get Luke and this guys book eventually.

11:29 chouser: I expect "in action" to be larger and have more examples relating to specific kinds of deployments (testing, IDEs, web sites, amazon services)

11:30 Raynes: chouser: Are you trying to accomplish something specific with Joy?

11:31 chouser: "joy" is meant to be more about understanding clojure itself in more detail. not so much how it works internally, but how best to use it and hopefully bring the reader along to be able to think about problems in a more clojurey way.

11:31 * lypanov is always disappointed by books with examples in them as half the time they are out of date by the time he gets around to reading

11:32 lypanov: (also, i'm really picky, and 99% of the time i end up not using the libs that are the most popular)

11:32 Raynes: chouser: Yessir, your book is definitely for me.

11:32 {newbie}: so wich books is more focused in the innerwards of clojure?

11:33 * Raynes does an interactive rebase of clj-oauth to remove the commit where the lib/ directory was added.

11:33 Raynes: Damn people and their fancy lib directories full of jars on github.

11:33 mjt0229: ooh, more clojure books?

11:34 Raynes: Luke's book will be coming out before the rest of them.

11:35 lypanov: Raynes: which is that?

11:35 Raynes: lypanov: It's on apress.

11:35 chouser: {newbie}: I don't know of a book that plans to cover the internals.

11:35 Raynes: http://www.apress.com/book/view/9781430272311

11:35 It's a whole other book.

11:35 chouser: {newbie}: http://java.ociweb.com/mark/clojure/article.html has a lot of detail about the innards of the STM

11:36 lisppaste8: stuartsierra pasted "Automated 2-argument type dispatch with protocols" at http://paste.lisp.org/display/93387

11:36 stuartsierra: Phew!

11:36 I did it!

11:36 chouser: {newbie}: for innards of PersistentVector, try http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/

11:37 {newbie}: chouser: that last link was good

11:37 the previous one ins't very detailed

11:37 thought

11:38 chouser: stuartsierra: whoa

11:38 angerman: interesting. lein swank does not add the classes folder to the classpath

11:38 :/

11:38 {newbie}: here is the deal the compiler/interpreter classes at my univ where optional, and I choose another option so where i'm realy lacking is in hte parsin compilation front

11:39 dysinger: stuartsierra what's needed for rsync for the maven repo ?

11:39 (IE, do we need an rsync server set up )

11:39 do you have an RTFM doc pointer ?

11:39 stuartsierra: dysinger: I think all you need is SSH access and an rsync client on the server

11:40 let me find the link

11:40 dysinger: k

11:40 I know you can rsync with ssh

11:40 but you can also rsync with rsync:// without giving someone a login on your box

11:40 stuartsierra: Here's one post describing what to do: http://vafer.org/blog/20081026142413

11:41 here's the Maven docs: http://maven.apache.org/guides/mini/guide-central-repository-upload.html

11:42 looks like Maven needs a user account set up with their public key

11:42 dysinger: I see

11:42 ok that looks easy enough I'll get it done today

11:42 stuartsierra: great!

11:43 But back to the fun stuff - double dispatch!

11:44 mjt0229: stuartsierra: which version of clojure provides deftype? Is it not in 1.1?

11:46 chouser: mjt0229: master branch from github

11:46 mjt0229: thanks.

11:46 I've got some reading to do, it looks like.

11:47 stuartsierra: I don't know if this is worth the trouble. I just wanted to see if it was possible.

11:47 In theory, I suppose one could extend it to more than 2 arguments, but the mind boggles.

11:47 chouser: stuartsierra: very interesting

11:50 that is indeed very much like what I did (by hand) for app3: http://tinyurl.com/ylx4j3k/finger_tree.clj#LID288

11:50 I'm trying to think if I could use your macros...

11:52 the problem being that I've alrady got protocols with other methods, the double-dispatch is just for one of the methods.

11:52 stuartsierra: Have you rewritten the finger-trees with deftype and defprotocol?

11:53 chouser: oh, yeah, that was an older version.

11:54 and the api for deftype has changed since I converted it over

11:55 http://tinyurl.com/yeh5fgg/finger_tree.clj#LID343

11:55 dabd: it would be nice if the if-let macro let the user refer to the binding in the 'else' part. Is there any reason this is not possible?

11:55 lisppaste8: stuartsierra annotated #93387 "Removed some dead code" at http://paste.lisp.org/display/93387#1

11:56 chouser: dabd: you want to know if it was nil vs. false?

11:56 dabd: chouser: no, I want to use the value of the test in the else part too

11:57 chouser: in the else part, the value of the test could only have been either nil or false.

11:57 stuartsierra: I'm not sure if it works for non-commutative functions.

11:57 At least, you have to be very careful.

11:58 chouser: stuartsierra: ah, app3 is not commutative, so yes the args are sometimes in reverse order and must be handled carefully.

11:59 stuartsierra: I wonder if I can fix that?

12:00 dabd: yes you are right I am misusing the macro. the test should return a boolean and I was trying to make it return a numeric value.

12:00 stuartsierra: yes!

12:01 lisppaste8: stuartsierra annotated #93387 "Fix argument order" at http://paste.lisp.org/display/93387#2

12:02 stuartsierra: That works for non-commutative functions as well.

12:11 You wouldn't want to do this for 3 arguments anyway - you'd need too many methods

12:14 2^3 for two types, 3^3 for three types, 4^3 for four types, ...

12:24 Raynes: Why oh why did this guy have to add his lib directory and all of his project's dependencies to his repo on the initial commit.

12:35 stuartsierra: Because everyone's afraid of Maven.

12:37 Raynes: stuartsierra: I just went through hell trying to remove stuff from the initial commit. Took me 2 hours to figure out how to do it. You do it by looking up the answer on stackoverflow.com.

12:37 :>

12:38 * Raynes is off to find find some Alieve for this headache.

12:42 polypus: what's the deal with AOT compilation and namespaces. i seem to remember somebody in here say something about them having to be at least binary (foo.bar) in order to compile. is that right?

12:43 wilig: technomancy: Ok, I have some working code for swank-clojure that fixes that bug at least in my simple tests.

12:43 mtm: chouser: Congrats on getting the MEAP up; I know it's probably ridiculous to ask, but are there any "coupon codes" for 'The Joy of Clojure' yet?

12:44 technomancy: wilig: wow; great

12:44 can you use read-line in the slime-repl buffer?

12:44 wilig: technomancy: hmm, explain what you mean? sorry, I'm really green.

12:44 * tcrayford finds it amusing that manning use yahoo store

12:46 technomancy: wilig: currently entering (read-line) in the slime-repl hangs it since the I/O streams for that buffer are not hooked up quite right

12:46 stuartsierra: polypus: I think that's correct; namespaces need 2 parts

12:46 technomancy: I think this is related to the bug you were talking about, but I'm not 100% sure

12:46 wilig: ah, let me try

12:46 polypus: stuartsierra: ty

12:47 chouser: mtm: none that I know of -- will tweet as I hear of them.

12:47 wilig: technomancy: Still hangs, let me have a look at it.

12:47 technomancy: wilig: must be something else then... thanks for looking into it!

12:47 what did you end up changing?

12:48 wilig: io.clj right where you said it would be.

12:48 mtm: chouser: no problem, thanks (as an aside I find it amusing that Manning has free shipping for orders > $45; 'The Joy of Clojure' is $44.99) ;-)

12:48 polypus: mtm: same happened to me the other day with snow leopard on amazon. 1 cent off

12:49 wilig: the clojure.contrib.sql tries to call println on the proxied object, but was failing. so I created an interface, and added that to the proxy

12:49 so sql exceptions now get reported correctly.

12:50 polypus: so i ended up buying an ssd to make up the diff :)

12:51 wilig: technomancy: I also rewrote call-on-flush-stream to call-on-write stream and was able to get rid of the scary threading bit. Hopefully it will work for all cases, but I don't know enough to test it rigorously.

12:53 chouser: mtm: one benefit of working with a publisher: I don't have to defend such decisions. :-)

12:54 mtm: chouser: I would have gladly overpaid by $0.02, it's just the generous kind of guy I am

12:55 chouser: I didn't even know what they were going to charge until it showed up on their site.

12:55 technomancy: chouser: they let you work in your own document format?

12:55 I've heard of authors writing for manning in the past that had to use MS Word; that shocked me.

12:55 tcrayford: chouser: do you want feedback on ze book?

12:55 mtm: well, the book is ordered; now, get cracking on the next chapter! :-D

12:56 chouser: technomancy: I guess they've used Word in the past, but now they've also got a docbook-like format. So we've built a toolchain that produces that xml.

12:57 technomancy: nice

12:57 chouser: mtm: yessir!

12:57 technomancy: I guess the prags use docbook too; makes sense

12:57 chouser: tcrayford: of course!

12:57 tcrayford: I'm finding one of the paragraphs annoyingly written (end of page 8)

12:57 the one talking about concurrency and idioms

12:58 * lypanov should grab it and give feedbackz 2, he's good at that

12:59 chouser: tcrayford: noted

13:00 tcrayford: I can rewrite it if you want

13:01 chouser: heh... Well the first couple chapters are already getting major rework. Thanks anyway.

13:01 tcrayford: aye

13:01 mtm: chouser: do you want minor editorial comments (grammar, case, etc.) posted to the author forum, sent by email, or noted here?

13:01 * gravity will try and submit some feedback on chapter 1 to manning's forum tonight

13:02 chouser: mtm: the forum is probably the best, though I think the whole book will go through a couple more rounds of review an editing for that kind of error before it goes to print.

13:02 review and editing

13:03 all comments are welcome

13:03 ...especially comments that contradict other comments, because then we can just do whatever we want. ;-)

13:05 37% off with code "j1337"

13:07 * tcrayford might end up being a technical book editor later in life

13:08 technomancy: "Take this REPL, brother, and may it serve you well." always makes me feel like coding is an adventure.

13:08 tcrayford: it feels like the start of a choose your own adventure book

13:09 technomancy: or like you just got the Master Sword in Zelda

13:09 Mefached: Lisp is an adventure

13:10 It's an interesting language, unlike C-likes

13:10 tcrayford: I'd dispute the idea that interesting programming comes from the language

13:10 Its like saying interesting gardening comes from a good lawnmower

13:11 gregh: there could still be an interesting lawnmower, though

13:12 qbg: tcrayford: Then Lisp is like having a mecha for a lawnmower.

13:12 hiredman: the language is not just a single tool

13:12 it is a set of tools

13:13 tcrayford: and what you think in

13:13 and a religion

13:13 hiredman: anyone who actual works with tools can tell you the end product relies a lot on the tools used

13:14 e.g. a square cut with a hand saw is harder than with a chop saw

13:14 and there are also techniques and opinions too

13:15 the bookkeeper were I work is into woodworking, he would rather die than use a metal fastener of any kind

13:15 just does all kinds of joints

13:16 chouser: and a lisp is different from many other language types because it gives you a wider range to tool-making tools

13:16 tcrayford: Which *can* be more interesting

13:18 Raynes: tcrayford: That gardening metaphor needs work. :\

13:18 tcrayford: yeah :(

13:19 Raynes: Besides that, there are some really cool lawn mowers out there. :>

13:19 tcrayford: was kinda implying that lisp was a really cool lawn mower

13:20 Raynes: Indeed. Lisp would be a lawnmower transformer.

13:20 Optimus Macro.

13:27 LauJensen1: Raynes: Are you what is commonly referred to as a 'redneck' ?

13:27 Raynes: LauJensen1: No. My family is from the north. I hardly even have an accent.

13:28 LauJensen1: Ok

13:29 wilig: technomancy: Trying to add read-line support to swank-clojure, but there is nothing currently as far as I can tell. Here's to mucking things you don't understand!

13:29 technomancy: wilig: that's been my entire strategy so far with swank-clojure

13:29 apparently it used to work (over a year ago)

13:30 wilig: lol

13:30 hmm, troubling. then I just don't understand what's going on it here. wish I had the working version.

13:30 *in here

13:32 woot! just got it to fail where I expected it to. on the first try no less. progress. :-)

13:32 technomancy: I'm cheering for you

13:33 wilig: I'm so in the blind. Wondering what the heck #^ means.

13:34 technomancy: it's a type hint for the following form

13:34 Raynes: technomancy: Thanks for telling me about interactive rebasing. I never would have thought to get rid of the lib files from history. I'm new to gi.

13:34 wilig: ah

13:34 Raynes: git*

13:35 technomancy: Raynes: see also: http://alexvollmer.com/index.php/2009/01/18/meet-magit/

13:35 wilig: so now to impersonate a bufferedreader

13:37 technomancy: wilig: fyi: swank-clojure uses a lot more type hints than necessary

13:37 don't feel the need to be that explicit in your own additions

13:37 wilig: great! and I plan to add a test or three.

13:39 technomancy: is there some significance to returning {:tag StringWriter}? Does :tag have some meaning I'm unaware of?

13:41 technomancy: it's not actually a return value; it tells the compiler that the function is going to return an object of a certain type

13:41 the return value is the form immediately preceeding that

13:41 if the type hints are getting in the way don't be shy about ripping them out

13:41 wilig: Ah, now that is enlightening

13:42 will do, just nice to understand what the heck it means.

13:42 technomancy: I highly doubt they were added only to performance hotspots as they should be; they seem to be sprinkled liberally all over the place

13:43 hiredman: it's hard to imagine slime having performance hotspots

13:43 technomancy: that too =)

13:43 chouser: I was just about to say something to that effect.

13:44 technomancy: swank-clojure is a prime example of "my first clojure project" that was just too useful not to become widely used. every language has 'em. (cough *rdoc*)

13:46 not to knock jochu; I'm really grateful for his work

13:47 hiredman: he is apparently writing another reader

13:48 technomancy: isn't that joshuachoi?

13:49 hiredman: ok, there was a j and a ch

13:50 kotarak: Wasn't Chousuke writing something up about a reader? He has at least a working syntax-quote in Clojure.

13:50 bpattison: I'm calling a Java method from Clojure that a JNI wrapper to a C function. It takes a single argument, which is an array of double of size 1. I'm assuming that's a JNI thing. If I invoke the routine in Java it works fine, but when I try to invoke it in Clojure is get exception aoubt boxArgs

13:50 at java.lang.Class.cast(Class.java:2990)

13:50 at clojure.lang.Reflector.boxArg(Reflector.java:364)

13:50 at clojure.lang.Reflector.boxArgs(Reflector.java:396)

13:51 any ideas to try?

13:51 hiredman: that is not the whole exception, feel free to pastebin it somewhere

13:53 Chousuke: kotarak: Actually I ran into so many corner cases in the macro version that I decided to take the same "reader magic" approach as the current reader does.

13:54 bpattison: here's the complete exception http://pastebin.com/m6fe684dd

13:54 but I'm not sure its all that helpful

13:59 chouser: bpattison: what the your line of clojure code look like that's doing the interop call?

14:02 Mefached: will someone send me their ~/.clj_completions ? I can't get this script from the wiki to generate it. easyegoism@gmail.com

14:04 Nevermind, I got it to work

14:05 bpattison: chouser: (let [minv (make-array Double/TYPE 1)] (.GetMinimum band minv)) where band is a Java JNI class

14:09 chouser: bpattison: class cast error suggests that .GetMinimum is expecting a different type than what its getting. You're clearly giving it a array of primitive doubles, so perhaps its expecting something else.

14:10 bpattison: does your version of clojure have double-array ?

14:11 if you use that instead of make-array, and also type hint 'band' if it isn't already, the exception should show you the name of the class it's actually expecting.

14:11 bpattison: chouser: yep, I'm running 1.1.0-alpha -- should upgrade to the new release -- but here's the java code that works Double[] min = new Double[1]; poBand.GetMinimum(min);

14:11 chouser: ah!

14:11 that's an array of boxed (not primitive) doubles

14:12 try just Double instead of Double/TYPE in your make-array

14:13 bpattison: chouser: woo hoo. that worked like a champ -- would have never figured that one out

14:14 cemerick: cgrand: I've been pondering http://groups.google.com/group/enlive-clj/browse_frm/thread/f9a9f280110d6d2f and it looks like the "functional" approach you outline there will work for us. Does that remain the ideal approach?

14:17 Raynes: clj-oauth is now on zeh clojars!

14:17 One more project to go.

14:17 * Raynes procrastinates for 13 hours.

14:18 LauJensen: How many people would dred using a library which required you to add 5 items to your classpath to work on/with it ?

14:18 cemerick: LauJensen: that's why some of us are beating the maven horse :-)

14:19 konr: does it really matter if I compile or eval my code (slime-eval-defun vs slime-compile-defun) while developing it?

14:20 Chousuke: konr: they probably do the same thing.

14:20 since Clojure has no interpreter.

14:20 technomancy: konr: the distinction is leftover from common lisp; in clojure they should have the same effect

14:22 tcrayford: chouser: liking the infix example at the start of your book. Had never thought about doing that

14:23 chouser: heh. great. :-)

14:25 tcrayford: though maybe put the operators in proper BDMAS order [/ * + -]

14:25 cgrand: cemerick: yep, that's still the way I promote

14:25 qbg: If I have a loop that concat's and next's on a seq but the total length of the seq never grows large, am I at risk of running out of memory?

14:26 Raynes: LauJensen: That is exactly why I'm moving these projects to leiningen. ;)

14:27 LauJensen: Raynes: I'm not talking about when compiled, but about when you fork it etc to hack on it

14:27 Raynes: LauJensen: Still doesn't really matter. If it's Leiningen, and you use swank-clojure-project, you never have to deal with those 5 items directly.

14:27 chouser: tcrayford: I guess that would be [- + * /]

14:27 arohner: qbg: probably not. the real determination of whether you run out of memory is whether you hold the head somewhere

14:28 tcrayford: technomancy: is it just me, or does disconnecting from swank-clojure mean you can't reconnect?

14:28 chouser: the way you've defined it there, yes

14:28 cgrand: cemerick: I'll wrote some examples as soon as I have more time

14:28 qbg: Good, then I should be able to TCO my DSL I'm writing.

14:29 Raynes: LauJensen: But I suppose that applies to Maven as well.

14:30 cemerick: cgrand: The alternative where one (for example) defines specific element classes that are going to get plucked and dropped into matching slots in a parent template is intriguing. I suspect something like this will be needed eventually -- I worry about managing that composition manually.

14:31 Raynes: LauJensen: If I don't reply to your next message, it's not because I'm ignoring you. It's because I wont be here in about 13 seconds.

14:31 LauJensen: Ok- thanks for sharing your opinion

14:33 polypus: i have a list of namespace names each of which contains a single (def specs ...). i'd like to get a list containing the values of each specs. what's the best way?

14:36 in file a i have (ns a) (def specs ...) in file b the same. i have '[a b c ...]. i'd like a list of specs by going (map f '[a b...])

14:36 stuartsierra: (map (fn [namespace] (ns-resolve namespace "specs") list-of-names))

14:36 or something like that

14:37 polypus: ty, i'll have a look

14:37 stuartsierra: (map (fn [ns-symbol] (ns-resolve ns-symbol 'specs)) list-of-symbols)

14:38 polypus: stuart: thx that's it

14:39 ordnungswidrig: oauth? nice!

14:44 Mefached: I can't get M-x slime to bring up Clojure in Emacs. I followed the instructions at http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started and my .emacs is http://pastebin.com/m6e10a365

14:45 arohner: I have a big nested data structure (maps and vectors). I want to run a function f on every child node, and return the "updated" structure. Is there a better function to use than for + update-in?

14:45 I want something that does a walk + update-in

14:47 stuartsierra: arohner: clojure.walk does that

14:48 arohner: stuartsierra: interesting. though that seems like a big hammer, and I'd have to distinguish between the nodes I want to change and the nodes I don't

14:48 stuartsierra: The function you pass to pre/postwalk has to have a conditional then

14:49 You could also copy the style of walk with more conditions to avoid walking the nodes you don't need to change.

14:51 arohner: hrm. in my ideal world, I want a function that I can pass some kind of "x-path" like spec and a function. distinguishing between nodes seems messy.

14:51 (update-in-many [:a :b * :foo] f)

14:51 stuartsierra: arohner: that would be cool, but I don't think it exists. clojure.zip might help

14:52 arohner: I might write it...

14:53 stuartsierra: thanks for the help

14:53 hiredman: that soulds awful familiar

14:53 sounds

14:53 I think there was talking about some kind of wildcard update-in

14:55 I think it floundered on the "how to represent wildcards" issue

14:55 arohner: does clojure.zip handle maps?

14:55 hiredman: * is a symbol that could resolve to something, :* could be a key

14:56 arohner: it can

14:57 I would be surprised if there where by default

14:58 the "mapping" of a map to a zipper has no, uh, default? immediate? obviouse solution?

14:58 it depends on the domain of the maps

14:58 like xml-zip

14:58 ah

14:59 the "mapping" of a map to a zipper has no obvious domain

15:00 arohner: k. I'll make this work the ugly way, then see if I can come up with an update-in-many that makes sense

15:03 stuartsierra: rhickey: When/how will protocols take over clojure.core?

15:04 ordnungswidrig: take over?

15:04 arohner: ordnungswidrig: the whole point of rhickey building protocols was to rewrite the clojure compiler / core in terms of them

15:05 lypanov: chouser: should i use the manning forum for stylistic corrections? (aka, smoother reading)

15:06 chouser: lypanov: sure, thanks!

15:06 konr: wow @ http://bc.tech.coop/blog/081120.html

15:06 technomancy: konr: stuart halloway added that to swank-clojure so it's built-in now

15:07 rhickey: stuartsierra: after we get enough feedback on stand-alone implementations of protocols, we can look at moving some of the core abstractions to protocols. But - we need to avoid breaking changes for Java (and Clojure) clients extending the current abstraction interfaces. I think there will be a new protocol (with its new interface) and extension to existing interface

15:08 stuartsierra: rhickey: So you don't plan on major breaking changes in, say, 2010?

15:08 rhickey: did I say that?

15:08 lpetit: hello, there

15:08 rhickey: lpetit: hi

15:09 stuartsierra: it depends on how far we get. but it would be with a major (2.0-ish) release

15:09 hiredman: the main effect on core.clj seems like it mostly be changing tests for implementing certain interfaces to tests for protocols

15:09 stuartsierra: rhickey: This is for purposes of the book.

15:10 rhickey: stuartsierra: which book?

15:10 stuartsierra: rhickey: Ok, 2.0, that's what I wanted to know.

15:10 rhickey: the one that I am theoretically writing with Luke.

15:10 rhickey: ah

15:11 stuartsierra: hiredman: It's more than that. Imagine if 'map' is a protocol. Then you can implement a 'map' specific to strings, arrays, maps, etcetera.

15:11 rhickey: arohner: a broader goal is really to support, in Clojure, the kinds of things I needed to do to write Clojure itself, such things being useful in general

15:12 Raynes: Protocols are awesome. I missed typeclasses.

15:13 rhickey: heh

15:13 hiredman: stuartsierra: I don't believe map would be a protocol

15:14 seq would be a protocol, and map operates on seqs

15:15 rhickey: there would be a protocol for the map data abstraction

15:15 hiredman: rhickey: a protocol for map the noun, yes?

15:16 rhickey: hiredman: right, but map the verb would still be a fn on seqs

15:17 there could be a polymorphic mapping fn, but it wouldn't be map, that contract specifies seqs, laziness etc. It can't start returning Strings when given Strings

15:17 hiredman: making the core seq processing functions into extendable protocols (leaving out the implicit seq transformation) would completely change the language

15:18 rhickey: hiredman: not really, the polymorphism is already there for most of those. While there are some manually-handled types, I haven't gotten a request for a new manual handler in over a year

15:19 it is just a move from interfaces for polymorphism to protocols

15:19 hiredman: or maybe I misunderstood you

15:19 you mean map/filter etc?

15:19 lpetit: rhickey: just sent my donation through paypal. No pb to add my name on the donators page

15:19 hiredman: rhickey: the sequence processing functions are at the core of the user experience of the language

15:19 rhickey: ys

15:19 rhickey: lpetit: thanks!

15:20 lpetit: rhickey: now would you go to ccw's "donate" page and submit the form ? :-p

15:20 rhickey: just joking, of course :)

15:20 * rhickey needs to try ccw

15:21 rhickey: I often get asked about Eclipse support

15:21 Raynes: lpetit: You need to add auto-indentation already. ;)

15:21 lpetit: Raynes: ok ok, I know that, and you're right. Don't remember, though : "help welcome" :-)

15:22 Raynes: :p

15:22 lpetit: Raynes: I'm currently working on a port of paredit for ccw. Already have been able to code, on my free time, open-round, open-curly, open-square

15:22 Raynes: Neato.

15:24 lpetit: rhickey: I don't publish news about ccw releases each time I make one on the ml. I will certainly do when I feel a gap has been filled in some areas (auto-indentation, paredit, faster code completion). Since I know your time is counted, I invite you to only spare it on ccw when you see news about it from me in the ml.

15:24 stuartsierra: rhickey: what about things like first/second? Could there be an "ordinals" protocol?

15:25 rhickey: I think I have a bias against Eclipse - I've never liked it for Java

15:25 stuartsierra: other than the one for nth?

15:26 stuartsierra: rhickey: Maybe that would be enough. I was thinking about tuples

15:26 rhickey: I'd certainly concentrate on replacing the existing interfaces before new inventions

15:26 stuartsierra: ok, fair enough

15:26 rhickey: stuartsierra: tuples are specialized vectors

15:26 would satisfy same set of protocols

15:26 stuartsierra: ok

15:27 So basically, anything currently implemented as RT/foo or an interface is a good candidate for a protocol.

15:27 * rhickey writing code in the pre-cambrian section of core.clj...

15:28 rhickey: stuartsierra: interfaces first

15:28 hiredman: anything in a .java file

15:28 stuartsierra: ok

15:28 thansk

15:29 rhickey: 42 interfaces in clojure.lang

15:29 stuartsierra: wow, I didn't realize it was that many

15:29 rhickey: Clojure really is abstraction-based

15:30 * rhickey does OO so you don't have to :)

15:30 stuartsierra: I count 47 by grep.

15:31 {newbie}: I frear that clojure is becoming an OO language

15:31 _fogus: rhickey: pre-cambrian == pre-defmacro?

15:31 stuartsierra: {newbie}: not at all; it's becoming something better

15:31 {newbie}: ppl will start writing java in clojure

15:31 stuartsierra: they try to do that anyway

15:31 rhickey: {newbie}: not by any common definition of OO

15:31 Chousuke: Yeah, I think we'll see an explosion of inappropriate deftype use at first :/

15:32 {newbie}: rhickey: but the new deftype looks alot like an object

15:32 Chousuke: until people figure out how it really should be used.

15:32 rhickey: except immutable

15:32 and no concrete derivation

15:32 no statics

15:32 {newbie}: okay

15:32 rhickey: no ctor bodies

15:32 etc

15:33 hiredman: general usage deftype should be without methods all together, yes?

15:33 stuartsierra: yes

15:33 Raynes: Somebody should write a blog post on how it should be used, along with protocols.

15:33 rhickey: hiredman: in-place protocol impls are fine

15:34 whenever the type defininer knows they need to support a protocol, that will be fastest

15:34 lypanov: chouser: wonderful book. inaction lost me on the 3rd page.

15:34 rhickey: extend when you are not the type owner and can't convince them :)

15:34 * lypanov buys

15:35 stuartsierra: rhickey: Really? deftype with protocol impl's inlined is faster?

15:35 ordnungswidrig: *lol* googling for "rainbow emacs" gives me: http://tinypic.com/view.php?pic=2urqmgl&s=6

15:35 rhickey: stuartsierra: yes

15:35 stuartsierra: interesting

15:35 the-kenny: ordnungswidrig: Looks like the url isn't working

15:35 stuartsierra: worked for em

15:36 ordnungswidrig: the-kenny: works for me?!

15:36 the-kenny: ordnungswidrig: Ah, sorry. Bug in my weechat plugin for detecting urls

15:36 lypanov: rhickey: silly random q, do you think clojure refactoring tools could ever rock?

15:36 ordnungswidrig: anyway, does anybody know how to _get_ emacs rainbow parens?

15:37 rhickey: lypanov: some refactorings, yes. Unlike a lot of dynlangs, in a Clojure ns every name has only one mapping, so rename can work. I think IntelliJ already does this well

15:38 stuartsierra: rhickey: by the way, did you see my generalized 2-arg-dispatch-protocol macro?

15:38 rhickey: stuartsierra: yes - very cool!

15:38 hiredman: ordnungswidrig: http://delicious.com/search?p=rainbow&chk=&context=userposts|clojurebot&fr=del_icio_us&lc=0

15:38 stuartsierra: rhickey: thanks

15:39 lypanov: rhickey: (one of the first things that made me even look at clojure was the fact that you noted that you used idea)

15:39 lpetit: stuartsierra: where is it please ?

15:40 ordnungswidrig: hiredman: thanks. would you mind to update the second link on del? The final period brakes the url

15:40 stuartsierra: lpetit: http://paste.lisp.org/+2023/1

15:41 lpetit: rhickey: a correct "rename" refactoring would have to know about aliases, wouldn't it ?

15:41 rhickey: lpetit: yes

15:41 but doable

15:41 lpetit: rhickey: so not so easy to make it bullet proof. aliases could be created under the hood via macros ..

15:42 rhickey: lpetit: right, macros can do things no static analysis can ever see

15:42 lypanov: it could still warn on textual matches.

15:43 (with heuristics)

15:43 lpetit: sure, but my point is, it will never allow the same degree of confidence java refactoring tools provide, and thus, I doubt one will use it as extensively as e.g. with java, where aggressive refactoring is quite usual

15:44 lypanov: i've never worked on a java codebase that didn't require some level of understanding of implication when doing refactors.

15:45 * stuartsierra refactors with sed

15:45 lpetit: stuartsierra: I was getting confused by the name defdouble, and then the example on numbers :-)

15:45 stuartsierra: oh yeah, hadn't thought of that

15:45 Didn't know what to call it, really.

15:46 defprotocol2? defdoubleprotocol? def-2arg-generic?

15:46 lpetit: lypanov: when seeing a new codebase, it's really common for me to to rename refactorings as I read the code, with total confidence, improving the codebase by the way (at least I hope so! :-) )

15:47 Raynes: stuartsierra: defstuartsierrawroteaneatdoubleargdispatchprotocolmacro

15:47 lpetit: stuartsierra: defbiproto :-p

15:49 stuartsierra: defbi

15:49 addbi, extendbi

15:49 Raynes: Is there any information anywhere that explains when deftype/defprotocol should be used, and why?

15:49 lpetit: is it not too connoted ?

15:49 stuartsierra: there's some notes on the assembly wiki

15:50 lpetit: that was a joke, mostly

15:50 lpetit: ok, so it's like in French :)

15:50 Raynes: Not what I'm really aiming at.

15:51 rhickey: Raynes: want to write a fn like seq - use a protocol

15:51 Raynes: Nobody has really written any real world examples yet. Of course, chouser will be doing so in his book.

15:51 rhickey: want to use defstruct - use deftype

15:51 stuartsierra: I wrote some conceptual stuff; at http://stuartsierra.com/2009/12/14/objects-are-not-adts

15:52 lpetit: stuartsierra: could it be even more generalized to an arbitrary number of n first args dispatch ?N

15:53 stuartsierra: lpetit: I thought about that, and my mind boggled.

15:53 lypanov: lpetit: i work in web world. where code references eg js / html. or custom sql. or whatever.

15:53 stuartsierra: Just think, for 3-arg dispatch on N types you need N^3 methods.

15:54 lpetit: stuartsierra: multimethods use :default for that, no ?

15:54 rhickey: stuartsierra: don't solve problems you don't have

15:54 lpetit: arg, no, no default impl for protocols so far

15:54 stuartsierra: :)

15:54 lpetit: rhickey: just brainstorming :)

15:54 rhickey: lpetit: Object works as a default for all but nil

15:54 lpetit: rhickey: oh yes, remember now, thx

15:55 stuartsierra: And I couldn't think of a case where you would actually *need* 3-argument dispatch.

15:55 rhickey: and you can extend protocols to nil

15:55 polypus: btw, to anybody reading stuartsierra's post. liskov did a talk at oopsla recently which you can view at infoq

15:56 stuartsierra: polypus: got a link?

15:56 polypus: http://www.infoq.com/presentations/liskov-power-of-abstraction

15:56 * lpetit will now stop musing on 3-argument dispatch protocols and try work on ccw instead :)

15:56 stuartsierra: polypus: thanks

15:56 lpetit: lypanov: don't understand

15:56 polypus: ss: np

15:59 stuartsierra: polypus: added link to the post

16:01 polypus: cool

16:02 lypanov: lpetit: sorry, busy here. point was, i've never worked on a project before in which i could reliably do refactors without knowing something. but sounds wonderful ;)

16:04 lpetit: lypanov: ok, sorry, had switched subject in the mean time :)

16:11 arohner: lisppaste8: url

16:11 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

16:13 arohner pasted "what do you think of update-in-many?" at http://paste.lisp.org/display/93406

16:13 arohner: I think this is pretty cool.

16:14 stuartsierra: nice

16:14 loses some type information, e.g. vectors become seqs

16:14 arohner: oh right. I can add an into

16:14 stuartsierra: just be careful with lists - they conj backwards

16:17 arohner: that sounds like another function

16:17 type-preserving map

16:17 stuartsierra: Sean Devlin posted "same" on the list, but that's a heavyweight version.

16:18 You only need a handful of tests - clojure.walk shows which ones

16:18 chouser: hm, maybe just a fn that does (into (empty ...)), but reverses the result if its a list

16:18 stuartsierra: that ... should ... work

16:19 If you don't have to handle MapEntry's

16:20 (let [x (into (empty y))] (if (list? x) (reverse x) x))

16:21 hiredman: or just switch to cons if it is a list

16:21 chouser: ,(class (cons 1 '(2 3)))

16:21 clojurebot: clojure.lang.Cons

16:21 chouser: ,(class (empty (cons 1 '(2 3))))

16:21 clojurebot: clojure.lang.PersistentList$EmptyList

16:21 chouser: huh

16:21 stuartsierra: cons makes seqs, not lists

16:21 hiredman: ,(binding [conj cons] (into () '(1 2 3)))

16:21 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer

16:22 hiredman: gar

16:22 ,(binding [conj (fn [a b] (cons b a))] (into () '(1 2 3)))

16:22 clojurebot: (3 2 1)

16:22 hiredman: :|

16:22 arohner: stuartsierra: do you have a hint on where to find 'same'? google is failing me

16:22 hiredman: wait

16:22 hmm

16:23 anyway, I just hate to see that reverse

16:23 stuartsierra: arohner: it was posted to clojure-dev

16:23 chouser: stuartsierra: well, cons makes Cons', but apparently an empty Cons is a EmptyList. :-)

16:24 technomancy: any chance we could get dynamic binding enabled on a whitelist basis rather than for all namespaces starting with "clojure"?

16:24 arohner: oh right, I remember this thread

16:24 hiredman: ,(isa? clojure.lang.Cons java.util.List)

16:24 clojurebot: true

16:24 technomancy: is that something for which I should draw up a patch?

16:24 sorry--*direct* binding

16:25 stuartsierra: I thought direct binding was enabled everywhere unless you specifically disabled it?

16:25 hiredman: :(

16:25 technomancy: stuartsierra: from a usage perspective it's enabled everywhere for vars that point to fns in namespaces that start with clojure

16:26 but there's no way to turn it off to, say, rebind clojure.test/test-var

16:26 which is a problem

16:26 less problematically, there's no way to turn it *on* for namespaces in which you want it (other than naming your namespace "clojure-$FOO")

16:26 ~ticket #246

16:26 clojurebot: {:url http://tinyurl.com/ybzjj4e, :summary "direct binding inhibits clojure.test functionality", :status :new, :priority :normal, :created-on "2010-01-14T00:35:44+00:00"}

16:27 hiredman: I would rather have opt in than opt out

16:27 stuartsierra: I see

16:27 technomancy: definitely

16:27 stuartsierra: I thought there was a call-site metadata param to turn off direct binding

16:28 hiredman: really?

16:28 technomancy: oh, maybe I'm missing something

16:28 that would certainly help

16:28 I was just looking in the compiler where isDirect was set

16:28 hiredman: it would be great, if someone who knows about direct binding could write something up on the curret state of same

16:28 rhickey: technomancy: is test-var designed to be rebound?

16:29 ordnungswidrig: What is the best practice for unit tests? I have a separat .clj file which declares the test in the same ns. But now after load-file the files seem to fight for the ns.

16:29 technomancy: rhickey: it's not specifically, though clojure.test/report is

16:29 the ns docstring for clojure.test suggests rebinding it

16:29 stuartsierra: clojure.test/report has {:dynamic true} metadata

16:30 rhickey: technomancy: then it is designed to be rebound and can be declared :dynamic true

16:30 hiredman: hmm

16:30 rhickey: there will be other knobs

16:30 technomancy: here's the situation I'm in though: we have some tests that hit the network, and we'd like to skip them for normal test runs and have them be opt-in

16:30 rhickey: TBD

16:31 technomancy: if we could rebind test-var, it's easy

16:32 direct binding in clojure.core gets you real measurable production performance increase. direct binding in clojure.test gets you faster tests, which is nice, but in many cases not worth the loss of dynamism.

16:33 in our case it gives us much slower tests since we no longer have a way of switching off the tests involving network access

16:34 lisppaste8: lpetit pasted "reinventing the wheel ?" at http://paste.lisp.org/display/93408

16:34 rhickey: technomancy: so the question becomes, should you get that feature by runtime-patching test yourself or adding the toggle capability you want ,to clojure.test

16:34 lpetit: Am I reinventing the wheel with this function ?

16:34 technomancy: rhickey: I just think a whitelist approach to direct binding would be wise

16:35 rhickey: technomancy: who owns the whitelist?

16:35 technomancy: rhickey: since it will now be enabled in things like clojuresque, clojure-http-client, clojure-jna, etc. without the approval of the authors of those libs

16:35 rhickey: a better approach would be to use ns-level metadata, but currently ticket #130 means that won't work with AOT'd namespaces. =\

16:35 lisppaste8: arohner pasted "map-same" at http://paste.lisp.org/display/93409

16:35 ordnungswidrig: lpetit: how does startslike differ from startsWith?

16:35 technomancy: rhickey: I think even a whitelist that's hardcoded into Compiler.java would work for the present

16:36 until #130 is resolved

16:36 lpetit: ordnungswidrig: startsWith implies a full match on the arg, look :

16:36 ,(.startsWith "b" "bar")

16:36 clojurebot: false

16:36 arohner: interestingly, map-same resolves my need for map-keys and map-vals

16:36 lpetit: where (starts-like "b" "bar") returns true

16:36 rhickey: technomancy: I'm not enamored of the whitelist idea, one persons whitelist might not correspond to another's

16:37 Chousuke: ,(.startsWith "bar" "b")

16:37 clojurebot: true

16:37 ordnungswidrig: lpetit: hmm, isn't it simply flip . .startsWith ?

16:37 rhickey: technomancy: but my question still stands - isn't this toggle capability a missing feature of test?

16:37 lpetit: hmmm

16:37 ordnungswidrig: lpetit: say, #(.startsWith %1 %2) ?

16:38 lpetit: ,(.startsWith "bar" "bartoldi")

16:38 clojurebot: false

16:38 ordnungswidrig: lpetit: uhm, #(.startsWith %2 %1) I mean

16:38 technomancy: rhickey: sure; I've considered cooking up a patch to clojure.test to implement it there, but I wanted to try it out for a while in our own project to see how it works in practice first.

16:38 lpetit: where (starts-like "bartoldi" "bar") returns true

16:38 Chousuke: ,(.startsWith "bartoldi" "bar")

16:38 clojurebot: true

16:38 technomancy: it's certainly not a feature that's too specific to our project

16:38 Chousuke: again, isn't it just the argument order? :)

16:38 lpetit: yes, but I don't want to know how to order the arguments !

16:39 Chousuke: so does (starts-like "bar" "bartoldi") also return true? :/

16:39 arohner: lpetit: so why not sort by length?

16:40 ordnungswidrig: arohner: good point!

16:40 lpetit: Chousuke: sure. I need to go to sleep, or tomorrow I'll have to recode everything I'm doing tonight :-)

16:40 technomancy: I'm really just advocating using direct binding more sparingly for now until it's seen more use and the implications are better-understood.

16:41 rhickey: I figured this note in the code was an indication that you felt the same way: //todo - more specific criteria for binding these

16:41 =)

16:42 rhickey: technomancy: yes, and direct binding is on in order to flush out use cases like yours. In the absence of knobs, it's easiest to turn it off. But ther eis one knob now, :dynamic true

16:42 ordnungswidrig: lpetit: so "bar" "boo" will also return true? Then its a simple equals on the first letter?

16:42 rhickey: I'm not going to rush to whitelists

16:42 arohner: rhickey: how would you turn off direct binding? re-def'ing?

16:43 technomancy: ok, I guess I can do that with a re-def inside a with-ns call

16:43 rhickey: arohner: could be any of: build flags, ns attributes, declarations, whitelists etc

16:43 arohner: I mean now, in the clojure.test case

16:43 technomancy: assuming using vary-meta to add :dynamic won't work since once it's compiled it's too late

16:44 lpetit: No, I missed a test case : inverting the args will not work for (starts-like "bar and foo" "bar") (which should return true) :

16:44 ,(.startsWith "bar" "bar and foo")

16:44 clojurebot: false

16:44 rhickey: technomancy: you realize the kind ofthing you are doing is subject to random breakage of other things?

16:44 technomancy: rhickey: well in this case I still call the old version of test-var. I just check a predicate first.

16:45 so the chance for breakage is pretty slim

16:45 If I were rebinding it to a totally new function that didn't reference the old, then I'd be more worried

16:45 rhickey: technomancy: until someone else does the same thing

16:45 technomancy: sure

16:45 I do think this would be better implemented in clojure.test

16:45 rhickey: right

16:45 technomancy: I'd just like to flush it out in my own code first

16:46 rhickey: :dynamic true

16:46 technomancy: yep, will give that a go. thanks.

16:47 rhickey: technomancy: I'm going to try to hold out on turning off dynamic binding in an effort yo flush out more cases like yours, then probably disable until knobs are in place

16:47 er, direct binding

16:48 technomancy: sounds good. right after a release _is_ a good time for that kind of thing.

16:48 and for the record I like the idea of basing it off ns-level metadata a lot better than a whitelist, it's just not feasible given the AOT-ns-metadata bug right now.

16:50 I'll close out that ticket then.

16:57 Mefached: http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Installing_clojure.contrib I built clojure-contrib with ant, but I don't understand what the next line is telling me to do.

16:58 tcrayford: you need to build it with a command line option that has a path to clojure.jar

16:59 oops

16:59 ignore that

16:59 the bit after that is to do with actually launching clojure

16:59 Mefached: I run Clojure in Emacs, not from a command line

17:00 tcrayford: with swank-clojure?

17:00 Mefached: Yes, I believe so

17:00 tcrayford: just change to a directory that's setup right and launch it then (you want your source code in ./src/ and your tests under /test/

17:01 you can ignore the stuff about startup scripts, they aren't needed if you're launching from emacs (or using lein)

17:02 Mefached: OK

17:03 tcrayford: and that article is kinda old/outdated

17:04 check out the readme for swank-clojure on github

17:19 lisppaste8: lpetit annotated #93408 "completed, and now, reinventing the wheel, or not ?" at http://paste.lisp.org/display/93408#1

17:20 Qvintvs: how can I change a seq of chars to a string? ie, (\a \b \c) -> "abc"

17:20 lpetit: so, reinventing a function in java, core or contrib ?

17:20 hiredman: Qvintvs: apply str

17:21 Qvintvs: hiredman: thank you

17:22 chouser: lpetit: there is subs for .substring

17:23 lpetit: (doc subs)

17:23 clojurebot: "([s start] [s start end]); Returns the substring of s beginning at start inclusive, and ending at end (defaults to length of string), exclusive."

17:24 chouser: I don't know of an existing fn that does exactly what you've got there.

17:24 lpetit: chouser: ok, so more java independent.

17:25 chouser: I need this for my parser : brute force lookahead, without having to bother whether the string I'm parsing abruptly finishes without knowing if the match is exact. In doubt, say it matches.

17:25 chouser: also saves you from having to hint to avoid reflection, as would 'count' instead of .length

17:25 technomancy: would it be cool if subs counted negative offsets from the end of the string?

17:25 I got spoiled by that in Ruby and Elisp

17:26 chouser: python does negative offsets like that too -- liked it in every language that had it.

17:26 but nothing in clojure does currently, I think?

17:26 technomancy: I patched up subs to do it at one point

17:26 can't remember if I submitted a ticket for that

17:27 chouser: maybe nth too. and subvec

17:27 lpetit: would make subs have more substance than just being a simple java wrapper :)

17:27 technomancy: looks like I was a lazy slacker and didn't ticket it =(

17:27 chouser: oh, good call

17:28 lpetit: technomancy: to which extent did you patch paredit to be more clojure-aware ?

17:28 chouser: dunno if rhickey would go for it or not.

17:28 technomancy: chouser: dunno about nth though; couldn't that cause unintended realization of lazy seqs?

17:28 chouser: any negative would have to fully realize the lazy seq

17:29 technomancy: lpetit: I just had to teach it to treat [] and {} as pairs; I think that was all there was to it.

17:29 lpetit: technomancy: I mean, when having this "#{ }|" (with cursor represented by pipe | at the end), do you end up if trying to delete } with "#|" or with "" for example ?

17:30 technomancy: ok, so eventually paredit.clj will beat paredit on clojure support :-p

17:30 technomancy: lpetit: oh, I see. no, it only deals with paired characters.

17:30 lpetit: well you certainly have an advantage; you don't have to use elisp. =)

17:30 of course, once I implement a clj-to-elisp compiler, then it won't matter.

17:31 chouser: wouldn't elisp-to-clj be easier?

17:31 lpetit: technomancy: I'm in the process of writing paredit in clojure, for clojure. I make this IDE independent so that eventually everyone can benefit from this.

17:31 technomancy: cool

17:33 chouser: well theoretically once clojure is more self-hosted, it would be a lot less work to write a new compiler target for. elisp is pretty huge in comparison.

17:33 polypus: lpetit: verry nice

17:34 lpetit: technomancy: I've rather quickly stopped trying a elisp-to-clojure direct port of paredit.el, too many hooks inside of emacs internals, too many functions with side effects. I finally just copied the commands spec. Currently just have open-* commands, but it's a start :-)

17:34 tolstoy: Is memoize thread-safe?

17:34 hiredman: yes

17:35 technomancy: lpetit: sounds wise

17:35 tolstoy: Er, hm.

17:35 jcromartie: tolstoy: everything is thread safe as long as it's pure clojure

17:35 other Java classes can't be guaranteed to be thread safe though

17:35 tolstoy: Ah, okay. the (doc memoize) didn't say much, but I can see that. Oops! ;)

17:35 lpetit: technomancy: yes. Then back to coding, I need to handle the case of literal chars I've forgotten in the process :-)

17:37 tolstoy: jcromartie: Yes, I mess myself up because I'm creating a cache of complied schemas, thus the self-confusion.

17:38 chouser: jcromartie: almost. there are a few gems like super-proxy that are not thread safe

17:38 jcromartie: oh really? I haven't heard of it

17:38 how can you make pure clojure code non-thread-safe?

17:39 chouser: er, proxy-super I mean.

17:39 Chousuke: proxy-super is not pure clojure I suppose.

17:39 since it very much sounds like Java interop :P

17:39 jcromartie: yeah

17:39 chouser: well, it's used for java interop

17:40 but you could make something similarly unsafe using an atom.

17:41 Chousuke: even then, it's at least atomically unsafe :P

17:42 chouser: heh

17:42 arohner: you can always race if you try to do something stupid, like keep two unrelated atoms in sync

18:15 lpetit: is the clojure 'reader' page up to date according to the special literal characters : \newline, \space and \tab ? Any other that could miss ?

18:16 Chousuke: linefeed and... hm.

18:17 hiredman: http://github.com/hiredman/clojure/blob/readerII/src/clj/clojure/reader.clj#L516

18:17 "formfeed"

18:19 Chousuke: oh, right

18:19 I always forget them :P

18:23 lpetit: oh yes, so some are missing in the documentation. Thx hiredman

18:29 Mefached: Would copying the "contrib" directory in clojure-contrib/src/ to clojure's own src/ be an effective way to add clojure-contrib? I can't get it to work any other way.

18:32 hiredman: Mefached: because it would put everything in the same place on the classpath

18:43 tcrayford: is there a function to cast a string to a regex?

18:44 hiredman: that is not a cast

18:44 a string is not a regex

18:44 tcrayford: :/

18:44 to turn a string into a regex then?

18:44 hiredman: there is a function to create a regex pattern from a regex

18:45 (doc re-pattern)

18:45 clojurebot: "([s]); Returns an instance of java.util.regex.Pattern, for use, e.g. in re-matcher."

18:45 tcrayford: already found

18:46 needed the right search term (find-doc "re") ain't exactly helpful

19:46 tolstoy: I wonder why schema validation in the JDK ain't thread safe. Seems kinda, well, unfortunate.

19:46 Maybe the thought is that if you have lots o threads, you're a transaction processor, and you shouldn't be validating (to slow) in the first place.

19:55 ndimiduk: I have a dumb noob question: what undoes (str 'foo) ?

19:55 so, given a string, return that string as a symbol

19:55 tcrayford: ,(str 'foo)

19:55 clojurebot: "foo"

19:55 dabd: what is the most widely used build tool for clojure? maven or leiningen?

19:55 tcrayford: lein is built on top of maven

19:56 ndimiduk: oh wait, there's (symbol "foo")

19:56 tcrayford: ,(str (symbol "foo"))

19:56 clojurebot: "foo"

19:56 tcrayford: I like lein, but depends what you want

19:58 dabd: leiningen seems easier to use but lacks detailed documentation. maven is harder to learn but has more documentation

19:59 tcrayford: lein is so damn easy to use, there's barely any need for documentation

19:59 just make sure your dependancies are in project.clj, run lein deps before you do things and you're good

20:01 dabd: yes if i want to learn the syntax of defproject i have to look at the source code since the options are not fully documented

20:01 tcrayford: what options do you need/care about?

20:02 they probably could be better

20:02 dabd: all the options for ex. :dependencies

20:04 tcrayford: as far as I can see you just pass dependancies a vector that's configures in the right way and you'll get your deps (assuming their in the mvn repo or on clojars)

20:06 alexyk: can I break a list to pattern-match like, non-working: (let [[x:xs] [1 2 3]] (print x)) ?

20:07 tcrayford: what are you wanting x to be out of that result?

20:07 alexyk: x is (first s), xs is (rest s)

20:08 I wonder how can I mimic haskell/ocaml's breakup on LHS

20:08 tcrayford: you can probably get that from :as

20:08 fanatico: ,(let [[x & xs] [1 2 3]] (print x xs))

20:08 clojurebot: 1 (2 3)

20:08 tcrayford: ooh, hadn't realised that

20:08 that's nice

20:09 alexyk: great! So when writing a defn which does something for x & xs, and something else for x, and still else-thing for [], can it be separated by arity using this trick?

20:10 fanatico: yup

20:14 alexyk: how do we separate bodies for different arities?

20:15 fanatico: (defn f ([x] ...) ([x y] ...))

20:15 powr-toc: does anyone know how to get "lein repl" to accept arbitrary directories on the classpath, without mavenizing them?

20:16 tcrayford: you can probably hack ground with the lein script itself to get that

20:16 (the bash script)

20:17 powr-toc: tcrayford: yeah... is that a great idea though?

20:17 I'd rather lein itself supported an arbitrary lib option

20:17 fanatico: alexyk: I was wrong about pattern matching differentiating between x and []. You're going to want to start with an (if (seq x) ...)

20:17 tcrayford: por-toc: probably not. I've done it to customize java.library.path

20:18 powr-toc: put an issue on lein's repo then

20:18 powr-toc: tcrayford: yeah, but java.library.path is pretty different to the classpath

20:19 tcrayford: where's the bug tracker? github?

20:19 tcrayford: yep

20:19 at least that's where I'd put issues. Otherwise maybe the google group

20:20 yeah looking at the lein source, you could pretty easily add a $CLASSPATH: onto the front of its classpath definition

20:20 powr-toc: tcrayford: I know... but ideally would it not come from project.clj?

20:21 tcrayford: or that

20:21 alexyk: fanatico: alas, no ocaml emulation just yet :(

20:21 tcrayford: something like a :classpath option

20:21 powr-toc: tcrayford: because as far as I'm concerned project.clj should become the spec for building and running the project, with it's classpath...

20:22 tcrayford: yeah agreed on that

20:22 I'd like project.clj to support library path as well

20:22 it feels pretty bad to be hacking around with a bash script (both for dev and deployment)

20:23 powr-toc: tcrayford: that's my other issue with lein... it has a :library-path option, but I don't think it means java.library.path... but then it doesn't seem to work like classpath either...

20:24 fanatico: alexyk: you might want to look at http://www.brool.com/index.php/pattern-matching-in-clojure

20:24 tcrayford: I think its :library.path option is to change what you usually have under /lib/

20:25 powr-toc: tcrayford: yeah... I know... i was hoping lien would support the various dev, deployment and staging environments you might need, within project.clj

20:26 tcrayford: I think it is too... which seems analagous to a significant part of the runtime classpath.... but it doesn't seem to allow multiple options etc...

20:26 alexyk: fanatico: yes, thankx!

20:26 tcrayford: aye

20:26 I think most of the things I'm doing can be done with swank-clojure from a directory anyway

20:27 and swank-clojure has a set-java-library-path option

20:28 powr-toc: tcrayford: I thought lien would solve my dilema of having to configure a different classpath/clj-shell-script for every project I run within slime and then deployment etc... sadly it doesn't seem to quite fill that hole :-(

20:28 tcrayford: it can if you're doing simple stuff, or your dependancies are all found on clojars/mvn

20:31 powr-toc: tcrayford: that's the problem though... my dependencies are proprietary... and I don't want to have to install them all with maven...

20:31 tcrayford: aye :/

20:32 powr-toc: Sadly I need very explicit control over the classpath :-(

20:32 tcrayford: it's probably not that hard to write a patch for lein that supports :more-classes or summat

20:36 powr-toc: tcrayford: true... except I think add-classpath is deprecated in clojure, and I wouldn't want to force startup of another JVM to kickstart the apps JVM (as commons launcher does)

20:36 and having it in the bash/bat script sucks

20:37 tcrayford: just patch lein and submit the patch then?

20:37 but yeah, java's build stuff is annoying

20:38 powr-toc: tcrayford: I don't have any objection to submitting a patch... I just don't know *how* best to do what I want

20:38 tcrayford: so try some ideas in git branches

20:41 powr-toc: tcrayford: git branches smanches... my problem is I don't currently know how to go about extending the classpath for lein without screwing with either the bat/sh file (a crap inadequate solution) or getting into java classloader nonsense which is full of lots of wierd stuff...

20:42 tcrayford: aye

20:42 powr-toc: I was hoping someone else, would be more familiar with this than me

20:42 tcrayford: (definitely not me)

20:42 talk to technomancy next time he's on

20:42 powr-toc: otherwise I would've just patched it...

20:42 tcrayford: gotcha

20:42 powr-toc: anyway I've added an issue on github

20:44 it's not that I'm completely ignorant about classpath stuff... it's just I've heard mention that clojure does something odd with the classloaders... which I'm guessing is why (add-classpath was deprecated)... can anyone enlighten me here?

20:44 s/classpath/class-loader/

20:51 alexyk: what's the shortest way to refer to + in (reduce ??? [1 2 3]) to sum the vector?

20:52 tcrayford: (reduce + [1 2 3]) ?

20:52 tomoj: hard to get shorter than that

20:52 alexyk: wow

20:52 I thought I need lambdaisms

20:52 tomoj: ,+

20:52 clojurebot: #<core$_PLUS___4745 clojure.core$_PLUS___4745@16de797>

20:52 alexyk: crysta;-clear

20:52 \

20:53 meaning crystal-clear)

20:53 tcrayford: I did that a lot a while back, using anonymous functions where I didn't actually need them at all

20:53 tomoj: clojure is a lisp-1 oslt

20:53 i.e. you can refer to functions by their names just like any other value

20:53 alexyk: how does the same namespace for functions and values affect the ability to use + as itself?

20:54 tcrayford: give an example useage

20:54 tomoj: in CL I believe it would be something like (reduce #'+ ...)

20:54 alexyk: ah, i.e. lisp-2 is something even more perverse

20:54 tomoj: (except with whatever they call reduce instead)

20:54 alexyk: s/even more// :)

20:55 tomoj: of course this means you have to use clever names sometimes

20:55 tcrayford: add :P

20:55 tomoj: e.g. list is a bad name for a list variable

20:55 or seq for a seq

20:55 tcrayford: so use coll for a seq

20:55 iirc

20:56 Programming Clojure has a nice table of variable names

20:56 fanatico: lisp-2 is only really necessary with dynamic scope. if you screw up, it's prety easy to see.

20:56 tomoj: yeah I was about to mention that

20:56 jcromartie: Stuart's article featuring Liskov and CLU is a great read

20:56 tomoj: I should dig that out and paste it somewhere

20:56 tcrayford: already on it

20:56 tomoj: don't we have dynamic scope, though? with vars

20:57 jcromartie: Clojure really is speeding away from Java at an incredible rate.

20:57 tomoj: jcromartie: you mean towards clojure-in-clojure?

20:57 jcromartie: heh

20:57 I mean it was leaps and bounds ahead when 1.0 was ready...

20:58 but protocols and datatypes... wow

20:58 tomoj: ah, yeah

20:58 tcrayford: http://gist.github.com/277709

20:58 tomoj: tcrayford: thanks :)

20:58 fanatico: kinda. let (which is what you'll be using 99% of the time) uses locals, and binding (which uses vars) is only used when you want to affect dynamic scope.

20:58 jcromartie: cinc is interesting but I'm not so sure I'd be using Clojure on other platforms too often

20:58 tomoj: hmm, val is a clobber

20:58 devlinsf: tcrayford: don't forget pred

20:58 tomoj: but the val function is rarely used I guess

20:58 tcrayford: devlinsf that's straight out of the pragprog book

20:59 devlinsf: oh, n/m

20:59 tcrayford: but I'll add that in as well

20:59 jcromartie: I mean Clojure on llvm or CLR would be cool, but Java just has so much stuff going on it's hard to give up the libraries

20:59 tcrayford: (mostly because I'll probably use that as a reference for myself)

20:59 tomoj: jcromartie: yeah it seems like it would split the library community

20:59 devlinsf: jcromartie: ClojureCLR already is in progress

21:00 tcrayford: the thing that I like about cinc is that it means clojure can be written faster

21:00 tomoj: because for any particular library that uses interop, it'd have to be written using your interop

21:00 tcrayford: less farting about with java

21:00 jcromartie: yeah

21:00 tcrayford: and probably more easily modifiable by some people

21:00 tomoj: unless there is a good abstraction over the available interop? seems like a hard thing to do...

21:00 tcrayford: aye

21:01 I think things devved in clj will have to stay on their respective platforms

21:01 jcromartie: that's too bad

21:01 although it might mean more pure-clojure libraries

21:01 which would be great

21:01 tomoj: maybe someday we will have enough of our own stuff that interop is unnecessary :)

21:01 jcromartie: heh maybe

21:01 tomoj: but that means for me writing whole new server libraries etc :/

21:01 jcromartie: then cinc on llvm will be perfect

21:01 tcrayford: might be a loooong time coming them

21:01 jcromartie: yeah

21:02 tcrayford: and I wouldn't be surprised if a better language came out before that point

21:02 tomoj: java's library is currently a great boon

21:02 I wonder, what is wrong with haskell? has rhickey ever commented on it? I guess the problem is bad same-process concurrency?

21:02 tcrayford: it has stm

21:03 and no proper mutable state

21:03 iirc

21:03 tomoj: yeah, that's what made be wonder

21:03 tcrayford: not a lisp though

21:03 jcromartie: The problem with Haskell is that I don't know enough math.

21:03 tomoj: ah, yeah

21:03 I got the sense that rhickey didn't care a whole lot about static vs. dynamic typing

21:03 tcrayford: though writing a lisp interpreter in haskell is pitifully easy

21:03 ~200 lines

21:03 clojurebot: excusez-moi

21:03 tomoj: except maybe haskell's type system is broken?

21:04 jcromartie: the type system is great but it's just not a good environment to build things in

21:04 you can build great rock-solid programs

21:04 tcrayford: and haskell is focussed at not being a practical language

21:04 jcromartie: but they are generally going to be pretty isolated

21:04 it's amazing how long Haskell has been around without catching on

21:04 it's as old as Java

21:04 tcrayford: hey, how old is python

21:04 tomoj: I think the math complaint is relevant

21:04 but I like math :D

21:05 tcrayford: monads still confuse me (and many others)

21:05 tomoj: struggling to find a reason to stay with clojure for some work

21:05 tcrayford: as opposed to haskell?

21:05 tomoj: yeah

21:06 well, and erlang, but I'd be using that anyway alongside clojure

21:06 jcromartie: Haskell 1.0 was defined in 1990

21:06 tcrayford: yeah tis pretty old then

21:06 jcromartie: tomoj: struggling?

21:06 tcrayford: it depends on the problem space and your familiarity mostly

21:06 powr-toc: jcromartie: perhaps, but it's an academic language and community without a great interop story... clojure being on the JVM with awesome Java interop seems more likely to succeed, what with less maths and the easier sell

21:07 jcromartie: heh yes

21:07 tomoj: I like lisps a lot and I particularly like clojure

21:07 but haskell is recently making me very interested

21:07 jcromartie: Clojure is the best. lisp. ever.

21:07 If I may use an annoying typographic trend...

21:07 tcrayford: its the best lisp I've used (so far)

21:08 powr-toc: and erlang... though a great language... again lacks enough library interop to be acceptable to industry beyond it's admitedly growing niche...

21:08 jcromartie: I've tried various CLs and Schemes

21:08 but clojure is like rocket-powered lisp in terms of just getting shit working

21:09 thanks to interop

21:09 tomoj: that niche is right where I'm at :)

21:09 powr-toc: tcrayford: I've been interested in lisp for many years... but clojures the first one I considered really learning and doing anything...

21:09 im

21:09 s/im/in

21:09 tcrayford: yep

21:09 about the same here

21:09 tomoj: same here

21:10 except I don't have "many" years perhaps

21:10 tcrayford: I've read the first chapter of sicp, and the first 15 chapters of on lisp

21:10 and disliked common lisp enough to run away from it

21:10 tomoj: (since I only started programming 6 years ago or so.. :( )

21:10 tcrayford: I started programming less than a year ago

21:10 powr-toc: tcrayford: Common Lisp and Scheme always seemed impractical

21:11 tomoj: I wonder if rhickey has commented anywhere on haskell's stm

21:11 alexyk: where's the error here, it's checking that a sequence is increasing:

21:11 tomoj: so we have 3 people at 3 different timescales making the same progress from general lispy interest to love of clojure ?

21:11 :D

21:11 alexyk: ,(let [[x & xs] [1 2 3]] (-> xs (reduce (fn [[r x] y] [(and r (< x y)) y]) [true x])))

21:11 clojurebot: java.lang.ClassCastException: clojure.lang.PersistentVector$ChunkedSeq cannot be cast to clojure.lang.IFn

21:11 powr-toc: tomoj: well I guess I don't have many years either... interest and "learning/doing" are very different

21:12 tcrayford: confirm that powr-toc

21:12 jcromartie: the CL hyperspec is like stepping through a gateway into 1995 or something

21:12 tcrayford: more like 1987

21:12 alexyk: this works:

21:12 jcromartie: it's kind of awesome in that way

21:12 alexyk: ,(let [[x & xs] [1 2 3] [r _ ] (reduce (fn [[r x] y] [(and r (< x y)) y]) [true x] xs)] r)

21:12 clojurebot: true

21:12 jcromartie: I like the aliased two-color graphics

21:12 tcrayford: I think common lisp is actually older than I am

21:12 alexyk: but I wonder what's wrong with the above -> form

21:13 fanatico: alexyk: ->>

21:13 alexyk: ah! arrgh

21:13 qbg: The hyperspec is part of the simpler, more refined web

21:13 fanatico: -> is thread-first, ->> is thread-last

21:13 alexyk: it's been a few days

21:13 tcrayford: -> and ->> really confuse me

21:13 tomoj: using -> or ->> seems strange to me there

21:13 since there's just the thing and one thing to do to it

21:13 alexyk: tomoj: we need to extract the result from the tuple

21:14 jcromartie: what are people doing to set up Java and clojure stuff on OS X?

21:14 alexyk: after a long reduce, a first or (... 0)

21:14 jcromartie: i.e. where do you put it all?

21:14 powr-toc: clojure is my first commitment to lisp... except maybe a brief fling with emacs-lisp which was more out of a desire to use emacs, than learn lisp... though I have to admit, emacs being implemented in lisp was a factor in me choosing emacs over vim... as lisp felt like something worth knowing vim's config language didn't.

21:14 jcromartie: I have a ~/src

21:14 alexyk: hence ->> seems useful for decluttering/suffixing

21:14 tomoj: powr-toc: exactly on emacs vs. vim for me as well

21:14 alexyk: ok, I'll take your word for it

21:14 I haven't understood your code yet :)

21:14 alexyk: tomoj: :)

21:14 qbg: ->> is a poor man's concatenative code

21:14 jcromartie: emacs is like Eclipse to me... it's an development-environment-development-environment

21:15 alexyk: qbg: what's the rich man's?

21:15 tomoj: like eclipse, except usable (to me)

21:15 qbg: alexyk: I'm trying (key word there) to work on it

21:15 tomoj: can't haskell do that stuff fairly well?

21:15 alexyk: qbg: ah!

21:15 tomoj: concatenative I mean

21:16 alexyk: Guy Steele btw is doing some weird Fortress, in case folks think time goes back to Lisp

21:16 tomoj: oh, I don't think I understood what "concatenative" means

21:16 alexyk: and he got really cure math symbols a la Mathematica

21:16 cute

21:16 tomoj: I saw his talk about that

21:16 jcromartie: Forth :)

21:16 powr-toc: not an eclipse fan either... I prefer netbeans... but even then despite being a java developer I've never bothered myself to build anything for either... java's too clunky to take home.

21:17 tcrayford: alexyk, is that code just checking that a collection is increasing?

21:17 tomoj: seems like it was targeted for scientific computing, right?

21:17 alexyk: tomoj: exactly

21:17 jcromartie: "Java is too clunky to take home." great quote

21:17 alexyk: what do you mean just? should it play a violin, too? :)

21:17 or is it too verbose? :)

21:18 tcrayford: trying to see if I can come up with a simpler way of doing it

21:18 seems very complex

21:18 jcromartie: Java is just no fun, alexyk

21:18 powr-toc: alexyk: it's too clunky... verbosity I can live with... if it has utility

21:18 jcromartie: it's C in a polo and khakis

21:18 alexyk: tcrayford: I do everyting with reduce's. Shorter versions welcome! :)

21:18 jcromartie: it's C++ with its balls cut off

21:18 tcrayford: I dislike having to learn java at college :/

21:19 (let [sorted (sort < [1 2 3])]

21:19 (= sorted [1 2 3]))

21:19 tomoj: ,(every? (fn [[x y]] (< x y)) (partition 2 1 [1 2 3 4 5]))

21:19 clojurebot: true

21:20 powr-toc: jcromartie: alexyk: I personally don't like beating on Java too bad... It's too fasionable these days :-) ... Java's clunky, reliable and built to survive the next trillion years... just like everything Sun ever made!!!

21:20 tcrayford: ,(let [sorted (sort < [1 2 3])] (= sorted [1 2 3]))

21:20 clojurebot: true

21:20 jcromartie: yes, it's fine... it's just insipid

21:20 flavorless

21:20 alexyk: tcrayford: no sorting. :)

21:20 tomoj: I think I made a cute name for (partial partition 2 1)

21:20 alexyk: think 10000000 tweets' timestamps :)

21:20 ...000...

21:21 tcrayford: oh ok

21:21 alexyk: you guys mostaken me for some Java advocate or something. I hate Java with a passion, FTR.

21:21 tomoj: hmm, could also do (map vector (seq coll) (next coll))

21:22 is there a clearer way to write that, I wonder?

21:22 alexyk: I prefer OCaml, but JVM lets me plug in into some libs :)

21:22 although it's damn slow, so I wanted to see if Haskell is a speedup :)

21:22 jcromartie: I'm not saying I hate Java or anything. The libs are great. It's just dull! That's why Clojure is great.

21:22 powr-toc: I guess I don't like bashing on Java, because half the developers I know only know .net, and somehow think it's massively better than java.... When I say Java, I mean the java language and c#... not the JVM or Java eco system :-)

21:23 tomoj: alexyk: are you doing data mining on twitter?

21:23 alexyk: jcromartie: well, I hate verbosity, and Blah someBlah = new BlahstyBlah(new BlashphetyBlah...)) is horrible, horrible abomination.

21:23 tomoj: yes

21:23 jcromartie: oh man

21:23 then you'd hate Objective-C :)

21:23 tcrayford: haha

21:23 fanatico: haha

21:23 tcrayford: and cocoa

21:24 jcromartie: Foo *foo = [(Foo *)[Foo alloc] initWithBar:bar bat:bat]];

21:24 alexyk: there's MacRuby :)

21:24 jcromartie: yes, the cast is sometimes needed

21:24 tomoj: alexyk: I'm interested in that problem

21:24 alexyk: for academia?

21:24 tcrayford: pyobjc even more

21:24 qbg: Given the horrible Java code I've seen, I'm just glad it's not C++ code.

21:24 alexyk: tomoj: yes, for now :)

21:24 powr-toc: qbg: lol

21:24 tomoj: alexyk: you got a firehose, right? how do you go about getting one of those?

21:25 alexyk: tomoj: we don't get it, no need for it for now, gardenhose is ok

21:25 tomoj: some of the ideas I'm thinking about with haskell now tie into that sort of thing and I'd like to test them out

21:25 thanks, I'll look into the gardenhoses

21:25 tcrayford: iirc the twitter people have done some data mining with clojure recently

21:26 powr-toc: I think after a lot more time with clojure, the next languages I want to dig into are Ocaml, Haskell and more Prolog.... oh and I'd like to return to factor.

21:26 tcrayford: (just for kicks)

21:26 beutdeuce: If i have a list of strings ("clojure" "is" "cool") and a list of identifiers (:word :word: :word), how do i create a map {"clojure" :word "is" :word "cool" :word} ?

21:26 tcrayford: ,(doc zipmap)

21:26 clojurebot: "([keys vals]); Returns a map with the keys mapped to the corresponding vals."

21:26 tomoj: twitter data mining will just be a demo application for what I'm working on, I don't think I can use clojure :(

21:26 alexyk: tomoj: you mean data mining twitter in haskell?

21:27 tcrayford: ,(zipmap ["clojure" "is" "cool"] (iterate :word))

21:27 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$iterate

21:27 tomoj: alexyk: yeah

21:27 beutdeuce: tcrayford: it ends up returning {("clojure" "is" "cool") :word}

21:27 tomoj: well, maybe with erlang's help

21:27 tcrayford: woops

21:27 tomoj: but the business logic in haskell

21:27 jcromartie: ack

21:27 clojure + erlang + haskell, seriously?

21:27 tomoj: no clojure, probably

21:27 jcromartie: you should be fine with one of those

21:27 tomoj: I like it but I don't think I can afford it

21:28 tcrayford: ,(zipmap [ "clojure" "is" "cool" ] [:word :word :word])

21:28 clojurebot: {"cool" :word, "is" :word, "clojure" :word}

21:28 tomoj: yeah erlang alone might be OK but I like what haskell can do for some stuff (which clojure, though more friendly, can't, I'm afraid) :)

21:28 tcrayford: ,(zipmap [:word :word :word] ["clojure" "is" "cool"])

21:28 clojurebot: {:word "cool"}

21:29 headius: hey, how do you specify multiple overloads for a given method to be gen-class'ed

21:30 powr-toc: tomoj: Curious, what can Haskell do that clojure can't?

21:30 beutdeuce: tcrayford: doesnt work for me when i do (zipmap ("clojure" "is" "cool") (repeat :word)), cause i get {("clojure" "is" "cool") :word}

21:31 powr-toc: tomoj: the type system?

21:31 tomoj: powr-toc: yeah

21:31 fanatico: beutdeuce: quote the list

21:31 tcrayford: or use a vector

21:31 qbg: ,(zipmap ["clojure" "is" "cool"] (repeat 3 :word))

21:31 clojurebot: {"cool" :word, "is" :word, "clojure" :word}

21:31 tomoj: powr-toc: extra assurance imo about what _exactly_ the code is doing

21:31 fanatico: ,(zipmap '("clojure" "is" "cool") (repeat :word))

21:31 clojurebot: {"cool" :word, "is" :word, "clojure" :word}

21:32 tcrayford: iirc its a bit more idiomatic to use a vector

21:33 powr-toc: tomoj: I've never used a language with such a damn-strong type system... is it just the scope for catching... I mean err proving the absence of certain errors that helps... or is it more?

21:33 beutdeuce: well, the thing is that i am actually doing (zipmap (list tokens) (repeat :word)) where tokens is a seq of split strings

21:34 nvm

21:34 got it

21:34 powr-toc: and what problems are best solved by a language with a strong type system?

21:34 fanatico: if tokens is already a seq, (zipmap tokens (repeat :word))

21:34 beutdeuce: seq is already encapsulated

21:34 fanatico: powr-toc: parsers.

21:35 tcrayford: does clojure have anything like haskell's parser combinators?

21:35 headius: hmm

21:35 I'm not finding an examples of generating classes with overloaded methods

21:36 powr-toc: tcrayford: http://github.com/joshua-choi/fnparse ??

21:36 tomoj: someone should write a good tutorial for fnparse I think

21:37 fanatico: tcrayford: there are libraries (and it's easy enough to write one yourself using clojure.contrib/monads) but it doesn't feel as elegant.

21:37 tomoj: maybe I'm just too stupid, I couldn't understand it when I looked at it

21:37 * tcrayford needs to understand monads better

21:38 hiredman: headius: I don't think there is a mechanism for that, you have to take care of it in the implementing functions

21:38 headius: dang

21:38 I'm trying to find a way to avoid that situation in my class generation for jruby

21:38 technomancy: yeah, unfortunately I don't think that's hooked up in the compiler yet

21:38 hiredman: technomancy: eh?

21:38 technomancy: hiredman: I don't think it's been ruled out for the future, has it?

21:39 headius: probably via something like def_java "String foo2(String, int)" => :foo_string_int

21:39 hiredman: tomoj: actually fnparse is about to go through it's third big architectural change

21:39 headius: hiredman, technomancy: so currently, if you specify multiple signatures, they all generate but dispatch to the same function?

21:40 tomoj: hiredman: oh, great, I thought it was dead

21:40 hiredman: headius: you only spec signatures for stuff you are extending

21:40 technomancy: headius: maybe in gen-class; in regular fns I think it's an error to specify multiple signatures that have the same arity

21:41 headius: I'm talking about gen-class

21:41 hiredman: sure

21:41 powr-toc: whenever I read anything about monads I simultaneously come away feeling I've realised some fundamental property of programming... akin to maybe zen enlightenment... but I also feel like I'm more confused and don't understand anything...

21:41 technomancy: I suspect the way gen-class methods are fed functions means the same limitations apply there

21:41 wilig: ugh, fighting swank-clojure but it's a losing battle at the moment. keep wondering if it really needs to be this complex. slime is a really simple protocol.

21:41 hiredman: :methods adds method signatures, you don't specify signatures for already existing methods

21:41 technomancy: wilig: it's certainly accumulated over time

21:41 fanatico: tcrayford: I worked through http://www.cs.nott.ac.uk/~gmh/monparsing.pdf, translating the examples to clojure. I found it helped a lot.

21:41 headius: let me put it more simply

21:41 hiredman: it just looks for vars in the current namespace

21:41 technomancy: wilig: I've pondered a from-scratch rewrite, but I'm not currently brave enough

21:42 headius: if I want to gen-class a new class that has multiple overloads, is it possible

21:42 technomancy: wilig: the swank-clojure is a pretty literal port of the CL version though

21:42 powr-toc: Ultimately I'm sure I don't grok monads at all...

21:43 wilig: technomancy: I understand. The from scratch rewrite sounds appealing and I'm sure it would be a decent way to learn clojure. But ugh, my head hurts.

21:43 hiredman: headius: gen-classed methods just distpach to the clojure function with that name

21:43 so (.foo bar) will look for -foo in hte namespace implemnting bar

21:44 and -foo is responsible from there on out

21:44 technomancy: so in the end it comes down to a limitation of fns

21:44 headius: ok, that doesn't really answer my question either

21:45 perhaps what I'm getting is that you can't do overloads

21:45 technomancy: yes

21:45 hiredman: you can, but not as a mechanism in gen-class

21:45 wilig: as far as I can tell, which isn't very far. In order to get read-line working I need to send emacs a read-string message, but I can't find that anywhere in the swank-clojure sources. /sigh

21:46 technomancy: ,(fn ([#^String a]) ([#^Boolean a]))

21:46 clojurebot: java.lang.Exception: Can't have 2 overloads with same arity

21:46 headius: so putting it a different way: you can't generate a completely new class entirely from clojure code that presents multiple different overloads of the same method name

21:46 hiredman: so if you actually want to do it in clojure, I can tell you how, but if you just are looking for a technique to apply else well, there isn't one

21:46 headius: hmmm

21:46 ah I understand

21:46 headius: right

21:47 hiredman: "The generated class automatically defines all of the non-private

21:47 methods of its superclasses/interfaces."

21:47 guess it can, just not how you want

21:47 headius: that's an intriguing decision in itself

21:47 I assume that means it generates them all with logic to call the fn of the same name if it exists, or super otherwise

21:48 I have considered a similar approach for jruby's generated java classes

21:48 but yes, it doesn't sound like it's possible to create overloads unless they come from the parent class/interfaces

21:48 chouser: headius: yes, that's what is generated. It means you can add, change, remove method defintions dynamically.

21:49 hiredman: headius: uh, if it;s not from the parent class/interface, how is it an overload?

21:49 you can use :methods to add more method signatures

21:50 headius: overloads are not overrides

21:50 I think you are confusing the two

21:50 overload = same name, different signature

21:50 hiredman: ok, then you can use :methods

21:50 headius: override = same name and signature as parent class method, replacing it

21:50 hiredman: define a new signature

21:50 headius: ok

21:50 hiredman: the resolution to implmenting fn will be the same

21:51 headius: so you can have multiple entries in :methods for the same fn name

21:51 and all overloads will dispatch to the same fn

21:51 no way to specify one overload goes one place and another goes another place?

21:51 hiredman: or multifn or multimethod

21:52 technomancy: yeah, a multimethod would get the same functionality, but from a bytecode level has nothing to do with an overload

21:52 hiredman: hmmm

21:52 technomancy: sure, but the overload is there thanks to the signature in :methods

21:52 headius: multimethod still represents a single entry point but then chooses a different body based on the actual types/arity?

21:52 so all the overloads would dispatch to the multimethod, and it would re-branch

21:53 technomancy: headius: based on an arbitrary dispatch function

21:53 headius: ok

21:53 technomancy: yes

21:53 hiredman: headius: yes

21:53 headius: that's closer, certainly

21:53 that's how you'd do it in ruby as well, but not through any explicit mechanism

21:53 * hiredman isn't a fan of gen-class

21:53 headius: case arg; when String; ... when Integer; ....

21:54 chouser: go go gadget protocol

21:54 hiredman: chouser: :D

21:54 headius: I'm hoping to provide a way to route different overloads *actually* to different methods

21:55 but it's good to know clojure doesn't handle that yet either

21:56 if anyone's interested, I have this at the moment for a prototype class generator:

21:56 (for jruby)

21:56 tcrayford: chouser: liking that the joy of clojure has a style guide in it

21:57 headius: http://gist.github.com/277771

21:57 rough sketch

21:57 chouser: tcrayford: great!

21:58 technomancy: headius: interesting. so "signature" prepares the compiler for the next call to def? or is it for all further calls to def like private/public?

21:58 headius: technomancy: yes

21:59 this is all pulled out of the code statically

21:59 public/private would work the same way, setting a flag at compile time

21:59 technomancy: cool

21:59 headius: signature would be a no-op at runtime

22:00 the basic logic would be to generate a really slim stub class that loads the associated script code, ties itself to the ruby class, and then proceeds

22:00 the logic for each Java method just does a dyncall to the ruby version

22:02 alexyk: ok what's the prettiest way to convert a list of pairs to a plain vector, filling blanks by 0? ([0 12] [1 23] [3 65]) => [12 23 0 65]

22:03 the first elements are indices, 0-based

22:04 hiredman: that makes no sense

22:04 how is there a blank?

22:04 headius: hmm

22:04 alexyk: hiredman: the pairs is a sparse vector representation. sorry, blank means we have a gap

22:05 [0 x] [1 y] [3 z] => [x y 0 z]

22:06 technomancy: ,(let [l '([0 12] [1 23] [3 65]) m (into {} l)] (reduce #(conj %1 (m %2)) [] (range (inc (first (last m))))))

22:06 clojurebot: [12 23 nil 65]

22:06 technomancy: just add an (or (m %2) 0) into the #() form

22:07 hiredman: erm

22:07 what is with the into?

22:07 qbg: Wouldn't (last l) be safer?

22:08 technomancy: qbg: yeah, that's what I meant; typo

22:08 hiredman: and if there is a reason for the into, you should use a sorted-map

22:08 alexyk: interesting...

22:08 hiredman: and still unconvinced of the need for the into

22:09 qbg: hiredman: Big O?

22:09 technomancy: hiredman: you can't use nth to look up things in l because it's sparse, so I don't see how else you'd look up the value for a given index

22:09 I mean, without traversing l every time

22:09 sure, it's an optimization

22:10 alexyk: just don't ask for a lazy version =)

22:10 hiredman: ,(let [l '([0 12] [1 23] [3 65]) v (repeat (count l) 0)] v)

22:10 clojurebot: (0 0 0)

22:10 alexyk: technomancy: nothing lazy here :)

22:12 hiredman: ,(let [l '([0 12] [1 23] [3 65]) v (repeat (count l) 0) f (fn [v [k v’]] (assoc v k v’))] (reduce f v l))

22:12 clojurebot: java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.Associative

22:12 hiredman: erm

22:12 ,(let [l '([0 12] [1 23] [3 65]) v (vec (repeat (count l) 0)) f (fn [v [k v’]] (assoc v k v’))] (reduce f v l))

22:12 clojurebot: [12 23 0 65]

22:13 qbg: ,(let [l [[0 12] [1 23] [3 65]]] (reduce #(assoc %1 (first %2) (second %2)) (range (inc (first (last l)))) l))

22:13 clojurebot: java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.Associative

22:13 technomancy: oh dang... I forgot assoc worked on vectors

22:13 well-played

22:13 qbg: ,(let [l [[0 12] [1 23] [3 65]]] (reduce #(assoc %1 (first %2) (second %2)) (vec (range (inc (first (last l)))))))

22:13 clojurebot: java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer

22:14 hiredman: qbg: that assumes l is sorted

22:14 technomancy: thank you

22:14 qbg: hiredman: True

22:14 alexyk: l is sorted in my data

22:15 index is increasing, although may be sparse

22:15 hiredman: actually

22:15 mine assumes the vector is not that sparse

22:16 ugh

22:16 I hate to see last

22:17 chouser: ,(let [v [[0 12] [1 23] [3 65]], m (apply max (map first v)), o (vec (repeat (inc m) 0))] (reduce (fn [o [k v]] (assoc o k v)) o v))

22:17 clojurebot: [12 23 0 65]

22:17 hiredman: oooh, max

22:18 alexyk: wow

22:19 tcrayford: chouser: The start of page 70 about closing parens could use an example of good style (or a note that every other bit of code in the book puts its ending parens in the right place)

22:21 alexyk: qbg: so any final working version for my collection? :)

22:21 * qbg becomes lazy; working code has been posted

22:22 alexyk: :)

22:29 qbg: Anyways, my solution would be similar to chouser's

22:33 chouser: alexyk: you said the keys are increasing?

22:34 alexyk: chouser: yep

22:34 hiredman: you could concievably do a check and pad the vector out as you go

22:34 chouser: yeah, that's what I'm thinking

22:34 hiredman: instead of doing another seq traversal

22:39 jcromartie: holy crap how much does Maven download every time you run a command?

22:43 chouser: ,(loop [[[k v] :as i] [[0 12] [1 23] [3 65]], o []] (cond (empty? i) o (== k (count o)) (recur (next i) (conj o v)) :else (recur i (conj o 0))))

22:43 clojurebot: [12 23 0 65]

22:46 hiredman: :(

22:46 loop

22:46 chouser: yeah

22:47 alexyk: loop! recur! finally, real code! :)

22:47 timothypratley: jcromartie: maven requires the whole internet as a dependency tree that needs to be refreshed every command,

22:47 alexyk: I was writing similar with reduce, carrying tuples

22:47 chouser: can't think of how to pad or not in any of the high-level fns

22:47 jcromartie: seems that way

22:47 but hey, at least it's not ant

22:49 hiredman: ,(reduce conj [:a :b :c] (range 10))

22:49 clojurebot: [:a :b :c 0 1 2 3 4 5 6 7 8 9]

22:49 hiredman: ,(reduce conj [:a :b :c] (repeat 10 0))

22:49 clojurebot: [:a :b :c 0 0 0 0 0 0 0 0 0 0]

22:49 alexyk: jcromartie: it will download until it has it. if you installed manually and forgot to install the pom, it will try to download until you install the pom

22:50 jcromartie: has what? and install what pom?

22:51 hiredman: ,((comp (partial apply reduce conj) (juxt identity range)) [:a :b :c] 4)

22:51 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$identity

22:51 hiredman: ,((comp (partial apply reduce conj) (juxt (comp first list) (comp range second))) [:a :b :c] 4)

22:51 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$second

22:51 hiredman: ,((comp (partial apply reduce conj) (juxt (comp first list) (comp range second list))) [:a :b :c] 4)

22:51 clojurebot: [:a :b :c 0 1 2 3]

22:52 hiredman: :|

22:52 timothypratley: Having said that - Maven is really great at what it does. And I'm really impressed with leiningen, very slick.

22:55 jcromartie: ok but still, what is the "it" and the pom in alexyk's comment?

22:55 alexyk: jcromartie: depends what it wants in your case! study the [INFO] lines

22:56 jcromartie: k

22:56 it seemed to be all basically maven-related

22:57 qbg: ,(let [a (into {} [[0 12] [1 23] [3 65]]) b (apply max (map first foo))] (map #(get a % 0) (range (inc b))))

22:57 clojurebot: java.lang.Exception: Unable to resolve symbol: foo in this context

22:57 qbg: ,(let [a (into {} [[0 12] [1 23] [3 65]]) b (apply max (map first a))] (map #(get a % 0) (range (inc b))))

22:57 clojurebot: (12 23 0 65)

22:58 qbg: Finally

22:59 alexyk: That should be a lazy solution to the problem

23:00 alexyk: hah!

23:00 thx!

23:00 hiredman: max is not lazy

23:00 chouser: except max will realize the whole seq

23:00 hiredman: neither is into

23:00 alexyk: :(

23:00 qbg: Well, the resulting sequence is lazy at least

23:07 alexyk: I have a transform f for all values of a map; it should remain a map with same keys. How do I do that?

23:08 hiredman: reduce

23:08 or map + into

23:09 chouser: or zipmap + map

23:10 hiredman: is the order returned by keys and vals always going to be the same?

23:10 I don't trust zipmap

23:11 chouser: ,((fn f [n [[k v] :as i]] (lazy-seq (when i (if (== k n) (cons v (f (inc n) (next i))) (cons 0 (f (inc n) i)))))) 0 [[0 12] [1 23] [3 65]])

23:12 clojurebot: (12 23 0 65)

23:12 chouser: fully lazy

23:12 hiredman: yes, the same order as a seq on the map itself

23:12 the map doesn't change in the meantime of course

23:18 qbg: ,(let [a [[0 12] [1 23] [3 65]] b (map #(- (first %1) (first %2) 1) a (cons [0] a))] (mapcat #(concat (repeat %1 0) [(second %2)]) b a))

23:18 clojurebot: (12 23 0 65)

23:19 qbg: Should be fully lazy, but messy

23:22 chouser: qbg: interesting!

23:29 ,(let [a [[1 23] [3 65]] b (map #(- (first %1) (first %2) 1) a (cons [0] a))] (mapcat #(concat (repeat %1 0) [(second %2)]) b a))

23:29 clojurebot: (23 0 65)

23:30 chouser: ,(let [a [[1 12] [2 23] [4 65]], ks (map first a), b (map - ks (cons -1 ks))] (apply concat (interleave (map #(repeat (dec %) 0) b) (map #(list (second %)) a))))

23:30 clojurebot: (0 12 23 0 65)

23:31 chouser: I guess that's not really any cleaner.

23:31 qbg: ,(let [a [[1 23] [3 65]] b (map #(- (first %1) (first %2) 1) a (cons [-1] a))] (mapcat #(concat (repeat %1 0) [(second %2)]) b a))

23:31 clojurebot: (0 23 0 65)

23:31 qbg: Now even more horrible!

23:35 chouser: ,(let [a [[1 12] [2 23] [5 65]], m (into (sorted-map) a)] (map m (-> a last first inc range) (repeat 0)))

23:35 clojurebot: (0 12 23 0 0 65)

23:35 chouser: oh.

23:35 that's not using the sorted map at all.

23:36 qbg: I just reinveted yours. :-P

23:36 tcrayford: chouser: there appear to be some rendering errors on page 79

23:39 chouser: tcrayford: indeed, thanks.

23:45 alexyk: chouser: for zipmap, are we guaranteed that (keys m) and (vals m) will return aligned lists?

23:45 ,(let [m {:a 1 :b 2}] (zipmap (keys m) (map inc (vals m))))

23:45 clojurebot: {:b 3, :a 2}

23:45 chouser: alexyk: yes

23:46 both return items in the same order as (seq m)

23:46 tcrayford: chouser: also much enjoying the book so far. Its taught me a couple of tricks that I didn't know (like :keys in map destructuring)

23:46 chouser: tcrayford: great, thanks!

23:46 tcrayford: have you read any of the other books?

23:46 tcrayford: yep

23:47 chouser: Halloways?

23:47 tcrayford: and in action

23:47 chouser: oh, ok. great.

23:47 tcrayford: yours seems better as a second book

23:47 or more advanced than the other two at least

23:47 chouser: excellent! That's exactly what we're aiming for.

23:48 tcrayford: and pretty much what I was looking for in a book as well

23:48 I can read the language well enough, just don't use it quite as well as I'd like

23:48 nice one.

23:48 alexyk: hmm, I missed it -- where can I read chouser's book? :)

23:49 chouser: alexyk: http://joyofclojure.com/

23:49 alexyk: thx!

23:50 tcrayford: looks like its going to be quite a long book

23:50 if you stick to the current contents

23:51 chouser: we really don't want it to be a giant tome. Hopefully we can shake out some of the less useful bits and extra wordiness, and get a nice succinct result.

23:51 tcrayford: aye

23:52 tomoj: chouser: looks awesome

23:52 chouser: Thanks! I really hope it lives up to the high expectations. :-)

23:52 tcrayford: my only problem with meap is that I want to read certain parts of the rest of it now (the concurrency chapter and probably ch6-8)

23:53 patrickdlogan: question... I'm returning to clojure after some time... tried leiningen early in its being...

23:53 tomoj: when can I start reading it? already?

23:53 I will buy it right now

23:53 patrickdlogan: is lein considered the place to start and use clojure projects now?

23:53 chouser: tcrayford: yeah, I'd like to read those too. ...would help make the writing of them go faster.

23:53 tomoj: (I wonder if that book will talk about lein..)

23:54 tcrayford: tomoj: you can read what's been written so far, with updates as they come

23:54 chouser: tomoj: not currently planned, but that may change. lein didn't exist when the early outline were drawn up, and is rapidly becoming a defacto standard.

23:54 tomoj: first chapter is free now, through 4 available now if you buy

23:54 tcrayford: you've got a bit about larger project design in there right?

23:55 lein should probably go in there

23:55 at least like a paragraph or summat

23:55 tomoj: chouser: buying now

23:55 :)

23:55 chouser: tcrayford: possibly. or perhaps in an appendix.

23:55 tomoj: I think as lein cleans up it would be good to have nicer docs for them too

23:56 chouser: tomoj: great, thanks!

23:56 tomoj: a tutorial or something maybe

23:56 tcrayford: the lein sample project and `lein new` worked pretty well for me

23:56 tomoj: last I tried it I still couldn't grok like I could rubygems

23:56 though admittedly I never did much about setting up gems

23:56 tcrayford: lein isn't really like rubygems though

23:57 tomoj: well, at least a tutorial would be nice

23:57 also how to deal with projects which aren't in clojars yet and also have java dependencies

23:58 possibly spread across multiple maven repos :(

23:58 tcrayford: those are pretty tricky with lein's current setup :(

23:58 tomoj: I don't remember if I managed to get compojure working or not

23:58 and I had trouble with lein-swank and swank-clojure-mode

23:58 tcrayford: I've had compojure working out of lein for donkeys years

23:58 also what trouble with lein swank?

23:59 tomoj: chouser: I wonder, are some of the profits from your soon to be ridiculously popular book going to clojure? I'll still buy if not, but that would be cool. dunno how much money books actually make that the publisher won't claim

Logging service provided by n01se.net