#clojure log - Aug 06 2009

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

0:00 hiredman: anyway, read the docs for set! on the special forms page

0:00 Carkh: binding would require that i go all over the place and establish that binding

0:00 i did

0:00 looks like i first nit to use bindings, then i can set!

0:01 hiredman: http://clojure.org/vars#set

0:02 Carkh: ohwell i'll make it an atom and a function to check the value

0:02 hiredman: :(

0:02 global state

0:02 Carkh: well the use case it pretty good

0:03 i would use conditional compilation in a static language for this

0:09 AOT compilation is slowwww

0:10 back to the c++ age

0:11 hiredman: really?

0:11 Carkh: not _that_ bad ... but yes 1:30 min to build a fairly small web app

0:13 and 3sec to just load the source files and start the application from emacs

0:13 hiredman: I imagine most of that is jvm start up time

0:14 Carkh: i first start the jvm, then compile the file that starts the app

0:14 only the second part is 3 secs

0:15 anyways no big deal, that's not like i'm AOT compiling every minute

0:19 i'm within a couple days of deploying my second "commercial" clojure project to a customer

0:19 started quite a while back .. still using pre 1.0 clojure

0:25 hiredman: lisppaste8: url

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

1:12 mebaran151_: Carkh, have you tried using something like nailgun to keep the jvm live

1:12 I used to use it for dev'ing with Jruby

1:15 Carkh: no i didn't

1:15 i'm not worried about the start times ... i usually develop with the repl ...

1:30 mudphone: does anyone know how to give the compiler a type hint for byte[]

1:31 hiredman: #^bytes

1:31 mudphone: hiredman:thanks you rock

1:32 hiredman: so they tell me

2:05 mudphone: hiredman: who are you that are so wise in the ways of science?

2:06 hiredman: some dude

2:14 jwhitlark: so, (org.enclojure.repl.main/run-repl-server 11345) works in the repl, but not as part of a script. I get the error: Caused by: java.lang.IllegalArgumentException: No matching method: run-repl-server

2:15 anyone seen something like that before?

2:15 hiredman: hmmm

2:15 jwhitlark: I'd have thought it was a classpath problem, but it's finding org.enclojure.repl.main without problems.

2:15 java -cp $CLOJURE_DIR/*:$CLOJURE_JAR \

2:15 jline.ConsoleRunner clojure.lang.Repl

2:15 That's my bash script for the repl...

2:16 scriptname=$1

2:16 java -cp $CLOJURE_DIR/*: clojure.lang.Script $scriptname -- $*

2:16 Jomyoot: we need an all-inclusive web-framework like rails?

2:16 but all written with clojure

2:16 hiredman: use clojure.main instead of clojure.lang.Repl

2:16 jwhitlark: and that's mine for running a script. I don't see any difference.

2:16 k. just a sec.

2:16 hiredman: I doubt that it'll fix things

2:16 but clojure.lang.Repl is depricated

2:17 and Script

2:17 jwhitlark: clojure.main for both?

2:17 hiredman: yep

2:17 java clojure.main --help will tell you all about it

2:19 do you know what kind of number the method takes

2:19 ?

2:19 jwhitlark: should be just an int, it's a port #

2:20 oh! That's interesting, now it's failing in the repl too.

2:20 hiredman: maybe try wrapping it in (int …)

2:20 are you sure the method only takes one parameter?

2:22 jwhitlark: copied it right out of: http://www.enclojure.org/REPLSupport

2:22 one page down.

2:22 interesting. it worked for me *once* in slime, and that's it.

2:23 hiredman: are you using enclojure/

2:23 ?

2:23 jwhitlark: trying to.

2:23 oh, no. not for an ide.

2:24 just to embed a repl in an application. I asked earlier today if http://clojure101.blogspot.com/2009/05/creating-clojure-repl-in-your.html was still the way to go and was told it was still good to go.

2:26 hiredman: I think the problem is the enclojure namespace is gen-classed

2:27 so clojure is treating a reference to it like that as a static method call

2:27 maybe if you (require '[yadda.yadda :as enclojure])

2:28 and (enclojure/something-something 43242)

2:30 jwhitlark: java.lang.Exception: lib names inside prefix lists must not contain periods

2:30 hiredman: http://gist.github.com/163140 makes a repl you can telnet to

2:30 jwhitlark: oh!

2:31 that's what I wanted.

2:31 and it works just fine.

2:32 thanks for the help.

2:32 hiredman: sure

2:34 jwhitlark: I saw somewhere that you could configure slime to connect to an application, but that's a task for another day.

3:27 Anniepoo: is there a jira for Clojure?

3:32 LauJensen: From Google definitions: "Jira is a Thai given name. Notable people bearing the name include: * Jira Boonpojanasoontorn, Justice of the Constitutional Court"

3:32 Anniepoo: LOL

3:32 LauJensen: So in a sense, yes there is JiraAnniepoo

3:32 Anniepoo: ok, more to the point, I've found a small bug in clojure.contrib

3:32 mudphone: these aren't the droids you're looking for

3:32 Anniepoo: where should I report it

3:32 LauJensen: these arent the droids?

3:33 Anyway - I think all project details are handled on Assembla now, you should report there

3:33 Anniepoo: ok

3:34 what and where is an Assembla?

3:34 LauJensen: ~assembla

3:34 clojurebot: assembla is http://www.assembla.com/spaces/clojure

3:34 Anniepoo: Assembla is what system pah-rogramma's use in gah-ga

3:34 thanks

3:34 LauJensen: np

3:37 Anniepoo: I submit a 'ticket'?

3:38 jdz: well, are you sure it's a bug?

3:38 have you asked here or in the mailing list?

3:38 Anniepoo: ok, there's a note to say put it on the mailing list first

3:38 I'll do that

3:38 I'm quite sure it's a bug

3:38 LauJensen: Anniepoo: Yes, a Support Ticket

3:39 mebaran151_: what's the bug?

3:39 lisppaste8: Anniepoo pasted "untitled" at http://paste.lisp.org/display/84890

3:39 Anniepoo: it's putting Unix newlines in the file in this code

3:40 when run on XP Tablet

3:40 I'll try to characterize it better before submitting

3:40 LauJensen: Best to demonstrate by a very simple case :)

3:41 Anniepoo: that's what I meant

3:41 LauJensen: Ok

3:45 jdz: ye, it's right there, the newline function

3:46 although i think outputting DOS line endings is a braindamage

3:47 and if you want to do it, you just use print and add whatever you want at the end

3:47 Anniepoo: the newline function puts out a newline

3:47 ,(doc newline)

3:47 clojurebot: "([]); Writes a newline to the output stream that is the current value of *out*"

3:47 Anniepoo: sorry, that's not enlightening me

3:47 jdz: ,(int \newline)

3:47 clojurebot: 10

3:48 jdz: newline function outputs this character

3:48 Anniepoo: and I'm not a huge whoppign fan of DOS line endings either

3:48 yah, that's excluding 2/3rds of the world

3:49 tomoj: most of those people aren't coding in clojure :P

3:49 Anniepoo: and if you make it difficult for them to do so they will continue to not do so

3:49 jdz: Anniepoo: your calculations are wrong

3:49 Anniepoo: ok, if you count by users it's 95% or something

3:49 jdz: nothing close to 2/3rds of computer users read plain text files

3:49 in notepad

3:50 all other text editors can deal with single newline character

3:51 Anniepoo: but 100% of C# input streams are confused by the things

3:51 mebaran151_: I think the JVM makes it simple to figure these things out...

3:51 what kind of newline

3:51 tomoj: I see java uses a system property to decide what the line separator is

3:51 mebaran151_: yeah

3:51 jdz: Anniepoo: using DOS line endings is not gonna fix the problem you know

3:51 mebaran151_: exactly

3:51 Anniepoo: cause I'm writing a file to be interpreted by a program

3:52 and at the very least, *I* need to be able to read the thing without manually changing the line endings

3:52 jdz: Anniepoo: so you should output your file in a format that is expected by the other program

3:52 Anniepoo: ok, it expects dos line endings

3:53 jdz: Anniepoo: and you should not expect that some function will figure out what the other program expects magically

3:53 tomoj: PrintStream.println will use DOS endings, though

3:53 does seem a bit strange that clojure's println isn't consistent with java's

3:53 Anniepoo: but I do expect it to put out the line endings that system.properties says to use

3:53 jdz: Anniepoo: what i'm trying to tell you is that if you write your program, and then somebody runs it on, say, OSX, the output will be wrong, anyway

3:54 tomoj: not if it uses line.separator...

3:54 oh, yes, I see

3:55 so the solution in that case is to specifically ask for dos endings, I suppose

3:55 jdz: yes

3:55 mebaran151_: sigh, the line ending wars

3:55 tomoj: is rebinding newline a bad way to do that

3:55 just curious

3:56 jdz: so the real problem is that pr*l?n functions don't respect the system property mentioned above

3:58 Anniepoo: I'm with tomoj, I think the correct behavior here is to respect line.separator

3:58 jdz: Anniepoo: that would be the correct behaviour of println function, but you should not use it

3:59 Anniepoo: so yes, my program will break on OSX only if the C# program it's interacting with doesn't respect the system line separator

3:59 and, while I wrote the program it's interacting with, it's the only thing I've ever written in C#, I have no idea

3:59 jdz: and, btw, i'm pretty sure C# can deal with single-character line endings with no problems

3:59 Anniepoo: what it does with line endings

4:00 yah, I'm actually unit testing, and the test is failing.

4:00 jdz: relying on magic defaults in cross-platform cross-language communication is a way of asking for big trouble

4:02 Anniepoo: it's not as bad as 'cross platform means fsck off if you're not a cool linux user'

4:02 certainly the different line endings are a stupidity that needn't have happened

4:07 LauJensen: Its quite amazing that in 1980's we were anticipating flying cars etc in the new millenium, and here we are in 2009 discussing newline formats..

4:08 Anniepoo: I referred to EBCDIC the other day 8cD

4:09 hey, get on a network hardware forum, you'll hear about mark and space all the time

4:09 the terms are from telegraphy

4:09 soon after telegraphy was invented, they realized people could send it faster than someone could copy it down

4:10 so they made a clockwork gizmo that pulled paper tape through a holder

4:10 and attached a goose quill pen to the sounder of a telegraph

4:10 down is mark, up is space

4:10 clojurebot: mark is 1

4:10 mebaran151_: mark is 1?

4:10 Anniepoo: ah, come on! I bet this is the first time we've discussed mark on this forum!

4:11 mebaran151_: no I was just confused about the clojurebot

4:11 I want to know what mark it thinks is 1

4:11 Anniepoo: mark wrote a cool clojure program (see if it does it again)

4:11 so did marky mark

4:12 mebaran151_: I wonder if we still use any of the old telegraph lines, repurposed for digital communication

4:12 esp the the cross the atlantic ones

4:12 Anniepoo: does it mean Mark Mark, the lead rapper of Marky Mark and the Funky Bunch, or Marky Mark the wrestler

4:13 mebaran151_: this beginning to resemble a Markov

4:13 chain

4:13 Anniepoo: I believe they've all been replaced with more modern stuff

4:13 mebaran151: yeah, that's too bad

4:13 Anniepoo: but the hard part of laying a cable is laying the first one

4:13 wtetzner: what is mark

4:13 Anniepoo: so in a sense we still use them

4:13 wtetzner: mark is

4:13 hmm

4:14 Anniepoo: just as there's probably none of the original rails, spikes, or ties from the transcontinental RR still out there

4:14 but the track is still there.

4:15 many houses in San Francisco were converted to electric light after the quake,

4:15 and have the old tube and post wiring still in them

4:16 mebaran151: gotta avoid the sea monsters

4:16 well the clojurebot has declare mark is 1

4:17 Anniepoo: I was dating a guy who was a diver for a while. He had a video of an octopus attacking the ROV he was operating

4:20 wtetzner: clojurebot: mark

4:20 clojurebot: mark is 1

4:20 wtetzner: clojurebot: XML

4:20 clojurebot: XML is like violence; if it doesn't solve your problems, you're not using enough of it.

4:21 Anniepoo: clojurebot: space

4:21 clojurebot: namespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it

4:22 Anniepoo: anybody know how clojurebot works?

4:22 wtetzner: clojurebot: math

4:22 clojurebot: math is hard.

4:22 wtetzner: clojurebot: brain dump

4:22 clojurebot: brain dump is http://clj.thelastcitadel.com/clojurebot

4:23 wtetzner: Anniepoo: look here ^

4:23 Anniepoo: ah, fun

4:31 I'm about to write my first loop because I can't find a good map/reduce form for this

4:31 I have two seq's a and b. I want to create a modified a by looking through the elements of a

4:32 LauJensen: ~paste

4:32 clojurebot: lisppaste8, url

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

4:38 Anniepoo pasted "untitled" at http://paste.lisp.org/display/84892

4:42 mebaran151: there's usually a better way

4:42 are a and b the same length?

4:42 eevar2: anniepoo: (defn myfun [pred foo a b] (let [filtered-a (filter pred a)] (map foo a b))))))) .--- or something?

4:43 Anniepoo: no, a and b are NOT the same length

4:43 eevar2: probably can't use map like that, but ;)

4:43 mebaran151: there is almost always a map reduce form that is better than a loop recur form

4:43 I assume you have something function of b that you want to apply to a

4:43 Chousuke: (fn f [foo pred [a & as] [b & bs]] (lazy-seq (when a (cons (if (pred a) (foo a b) a) (f as bs)))))

4:43 Anniepoo: yes

4:44 Chousuke: somthing like that?

4:44 Anniepoo: yes mebaran

4:44 eevar2: ,(doc map)

4:44 clojurebot: "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."

4:44 mebaran151: so if pred a is true apply a to b

4:44 the way I'd do it

4:44 first match up all your a and b's

4:45 Chousuke: hmm, right

4:45 mebaran151: then filter by a

4:45 (which will probably be something like (first blah)

4:45 Anniepoo: yes, but Chousuke, isn't that tail recursion?

4:45 Chousuke: Anniepoo: it's a lazy seq

4:45 mebaran151: then finally with the filtered form apply your foo

4:46 Chousuke: Anniepoo: they *need* to be done using recursion, and take care not to blow up the stack

4:46 mebaran151: then you get all your laziness, which is a huge boon

4:46 Chousuke: but hmm

4:46 mebaran151: so how do you match up a and b

4:46 that's a little confusing

4:46 does a always go with the next b

4:46 so if a is at place 0 you want b to be 1?

4:47 Anniepoo: suppose you have a class of students who always line up in the same order

4:47 mebaran151: or do you want to use b like a stack of operands to be applied to a successive line of a's

4:47 Anniepoo: what mebaran said

4:47 mebaran151: so on your filtered a's, you'd take b0 b1 b2

4:48 oh that's pretty simple

4:48 first filter a

4:48 Anniepoo: sure, but I need to have the unfiltered a's back at the end

4:48 mebaran151: what do you mean?

4:48 Anniepoo: suppose you're working on a farm

4:49 the farmer tells you to go paint the fenceposts that aren't currently painted

4:49 mebaran151: is this for some job queueing system

4:49 Anniepoo: (ok, ignroe the farmer) I have a list of objects in my system

4:49 mebaran151: yeah

4:50 so why do the unfiltered ones need to go to the back

4:50 I mean you can get that

4:50 Anniepoo: no, they're ordered, don't rearrange them

4:50 mebaran151: okay

4:50 Anniepoo: these objects represent objects on another system

4:50 mebaran151: so you need to record their position

4:50 probably

4:51 maybe as a tuple

4:51 [a pos-a]

4:51 Anniepoo: those that are dirty, I add their info to some list

4:52 run some external process that does the transfer

4:52 and it returns the ID's I use to reference them on the other system

4:52 mebaran151: so why can't you filter by a

4:52 then map over b

4:53 Anniepoo: because at the end, I need to preserve the ordering on my end

4:53 mebaran151: keep an index with each a

4:53 so first map each a to its index

4:53 in a vector

4:53 then filter that vector by its first element

4:54 Anniepoo: I need to (assoc ) the ones I updated to get the other system's UUID into their map

4:54 mebaran151: then map b to apply to the first element of each of yours a's and remap it back in

4:54 Anniepoo: then sort

4:54 mebaran151: actually, this might be a perfect use for metadata

4:54 to maintain your position information

4:55 assuming a is some sort of clojure thing

4:55 so you have a bunch of a's whose uuid's you need to get

4:55 Anniepoo: oh, sure, the a's are maps. It's a GUI editor

4:56 mebaran151: but some a's come with uuid's already

4:56 Anniepoo: yes

4:56 some already have UUID's

4:57 and the spawned process takes some info from the ones that need UUID's

4:57 as lines in a file

4:57 mebaran151: so why is mainting order so important?

4:57 Anniepoo: and returns lines in a file with the UUID

4:58 because that establishes Z order for the objects in the virtual world that is the other end

4:58 mebaran151: it always seems ugly and imperative to rely on absolute ordering

4:58 Anniepoo: yes, maybe that's my problem

4:58 Chousuke: http://gist.github.com/163202

4:58 mebaran151: this order attribute sounds like it belong as another attribute in your map

4:58 Anniepoo: I shouldn't be depending on it

4:59 mebaran151: well Chousuke just made the right loop

5:00 * Chousuke <3 M-x gist-buffer

5:00 Anniepoo: ,(doc gen)

5:00 clojurebot: "/;nil; "

5:00 Anniepoo: what's gen?

5:00 Chousuke: gen is the name of the fn

5:00 Anniepoo: ah, I see

5:01 mebaran151: I still think we could be a little more functional than rolling our own lazy-seqs

5:01 lazy-seqs are always a little more brittle

5:01 for this sort of thing, I think you can map and reduce your way out yet

5:01 Chousuke: hmm

5:01 mebaran151: Anniepoo, what do you have recording the position in the map?

5:01 *have against

5:02 the position seems to be an instrinsic attribute of a: maybe it deserves its own key

5:02 Anniepoo: yes, I'm beginning to think so

5:02 mebaran151: that way you could even uses sets if you wanted and not lose any data, or resort them and always have a way out

5:02 Chousuke: ,(for [a [1 2 3 4] b [1 2 3 4] :when (even? a)] [a b])

5:02 clojurebot: ([2 1] [2 2] [2 3] [2 4] [4 1] [4 2] [4 3] [4 4])

5:02 Anniepoo: though it's nice that it stays a compact set

5:02 mebaran151: then you have a simple path for filtering map and reducing

5:03 compact set?

5:04 Anniepoo: yes, the objects are 'stacked' in 3D in the virtual world that's at the other end

5:04 so a3 is always up a constant amount from a2

5:04 if I delete a2 in the set a3 should move down

5:05 mebaran151: that wouldn't be true though in a vector either (they don't automagically compact themselves)

5:06 Anniepoo: first/rest does

5:06 mebaran151: I might be lying :)

5:06 Anniepoo: the data's really a list, not a set

5:06 mebaran151: I see

5:07 so essentially for each a that the pred is true

5:07 you want to pop a b off the stack

5:07 Chousuke: hmm

5:07 Anniepoo: yes

5:08 Chousuke: ,(merge-with + #{1 2 3 4} #{10 2 30 4})

5:08 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.util.Map$Entry

5:08 Chousuke: damn :)

5:08 mebaran151: but you have to remember where a came from at the same time

5:09 Anniepoo: another way to look at it is that my architectural error is in using the order to map the external process's I/O

5:10 that is, I have to give it a list of filenames (that's what I get out of the a's) and I get back a same length list of UUID's

5:11 so I should wrap this very imperitive nastiness with making a map

5:11 that maps filename to UUID

5:12 then look through all of the a's, and if it's got a filename that's in my map, remap it

5:12 that's the correct thing, I think

5:12 ,(doc merge-with)

5:12 clojurebot: "([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."

5:13 Chousuke: (merge old-map (zipmap filenames uuids))

5:13 Anniepoo: ,(doc zipmap)

5:13 clojurebot: "([keys vals]); Returns a map with the keys mapped to the corresponding vals."

5:14 Chousuke: merge is basically (merge-with (fn [x y] y) ...)

5:14 Anniepoo: yes, this is the architecturally clean thing

5:14 make the structure I need

5:16 mebaran151: it's all about datastructures

5:17 Anniepoo: ok, gimme a minit to try this

5:23 is there a way to start with (:foo :bar) (1 2) and get {:foo 1 :bar 2}?

5:23 ah, zipmap

5:23 sorry,

5:32 ok, this looks a lot saner

5:35 mebaran151: yeah

6:00 tomoj: is there a reason ns-reload! needs to be a macro here? http://bc.tech.coop/blog/docs/user.clj

6:35 Chousuke: tomoj: not as far as I can tell.

6:35 tomoj: me neither, strange

6:35 Chousuke: probably just convenience

6:36 as you can white (ns-reload! your.namespace) instead of (ns-reload! 'your.namespace)

6:36 write* :P

6:39 does the repl automatically load user.clj btw? :/

7:09 Jomyoot: hi man

7:09 yo

7:09 is there a better way than clojure.org/api to find the functions in eed

7:09 i need?

7:10 the good thing about object oriented is that i can always look at the right class to find the right method for what i need

7:10 but now all functions are listed alphabetically. i can never find the right ones i need

8:25 * rhickey still likes 'reify' for new new today

8:26 LauJensen: hehe, seriously?

8:26 rhickey: yes

8:26 LauJensen: oh... :)

8:28 I thought proxy was quite good in terms of naming

8:58 Jomyoot: hi

8:58 LauJensen: Yo

8:58 Jomyoot: sup dude

8:58 woder if anyone actually has a job that uses clojure

8:59 LauJensen: Sure they do

8:59 Jomyoot: like what kind? research?

8:59 ai ?

8:59 LauJensen: Number crunching and data parsing

9:02 cemerick: Jomyoot: 95% of the new code we write is in clojure

9:02 Jomyoot: camerick what kind of project?

9:02 cemerick: when we're hiring next, I'm sure we'll make it well-known here and on the group

9:03 Jomyoot: there's lots of moving pieces. In the first place, v3.0 of PDFTextStream

9:03 http://snowtide.com/PDFTextStream

9:03 Jomyoot: can't wait to see a web project

9:03 alinp: hi

9:04 Jomyoot: replacement of rails but with clojure

9:04 cemerick: We have a far more ambitious project running in parallel.

9:04 alinp: is there any "power of" function in clojure ?

9:04 fffej: alinp: use Math/pow?

9:04 alinp: beside of that, of course :)

9:05 that's why I asked: in clojure

9:05 not in java

9:05 Chousuke: then, no :P

9:05 fffej: alinp: my bad

9:05 Chousuke: except maybe in contrib somewhere.

9:05 alinp: ok, thanks

9:06 fffej: alinp: clojure.contrib.math has (expt x y)

9:06 alinp: oh, pretty cool

9:06 thanks

9:09 rhickey: cemerick: I missed you yesterday, but I think reify makes sense as a concrete realization of an (otherwise non-instantiable) interface abstraction

9:16 cemerick: rhickey: Yeah, I guess that makes sense.

9:17 rhickey: and it makes sense as a realization both as code and as an object

9:18 cemerick: naming things is so fuzzy -- so much about 'feel'...

9:20 I'm all for the pedagogical utility of naming it 'reify', but we'll have to be prepared for even more q's about 'how do I implement an interface...'

9:20 rhickey: cemerick: people found proxy even though it's not a great name

9:21 cemerick: heh, I thought it made perfect sense because of j.l.r.Proxy

9:22 rhickey: that's what's fun about this conversation, I think we are thinking about this feature completely differently :)

9:23 cemerick: yup -- I just don't have the CS chops to think about it outside of its actual utility for too long :-)

9:23 rhickey: cemerick: I don't think it's a matter of CS chops, I'm just looking out for ClojureScript :)

9:24 cemerick: rhickey: oh, that. I thought you were referring to your line of thought from yesterday, about how newnew's impl shows that the typical lambda construct is a specialization, etc.

9:24 Chousuke: What happens if you actually subclass a concrete class with newnew? Will the code look at you in a condescending manner?

9:25 cemerick: I have moments of clarity when I enter those waters, but that's about it. :-(

9:25 rhickey: cemerick: there is that, but here I'm just trying not to depend on Javaisms

9:25 Chousuke: definitely

9:26 cemerick: Chousuke: you'll softly hear, 'tsk, tsk, tsk', but you won't be able to tell where it's coming from.

9:27 rhickey: a good thing, definitely

9:28 On my drive in this morning, I was daydreaming about a couple of macros to implement something like traits using newnew. Surely that's a sign of some kind of illness?

9:29 rhickey: cemerick: at your suggestion I looked at Scala traits. They really frightened me.

9:30 cemerick: concept, or implementation?

9:30 (I found them to be pretty pleasant to use, as long as you stayed away from the loftier bits of type mumbo-jumbo.)

9:30 rhickey: complexity, ordering rules, cascading dependent definitions... seems fraught

9:33 cemerick: I just want to be able to program to (for example) NetBeans' APIs in clojure in some rational way, which would ideally involve having default implementations of certain interfaces and abstract classes here and there, combining them as desired.

9:34 The general case is surely far more complex.

9:34 Right now, UI / NetBeans dev is our #1 cluster of Java development, thus the attention.

9:35 rhickey: I think, in my ideal world, nothing would ever be isa some concrete thing from which it inherited, e.g. if you could derive from an abstract superclass but not be instanceof it, only an instance of interfaces it implements

9:37 i.e. we inherit things from our fathers but are not our fathers

9:37 I'm not opposed to mixins in general, but it is so easy to design a mess-making system

9:38 cemerick: it seems like your ideal world *is* mixins

9:38 rhickey: how you do mixins matters

9:39 cemerick: ah -- so your concern with scala traits really are related to implementation complexity?

9:39 rhickey: cemerick: no, user complexity

9:40 cemerick: Huh. When I used them, I found them pleasant enough.

9:40 Though, I wasn't trying to dig myself a hole :-)

9:43 yeah, I can see how you could really spin a web with them.

9:43 rhickey: cemerick: but you could still find yourself in the bottom of one, cursing your shovel

9:45 cemerick: rhickey: oh, I ended up in a very deep hole, and I cursed scala for it, but it was the type system (or, my application of it, others might say) that got me there.

9:46 I seem to remember having come to the conclusion that I would have had to build a whole new type hierarchy, rooted at Any, with my own datastructures, in order to get things to line up properly. Don't remember the specifics though.

9:48 rhickey: I smiled also (in recognition) at the lack of ctor args for traits

9:54 (musing here) what if I let you specify multiple ctor-less classes but the resulting object would not be isa any of them, only the interfaces they implement?

9:55 cemerick: That sounds like the ideal.

9:56 Wouldn't work for libs that have a dependency on an abstract class, but in that case, the interface is semi-worthless anyway.

9:56 rhickey: that's one of the problems I have with traits, they're the substitute for interfaces, but, then you put in concrete code and have left yourself without an interface

9:56 cemerick: well, the interface is there, just name-mangled

9:57 LauJensen: Guys, if its impossible thats ok, but I'd like to understand what youre talking about. Where do I go to read some background info which will let me understand the implications of your propositions?

9:57 rhickey: cemerick: I'm determined not to try to fix bad Java designs

9:57 cemerick: but not part of the program design

9:59 cemerick: rhickey: yes, definitely quarantine those vectors

9:59 LauJensen: I generally barely keep up myself :-)

10:00 LauJensen: Good to know :)

10:00 rhickey: me too!

10:02 cemerick: rhickey: you'll understand if we all collectively roll our eyes, right? :-)

10:02 programming is one of those fields where, the more you learn, the more you realize you don't understand a damn thing.

10:02 rhickey: cemerick: I had to read the Scala book to follow up on your suggestion

10:03 it works both ways

10:03 cemerick: rhickey: oh, I'm so sorry.

10:03 rhickey: re-read the traits section I mean

10:04 cemerick: jeez, back when I started learning scala, all there was were the tutorial PDF and the language spec PDF (with the former consistently being out of date/sync with the latest version). That was brutal.

10:04 LauJensen: Reminds me of when I picked up Clojure... All I had was Chouser :)

10:05 cemerick: Yeah, Chouser_'s been here "forever".

10:05 Likely off coding some hairy C++ right now. :-/

10:06 LauJensen: Yea he loves that stuff

10:06 cemerick: Chouser_: come back to the fold, buddy! :-D

10:06 cp2_: feels good man

10:07 LauJensen: rhickey: What happend to that virtual study session you were considering at one point?

10:10 rhickey: LauJensen: right now we're putting together a NYC Clojure meetup

10:10 Chousuke: Hm

10:10 LauJensen: rhickey: How can I benefit from that ?

10:11 ( I realize Im being very selfish )

10:11 Chousuke: I wonder why an exception from my reader got wrapped in ~eleventy billion RuntimeExceptions :/

10:11 LauJensen: Chousuke: Sounds like you've gotten into 'state'

10:13 Chousuke: my reader does not "consume" its source.

10:14 I can (def source whatever) and then try to read it multiple times.

10:14 but still, I get this: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.Exception: Expected token, got nothing. (line 10, character 7)

10:14 (It's just an unimplemented reader macro, but the runtimeexceptions are puzzling)

10:18 LauJensen: rhickey: I meant it seriously. Will you put out some info from those meetings, videos, docs, etc ?

10:18 Chousuke: hm, maybe I should do this work in the newnew branch

10:18 I could use a "/dev/null" right now.

10:18 rhickey: LauJensen: no plans right now

10:18 LauJensen: ok

10:18 Chousuke: something that discards the item if you conj on to it.

10:19 I suppose proxy would work too

10:22 cemerick: rhickey: any idea of the schedule yet? I/we would try to make it.

10:23 rhickey: cemerick: you can sign up here for notices: http://www.meetup.com/Clojure-NYC/

10:39 lisppaste8: cgrand pasted "clojure on par with java?" at http://paste.lisp.org/display/84909

10:40 Chousuke: hmm

10:40 rhickey: cgrand: looks pretty good!

10:40 * Chousuke wonders what SLIME is doing to his debug prints

10:41 Chousuke: I have a println statement in a defmethod accompanied by a flush, but I'm not seeing it anywhere. :/

10:41 cgrand: rhickey: I'm really surprised by these results

10:42 rhickey: in what way?

10:42 cgrand: they are too good

10:42 rhickey: :) that's the point, no more need for Java!

10:43 I presume ISetNode is because no non-reflective helpers yet?

10:44 cgrand: can reify declare new methods?

10:44 rhickey: yes

10:44 cemerick: cgrand: those benchmarks are using transients in the reduce?

10:44 Chousuke: durr

10:44 rhickey: but right now calls to them are reflective

10:45 Chousuke: I didn't even have a bug. D:

10:45 rhickey: self-calls will be non-reflective, will always be reflective from outside the class

10:45 Chousuke: I just had mismatching parentheses in a *comment*

10:45 LauJensen: rhickey: is 'reify' the decided name? Am I the only one to whom it really sticks out in a bad way?

10:45 cgrand: cemerick: no transients on sets yet plus I'm in the "new" branch

10:46 rhickey: LauJensen: you are the only public complainant at the moment, maybe everyone else is just cringing in private :)

10:46 cemerick: well, goodness, lots of potential yet :-)

10:46 LauJensen: hehe, I just earned a bad title then

10:47 rhickey: cgrand: I love how few #^s

10:47 although it begs for #^objects akin to #^doubles etc

10:48 cemerick: rhickey: LauJensen may find some friends on the group. It's not a bad name, but it's certainly unusual and uncommon.

10:48 rhickey: cemerick: not bad traits for a new special op, in terms of conflicts

10:48 clojurebot: for is not used often enough.

10:49 cemerick: oh, I don't disagree. There will definitely be some groaning and muttering, though.

10:49 rhickey: cgrand: so, with high-perf helper methods, ISetNodes/Utils could go away and I SetNode could be defined with gen-interface?

10:49 cgrand: yup

10:50 rhickey: cool

10:50 cgrand: this is a terrific validation, thanks for tackling it

10:52 AWizzArd: rhickey: btw, do you expect this InvokeDynamic bytecode instruction from Java 7 to speed up Clojure here and there even more?

10:53 cgrand: rhickey: I'm not sure to understand how non-reflective self-calls will help to remove the need for an explicit interface

10:53 rhickey: AWizzArd: perhaps, but it would mean bifurcating the code to deal with older VMs. One of the design constraints for Clojure was to work well on the JVMs people are using right now

10:54 cgrand: they don't remove the need for ISetNode, but for ISetNode/Utils, and the former we can write with gen-interface

10:55 in order to make your solution Java-free

10:57 cgrand: but this benchmark is unfair: no dummy map and slightly different algorithms (half-full bitmap nodes become array-nodes, no leaf-node)

10:59 AWizzArd: rhickey: will I be able to build my own abstraction over newnew which can give me something like defstruct, but with faster instantiation (under the hood I would build a simple Java class, to which I can't add k/v pairs of course)

10:59 rhickey: AWizzArd: you have to stop asking me about that

11:00 cgrand: true, but still shows an (almost) all-clojure data structure with speed akin to the Java-written ones

11:04 cgrand: rhickey: can't we have non-reflective method calls to a reified object (a "reclausa"? :-) ) in the whole lexical scope? Is this impossible or hard?

11:04 AWizzArd: i see

11:05 rhickey: cgrand: oh yes, by self-calls I meant only from within any of the methods, on a target of "this"

11:07 cgrand: or do you mean on another instance of the same anonymous class?

11:07 (of course your helpers don't use "this")

11:10 cgrand: I was thinking about something like that: (let [o (new [] (foo [x] (str "bar" x)))] (.foo o "baz"))

11:12 rhickey: cgrand: ah, I'm not there yet, I need to think about it, my inclination is no, I'm trying to encourage programming to interfaces

11:12 cemerick: all such calls would always be reflective though, right?

11:13 rhickey: also, if they move that body into a helper, they'll get reflection warnings they can't remove

11:13 cemerick: if I let them be public at all, that style of programming is really icky

11:13 tomoj: damn. this site uses multiple cookie headers, spelled "Set-cookie" instead of "Set-Cookie". clojure-http-client supports neither

11:14 rhickey: right now the intended use for additional methods is private high-perf helpers

11:14 cemerick: is that even necessary? You can just close over some 'bare' helper fns, right?

11:15 (that's totally aside from convenience, clarity, etc)

11:15 rhickey: cemerick: methods can have fully primitive args/returns

11:15 fns can't

11:15 cemerick: ah-ha, right

11:15 rhickey: plus fns need to be allocated

11:15 everything in a reify is one allocation

11:16 only non-closing helper fns could be one-time allocated

11:16 and fns don't have access to the other members except through a public interfaces

11:17 so there's a good argument for additional helper methods, and no really good ones for leaking them out

11:18 cgrand: ok

11:18 cemerick: rhickey: I'll just keep asking naive questions so you can fully examine your reasoning :-P

11:25 cgrand: rhickey: btw, on thie "new" branch, lazy-primes3 (see here http://clj-me.blogspot.com/2009/07/everybody-loves-sieve-of-eratosthenes.html ) throws an IllegalAccessError when called

11:43 cemerick: gawd, trying to get NetBeans folks to understand that there is a world outside of big-J Java is proving nigh-impossible.

11:43 odd, since they've got the best JRuby IDE impl out there.

11:58 AWizzArd: cemerick: so currently they don't see enough critical mass behind Clojure to provide more support in NetBeans?

11:58 tomoj: do dan larkin or phil hagelberg ever come around here?

11:59 cemerick: tomoj: danlarkin is over there :-)

11:59 * danlarkin stands proud

11:59 cemerick: AWizzArd: not a matter of support or critical mass -- they just don't seem to recognize that there's a universe outside of Java

12:00 tomoj: danlarkin: hey, got some issues with clojure-http-client. I'll try to figure out the patch needed. should I put them in github's issue tracker?

12:00 cemerick: There are a couple of things they could do that would simplify things for other jvm language users, and introduce zero breakage for Java devs, but they don't see the point.

12:01 AWizzArd: hmm

12:01 cemerick: we'll see, I'm swinging for it :-)

12:02 danlarkin: tomoj: sure! You might also check out contrib's http library. It was added after we started clojure-http-client, and I haven't used it yet. Not sure how much parallel functionality there is between the two

12:03 tomoj: danlarkin: ah, will check that out. just ran into a few problems with cookies (two of which are probably my university's fault for not strictly following HTTP)

12:06 looks like clojure-http-client has more of the features I need. currently fixed it with an ugly hack. I'll try to figure out a proper patch soon

12:06 danlarkin: tomoj: cool :)

12:08 Chousuke: ooh, progress! reader.clj is able to read itself without exceptions now. (though the results of the read are not usable, due to missing support for complex character escapes and such... )

12:09 \newline gets read as ewline :p

12:35 I still wonder why I get so many RuntimeException wrappers :/

12:36 mebaran151: yeah, I've always wondered that too

12:43 tomoj: what's like reduce but operates on one element at a time, rather than two?

12:44 Chousuke: that doesn't make sense?

12:44 or do you mean map? :P

12:44 tomoj: hrmm

12:44 OH

12:44 I was confused

12:44 reduce is exactly what I want

12:47 angerman: can I split a large clojure file into many smaller ones using (use and (in-ns ?

12:47 Chousuke: use load-file

12:47 or subnamespaces

12:49 tomoj: hmm

12:50 I have a function which takes a pred and a seq, and returns a map where the keys are the seq elements for which pred is true, and each value is a vector of the elements after that and up to the next element for which pred returns true

12:50 I wonder what to call it

12:51 angerman: filter?

12:52 Chousuke: "group" :P

12:52 angerman: group-filter or filter-to-group?

12:52 tomoj: like (my-function number? '(5 a b 7 c d e)) returns {5 [a b], 7 [c d e]}

12:52 angerman: grouped-filter, maybe

12:53 Chousuke: there's a similar function "group-by" in contrib I think

12:53 (doc group-by)

12:53 clojurebot: "([f coll]); Returns a sorted map of the elements of coll keyed by the result of f on each element. The value at each key will be a vector of the corresponding elements, in the order they appeared in coll."

12:53 Chousuke: hmm, not quite.

12:54 group-by-delimiter

12:54 tomoj: that's exactly what it does!

12:54 :)

13:00 cemerick: argh, just got caught by the fact that clojure in the same ns as a class with a package-private method can't invoke that method.

13:03 gko: Is there some macro for such destructuring: instead of (defn f [{a :a b :b c :c ...}] ...) => (defn f [XXX] ...) and the XXX would magically becomes {a: a b: b ...} etc?

13:04 Chousuke: gko: {:keys [a b c]}

13:04 or hm

13:05 something like that works in let anyway. I always forget the exact syntax :P

13:07 gko: Chousuke: oh... right, I must still explicitely say a, b, c, etc... otherwise I'll have compiler error...

13:08 Chousuke: OK, working. Thanks.

13:10 rhickey: cgrand: thanks, fixed letfn on new branch

13:14 gko: do you use different faces (in SLIME) for (), [], {}, #{}, @..., ^..., ^#'..., #', etc.?

13:15 * Chousuke just uses standard clojure mode settings

13:19 LauJensen: Btw - For those interested in Github: I contacted their support to ask about the slowness of their site. They said that they have been working on a solution since april (sounds like a c++ thing), and that things will be changing very soon

13:21 Chousuke: ooh. good news.

13:21 because github is *slow*

13:22 gko: When is it slow? Always? Morning? Evening?

13:23 Chousuke: every time I use it :

13:25 rhickey: is there a way to get a link to a particular source line on github, like we used to be able to do with gcode?

13:26 Chousuke: hmm

13:27 I think clojurebot does it somehow

13:27 rhickey: ah, looks like #LCnnn

13:27 LauJensen: There is

13:27 I think you just prepend #150 to get line 150, but lemme check

13:28 rhickey: LauJensen: #LCnnn works

13:28 LauJensen: k

13:29 Chousuke: rhickey: btw, do you have any idea what could cause my exceptions to get wrapped in multiple RuntimeExceptions? I'm writing a recursive reader for clojure and all exceptions it throws are rather well "packaged" :P

13:31 lpetit: Chousuke: a beginning of explanation in the "recursive" nature of your reader ?

13:31 Chousuke: I suppose it could be just slime being weird.

13:32 lpetit: what do you mean? :P

13:34 lpetit: Chousuke: maybe a totally idiotic idea of mine, but could exceptions be catched an rethrow (wrapped in a fresh one) at each level of the recursion ?

13:34 Chousuke: that's possible, but it didn't happen with a regular recursive function

13:34 hmm

13:34 lpetit: Chousuke: I'm interesting in knowing what you're pursuing by writing a recursive clojure reader. Is it as an exercise, or with other goal in mind

13:35 Chousuke: %s/interesting/interested/g

13:35 Chousuke: lpetit: well, if it turns out good enough I'm all for including it in Clojure. But if not, then at least it's been fun to write

13:36 as it is now, it's not as resistant to stack overflows as the java reader, and is a fair bit slower too I guess

13:36 but at least it doesn't contain mutable state

13:37 lpetit: Chousuke: oh yes, less java, more clojure. I see :-). If you came up with a reader that could have a "working mode" that would not throw anything that it reads (including comments, raw textual representation of the element, spaces) that would be great too !

13:39 tomoj: possible to get a map sorted by insertion order?

13:40 Chousuke: tomoj: not without having the information in the key.

13:40 tomoj: ah

13:40 just thought up a way around needing it anyway

13:41 Chousuke: lpetit: it's not quite that flexible at the moment, but... it might not be impossible.

13:43 first, I need to get in a state that produces eval'able code :P

13:45 syntax-quote is going to be interesting to implement in Clojure.

13:46 Currently I just call the java method that syntax-quotes a form. :P

13:46 lpetit: Chousuke: do you do this all by hand, or a helper library such as fn-parse ?

13:46 Chousuke: lpetit: pure clojure.core

13:46 fnparse would make it much easier I suppose.

13:47 but it would make it impossible to use my reader with clojure :)

13:49 tomoj: there has to be a better way to do this: https://gist.github.com/a625a6edd5824bfc4c81

13:51 Chousuke: tomoj: curious: why are you using lists instead of vectors? :/

13:51 tomoj: random choice

13:51 I dunno when one or the other is better yet

13:51 Chousuke: well vectors are easier to type. :)

13:51 tomoj: will switch to vectors, but still seems ugly

13:51 ah, and easier to read too I suppose

13:53 updated gist

13:53 Chousuke: take-while could help you I suppose.

13:54 or hm.

13:54 tomoj: ah, then I wouldn't have to pass around the current delimiter, I suppose

13:54 since I could just grab the delimiter's group all in one

13:55 oh, except I'm reducing

13:55 Chousuke: your current implementation is probably better.

13:55 tomoj: maybe it just seems ugly to me because I'm not used to functional programming yet

13:59 destructuring is fucking awesome

14:00 cemerick: that's a pretty good tshirt slogan :-P

14:01 tomoj: the clojure logo looks good for tshirts

14:01 cemerick: I think they're already on cafepress?

14:01 ~tshirts

14:01 clojurebot: Huh?

14:01 cemerick: hrm

14:01 ~shirts

14:01 clojurebot: Titim gan éirí ort.

14:01 tomoj: found a few on zazzle

14:01 cemerick: ah, zazzle

14:02 tomoj: http://www.zazzle.com/clojure+tshirts

14:02 cemerick: clojurebot: tshirts is <reply>Check 'em out: http://www.zazzle.com/clojure+tshirts

14:02 clojurebot: In Ordnung

14:02 cemerick: ~tshirts

14:02 clojurebot: Check 'em out: http://www.zazzle.com/clojure+tshirts

14:02 tomoj: nice

14:04 logo buttons are only $1.45

14:20 lisppaste8: cemerick pasted "group-by-pred alternatives" at http://paste.lisp.org/display/84926

14:20 cemerick: tomoj: ^^

14:21 the second one is (perhaps) a clearer way of doing what you did, but some will not like reducing of a vector for this purpose

14:22 tomoj: I was just about to update my gist

14:22 cemerick: split-groups-with is more general, and returns a seq of vectors that can be turned into map with (into {} (split-groups-with number? ...))

14:22 tomoj: I also need to transform the keys and values of the final map with different functions

14:23 ended up rolling it into my previous function like this: https://gist.github.com/a625a6edd5824bfc4c81

14:23 which I don't like at all

14:24 cemerick: yeah...you should definitely break things up there a little bit

14:25 lots of stuff going on in the * fn

14:25 tomoj: the problem is, after the map functions are applied, there's no way to distinguish delimiters from values

14:25 (in my case)

14:25 cemerick: aren't the delimiters always the keys?

14:26 tomoj: yeah, I just mean I can't transform the elements of the seq before grouping them

14:26 perhaps I could group, then transform the keys and values of the resulting map

14:26 cemerick: that's a far better approach

14:27 tomoj: actually, now that I think about it a bit more, I don't even want a map at all

14:27 cemerick: heh

14:27 tomoj: I want each element of the result to be a map with one pair for the delim and another pair for the grouped elements

14:28 and doing that I can transform after grouping easily

14:29 cemerick: tomoj: I'm a little confused, but mostly because there are no pairs in clojure :-)

14:29 you mean two-element seq / vector?

14:29 tomoj: I meant one key-value pair

14:29 cemerick: ah

14:29 tomoj: like each element will look like {:name <delimeter transformed> :children <group, each element transformed>}

14:30 cemerick: I thought you meant a dotted pair, which I don't even remember well from CL

14:30 tomoj: no dotted pairs in clojure?

14:30 oh, no conses really, I guess

14:31 even though we have "cons" :)

14:31 rhickey: ,(class (cons 1 nil))

14:31 clojurebot: clojure.lang.PersistentList

14:31 tomoj: I'm too noob to understand your examples quickly, but thanks, I'll step through them

14:32 cemerick: There is a cons (clojure.lang.Cons) data structure, but the cdr is always a seq.

14:32 rhickey: ,(class (cons 1 [2 3]))

14:32 clojurebot: clojure.lang.Cons

14:33 * cemerick hopes he hasn't bollocks'ed up any terminology in the last 3 min :-P

14:33 tomoj: empty seq for the last element?

14:34 cemerick: empty seq for rest

14:34 ,(cons 1 2)

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

14:34 cemerick: ,(cons 1 [2])

14:34 clojurebot: (1 2)

14:34 cemerick: ,(rest (cons 1 [2]))

14:34 clojurebot: (2)

14:35 tomoj: ,(cons 1 nil)

14:35 clojurebot: (1)

14:35 cemerick: contrast with:

14:35 ,(list 1 2)

14:35 clojurebot: (1 2)

14:35 cemerick: ,(list 1 nil)

14:35 clojurebot: (1 nil)

14:36 tomoj: those two behave just like CL

14:36 rhickey: Clojure cons cells are not arbitrary pairs

14:36 tomoj: the ones with nils i mean

14:37 but (cons 1 2) is different

14:37 cemerick: yeah. You can't do (1 . 2)

14:37 rhickey: and most ops prefer PersistentList

14:37 ,(counted? (cons 1 nil))

14:37 clojurebot: true

14:38 rhickey: ,(counted? (cons 1 [2 3]))

14:38 clojurebot: false

14:38 rhickey: so the cons function has polymorphic return values, it is not a constructor for a particular structure

14:47 angerman: how would I translate something like "sha.new(str(random.random())).hexdigest()[:5]" from python to clojure?

14:49 cgrand: rhickey: ok now I think it's worthy to rework PersistentHashMap (and TransientHashMap), do I get your green light?

14:49 tomoj: angerman: probably mostly with java I'd think

14:50 rhickey: cgrand: rework how, the leaf-less and not-packed ideas

14:50 ?

14:50 cgrand: yup

14:50 rhickey: you think that due to the set work?

14:50 clojurebot: that is not what I wanted

14:51 cgrand: yup (btw I forgot two or three #^"[Object" this makes things slightly faster)

14:51 rhickey: cgrand: this reworking in the Java version?

14:53 cgrand: rhickey: rewriting collections in clojure is a short term goal?

14:54 rhickey: cgrand: there is a problem with using them before cinc in that there are bootstrapping issues, e.g. the implementation of Clojure uses maps

14:54 but we might be able to bootstrap what we've got and swap in Clojure versions as we go

14:55 cgrand: so yes, I was talking abour reworking the java versions, I think TransientHashMap ca be way faster

14:55 rhickey: go for it then

14:55 cgrand: must run

14:55 ok

15:02 angerman: tomoj thanks

15:04 tomoj: angerman: i.e. java.security.MessageDigest

15:07 angerman: hmm another question, how would I loop over something that I want to stop once it's done

15:08 e.g. I want to try to create something it might fail...

15:08 so I'll retry for x times

15:08 wtetzner_: is there a way to check if something is named?

15:09 like with symbols and keywords, you can do (name :keyword) or (name 'symbol)

15:11 tomoj: (or (symbol? x) (keyword? x)) ?

15:12 wtetzner_: hmm

15:12 ok

15:16 tomoj: angerman: I suppose you could recur in a catch, passing along a counter counting up to the max number of tries

15:16 there's probably a better way

15:17 better to count down from max tries

15:19 Chousuke: hm

15:19 * Chousuke is connected to his irssi in an emacs buffer

15:20 tomoj: eshell? or what?

15:20 Chousuke: At least I found a third terminal emulator for OS X.

15:20 just terminal, running bash

15:20 inside emacs...

15:20 angerman: how about my faculty implementation? (defn fac [n] (loop [x n acc 1] (if (> x 1) (recur (- x 1) (* x acc)) acc)))

15:21 tomoj: there are no loops in clojure

15:21 clojurebot: clojure is the best way to learn java

15:21 Chousuke: tomoj: loop is there :p

15:21 tomoj: not like you'd think, anyway

15:21 Chousuke: but it's a functional loop.

15:21 tomoj: loop is misleadingly named for noobs

15:22 Chousuke: yeah, it's basically just a shortcut for ((fn [foo bar] (dostuff foo bar) (recur something else)) init vals)

15:23 though I don't know if it *really* is that.

15:23 tomoj: oh, but I forgot about loop-recur

15:25 how about (defn fac [n] (reduce * (take n (iterate inc 1))))

15:27 angerman: yours is faster

15:31 why in the world isn't there a time which returns the msecs

15:31 * angerman guesses his is faster because it's using pseudo-tail-call-optimization

15:32 tomoj: but mine doesn't even do any recursion anyway :(

15:32 Chousuke: the laziness overhead matters some.

15:33 * Chousuke should try running vim inside emacs

15:34 tomoj: how do you run bash inside emacs anyway?

15:34 Chousuke: M-x shell or M-x term

15:34 I'm not just running bash inside emacs. I'm running ssh inside that bash, and screen, and finally irssi

15:34 and it works just fine

15:35 I bet I could run emacs inside emacs.

15:35 tomoj: haha

15:35 I've got irssi and emacs in a screen through ssh

15:35 but not nested in emacs :)

15:36 Chousuke: hm

15:36 I ran emacs in emacs :P

15:36 it works too

15:36 tomoj: I can even get screen up

15:36 "clear screen capability required"

15:36 Chousuke: you probably need M-x term for that

15:36 M-x shell is just for shell interaction

15:37 but I think if I ran a terminal inside emacs inside emacs then the keybindings would conflict.

15:37 tomoj: wow this is nice

15:37 (irssi in emacs)

15:38 Chousuke: you can switch buffers with C-c b (C-c is the "escape" from terminal mode into emacs)

15:39 tomoj: can't get other minor modes in here?

15:39 e.g. paredit for typing to #clojure :)

15:40 dunno how to get something like M-x starting with C-c = C-x

15:41 oh, easy. but paredit doesn't like this buffer

15:42 fridim_: tomoj, do you have a screenshot ? :)

15:42 emacs is Lisp enabled, so I guess you guys use it.

15:43 would be logical. So if some of you use vim, that prooves the superiority of it.

15:43 :-O

15:43 tomoj: not a very interesting sshot

15:44 fridim_: I know

15:44 tomoj: hmm

15:44 fridim_: ah I thought you mean my attempt.

15:44 tomoj: http://skitch.com/tomoj/b4ptn/terminal

15:44 Chousuke: tomoj: maybe you need to enable line mode for the terminal hmm

15:44 tomoj: for some reason I can't send that url in irssi-in-screen-in-ssh-in-term-in-emacs

15:44 Chousuke: wooh

15:45 okay

15:45 screen does not like line mode :P

15:45 tomoj: had to switch back to Terminal.app to send that url

15:46 Chousuke: hmm

15:46 I wonder how to get back to character mode

15:46 line mode is a lot faster though.

15:46 tomoj: here's my clojure http://skitch.com/tomoj/b4ptw/users-thomasjack-code-clojure-utscheduler-src-com-tomojack-utscheduler.clj

15:47 C-c C-k and the repl has the updated code

15:47 vim probably has something similar

15:48 Chousuke: Gorilla, but it's not as good as slime. :p

15:48 tomoj: slime <3

15:48 I still have not achieved paredit zen

15:48 Chousuke: vim simply sucks at interacting with things that are not vim

15:50 which is one of the reasons I consider emacs superior. though I like vim's modal interface.

15:50 but for that, there's viper.el

15:50 tomoj: for some reason phil hagelberg's starter kit forces paredit 20 to load even though it bundles 21

15:50 and 20 sucks at clojure

15:54 fridim_: Chouser_, I totally agree

15:55 Chouser_, I'm definetly a vim person, and I want this kind of feature available in Emacs. I tried the VIPER mode but it sucks compared to the original vim ;(

15:55 Chousuke: I wish I could make emacs somehow able to differentiate between left and right apple key.

15:55 but I don't think OS X does that, so little hope for emacs being able to do it...

15:56 if it could, I could keep one as cmd and the other as meta

15:56 tomoj: looks like ukelele can't do it either

15:57 agreed, though, I sortof got used to cmd-as-meta while x forwarding to arch linux

15:57 angerman: is there any tutorial on project file layout?

15:58 tomoj: now i'm on aquamacs and alt is such a small key

15:58 angerman: technomancy mentions it in http://technomancy.us/126

15:58 briefly

15:58 and specifically in relation to clojure-mode's clojure-project (emacs)

15:59 technomancy: tomoj: sorry; didn't notice that (paredit problem) since I'm running from trunk.

15:59 will try to get that fixed

15:59 but the version of 20 that is bundled is patched to support clojure IIRC

16:00 tomoj: I was able to just remove paredit from the list of elpa projects to force download

16:00 technomancy: what's "trunk" ?

16:00 the problem i had was clojure-mode does special fixes for paredit, but only if 21 is loaded

16:00 technomancy: tomoj: upstream paredit; I think it's in darcs

16:01 tomoj: and deleting paredit in elpa didn't help since it would just be reloaded next time emacs starts.

16:01 technomancy: also, you should try rcirc instead of irissi-in-emacs

16:01 tomoj: so didn't you have to take paredit out of the list of elpa projects to download?

16:01 technomancy: anyway, thanks for the heads-up

16:01 tomoj: I manually load-file'd it after ELPA had loaded

16:01 tomoj: ah, I see

16:02 rcirc looks interesting, I'll give it a shot

16:03 technomancy: thanks, by the way. starter kit and http://technomancy.us/126 have helped me a lot

16:03 technomancy: great!

16:03 tomoj: greatly speeding up my weaning myself off textmate :)

16:04 * Neronus votest for erc - though he never tried rcirc

16:04 duncanm: it's possible to run irssi in emacs? in term-mode?

16:04 tomoj: wasn't pretty for me, but yeah

16:04 Neronus: you can even run mutt if you don't like gnus

16:04 or rmail

16:04 or whatever

16:04 tomoj: +termtter

16:04 duncanm: i use rcirc, it's pretty good

16:05 tomoj: it makes me happy there are more than a few emacsers here

16:05 I'm vastly outnumbered by vim people in the other channels I frequent

16:06 Neronus: That's because the world is full of people who don't have a good taste. There are even people who don't like lisp

16:07 tomoj: yup

16:07 mostly rubyists who haven't seen the light yet

16:08 technomancy: looks like the fix is to just delete line 12 of starter-kit-elpa.el

16:08 * Neronus just read a paper relating templating languages and the chomsky hierarchy... kinda fun

16:09 technomancy: tomoj: temporary fix, anyway. go for it.

16:09 tomoj: is the real fix to get 21 into elpa?

16:10 technomancy: 22, if we're lucky

16:10 I've been talking with the author, it seems it's right around the corner.

16:10 22 allows you to use paredit with nonlisps too.

16:11 tomoj: huh.

16:21 wwmorgan: If a class has a public field foo and a nullary function foo, how do I access the field from clojure?

16:26 gko: What's the most effective way to remove a map from a set in an alter?

16:32 tomoj: disj?

16:32 what other way is there?

16:33 Chousuke: wwmorgan: good question. :P

16:34 duncanm: heh, interesting

16:34 what's the lookup order, it gets the method before the field?

16:42 cemerick: wwmorgan: in a pinch, there's always Reflector.getInstanceField

16:42 gko: tomoj: yes, disj is what I wanted. Thanks!

17:02 Chousuke: hmm

17:02 egg makes using git a lot more pleasant once you get used to it.

17:03 now if I only had the skills and patience to provide viper-y bindings for it...

17:04 n/p for going up/down the hunks is not bad, but I am used to j/k

17:04 clojurebot: for is not used often enough.

17:04 duncanm: what's viper?

17:04 Chousuke: modal editing for emacs

17:04 duncanm: oh

17:04 you like using that?

17:04 Chousuke: yeah

17:05 It's what I like about vim the most

17:05 the editor itself is clearly inferior to emacs.

17:09 duncanm: but you like modal editing

17:09 Chousuke: I also did what I never could figure out how to do in vim and made C-ö equal "exit insert mode" (ö being to the left of l and right under my pinky on this keyboard layout

17:10 left... right!

17:10 * Chousuke is tired

17:10 Chousuke: and yeah, I like modal editing

17:10 I also like modal browsing, with vimperator. ;p

17:11 triddell1: technomancy: question: when you use clojure-install from the starter kit, what versions of clojure and contrib are installed? and how are these typically updated/changed... using git commands in the src directories?

17:12 LauJensen: triddell1: As I recall it pulls all the latests using Git, updating is manually done by Git pull. I could be wrong

17:13 Chousuke: I think it takes 1.0 by default

17:13 and the compat branch in contrib

17:13 triddell1: LauJensen: that's what it looks like but I didn't see any mention, thx

17:17 Chousuke: ok, I'll pull new versions if necessary

17:25 I usually use egg for git in emacs but I only see magit in the package-list-packages list... what do some of you use?

17:26 technomancy: triddell1: it should use clojure 1.0 and the 1.0-compatible branch of contrib

17:27 I've got a plan to make it optional to use the master branch of git, but haven't gotten around to that since I only use 1.0 myself

17:28 see the clojure-last-known-good-revisions var

17:28 triddell1: technomancy: ok, thanks... so do you use magit then... which in in the list of installable applications

17:29 technomancy: definitely; magit is one of my favourite tools.

17:30 triddell1: I'll have to give it a try

17:30 technomancy: triddell1: check out the screencast; it's really helpful: http://alexvollmer.com/index.php/2009/01/18/meet-magit/

17:31 triddell1: technomancy: cool, starting it now

17:32 Chousuke: technomancy: are you aware of egg?

17:32 it's like magit, except user-friendly.

17:32 (it uses *colour*)

17:33 technomancy: magit is pretty colourful

17:33 Chousuke: not mine :P

17:33 triddell1: technomancy: so if I want to use something like egg I just make those changes in my local username.el file then?

17:33 technomancy: triddell1: sure

17:33 Chousuke: suppose I never saw the colourful screens :)

17:40 technomancy: hm, how do I stage individual chunks with magit? :/

17:41 technomancy: Chousuke: it's just "s"

17:41 you need to expand the file first with tab then put the point on the chunk

17:42 drewr: kotarak: is there an idiomatic way to provide lexicals inside of an execute-sql macro call?

17:42 Chousuke: technomancy: hm, and how do you narrow down the hunk? :/

17:43 kotarak: drewr: do you have example, what you want to do?

17:43 technomancy: Chousuke: you mean splitting an existing chunk into smaller pieces? not sure.

17:44 Chousuke: hmm, it only shows me one chunk in the first place.

17:44 kotarak: drewr: you mean something like (let [x 5] (query some-table [foo bar baz] (>= foo ~x)))

17:46 lisppaste8: drewr pasted "variable in execute-sql expansion" at http://paste.lisp.org/display/84943

17:48 drewr: ah, an unquote, of course

17:48 * Chousuke wonders how clojureql handles the unquoting

17:48 kotarak: drewr: unquote work normally. You can also use query*, but be sure to quote all symbols then or use strings. keywords are broken at the moment. *coughcough*

17:49 Chousuke: be ripping of the syntax-quote algorithm from core and remove all the resolution stuff. It becomes what is known as "quasiquote" eg. in Scheme.

17:50 I posted that to the google group if you are interested.

17:50 drewr: the expansion looks right though, doesn't it?

17:50 why wouldn't that work?

17:50 Chousuke: kotarak: I'm looking at it

17:50 drewr: ahh, I didn't expand execute-sql

17:51 kotarak: exactly.

17:51 Chousuke: kotarak: I might end up implementing syntax-quote outside the reader

17:52 drewr: actually it was insert-into that hid the quasiquote

17:53 kotarak: Chousuke: http://www.mail-archive.com/clojure@googlegroups.com/msg04500.html <--- here's the original thread, but don't ask me how to find that on google groups....

17:53 Chousuke: kotarak: does your quasi-quote handle nesting though?

17:54 kotarak: Chousuke: not sure, never tried.

17:54 It also doesn't handle ~@ at the moment, which is sort of annoying.

17:57 Chousuke: I suppose checking for a (quasi-quote ...) and then just returning the list completely quoted would handle nesting.

17:57 the clojure reader is pretty weird about it.

17:58 ,(let [x 5] `(do ~x `(foo bar ~x)))

17:58 clojurebot: (do 5 (clojure.core/seq (clojure.core/concat (clojure.core/list (quote sandbox/foo)) (clojure.core/list (quote sandbox/bar)) (clojure.core/list sandbox/x))))

17:59 kotarak: Yes. I wonder whether this is really necessary. It looks at least scary.

17:59 Chousuke: it's because syntax-quote is completely read time

17:59 and the inner ones are expanded first

18:01 but I think returning '(do 5 (c.c/syntax-quote (foo bar (unquote x)))) should suffice

18:01 assuming syntax-quote as a macro

18:03 JAS415: you can seperate it out into two parts

18:09 kotarak: Chousuke: Hmmm.. Dunno. I found nesting to be very rare and when I needed it, it didn't solve my problem... ;p

18:12 JAS415: clojure bot is being weird

18:12 ah i'm mistaken

18:13 ,(let [x 5 inner `(foo bar ~x)] (list 'do x inner))

18:13 clojurebot: (do 5 (sandbox/foo sandbox/bar 5))

18:14 JAS415: ,(let [x 5 inner `(foo bar ~x)] `(do ~x ~inner))

18:14 clojurebot: (do 5 (sandbox/foo sandbox/bar 5))

18:15 JAS415: (let [x 5 inner `(~'foo ~'bar ~x)] `(do ~x ~inner))

18:15 ,(let [x 5 inner `(~'foo ~'bar ~x)] `(do ~x ~inner))

18:15 clojurebot: (do 5 (foo bar 5))

18:27 drewr: kotarak: I didn't see any support for LIMIT/OFFSET; any plans for that?

18:27 alrex021: if I have a list of maps, what is an easiest way to find a map that case a specific value for a given key?

18:27 clojurebot: maps are functions

18:27 alrex021: *case = has

18:28 kotarak: drewr: yes. there was a patch already a while back, but we noticed, that it somehow got lost. I will check to see whether it still applies.

18:29 alrex021: (first (filter #(= (:key %) value) list-of-maps))

18:31 Chousuke: hm

18:32 * Chousuke implemented unquote-splicing for quasiquote

18:32 Chousuke: surprisingly easy.

18:32 kotarak: :)

18:32 Chousuke: I just had to wrap stuff in lists, add a concat and then NOT wrap the spliced stuff in an extra list)

19:05 hiredman: http://clj-me.blogspot.com/2009/08/what-warn-on-reflection-didnt-tell-you.html

19:45 wavister: it seems like when one has a function with a variable argument list, and a collection which could serve as those arguments, there should be a way to use the collection as the argument list. I've looked around for it, and I'm not finding. Is it right under my nose?

19:45 dreish: apply

19:45 wavister: in ruby it's called splatting

19:45 dreish: ,(doc apply)

19:45 clojurebot: "([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."

19:45 dreish: ,(apply + [1 2 3 4])

19:45 clojurebot: 10

19:46 wavister: okay thanks! i'll work with that

20:43 tomoj: hmm.. how come I can't barf out the body of a defn?

20:43 durka42: say again?

20:43 tomoj: oh, kill/yank works fine for that

20:43 dreish: Referring to paredit mode?

20:43 tomoj: yeah

20:43 durka42: oh :)

20:43 dreish: Or expecting to vomit Lisp?

20:43 tomoj: hehe

20:44 dreish: paredit-forward-barf-sexp works for me, with the cursor right before the body of the defn.

20:47 Makoryu: Is it possible to interactively define functions on the console, and then dump them to a file?

20:48 dreish: You could if you coded your own repl that did that.

20:50 Or you could redefine defn to add the source code as metadata on the var.

20:50 cemerick: is there a shortcut to ensure that a dispatch value should always have some lowest priority?

20:50 basically, another level of default?

20:51 (I suppose I could just have a :default dispatch, and go from there)

20:52 tomoj: dreish: what version of paredit?

20:52 dreish: tomoj: 22

20:52 tomoj: forward-barf-sexp just moves to after the defn for me on 21

20:52 aha

20:53 guess I should figure out how to upgrade

20:59 hmm, actually I can't barf anything

20:59 this is odd

21:08 ./facepalm. I was using M-{ etc instead of C-{ etc

21:17 ataggart: what is the effect of adding :refer-clojure to the ns?

22:19 cemerick: ,(doc ns)

22:19 clojurebot: "([name & references]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class) with the syntax of refer-clojure/require/use/import/load/gen-class respectively, except the arguments are unevaluated and need not be quoted. (:gen-class ...), when supplied, defaults to :name correspo

22:19 cemerick: eh, not enough

22:19 ataggart: see http://clojure.org/api#ns

22:19 :refer-clojure is only used when you need to exclude or rename some vars in clojure.core

22:20 same options as http://clojure.org/api#refer

22:20 JAS415: ,(doc refer)

22:20 clojurebot: "([ns-sym & filters]); refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to something else in the current nam

22:20 JAS415: woowoo

22:34 ataggart: cemerik: thanks

22:34 cemerick

22:35 bah, I forot about the BAC tonight

22:36 mebaran151: the BAC?

23:41 JAS415: is there a place to announce clojure libraries?

23:41 cark: there is a thread on the mailing list

23:42 http://groups.google.com/group/clojure/browse_thread/thread/affb08d66c048c7f

23:42 JAS415: cool

23:42 i made this: http://github.com/JonathanSmith/CRIB/tree/89a3f4d9c797ef6f4e4f456001ff6a4c5c050064

23:43 tomoj: do clojure people use mocks/stubs?

23:43 not sure how those would fit into clojure's paradigm

23:43 JAS415: http://github.com/JonathanSmith/CRIB/tree/master

23:43 this rather

23:43 what are mocks/stubs?

23:43 tomoj: well.. mock objects for testing. the objects part doesn't really make sense

23:44 but say I'm testing a function that makes an http request

23:44 hiredman: you can use binding to alter function behaviour

23:44 tomoj: I suppose I could just rebind the function to return a fake http response

23:45 hiredman: ,(binding [+ *] (+ 2 3))

23:45 clojurebot: 5

23:45 hiredman: grr

23:46 oh

23:46 of course, inlined math op

23:46 ,(binding [+ *] (+ 2 3 4))

23:46 clojurebot: 24

23:46 hiredman: ,(* 2 3 4)

23:46 clojurebot: 24

23:46 JAS415: weird

23:47 probably because + gets inlined

23:47 ?

23:47 cark: mhh

23:47 that's a bug isn't it ?

23:47 tomoj: from my ruby perspective I would want to rebind the http request function to make sure it was passed the right args

23:47 JAS415: depends on your perspective i guess

23:47 tomoj: and fail the test if not (or if it's not called)

23:47 cark: mock functions =)

23:48 JAS415: really need in-lining levels like in CL

23:48 tomoj: but I get the feeling that's not the right idea for clojure

23:48 JAS415: well tom

23:48 tomoj: I mean, rhickey doesn't do any testing at all, right?

23:48 cark: tomoj: when doing pure functional, you know what goes in and check what goes out

23:48 JAS415: ideally it would be decomposed so that the http-function and the function calling it are composable

23:49 if that is the really important part

23:49 tomoj: oh, I see. so does binding the http request method to return a fake http request sound reasonable?

23:50 problematic there because http request = not pure functional

23:50 JAS415: well clojure isn't pure functional because its running on java :-P

23:50 but you can write code purely functional?

23:51 tomoj: sure, but not code that does http requests

23:51 JAS415: but anyway, i think that sounds reasonable

23:57 tomoj: I think I'm just hoping TDD will magically make my code pretty

23:58 I'm just going to delete it all and start over :)

Logging service provided by n01se.net