#clojure logs

2010-05-31

04:33LauJensenMorning all
04:34QuiesceHello
04:37bobo_is there any webframework for clojure that separates the view as strongly as lift/wicket? ie, you cant write any logic at al in it.
04:39Fossiwhy can't you do that in wicket?
04:39Fossiyou mean the html template?
04:39bobo_yeh, you can separate it entierly if you want to
04:40Fossihmmm. haven't seen a templating framework yet
04:42bobo_could probably use wicket, i think il have a look at that
04:46Fossibobo_: if you do i'd be interested how that feels
04:46tomojwith enlive, you have the html in a separate file
04:46tomojthen write some clojure which transforms the html
04:47tomojno clojure in the html files at all
04:47LauJensenFossi: Did you see my latest blogpost?
04:47LauJensenI've built bestinclass.dk entirely on Enlive templates and the Moustache micro-webframework, meaning 100% separation of logic and html/css
04:47FossiLauJensen: nope, could you link?
04:48LauJensenhttp://bestinclass.dk/index.clj/2010/05/refresh-your-cache--best-in-class-has-been-baked.html
04:50Fossijupp found it :)
04:50Fossilooks sane
04:50LauJensenThats a plus
04:51Fossibut still i wonder what wicket feels like from clojure. i used them both for zuite a while, but never together
04:51Fossi*quite
04:51unfo-LauJensen, oh cool! thanks for link
04:52LauJensennp
04:52LauJensenAnd I really should hurry up and opensource the code, it has a Wordpress -> Hthml converter, Atom feed generator, backend for posting and moderating comments
04:56unfo-what was this format-> [:body :> any-node]
04:57LauJensenIts selectors, similar to CSS but prefixed with :, so body > any-nody, means match any node directly under a body tag
04:58unfo-aaah css-style
04:58LauJensenhttp://enlive.cgrand.net/syntax.html
04:59unfo-ah thanks
04:59unfo-and also... my clj-fu has been written to swap in mah brainz
04:59unfo->_>
05:00unfo-need to reapply learning ^_^
05:20ravagreetings programs
08:49dnolenhmm if I want to extend-type int[] how can I refer to that as a class ?
08:59sparievhi, I need a function which takes a list of pairs on ints and 'concat' neighbour pairs together, ie ([0 2] [2 4]) becomes ([0 4])
08:59sparievhere's my take http://gist.github.com/419810
09:00sparievcould it be made more simpler ?
09:04canderaspariev: You could partition and then do a destructuring binding against the result.
09:04canderaAlthough I'm not entirely sure what algorithm you're trying to implement.
09:05Licenser_spariev: you don't have all specs, what happens if neighboring pairs do not match?
09:07sparievLicenser_: you just leave them as they were, ie ([2 4] [6 7]) => ([2 4] [6 7])
09:11canderaSo is it equivalent to flattening it and then removing any duplicates? Or will you ever wind up with pairs that have two elements the same?
09:13sparievI need this to corrently build a Lucene query with OR clauses. I have a vector with conditions, which can contain :or , like ["foo" "bar" :or "baz" :or "biz" "chunky bacon"]
09:14sparievSo I have to structure this vector into something like ["foo" [:or "bar" "baz" "biz"] "chunky bacon"]
09:15bartjspariev: I thought ([2 4] [6 7]) would give ([2 7] [4 6]) - care to explain the definition of "neighbourhood"?
09:20sparievbartj: it seems like I was quite unclear, my apologies. by the "neighbour pairs" I meant pairs like [2 4][4 6] , where the last item of first pair is equal to the first item of next pair
09:21sparievcandera: yep, you are right, flatten and remove duplicates will suffice
09:21sparievthanks all, sorry for the unclear question
09:23canderaspariev: Are you sure? If you flatten and remove dups from [0 2] [2 4] [4 4] [4 6], you'll get [0 6]
09:23canderaIs that what you want?
09:23sparievyes, there wont be pairs like [4 4]
09:24canderaOK. Was playing with the underlying problem (queries with :or) but didn't get anywhere.
09:29sparievcandera: thanks. my idea is to find indices of all conditions with :or near them, so ["foo" "bar" :or "baz" :or "biz" "chunky bacon"] will give [1 3] [3 5]
09:29canderaI see.
09:30canderaI was going at it from the direction of partitioning the original sequence with overlap, and looking at whether the subsequence has :or in it.
09:31canderaYours makes sense to me. But then again I fully expect someone else to say, "Oh, you just call these two functions on the original sequence." :)
09:32sparievcandera: heh, completely forgot about overlap param in partition. that's the solution I'm looking for :) thanks
09:33canderaI'll be curious to see your final code.
09:34sparievok, I'll update gist when it will be ready
10:33lessthantristani'm putting together a job queue. i have a ref counting the number of running jobs, and a (ref []) for the queue of waiting jobs. since i'm doing things like (if (> max-jobs @running-jobs) ... (dosync (alter ...))) in my add-job and finish-job, i should be wrapping the whole function in a dosync rather than just the bits where the refs are altered, correct?
10:34opqdonutyeah
10:35opqdonutotherwise you can accidentally go over the maximum job number
10:39lessthantristancool thanks. are all dosync calls linked, or is each one managed separately? i'm worried that my different add and finish job functions, which both read and manipulate the refs still might cause concurrency issues
10:40lessthantristanhmm. maybe some testing is required, i'm seeing lots of possible future problems with what i'm trying to do :)
10:48Licenser_lessthantristan: if you have multuiple dosync calls within eachothyer they all count as one transaction
10:58sparievcandera: here's what I finally came up with - http://gist.github.com/419810
10:58sparievfeels kinda wordy, but works
10:58spariev I tried to do it via partition with overlap, but decided to stick with my original idea in the end
10:58Chousukemore succinctly put: transactions have dynamic scope
12:09SinDoc[naïve] How can I use the bindings provided e.g. here [1] in another file?
12:09SinDoc[1] http://github.com/sindoc/algorithms/blob/master/src/main/clojure/whiteboard/y2010/hide-adt-state/datatype-01.clj
12:27cgrandSinDoc: add (:require [com.khakbaz.algorithms.clojure.whiteboard.y2010.hide-adt-state.datatype-01 :as d]) to the ns declaration in your other file
12:27cgrandthen d/op-a will reference op-a etc.
12:28SinDocHow does Clojure know where to find the file where that namespace is defined?
12:29bozhidarsame way as for java packages
12:29cgrandthey must be on your classpath
12:29bozhidarthe namespace reflects a particular
12:29bozhidardirectory structure
12:30bozhidarthe root of which should be available in the classpath
12:30bozhidarunless you have jar packaged code that is
12:32SinDocThank you, cgrand and bozhidar.
12:48noidid
12:49noidioops, didn't mean to write that :P
13:14LaPingvinohello
13:14LaPingvinohello Lau
13:15LaPingvinowhat was the date of that european Clojure stuff again, and where?
13:15LauJensenLaPingvino: June 23-25 in Brussels - All the details incl. schedule are on conj-labs.eu
13:16hugodI'm having problems modifying code at the repl - Could someone try entering http://gist.github.com/420007 at a 1.2-master-SNAPSHOT repl and comment on the result
13:16LaPingvinoLauJensen: tnx :)
13:18LauJensenLaPingvino: np - Let me know if you need anything else :)
13:18LauJensen
13:18LauJensen
13:18LauJensenhugod: I see 'b'
13:19hugodLauJensen: thanks, what is the date on you snapshot?
13:19LauJensenhugod: can the repl tell me ?
13:20LauJensenIts 20100427.170231-51
13:20hugodLauJensen: I'm seeing this on shapshots after around 20100521
13:22LauJensenhugod: Time to roll out --bisect
13:25hugodLauJensen: thanks :) I'm also having issues with redefining multimethods; presumably related somehow
13:26LauJensenhmm
13:26LauJensenFortunately you've got a simple way to test, so a bisect run shouldn't take long
13:26hugodLunch first :)
13:37Licensercooookies!
13:51naeuI'm just having a play with reify. I'm trying to reify a particular interface: http://users.frii.com/jarvi/rxtx/doc/gnu/io/SerialPortEventListener.html
13:52naeuHowever, I don't seem to be having much luck with the following: (reify gnu.io.SerialPortEventListener (serialEvent [e] (println "hi")))
13:53naeuI get the error: "Can't define method not in interfaces: serialEvent"
13:55LauJensenhugod: HTH, bisect log http://gist.github.com/420075
14:13naeuis there any way to inspect a Java interface from Clojure
14:13naeuit would be nice to see how Clojure sees a particular interface, i.e. what methods it thinks it requires to be implemented...
14:13LauJensennaeu: You can inspect anything Java using C-c I
14:14tomojclojure.contrib.repl-utils/show
14:14naeuLauJensen: how cool is that!
14:15LauJensennaeu: Its pretty high on the list :)
14:16naeuOK, so it still doesn't explain why I can't reify this particular interface - the emacs inspection gizmo says that the interface has one method: serialEvent and my reification form just contains that
14:17LauJensennaeu: but its not your method being run ?
14:18naeuLauJensen: I'm trying to reify this: http://users.frii.com/jarvi/rxtx/doc/gnu/io/SerialPortEventListener.html
14:18naeuusing this form: (reify gnu.io.SerialPortEventListener (serialEvent [e] (println "hi")))
14:18tomojnaeu: the inspection gismo says serialEvent takes one param?
14:18naeuthe gizmo says this: public abstract void gnu.io.SerialPortEventListener.serialEvent(gnu.io.SerialPortEvent)
14:18tomojoh, maybe you need a self param for reify?
14:19naeutomoj: that didn't fail...
14:19LauJensenIts been changed not too long ago I think, but reify takes an explicit this argument now
14:19tomojI mean, try (serialEvent [l e] ...)
14:19hugodLauJensen: thanks for the bisect
14:20LauJensenn
14:20LauJensenp
14:20naeuinteresting, it doesn't appear to be in the docs...
14:20naeutomoj: heay, i tried (serialEvent [_ e] ...)
14:21naeutomoj: s/heay/yeah
14:21LauJensennaeu: How are you determining that you're failing ?
14:21naeuLauJensen: Emacs is complaining when I eval it in slime
14:22naeubut if I add an initial anonymous param like tomoj suggested the eval completes successfully
14:22tomojnaeu: same error?
14:22tomojah, yes
14:22LauJensennaeu: tomojs suggestion is the correct form
14:22tomojthen what's the problem? :)
14:22naeunone, now, it seems :-)
14:22naeui said it didn't fail :-)
14:22tomojah, I see
14:22tomojthe first parameter is the object itself
14:22naeusure a this/self param
14:22tomojthe one which will have a .serialEvent method I mean
14:23mrTrololoHi! Tell me please how can I use my "do" if I have something like this: (let [do println] ...)
14:23naeuright, i'm off out for a walk now, i'll get back to this later
14:23naeuthanks so much for the help LauJensen and tomoj
14:23LauJensennp
14:23LauJensen$(let [do println] (do "hello"))
14:23sexpbot=> "hello"
14:24mrTrololoI mean do will work as println inside binding
14:24LauJensenThats right
14:25tomojno..
14:25tomoj$(let [do +] (do 1 2))
14:25sexpbot=> 2
14:26tomojalso..
14:26LauJensenhmm
14:26tomoj$(let [do 3] do)
14:26sexpbot=> nil
14:26tomoj:)
14:26tomojI can explain the former but not the latter
14:26LauJensenI dont get that
14:26tomojdo is a special form
14:27tomojso you can't replace it with let
14:27tomojnot sure why a lone do is allowed inside let, though.. I remember it being discussed here before but don't remember the explanation
14:27tomoj$(let [] do 3)
14:27sexpbot=> 3
14:28tomojsomething to do with the implicit do I guess
14:28LauJensenI didn't consider that its a special form
14:28LauJensenAnd Im not sure why it needs to be
14:28LauJensen,source do
14:28clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
14:28LauJensen$source do
14:28sexpbotCommand not found. No entiendo lo que estás diciendo.
14:29tomojhrmmm
14:29tomoj$(let [let 3] let)
14:29sexpbot=> 3
14:29tomojwat?
14:29clojurebotFor Jswat: start clojure with -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8888
14:29tomojlet is a special form too
14:29tomojso "do is a special form" is not an explanation
14:29tomoj$(let [let +] (let 1 2))
14:29sexpbotjava.lang.IllegalArgumentException: let requires a vector for its binding
14:29tomojwell, that works for me in 1.2
14:29tomoj(i.e. it returns 3)
14:30mrTrololoreally strange
14:30kotarakLauJensen: I think you need proxy to handle abstract methods. But I'm not sure.
14:31LauJensenkotarak: re the reify issue?
14:31kotaraktomoj: It should work, because the "real" let special form is let*. Not so for do.
14:31kotarakLauJensen: yes
14:31tomojkotarak: aha
14:32kotaraktomoj: let is macro adding destructuring and stuff.
14:32kotaraktomoj: but it should be treated as special form
14:32LauJensenkotarak: Ah I think you're right actually
14:32tomoj?def let
14:33kotarak~source let
14:35tomojstrange
14:35tomojso (doc let) special cases it and calls it a special form, I guess?
14:36tomojeven though it's really a macro
14:36kotaraktomoj: it should be treated as special form
14:44kotarakLauJensen: hmmm.... Why should the interface have an abstract method? I don't think, that's what happens. There is something else going on.
14:47BorkdudeIs there something like with fn (foo [coll] ...), (op foo x1 x2), op like apply, but the other way around?
14:48raekthe other way around? can you show an example?
14:49tomoj(foo [x1 x2]) ?
14:49BorkdudeI mean, foo expects a coll
14:49Borkdudebut I don't want to wrap x1 and x2 inside a coll
14:49Borkdudelike with apply, when it the fn does not want a coll, but direct args
14:50tomojwhy don't you want to wrap? just curious
14:50Borkdudebecause I'm too lazy
14:50kotarak(defn unspread [f & args] (f args)) (unspread foo 1 2 3)
14:51Borkdudefor example I want to do this: (merge-with (fn [r l] r) {:foo "Lucy"} {:bar "Ethel"} {:bar "Ricky"})... I can't pass just the first function, because first expects a coll
14:51Borkdudeand or isn't a function, so that doesn't work either
14:52tomojinteresting
14:53tomojso with (defn unspread [f] (fn [& args] (f args))), (unspread first) would work?
14:54BorkdudeThis works: (merge-with (partial unspread first) {:foo "Lucy"} {:bar "Ethel"} {:bar "Ricky"})
14:54kotarak(apply merge (reverse {:foo "Lucy"} {:bar "Ethel"} {:bar "Ricky"}))
14:55tomoj(partial merge-with (partial unspread first)) == merge, I think
14:57Borkdude(defn unspread [f]
14:57Borkdude (fn [& args]
14:57Borkdude (f args)))
14:57kotaraktomoj: merge merges left to right. So right wins. So probably (partial merge-with (partial unspread second)) => merge
14:57Borkdude(merge-with (unspread first) {:foo "Lucy"} {:bar "Ethel"} {:bar "Ricky"})
14:57tomojoh, yeah
14:58tomojthat unspread is kind of interesting
15:04BorkdudeI'm not sure about the name though
15:06Borkdudewhy not unapply?
15:06Borkdudeor deply? :)
15:09Borkdudeuncoll
15:10BorkdudeI think I like that one
15:11Borkdudebecause usually the argname in things like first is coll
15:11Borkdudeand it sounds a bit like 'uncall' which is close to 'unapply' in meaning
15:17Borkdudetnx for the help. gtg again
17:42Raynestechnomancy: Ping.
17:44technomancyRaynes: sorry, I'm on the phone
17:45technomancya github message is good
17:45Raynestechnomancy: It's cool. I'll just reply on github. :p
18:04zakwilsonI'm trying to use lein remote-swank. It looks like it's working, but no java process is running on the remote machine.
19:34Ankouhi, I have a map with a :type metadata and I defined a print-method on it. So when I now write (print m) it prints correctly but when I write (print (with-meta m {:type nil})) I get an clojure.lang.LazySeq cannot be cast to clojure.lang.IFn exception. How can this be?
19:35AnkouI mean, I thought print should always print something and never throw an exception like this one?
19:40Ankouanyone?
21:52jweisshi, i keep trying to use map, when not all the data i need to process is in the seq i'm passing to map. for instance, i want to add metadata to each item in a seq, but the metadata obviously isn't in the seq, it's in a different one. what's the functional way to do this
21:57zakwilsonjweiss: pass both seqs and a function that takes two args to map.
21:58jweisszakwilson: ah yes, i keep forgetting that map can take more than 1 coll :) thanks
22:26mebaran151I just reinstalled my linux installation and am having a little bit of trouble re-setting up emacs
22:26mebaran151I'd like to set up Clojure Slime to work with the new Clojure 1.2, but even the release versions are throwing strange errors
22:27mebaran151particularly wrong number of args passed to basic$eval#compile-file-for-emacs
22:36bhenrymembran151 what linux installation?