#clojure logs

2009-08-27

00:07lowlycoderthis really bit me: are vars created via defn and def dynamically, rather than lexicallys coped?
00:07lowlycoderare bindings created via let lexically scoped, or are they somehow dynamicallys coped too?
00:20rathorelet is lexically scoped
00:21JAS415uh
00:21JAS415let is lexical
00:21JAS415def and defn are dynamic
00:21JAS415(vars)
00:21JAS415binding form can alter a var's.. binding
00:31lowlycoderanyone here running clojure on the mac?
00:46tomojyeah
00:51durka42me too
00:59rathoreme too
01:01rathoredevelopment on mac, all deployments on ubuntu
01:02durka42rhickey uses a mac too, doesn't he
01:04tomojI've seen him use a mac in presentations
01:04tomojand emacs :)
01:10JAS415im use ubuntu
01:51adityogood morning folks
01:54adityowhy do we use #^ before a form? reading some code, seen it in a couple of places
02:00adityookie got it! works as metadata keys
04:15tomoj_YEEESSS http://skitch.com/tomoj/bhhw5/terminal-java-80x24
04:15tomoj_now to get this working with clojure :D
04:20Fossiweird :D
04:23tomoj_it's not ideal for my purposes but I think it's better than writing my own ncurses or ansi stuff
04:24Fossiit would be fun to port swing to that
04:26tomoj_some other implementations I found sortof did that
04:26tomoj_swing-like APIs
04:26tomoj_couldn't get them to work
04:27tomoj_I don't want swing-like anyway really
04:37tomoj_:D http://skitch.com/tomoj/bhhsj/terminal-java-80x24
04:39noidicool :)
04:58lowlycodersince clojure only provides the ACI in ACID, what should I use for durability?
05:02dosynclowlycoder: Have you looked at clojure.contrib.sql for working with sql databases?
05:02lowlycoderi don't want to touch sql
05:04Fossilowlycoder: schema free databases work pretty well for us. couchdb, google appengine datastore and such
05:05lowlycoderdoes couchdb actually require erlang to run?
05:05Fossiwell, as much as apache requires C to run
05:07tomoj_I got it running on my mac without much trouble if I remember correctly
05:08tomoj_sudo port install couchdb
05:08lowlycoderhmm; best solution so far looks like sqljet
05:08tomoj_thought you didn't want to touch sql?
05:08lowlycodermy bad
05:08lowlycoderi don't want an external server
05:08lowlycoderhorribly said
05:09lowlycodersomehoq mentally i group sql with mysql and postgresql and oracle
05:09lowlycoderbut not with sqllite
05:09lowlycodermy fault definitely
05:09Fossiah, that's another story then
05:09lowlycoderoh; explain
05:09tomoj_well looks like sqljet actually doesn't have a sql interface..
05:09tomoj_:)
05:11lowlycoderdoes clojure have 'builtin' serialization/deserialization?
05:12tomojwell.. the basic data structures are readable
05:14tomoj,(read (java.io.PushbackReader. (java.io.StringReader. "[1 2 3]")))
05:14clojurebot[1 2 3]
05:15lowlycoder,(java.io.StringReader. "[1 2 3]")
05:15clojurebot#<StringReader java.io.StringReader@111c3f0>
05:15tomojbut you can't serialize structmaps that way yet without some extra steps
05:27lowlycoderwhy does def write to the global environment rather than the local environment?
05:27tomojif I understand what you mean, the latter is impossible in clojure
05:28tomojthere are no local assignable variables
05:28lowlycoder(defn bar [] (defn foo [] ...))
05:29tomojuse let or letfn
05:29lowlycoderwhy can't i have this become (defn bar[] (let [foo fn [] ...] ..))
05:29lowlycoderas scheme/lisp tends to interpret it as
05:29lowlycoderwhat's the motivation behind clojure's def goes to global env?
05:29tomojit looks like imperative programming
05:30lowlycoderclojure or scheme?
05:30tomojusing def in the way you want
05:30tomoje.g. a clojure newbie might want to write (def x (inc x))
05:30tomojwhere they would write x=x+1 in an imperative language
05:30lowlycoderwhereas in this way, when I execute bar, it redefiens foo on the fly
05:30lowlycoderand breaks all my code
05:31tomojI'm not sure the code you wrote above makes sense
05:31tomojdefn returns a function, it doesn't execute the body
05:31tomoj(defn bar [] (defn foo [] ...)), even if it "wrote to the local env", wouldn't be equivalent to (defn bar [] (let [foo (fn [] ...)] ...))
05:32lowlycoderwhy ot?
05:32lowlycoder*not*
05:32tomojthe latter executes the body of the let form
05:32tomojthe former just returns a function
05:33tomojdefn doesn't say "define foo to be this function and then do this with it"
05:33tomojit just says "define foo to be this function and return it"
05:33tomojyou would need (defn bar [] (defn foo [] ...) (<something that uses foo>))
05:33tomojand that's evil
05:34tomojdefn is supposed to be toplevel, if you want to lexically bind something, use the lexical binding forms :)
05:34lowlycoderare there any besides let nad letfn?
05:34lowlycoderi just don't wnat the following code to be indented
05:35tomojit should be indented imo
05:35tomojit's in a new context
05:35lowlycoderscheme/lisp doesn't do it that way; old habits die hard
05:35tomojloop and for do lexical binding, there may be others
05:36tomojhow does lisp do it?
05:36lowlycoderwell, I can say things like
05:36lowlycoder(define (foo ...)
05:36lowlycoder (define (bar1 ...) .... )
05:36lowlycoder (define (bar 2 ...) ... )
05:36lowlycoder ... some code involving bar1 and bar 2 ... )
05:36lowlycoderwithout bar1 bar2 becoming global forms
05:36lowlycoderwhereas in clojure I have to do
05:37lowlycoder(define foo [...]
05:37lowlycoder (letfn [[bar1 [] ....]
05:37lowlycoder [bar2 [] ....]
05:37lowlycoder ]
05:37lowlycoder ... more code ... ))
05:37lowlycoderthe identing just looks more uglier and mucm more to the right
05:38_mstcommon lisp is the same--you would have to use flet/labels to get the effect you're after (as in clojure)
05:38lowlycoderokay; scheme then :-)
05:38tomojthat seems evil to me
05:38ChousukeI suppose defn could be made context-aware.
05:38Chousukebut it'd be weird.
05:39lowlycoderwhy?
05:39tomojI don't think it's the defn equivalent that's special in scheme, just guessing
05:39tomojbecause apparently those defines can only come at the beginning of the body
05:40Chousukehmm :/
05:40tomojlet would need to be made aware that defs at the beginning of its body are really lexical bindings
05:40tomojwell, let and defn and etc
05:40tomojbut I think a form that's using lexical bindings should be contained in the forms that set up those bindings
05:40tomojlowlycoder: you could always write a macro
05:41Chousukewell, defn could just check a bound var and emit a letfn instead of def if it is bound to true, and bind it to true if it's false
05:41lowlycoderi can't express this as a macro
05:41lowlycodertomoj: how would this macro look like? macros have to 'contain' the parts in them
05:41lowlycoderthe define i want needs to run to the end of the currnt environment
05:41tomojyou would need to use the macro at the toplevel
05:41tomoje.g. use silly-defn instead of defn
05:42tomojwhich goes through and replaces defs with lexical bindings
05:42lowlycoderhmm; this could be interesting
05:43lowlycoderlooks like the keyword define isn't taken up either :-)
05:43Chousukeclojure has a peculiar feature btw.
05:43lowlycoderwhat's that?
05:44lowlycoderbinding to vars rather than values?
05:44Chousukeuser=> (def def 1) -> #'user/def, user=> def -> 1, user=> (def foo 1) -> #'user/foo
05:44lowlycoderwt
05:44lowlycoderf ... isn't clojure a lisp 1?
05:45Chousukeyes
05:45tomojI guess you would have to go through the forms in the body and macroexpand, and take-while the car is def, then convert those into a let that you wrap around the rest of the body
05:45lowlycoderhow does this work?
05:45Chousukespecial forms are special only in operator position
05:45Chousukeotherwise, they're just symbols
05:45Chousuke,let*
05:45clojurebotjava.lang.Exception: Unable to resolve symbol: let* in this context
05:46Chousukethis is probably a half-bug, but rather harmless anyway
05:46lowlycoder(def def (fn [x] (println x))) (def 20)
05:46Chousukelowlycoder: that will give an error :)
05:47lowlycodernot the definition, but the (def 20)
05:47Chousukeyeah
05:47lowlycoderi feel like clojure has great ideas
05:47lowlycoderbut has some ugly hacks
05:47Chousukecan't avoid them sometimes.
05:50Chousukepurity is sacrificed for practicality if it's more beneficial than maintaining purity.
05:51lowlycoderwhy is this defn more practical?
05:51Chousukewell, it's easier for one.
05:51Chousuketo implement.
05:52Chousukebut also easier to use, because it doesn't have context-dependent effects.
05:53Chousukethough the scheme-style define is rather nice.
05:53liwpI find the current semantics confusing after scheme, but I guess that's cause I'm used to the scheme semantics
05:54liwplike lowlycoder I find the letfn forms noisy
05:54lowlycoderi actually thougth i had a race condition ....
05:55liwpI wrote a toy scheme once and I don't remember enclosed defines being any more difficult to implement than the top-level define...
05:55lowlycoderuntil I learned the real semantifs of defn today
05:55ChousukeI usually just do (let [foo (fn ...)] ...)
05:55liwpyeah, denf can really bite you
05:55liwps/denf/defn
05:55Chousukehmm, I don't have a scheme background so I can't relate to that. :/
05:55ChousukeI just use defn on the toplevel
05:56Chousukenever occurred to me to use it elsewhere.
05:56liwpin the end it's not a big deal after you realize what the semantics are, I was just surprised
05:56lowlycoder(defn foo [] 3) (defn bar [] (defn foo [] 4)) ... (bar) ... (foo) -> 4 ... WTF??? :-)
05:56liwpChousuke: if you have a look at SICP they use inner defines all over the place
05:57ChousukeI suppose common lisp people would be equally surprised by nesting defines if they had no knowledge of scheme :)
05:57tomojI was
05:57liwpyep :)
05:59tomojit would be very weird to me for defn to mean something different when it's at the beginning of a let/defn/etc body
06:00liwpI just think it's a really nice way to define helper functions that are not used anywhere else
06:00lowlycoderliwp: so how do you handle this now? just using let and letfn?
06:00liwpyep
06:01liwpto be honest I haven't really had to deal with it much
06:01liwpso it's not really a problem at all, just an observation
06:03ChousukeI suppose the extra indentation caused by letfn is unnecessary in a way, but I don't think it's that bad otherwise :)
06:06Chousukelowlycoder used vectors earlier to contain the function bodies but I use the form (letfn [(foo [x y z] ...) (bar [] ...)])
06:07ChousukeI like the scheme define for one other reason though, which is that the function definition looks like you're defining the value of a function call :)
06:09Chousukeeg. (define (f x) whatever) looks like it's defining (f x)
06:09clojurebotx is w
06:10AWizzArdxhatever?
06:18tomojI like the body of letfn indented
06:19tomojit shows me visually that that body is being executed within a special context
06:22Fossihow do i get the class for a Class? as in String.class
06:22clojurebotfor is not used enough
06:22Fossi(class String) says java.lang.Class
06:22clojurebot
06:23febelingis there a way a know the name of the function that currently executes?
06:24liwp,(.getClass "foo")
06:24clojurebotjava.lang.String
06:24liwpis that what you want?
06:24Fossiliwp: i can't create the object
06:24liwp,(type "foo")
06:24clojurebotjava.lang.String
06:24Fossias in, i don't have an instance
06:24liwpahh
06:24liwpwhat do you have?
06:24Fossia name ;D
06:24liwpyou have to use Java's classForName magic
06:25liwpgive me a minute
06:25Fossii need to pass (DocumentListFeed.class) to an api
06:26liwp,(Class/forName "java.lang.String")
06:26clojurebotjava.lang.String
06:26liwpthat can possibly throw all kinds of evil exceptions <http://java.sun.com/javase/6/docs/api/java/lang/Class.html#forName(java.lang.String, boolean, java.lang.ClassLoader)>
06:27liwpFossi: does that help?
06:27Fossiit's evil (tm) ;)
06:28liwpindeed
06:28tomojso there's no way to get from a literal classname to a class object?
06:28liwpI have no idea if Clojure gives you some nicer way to get the class
06:28tomoj(without instantiating)
06:29liwptomoj: Class.forName gives you the class, no instance required
06:29tomoj,(class Math)
06:29clojurebotjava.lang.Class
06:29tomojliwp: yeah, but you have to use a string
06:29liwpoh yeah
06:29liwpmissed dthat
06:29tomojFossi: I guess you already tried just passing DocumentListFeed?
06:35liwp,(.newInstance String)
06:35clojurebot""
06:36liwpso it seems that class names work as class literals in clojure, cool
06:36tomojseems to work fine to me
06:36liwpthis is probably obvious if I think about it a bit...
06:36tomoj,(.isAssignableFrom Number Integer)
06:36clojurebottrue
06:37tomojI don't like this idea that there's a separate class object which isn't the class itself
06:39tomojI wonder how clojure gets the class object
06:41liwpwhat is (cast) good for?
06:42tomojthrowing exceptions I guess
06:42liwpyeah, that's what I think as well...
06:42liwp,(source cast)
06:42clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
06:43liwpurgh
06:43achimhmm, as far as i know, all classes are Class objects in java, there's not really a distinction. class names evaluate to Class objects in clojure
06:44achim,(instance? Class Number)
06:44clojurebottrue
06:45tomojright, but class names don't evaluate to class objects in java
06:45tomojthat's what I don't like
06:45liwptomoj: you don't like that in Java?
06:45tomojcalling a static method should just be calling a method on the class object
06:45tomojliwp: rubyist..
06:46liwptomoj: ahh, got it
06:59Chousukejava has primitives in addition to classes too, which complicates things :/
07:00AWizzArdIs there something like a lazy slurp in Clojure?
07:00AWizzArdFor reading/parsing huge files?
07:00Chousukewell, there's line-seq
07:01AWizzArdbut if the line separator is not \n but instead a more complex regex?
07:01Chousukehmm
07:02Chousukemaybe you'll need your own sequence then :/
07:02AWizzArdyup, oki
07:30cschreinerAny work done on integrating Clojure with cocoa?
07:30cschreinerand if not, is this interesting?
07:45achimcschreiner: are you thinking about a clojure port or a cocoa bridge?
07:45cschreinerachim: yes
07:45cschreinerboth
07:45cschreinerbut first, a bridge
07:47achimwell, there's rococoa, but no clojure-specific project i know of
07:47achimhttps://rococoa.dev.java.net/
07:52Fossiclojures error messages are so not helping if you have an outdated api documentation
07:53Fossiis there an easy way to get a classes' inherited methods?
07:55tomojI think show from c.c.repl-utils might do what you want
07:57tomojcount is constant time on vectors, right?
07:59Fossiah, excellent
07:59Fossii also discovered that reading helps
07:59achimtomoj: yes, constant time for everything "counted?"
08:00tomojachim: ah, thanks
08:04achimrhickey: the docs of clojure.zip/down promise to return nil if there are no children, but that doesn't seem to be guaranteed, actually
08:05achim,(-> [1] clojure.zip/vector-zip clojure.zip/down clojure.zip/down)
08:05clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
08:05achimrhickey: may i create issue + patch for this?
08:06Chouserachim: is that the same as http://www.assembla.com/spaces/clojure/tickets/135
08:08achimChouser: ah, yes, this patch will fix it
08:09Fossihow do you read a simple string from the repl while running a program?
08:13Chouserachim: is that causing you an actual problem, or is it just a discrepency with the docstring?
08:16AWizzArdFor big files (do (def x (lazy-seq (slurp "/big.file"))) (count x)) gives me a stack overflow, while the same thing without lazy-seq doesn't. Can anyone confirm/explain that please?
08:21AWizzArdInstead of confirming this it would also be good to know if it works for you without stack overflows.
08:30achimChouser: well, it's not something i can't work around, but yes, it would make things simpler if it just returned nil on leaves
08:37Chouserbut that patch doesn't return nil, it throws an exception.
08:40rhickeythis was discussed here previously
08:42Chouserachim: http://clojure-log.n01se.net/date/2009-06-23.html#16:27b
08:42Chouserthere you go. go for it.
08:44rhickeydon't neglect: http://clojure-log.n01se.net/date/2009-06-23.html#17:00
08:45rhickeyrhickey: children could check if node is branch and throw if not
08:45rhickeykotarak: rhickey: should it throw or return nil?
08:45rhickeyrhickey: throw
08:45rhickeyChouser: thanks for pulling that up so fast!
08:46achimChouser: thanks!
08:46Chouserthe throw is #135 which has a patch. achim's seeing the earlier issue, which the log seems to claim is #134, but that doesn't match.
08:49Fossia
09:15saml==> (+ 1 2)
09:15saml!bot
09:16Chouser,(apply str (reverse "lmas"))
09:16clojurebot"saml"
09:17AWizzArddoes anyone else also get an exception for counting the chars in big files that were slurped in a lazy-seq body? See my example above, from one hour ago.
09:17saml,(apply str (interleave ["nicely, "] ["done"]))
09:17clojurebot"nicely, done"
09:28Chouser,(class (first (lazy-seq "abc")))
09:28clojurebotjava.lang.Character
09:28Chouser,(class (second (lazy-seq "abc")))
09:28clojurebotjava.lang.Character
09:28Chouser,(class (next (lazy-seq "abc")))
09:28clojurebotclojure.lang.StringSeq
09:30Chouser,(class (lazy-seq "abc"))
09:30clojurebotclojure.lang.LazySeq
09:30Chouser,(counted? (lazy-seq "abc"))
09:30clojurebotfalse
09:31ChouserAWizzArd: there's your problem. LazySeqs and StringSeqs are not counted, so require
09:32Chouserhm
09:33liwpis there a zip function in clojure that produces tuples?
09:34liwpor vectors I guess would be more appropriate
09:34Chouser,(map vector '(a b c) '(d e f))
09:34clojurebot([a d] [b e] [c f])
09:34liwpah yes
09:34liwpwhy didn't i think of that...
09:34ChouserAWizzArd: counting a seq like that will at least be O(n), so you should do that. But I think it ought not overflow the stack.
09:35AWizzArdI am also surprised that it overflows.
09:35Chouserliwp: in clojure, map is _the_ way to walk more than one collection in lockstep.
09:36liwpAWizzArd: I thought that the problem might be holding on to the head of the seq with the def, but again that should cause an OOM error rather than overflow the stack
09:36liwpChouser: fair enough
09:37liwpChouser: I quite like the way how you can give map more than one seq to walk, unlike haskell and friends that only do one seq at a time
09:37Chouserliwp: I guess there are others, but it's certainly the one to reach for first. The other is loop/recur and things built on one or the other (zipmap, contrib indexed)
09:37lpetit_hello
09:38liwpChouser: I'm just used to looking for zip and couldn't find it so I used map, but didn't think of using vector as the map operation
09:38Chouserlpetit_: g'morning.
09:40lpetit_brainstorming : is the general problem of coupling STM with a database transaction solved?
09:40cemerickChouser: any take on this: http://groups.google.com/group/clojure/browse_frm/thread/a0f30c25122cd232
09:43Chouser,(count (lazy-seq (apply str (range 1e5))))
09:43clojurebotjava.lang.StackOverflowError
09:44cgrandAWizzArd: looks like a bug StringSeq is counted but doesn't implements count() so ASeq/count() causes the stack overflow
09:45cgrandChouser: same pb if you use seq instead of lazy-seq
09:45AWizzArdSounds plausible.
09:45Chousercemerick: I imagine zip was writen before ::foo worked.
09:46rhickeyChouser: right
09:47dmixdoes anyone know of any good open source clojure apps with a command-line interface?
09:47Chousercgrand: yep, you nailed it. anything that implements IndexedSeq should provide a count() method.
09:48rhickeypatch welcome
09:48cemerickrhickey: seems like that should get fixed?
09:48cemerickoh, sure :-)
09:48cemerickrhickey: I didn't know if you wanted to keep those slots the way they are for compatibility purposes.
09:49rhickeycemerick: I meant patch welcome for StringSeq, let me look at your thing...
09:50cemerickah :-)
09:50cemerickit's not a problem really, just a slight inconsistency
09:50rhickeycemerick: so you just want to use ns-ed keywords in zip?
09:50cemerickmakes sense to me *shrug*
09:51cgrandrhickey: patch ready for StringSeq, I'm checking all classes implementing Counted
09:51cemerickthere is no 'zip' ns, after all
09:51rhickeythat's fine by me, definitely predated ::
09:51cemerickOK, I'll set up a ticket and patch
09:52AWizzArdcgrand: very nice, thanks. Good good, another bug eliminated :)
09:53Chousercgrand: probably in 1.0 as well
10:05AWizzArdregexperts: how can i split a string on a comma when the comma is not between the markers ( and )? Example: "1,2,3,(4,5),6" should result in ["1" "2" "3" "(4,5)" "6"].
10:06ChouserAWizzArd: need to handle nested parens?
10:06AWizzArdno
10:09Chouser,(re-seq #"(?:\(.+\)|[^,]+)+" "1,2,3,(4,5),6")
10:09clojurebot("1" "2" "3" "(4,5)" "6")
10:09Chouserthat won't include an empty string if you have ,, in the input
10:10AWizzArduh, thanks. Funny write-only regex
10:11Chouser,(re-seq #"\(.+\)|[^,]+" "1,2,3,,(4,5),6")
10:11clojurebot("1" "2" "3" "(4,5)" "6")
10:11Chouserthat's the same, just shorter.
10:11Chouserbah, also broken.
10:11Chouser,(re-seq #"\(.+\)|[^,]+" "1,(2,3),,(4,5),6")
10:11clojurebot("1" "(2,3),,(4,5)" "6")
10:12Chouser,(re-seq #"\(.*?\)|[^,]+" "1,(2,3),,4,(5,6),7,8")
10:12clojurebot("1" "(2,3)" "4" "(5,6)" "7" "8")
10:12Chouserthere
10:12AWizzArddanke
10:12durka42"\(.*?\)" match anything between two parens, but non-greedily, so you get the shortest match possible instead of the longest. "[^,]+" match a string of things that aren't commas. "|" allow either of them.
10:14liwp,(re-seq #"\(.*?\)|[^,]+" "1,(2,3),,4,(5,6)foo,7,8")
10:14clojurebot("1" "(2,3)" "4" "(5,6)" "foo" "7" "8")
10:14liwpis that desired? (see foo)
10:16liwpso the first pattern should probably be something like \(.*?\)[^,]*
10:16liwp,(re-seq #"\(.*?\)[^,]*|[^,]+" "1,(2,3),,4,(5,6)foo,7,8")
10:16clojurebot("1" "(2,3)" "4" "(5,6)foo" "7" "8")
10:17liwp,(re-seq #"\(.*?\)[^,]*|[^,]+" "1,(2,3),,4,bar(5,6)foo,7,8")
10:17clojurebot("1" "(2,3)" "4" "bar(5" "6)foo" "7" "8")
10:18Chouser,(re-seq #"(?:\(.*?\)|[^,()]+)+" "1,(2,3),,4,bar(5,6)foo,7,8")
10:18clojurebot("1" "(2,3)" "4" "bar(5,6)foo" "7" "8")
10:20liwpChouser: hmph, now I have to try to understand what that actually does ;-)
10:20liwpwhat's the ?: in the beginning? Something to do with Java's regexp support?
10:20Chouserhehe
10:21Chouser(?: ) is a non-capturing group
10:21liwpah, ok
10:21Chouserperlism, if I had to guess.
10:21liwpwhy do you care in this case? or do you?
10:21liwpisn't everything related to regexps a perlism...
10:22ChouserI need to group so that I can say + at the end, that is any number of paren or non-comma-nor-paren sections, alternating 1 or more times
10:22liwpbut do you care whether it captures or not?
10:23liwpI mean wouldn't (...) work just as well?
10:23ChouserI need to avoid capture because re-seq will emit seqs instead of strings if there are any captures.
10:23liwpah, got it
10:23Chouser,(re-seq #"(.)." "12345")
10:23clojurebot(["12" "1"] ["34" "3"])
10:23ChouserI mean vectors. :-)
10:23liwpmakes sense, thanks
10:24liwpso the regexp mathes everything that is in parens or that is not a comma or a paren
10:24liwpjust verbalising it for myself
10:46Chouser(aget #^bytes buffer 0) ; will 0 be unboxed for each call? that is, would (int 0) be any better?
10:48Chousermy guess is that (int 0) would indeed be better.
10:50stuartsierraI thought all Clojure functions receive boxed argument.
10:50Chouseraget is inlineable
10:52Chouserso when called directly (not passed as an arg to something), it acts like a macro, expanding in-place to a java static method call
10:52stuartsierraThen I would assume the arguments to the static method call are boxed.
10:52Chouserin this case (clojure.lang.RT/aget #^bytes buffer 0)
10:53Chouserthe aget method has several overloads, all of which take a primitive int as the second arg
10:54Chouserso that int must be unboxed before being passed to the java method. My question is whether 0 gets unboxed once at compile time, or once per call at runtime.
10:59liwpChouser: IIRC people have been reporting that they get better performance with (int i) in agets
11:00liwpe.g. http://groups.google.co.uk/group/clojure/msg/59161c122a29233e?hl=en
11:00danlarkinI seem to remember a while ago there was talk of an abstract representation of a queue, with a producer & consumer, does anyone remember/know what became of that?
11:03Chouserliwp: ah, very good. thanks.
11:07liwpChouser: there was some blog post which was a bit more informative (can't find it now), but in any case it seems that coercing indices when dealing with arrays is a good thing at the moment
12:39liwpping
12:39liwp~ping
12:39clojurebotPONG!
12:49liwpmock objects
12:49liwppiffle
12:49liwp~mock objects
12:49clojurebotYour mock object is a joke; that object is mocking you. For needing it. -- rhickey
12:49liwpmaybe expect should not be renamed mock after all ;-)
12:50rhickeyIs that name under consideration? - ick
12:50liwpI think Stu renamed it already in contrib
12:51cemerickhar har
12:51cemerickrhickey: when did you throw off that gem?
12:52rhickeycemerick: I don't recall - at a talk a while ago
12:52cemerickI've never gotten into the deep waters of testing. Seems like a *lot* of work.
13:54maacl_Does anyone have example code that uses clojure-couchdb ?
14:15wtetzner_if i want to use clojure code the way you would use json, can i just use the (print ...) function, or do i need to use some special printer to ensure i can read it back in?
14:16ChousukeI think you need to use pr
14:16Chousuke(doc pr)
14:16clojurebot"([] [x] [x & more]); Prints the object(s) to the output stream that is the current value of *out*. Prints the object(s), separated by spaces if there is more than one. By default, pr and prn print in a way that objects can be read by the reader"
14:17wtetzner_ok
14:17wtetzner_thanks
14:17wtetzner_(doc prn)
14:17clojurebot"([& more]); Same as pr followed by (newline). Observes *flush-on-newline*"
14:27wtetzner_(doc pr-str)
14:27clojurebot"([& xs]); pr to a string, returning it"
14:30wtetzner_being able to print and read clojure data structures is really nice
14:30rathore_do you guys think its OK to send a clojure job posting on the google-mailing-list?
14:30wtetzner_it's perfect for use as a data format in a client-server application
14:32rathore_wtetzner_: i use exactly that in swarmiji - to send job information back and forth between requesters & workers
14:32rathore_,(doc pr-str)
14:32clojurebot"([& xs]); pr to a string, returning it"
14:41Chouserrathore_: there has been one or two before. I would guess it's ok.
14:44rhickeyrathore: yes, fine by me
14:46cemerickheh, I didn't notice the prior job postings. Good to see :-)
14:52rathore_rhickey: thanks
14:56rhickeyrathore_: sure, glad to see it!
15:27cemerickare there any recommended idioms for implicit bindings established by macros?
15:28Chousukeother than "don't" and "document"? :P
15:28cemerickheh
15:28cemerickChousuke: I just knew that was going to be the response. :-D
15:30ChousukeI'm not aware of any idioms
15:30Chouserdo you mean dynamic bindings, like the with-* macros?
15:32cemerickno, implicit bindings, like 'this' in proxy method impls.
16:13jensliI had a job writing C# for a big, evil corporation. Now that has ended and I have placed an order for "Programming Clojure", Im going to spend my time hanging in cafes with my laptop, learning to lisp functionlly.
16:15arbschtgood luck. perhaps you can contribute to the clojure-clr project, too :)
16:19jensliIm going to keep far away from clr.
16:25Chouserha! delaying the middle of each finger tree also removes the threat of stack overflow.
16:33wavister... so if you want to give someone the middle finger, it might take a while?
18:13hiredmanhttp://www.thelastcitadel.com/images/clojurebot.png
18:15wavisternot sure why i'm looking at your inbox...
18:15danlarkinit's a _wave_
18:15durka42lower right corner
18:16danlarkinmaybe?
18:16danlarkinno
18:16danlarkinnevermind
18:16wavister... xmpp transport from wave to the irc clojurebot?
18:16danlarkinI redact my wave comment
18:20hiredmanno
18:20hiredmanjust clojurebot via xmpp
18:22wavisterspiffin!
18:25wavisterwhy is this so:
18:25wavister,(= (long 1) 1)
18:25clojurebottrue
18:25wavister,(clojure.set/union #{(long 1)} #{1})
18:25clojurebot#{1 1}
18:26rhickey,(.equals (long 1) 1)
18:26clojurebotfalse
18:26wavisterack. is there a way to do sets using = instead of .equals?
18:26rhickeyin order for Clojure sets to be java.util.Sets, they need to use .equals
18:26wavisteroh
18:59tomojhuh?
18:59tomojI don't get it
18:59tomoj,(= #{1 2 3} #{3 2 1})
18:59clojurebottrue
18:59tomojoh, you mean the elements I guess
19:16wtetzner_so is java.util.Set an interface?
19:17hiredman~jdoc java.util.Set
19:22wavisterhiredman: can I add clojurebot to my friends list?
19:23hiredmanclojurebot@thelastcitadel.com
19:23wavisterspiff
20:23Chouserwhy people think it would be better to allow similar out-of-order definitions in .clj files is beyond me.
20:29krumholt__i would like that :)
20:31krumholt__i program a function than i think of some helper function i might need and then i have to write that function above the the one i am writing. i like to order my code so that i see the main functions first and can read up on the helper function when i need to
20:33wavisteri've thought about that... you'd have to have a future pointing to a perhaps never defined function in the ns, and in parallel def your functions later to fulfill that future
20:35krumholt__wavister, load-file could just order the functions before evaluating them?
20:35cemerickChouser: is the haskell just masochism or something justifiable? ;-)
20:35Chouserit's solvable technically, but you'll end up with big ol' jumble
20:35wavisterwhat if there was a with-futures function similar to the with-local-vars, which just took a list of symbols to define within the clojure
20:35clojurebotfunction is <Chouser> there is one class per fn, one instance of it per closure
20:36Chouserwavister: 'declare'?
20:36wavisterin with-futures, each line would be evaluated in parallel rather than sequentially
20:36Chousercemerick: trying to understand the finger-tree paper.
20:37cemerickah
20:37cemerickI can read ML and its kin, but haskell is just unintelligible to me.
20:37wavisterChouser: i haven't messed with declare. maybe...
20:43cemerickwhoa, I just typed 'disclosure' as 'disclojure'
20:45wavistermuahaha
23:37technomancy`I've got a macro that generates a proxy form, but it's complaining "Caused by: java.lang.Exception: No such var: sketchbook.applet/this" when I try to bind this
23:37technomancy`http://p.hagelb.org/applet.clj.html
23:38technomancy`what's the trick to writing a macro that can do that?
23:43technomancy`hmm... (declare this) fixes it... but now I get an error running the macro even though running the macroexpansion works fine. I didn't think that was possible.
23:44technomancy`"Can't refer to qualified var that doesn't exist" when I try to run the macro. =\
23:45carkdid you try ~'this ?
23:45carkin the macro definition
23:46technomancy`cark: that solves the first problem; thanks
23:46technomancy`I think the second problem is due to the fact that my macro first defs a var and then tries to refer to the var in a defn inside the same macro
23:47technomancy`on second thought I don't really need the second defn to be inside the macro.
23:47carki'm not sure you're right
23:48carkmhh
23:50carkthe macro produces the code, then the defs are avaluated in order
23:51carkso that's exactly the same as having the macroexpansion in your source file
23:52technomancy`that's what I thought except... well... it's not the same.
23:52carkdid you try evaluating the macro-expansion ?
23:53technomancy`cark: that's what I mean, the macro-expansion works
23:54carkmhh i would call this a bug then ... though that seems hardly possible on such common stuff
23:56technomancy`actually my alternate approach breaks since proxies can't have metadata. boo.
23:56hiredmanuh
23:56hiredmanif they proxy IMeta
23:56hiredman
23:57technomancy`hiredman: oh, doh.
23:57technomancy`good call
23:57cark~paste?
23:57clojurebotlisppaste8, url
23:57lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
23:58lisppaste8cark pasted "well that works" at http://paste.lisp.org/display/86170