#clojure logs

2009-05-18

02:24Lau_of_DKTop of the morning gents
02:24markusgustavssonGood morning
02:50Lau_of_DKAnyone here familiar with Symbolic Web, and perhaps a Clojure pendant to it ?
02:54slashus2SymbolicWeb developed by lnostdal?
03:45sopelhey
03:46Lau_of_DKslashus2: yea
03:46sopeli'm trying to coerce a bunch of bytes read from a socket to an int
03:46sopeland the other way around
03:46sopelany neat way to do it or should i use java?
04:08Lau_of_DKa bunch of bytes = an array ?
04:09sopelyeah
04:09sopel(make-array Byte/TYPE 4)
04:09Lau_of_DKThen I think Java might be your best option, and cgrand would probably disagree :)
04:09sopelit's done here somehow http://gnuvince.wordpress.com/2009/01/29/reading-binary-data-in-clojure/
04:09sopelbut i can't figure out from the code how it's done
04:11Lau_of_DK(let [f ({:byte (memfn get) :word (memfn getShort) :dword (memfn getInt)} type)
04:11Lau_of_DKYou want to find "getInt"
04:12sopelyea i tried to call getInt on the array but it says there's no such field
04:13Lau_of_DKI think its something he wrote himself
04:13Lau_of_DKAlthough Im not sure, memfn takes a clojure function as far as I recall
04:13sopeloh ok.
04:13sopeli think i got it
04:13sopelhe converts it to a char array first.
04:13sopeland then calls getInt on it
04:13Lau_of_DK(doc memfn)
04:13clojurebot"([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn."
04:13sopelerr.. string.
04:13Lau_of_DKooh, clever :)
04:14Rayneshttp://hpaste.org/fastcgi/hpaste.fcgi/view?id=4978
04:14RaynesThat's a seriously long function.
04:14Lau_of_DKRaynes: We had to debug a function the other day, which was 500 lines long :)
04:15Lau_of_DK(no - We did not write it initially)
04:15Raynes:o
04:16RaynesHey, cool, HPaste does Clojure highlighting now.
04:21cadscan IEEE floating point numbers be printed out and read back in perfectly unchanged in clojure?
04:23sopelLau; argh that doesn't work.
04:24cadsin ruby i think I did that using printf with a format character for floats, and I think ruby's to-f function automatically read the special format back in to a float
05:36sopelhow to group a bunch of expressions? i.e. i want to do (if foo (some expr some expr 2) (else something))
05:37sopeland i want some expr and some expr 2 to be aprt of the if true clause and not some expr 2 being the else clause
05:37kotarak(if foo (do (expr1) (expr2)) (do (something) else))
05:38sopelthx. can't find 'do' in the reference.
05:38svdmit's on the special forms page
05:46lisppaste8cgrand annotated #80388 "Enlive selector for quidnunc" at http://paste.lisp.org/display/80388#1
05:47sopelany logging package for clojure?
05:47sopelor should i use java stuff
06:26kotaraksopel: apache commons logging is often mentioned as a good solution
07:22Raynes"Compared with Paul Hudak, John Hughes, Simon Peyton Jones, and Phil Wadler, Rich Hickey is chopped liver :-) "
07:23RaynesThat's low. :\
07:31Carkwhere did you catch that ?
07:54Chouserwell, that worked out nicely -- a Java lib wanted a object with a particular interface, but it was mainly going to just pass it back to me later.
07:55Chouserso I used proxy to make an APersistentMap that delegates to a regular hash-map like I was going to use anyway, but the proxy also implements the Java lib's interface.
07:56Chousermy clojure code can happily ignore the fact that it has a particular Java interface, and the Java code can ignore that it's a hash-map
07:57Carknice =)
07:57Carkbut
07:58Carkhum no forget it, had a question but you explained it already !
07:58Chouser:-)
07:58Chouserthe Java API is google protobufs, for which the Java API is quite nice.
07:59rhickeyChouser: neat
07:59Chouserum. that came out awkwardly. but anyway.
07:59Carkah, you are using protocol buffers in an application ?
07:59Carkis this to interface with google in some way ?
07:59rhickeyChouser: sorry, I got pulled away the other day - did you go with map with IRefs or IRef to map?
08:00Chouserthe message objects themselves are immutable, with a handy builder interface (also immutable)
08:00Chouserand all the required arg types for the various RPC pieces are abstract interfaces.
08:01Chouserrhickey: map of IRefs. I spent a couple hours on the phone with abrooks beating on the subject, and am happy with the solution.
08:03ChouserThe difference from what I described earlier is not trying to close over pieces of the obj's data, but instead pass in the whole object when needed.
08:03rhickeyok
08:03Chouserthis means, for example, that instead of trying to make the object the state of the main agent, the state of the agent is just nil and the obj is passed in as the next arg.
08:03tbbhi all, i have what feels like a silly question. within some dynamic bindings I start a thread, how can i make the bindings in the thread point to the same objects?
08:05kotaraktbb; you could do (Thread. (fn [] (binding [a a b b c c] (do-thread-things)))). But you have to know what you want in advance.
08:06tbbkotarak, thanks, i thought the same thing, maybe I made a mistake, let me double check
08:07kotaraktbb: I haven't tested, but it seemed to be an obvious idea.
08:08rhickeykotarak: you have to capture the bindings with a let, then re-establish in the fn
08:09kotarakOk. @ tbb => let then re-establish in the fn.
08:09tbbis the let outside of the fn?
08:10kotarakI would think so.
08:10kotarakAh. Of course.
08:10kotarakThe binding in the new thread already sees the old bindings.
08:11kotarakSo you have to do: (let [a a b b c c] (Thread. (fn [] (binding [a a b b c c] ...)))
08:11kotarakNow the a b c in the binding are coming from the let.
08:11kotarakWhich contain the modified bindings from the parent thread.
08:13tbbthank you! trying it out now
08:15rhickeyI had this idea last night (again, actually an old one) about a stack-discipline context-cache, like bindings but not dynamic name scope, for threading values to nested contexts without poisoning the call chain, since about half the use of binding, or attempted usage, is in that category. Could use for monads etc. It would be captured by fn. Only half-baked at this point.
08:33tbbkotarak, rhickey: it works just fine, the problem was a macro in between, thanks
08:34rhickeytbb: you're welcome. I'm surprised no one has written as with-captured-bindings macro yet
08:35kotarakThere was on the list some while ago, IIRC
08:35ChouserI was sure I saw one. It's not in contrib?
08:37jdzanybody experiencing problems with using classes that are in locations that are added using add-classpath?
08:37kotarakjdz: don't use add-classpath. Only from the REPL but not for production.
08:37kotarakThere are currently changes down in trunk, which influence add-classpath.
08:38jdzi have noticed :/
08:38hoeck,(proxy [clojure.lang.ISeq] nil (seq [] ()))
08:38clojurebotjava.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers)
08:39hoeckah, too bad clojurebot doesn't allow this, on my machine, the above expression returns (nil)
08:39jdzkotarak: is there going to be no way to add classpaths dynamically at all?
08:39hoeckis this correct or is this a bug?
08:40kotarakjdz: add a directory to your classpath, unzip the jar in this directory an runtime and the classes will be found.
08:41jdzi know there are many ways to work around that. but that does not answer the question...
08:41Chouserhoeck: I think .seq methods aren't expected to return empty lists -- either a list of stuff or nil
08:42Chouserjdz: It's not really supported by Java.
08:42kotarakjdz: To my information adding dynamicly stuff to the classpath was always broken and hacky.
08:43jdzwell it at least worked up to recently
08:43Chouseroh, really? I've never had much success.
08:44rhickeyadd-classpath is in conflict with modularity, since it requires a singly-rooted classpath-tree.
08:45rhickeyalso, it is a problem for a library (e.g. Clojure's) to load classes on behalf of consumers, since they might have visibility to something the library doesn't
08:46rhickeyI have been fixing the latter, moving Class.forName calls to the consumer of things like import, ns and new
08:46rhickeythis should greatly improve the story for Clojure in contexts like OSGi/Eclipse/ Netbeans, web app servers etc
08:48jdzwell i'm thinking of how to get swank running now...
08:48rhickeyadd-classpath was only ever intended for the "I'm already running and I found this lib on the net I want to check out" scenario. Once you've got a library you care about, you need to put it in your classpath using standard means
08:48kotarakjdz: use release? Or pre-changes SVN?
08:49jdzye, might as well
08:50rhickeywhat I'm thinking is there will be a narrowly-defined context in which you can get the shared root loader, like in the repl.
08:51rhickeyswank uses add-classpath?
08:51jdzyes
08:52hoeckChouser: I thought, since () implements ISeq, i can safely return it from a seq method of any (derived) clojure collection and get the same thing back.
08:52rhickeyhoeck: seq must return non-emtpy seq or nil
08:53hoeckrhickey: ah, okay
08:53jdzrhickey: swank also tries to compile itself on demand
08:54jdzrhickey: so it uses add-classpath twice
08:54rhickeyHelp wanted: http://groups.google.com/group/clojure/browse_frm/thread/ef2eee0a2ea12b76
08:55rhickeyjdz: what does it add?
08:56jdzrhickey: first it adds the location of .clj files based on the elisp file it is being loaded from. second it adds classroot for compiled files when compiling (or loading if already compiled).
08:56jdzrhickey: the first addition could be skipped by adding the path to the classpath argument when starting jvm
08:57jdzrhickey: the second one is trickier; the solution might also be to do things on emacs side, not clojure
08:58jdzrhickey: btw, what environment do you use for developing yourself?
08:59kotarakrhickey: should be something using concurrency? maybe the ants? That was what caught me, although I don't do much concurrency work. The whole Ref/Agent/Atom system is a main selling point, I think.
08:59jdzfor me the selling point is the easy interop with Java
09:00jdzand the functional side of clojure
09:00Chouserants is so 2008
09:00kotarakChouser: you are free to present something modern. :) ;)
09:00Chouser:-)
09:01rhickeyjdz: I use Aquamacs (with clojure-mode only) for Clojure code, and IntelliJ for Java. Have been playing with enclojure (much better now) and IntelliJ's La Clojure plugin, although I don't understand the latters' relationship (if any) to a repl yet
09:01kotarakI'm not experienced in concurrency. So I don't know any nice examples for 4 minutes.
09:02ChouserIf there were a Java entry, what would they show?
09:02rhickeykotarak: One of the interesting things about Clojure is its success in spite of the fact that only a small percentage of its users are currently leveraging its concurrency features.
09:02ChouserI mean, what do Java people like to do with their language?
09:03rhickeyChouser: get paid
09:03ChouserIf you could demo *that* in 4 minutes, I'd be impressed.
09:03jdzrhickey: i like the fact that i get concurrency for free when i want it (if the code is written properly, of course)
09:03kotarakrhickey: Well. For me these are reasons why I *love* clojure: immutability be default, Lisp (Lisp-1 in particular), nice integration of vectors, maps and sets, small footprint of the core, nice community
09:04ChouserYeah, I was chugging the kool-aid before I understood any of the concurrency features.
09:04kotarakAnd the Java interop, although I don't particularly like Java itself.
09:04rhickeythe 4 minute demo is actually an interesting problem. Last year, they had assigned a task (a twitter client) and everyone was showing their implementation of the same thing
09:04kotarakBut for the libraries it awesome.
09:05kotarakThe 5-minutes talk is the king of talks.
09:05rhickeywhy use Clojure instead of JRuby/Groovy/Jython/Scala is also a question the presentation needs to answer, indirectly
09:05clojurebotwhy not?
09:05ChouserComing from non-lisps, I love how pleasant I can make an API. Having written a library of functionality, it takes a matter of a minutes to layer functions and/or macros on top to make it absolutely beautiful to use.
09:06eevar2rhickey: because it's a lisp
09:07eevar2no idea how to demo that w/o scaring half the people away, tho ;)
09:09rhickeyI think FP/immutability as the default, Lisp, abstraction-based lib, and built-in concurrency story are all distinguishing features, but Scala can do FP and has actors, Groovy/Ruby/Scala DSLs. Superficially, people might not be able to see the distinctions, that's what we have to tease out (in 4 minutes)
09:10kotarakAlso nice: the concise of Clojure code. Do something non-trivially in less code, than the rest?
09:11rhickeyI think people that just want dynamic Java should go Groovy, people that want Java++, Scala, people with existing Python/Ruby Jython/JRuby. Who does that leave and why are you here? :)
09:11tWiplispers forced to live in the jvm?
09:12gnuvince_People who want a fun and simple language that has access to an established platform.
09:12kotarakBecause the others are no Lisp. :) I avoid macros like the devil the holy water, but it's nice to have them available. So maybe homoiconicity or whatever it is called?
09:12ChouserI never wanted Java, so that puts me in the Jython/JRuby category.
09:13Chouserseq abstraction and immutability are why I came here. And macros.
09:13rhickeyChouser: I wasn't saying people that know Python/Ruby, but more people that wanted to move that code
09:14Chouseroh, and dynamic typing -- that's why I finished my brief stint with Scala.
09:14rhickeyimmutability is a definite feature that doesn't necessarily seem like one at first, I think
09:15rhickeyI like to think that people find their Clojure programs more robust and easier to understand, but maybe they don't?
09:16kotarakI think they are easier to understand (if you are a Lisp guy) because they are so concise. With Java I scroll around all the day to skip those getter/setter ged�hnse stuff.
09:16marklarrhickey: definitely, like kotarak said, how concise the programs are is amazing
09:16rhickeyPractically there are many hurdles, esp. the fact that many will not be able to parse the syntax at all, and thus not know what they are looking at. The focus is supposed to be on code, not slides.
09:16kotarakWith Clojure its just less stuff polluting the cache in my brain.
09:17gnuvince_I was speaking with a few friends who are mostly C and C++ programmers yesterday, and one described the idea of mutability as "abject".
09:18gnuvince_"If the CPU can mutate values, why couldn't I?"
09:18kotarakBut this is also a problem for others, no? The Scala syntax is also not so intuitive when you never saw it before the 4min talk.
09:18rhickeykotarak: all the other langs will be showing x.foo in some form
09:18hoeckI was first afraid of the fact that all clojure datastructures are immutable by default, and really wondered wether one can write useful programs with such a limitation
09:19rhickeyhoeck: and now?
09:19hoeckwell, I've read that paper about necessary and accidential complexity ...
09:20kotarakAh: Another point: clojure's consistency in wide areas: (swap! atom f args) (alter ref f args) (update-in map [keys] f args) (send agent f args) ....
09:20Chousertarpit
09:20kotarakSo the abstractions are a big point.
09:20gnuvince_I think that as long as you're not looking to squeeze out every single cycle out of your CPU, immutability really ought to be the default. I feel it makes code easier to understand, not to mention that persistent collections are a big plus.
09:21hoeckand I really appreciate the way clojure works, and I try to build more immutable code in my day job, because its way cleaner and easier to understand
09:21kotarakgnuvince_: OCaml also has immutability be default and really squeezes a lot out of the CPU...
09:21kotarakSo it's not necessarily a trade-off.
09:21kotarakAlthough, the collections are mutable there. You are right.
09:22rhickeyI was thinking about showing the Amazon SimpleDB lib, which, in 300 lines, provides a full extensible API as well as an embedded DSL for queries. Has anyone looked at it?
09:22gnuvince_kotarak: yeah, arrays can be mutated with arr.(1) <- x
09:22clojurebotx is w
09:22gnuvince_or something like that
09:23kotarakgnuvince_: yes but local are immutable be default, also the "O" part has some simple syntax for immutable objects
09:23rhickeyI imagine a small ring/compojure/enlive demo could work
09:24gnuvince_kotarak: no need to convince me :)
09:24rhickeyI don't know enough about any of them to write one
09:24gnuvince_kotarak: but I was not able to convince guys who've been x++'ing their code for 15 years
09:24rhickeythe consensus was everyone was tired of web apps as demos
09:25kotarakgnuvince_: -.- "Old dogs don't learn new tricks." as the proverb knows.
09:25ChouserI wonder if the ring/moustache stuff would turn some head
09:25Chouseroh
09:25rhickeysince every lang now has a web-site with a couple of lines library now
09:25Chouser"heads", and nevermind.
09:25gnuvince_kotarak: maybe you're right
09:25eevar2how about a slick swing app?
09:26gnuvince_Took me a while to appreciate immutability, and I still sometimes question it.
09:26rhickeyI really liked the multithreaded Life demo video that had 1/2/4 cores side-by side, but I'll only have a dual core with me
09:28rhickeyhttp://www.youtube.com/watch?v=CFCYVfApPUc
09:29kotarakShowing seq abstractions and generic functions working on a variety of data structures is probably lacking the *BOOM*-effect for such a talk.
09:30gnuvince_For round 2, I think a simpledb demo would be cool
09:30rhickeygnuvince: I think round 2 should feature the work of the community, not mine
09:31gnuvince_rhickey: ah, ok.
09:31gnuvince_For round 1, I'd say that a Java crowd would be most interested in the Java interop access
09:31Chouserthat life demo is nice.
09:31rhickeygnuvince_: but that's something all the langs have
09:31gnuvince_We just need to come up with a short example that shows that, but that also highlights Clojure's specific strenghts.
09:32Chousershows off community collaboration as well
09:33rhickeyChouser: it would be nice in round 2 to give a sense of the community as a whole, esp. libraries
09:33rhickeye.g. for Scala, Lift is a big selling point
09:33rhickeyfor Groovy, Grails
09:34Chouserfor Clojure, error-kit
09:34Chousuke:P
09:34Chouserhehe :-)
09:34rhickeyObviously Clojure doesn't have as mature libs, being much younger
09:34rhickeyChouser: error-kit confuses me, so...
09:34clojurebotWho??
09:34kotaraklazymap ;)
09:35gnuvince_It might be just me, but I think showing yet another web framework in yet another language is gonna get boring
09:35gnuvince_Lift, Grails, Rails on JRuby and JDjango...
09:36Chouserbut that's what people use their languages for now. Like you had to have some kind of GUI story in the 90's -- tk bindings or *something*
09:36Chousukethe web stuff would be good for showing of DSLs in clojure though
09:37Chousukelike enlive's selector stuff or clj-html
09:37Chousukeshowing off* too
09:37rhickeyA web thingy showing something unique about doing it in Clojure might still be interesting, but DSLs are available elsewhere too
09:37Chouserbut if you have a compelling demo, you can just toss in a line about "Clojure has great web app support to get your site running with just a couple lines... but what language these days doesn't?" ...and move one.
09:37gnuvince_Chouser: maybe, but I don't think I'd want to switch to a very foreign language just for a web framework.
09:38Chousergnuvince_: a lot of people did that for Ruby, I think. Of course they may regret that decision now...
09:38Chousukewe could demo clojurebot :P
09:38gnuvince_Chousuke: isn't that in Java?
09:39Chousukewell, most of it is, yeah.
09:39Chousukethe actual irc stuff is handled by pircbot
09:39Chouserreally!?
09:39Chouseroh
09:39Chousukebut all the interesting features are in clojure :)
09:41gnuvince_Is there a short and simple demo that could be done with agents to show off Clojure's concurrency features?
09:41kotarakSomeone just mentioned on the list the dynamic modification of a running program as it was done in the ants demo. That would also be cool.
09:41gnuvince_Maybe downloading a bunch of files, but no more than 5 at a time, something like that?
09:43ChousukeI don't think it'd show off the concurrency features well enough. :/
09:43gnuvince_Chousuke: what can you show in just 4 minutes that would give Java a people a reason to look at a Lisp dialect with dynamic typing instead of Scala
09:44Chousukethat's the problem :P
09:45kotarakdon333: http://clojure-log.n01se.net to catch up ;)
09:45don333will look now, thanks :)
09:45gnuvince_Chousuke: this is why something simple that people not necessarily familiar with Lisp-like languages can grasp and can say "that's cool" would be best.
09:46rhickeyFor the community part, I think it would be possible to show the value of using the core data structures everywhere, you know, 1 line to load xml from a web site, another to filter and reshape it, another to stick it in a db, and a couple more to put up in a Swing or html view. In most langs each of those things would have their own object-based api
09:46Chouserkotarak: that's updating only once a day now. :-/
09:46kotarakChouser: Oh. Ok.
09:46rhickeyi.e. the value of non-oo libs
09:46don333kotarak: either I can't use it or it doesn't show the recent discussion
09:46cp2mornin'
09:46cp2exams today, no class :)
09:47kotarakdon333: see what Chouser wrote: update now only once a day... :/
09:47kotarakrhickey: maybe some zipper modifying a tree?
09:48Chouserzippers are most interesting after you're already sold on immutability. Otherwise they just look complicated.
09:49don333rhickey: is that what you described possible in Clojure?
09:49rhickeydon333: sure
09:50don333because I came to #clojure exactly to find out if it's better to devote my time to Scala or Clojure as "the next for the JVM"
09:50sopelrhickey; congrats on clojure, great job :)
09:50rhickeydon333: I think both will succeed
09:50rhickeysopel: thanks
09:50sopeli was really hurting not being able to do any lisp
09:50sopeland now there's a reason at last
09:53don333rhickey: where can I find examples for Clojure code doing something like what you described?
09:53don333or is Chouser working on a demo? :)
09:53sopeldon333; lisps are superior to javascript-like languages which Scala seems to be basing on the examples ;)
09:53rhickeyI think the Clojure libs + data structures as legos would be a great, distinguishing demo. When other langs read XML they get a DOM, when they read from a db they get recordsets, when they want to do logic on them they need to pour into collection classes, when they want to view them, they need to create model classes. A plethora of APIs, no interop
09:53don333sopel: I know Lisp (CL that is)
09:54sopeldon333; then i'm surprised that you're even considering scala. looks ugly :)
09:54don333I see Scala as an improvement over Java (language) and I have to code Java on the job
09:55don333I know nothing about Clojure except for the title "FP on JVM"
09:55don333and it made me curious
09:57sopeldon333; well I'll always pick a lisp over any imperative language, and you can use all of Java from Clojure
09:57rhickeydon333: most Clojure libs work like I described
09:58don333so, I should look at Clojure source then?
09:59don333sopel: that's what I'm most interested in, if I could use CL I'd use CL
09:59don333things like Hibernate, servlets, EJB or annotation support is what I'm after
09:59Chouserdon333: there is a CL for JVM
10:00Chouserbut you don't get Clojure's yummy immutability, concurrency support, etc.
10:00rhickeydon333: any example programs, blogs etc
10:00guineaHow do I download/install a contrib library? I checked out the -readonly tree from SVN and tried (add-classpath the-src-directory)
10:01don333rhickey: I'm digging through clojure.org in the mean time
10:01sopelguinea; you have to build it with ant first and then add the resulting jar to classpath
10:02guineasopel: thanks
10:02rhickeydon333: but you won't find Hibernate or EJB, that's just more of the same
10:02guineathe ant demo is a really fun intro. I was having fun adding user interaction on the fly, and learning a lot doing so.
10:03don333yes, I get that - but knowing that I won't be the first to try (and succeed) joining e.g. EJB code with Clojure code would help
10:05don333and I didn't find that (or the annotations) in "Java Interop" on clojure.org
10:09rhickeydon333: If you are doing EJB, annotations etc then Java is still driving the architecture (it's ok, that's where you are), so using Clojure there will be more about calling Clojure-based logic from Java. You can write Java classes in Clojure, but hopefully the need for that would be limited. There is no annotations support in gen-class yet.
10:09don333rhickey: thanks, that was very helpful
10:43Chouserthis is the first time I've written Clojure code with the intention of wrapping it in a Java API.
10:43ChouserI know others have done so, but it's pretty interesting.
10:44rhickeyChouser: do you control the interface or are you implementing an external interface?
10:45Chousera bit of each. protobuf provides a set of interfaces for me to implement, but that doesn't cover all the bases, so I'll have some API of my own.
10:46ChouserI'm currently expecting to provide a single class with a bunch of static methods for creating the various objects needed.
10:46Chousernot "normal" Java, I suspect, but I think it'll be easy enough to use.
10:46rhickeyinterfaces + proxies + factories is ideal, IMO
10:47Chouseryes, is going nicely so far. protobuf's supplying the interfaces, I'm writing proxies now, and will layer a factory piece on top.
10:47Chouserthe protobuf objects all use interfaces and factories. ...I'm not sure there's a single public constructor in there anywhere.
10:48rhickeypublic ctors have fallen into disfavor, everyone hates them for testing reasons at least
10:48Chouserinteresting.
10:49rhickeyhttp://code.google.com/p/google-guice/
10:49rhickeyeven factories
10:50ChouserI was happy to see a nice constructor for Ref, though. I've got a (proxy [Ref RpcController] [{...}] ...) that looks quite nice.
11:18Chouserwhat are the latest thoughts on handling of agent errors?
11:19Chouserwatchers aren't triggered on error, are they?
11:31rhickeyChouser: same thoughts, error queues
11:45Chouserrhickey: you'd register an agent with a particular queue?
11:47rhickeyChouser: there'd be a default, or yes, register one
11:48Chouserthis is a PersistentQueue, or something on which you can register a handler?
11:50rhickeyChouser: the agent side shouldn't care
11:50rhickeythis is waiting on abstractions for queues so that will be possible
11:51Chouseroh, ok.
11:52rhickeythe write part of a queue abstraction might not look any different from IFn
11:52rhickeybut some queues could block, or have transactions, or yield message ids etc
11:52Chousernice
11:57rhickeyso, perhaps the agent side need wait on nothing else, just add an on-error handler fn, like validator
11:59biillywhen you guys start a slime-repl, do you have to hit RET multiple times to get from inferior-lisp to the slime-repl?
12:04replacabiilly: nope
12:05replacaChouser: are you doing a general purpose protobuf implementation for Clojure?
12:06Chouserthere's hardly anything to do to use protobuf nicely in clojure.
12:06biillyhmm, thanks. aloso if i lauch javadoc within the slime-repl it hangs, and i have to go to the lisp-inferior buffer and hit RET - but only once
12:06replacaChouser: cool
12:06Chouserno, I'm doing a closed-source proprietary RPC thing built on protobuf
12:07replacaChouser: for your new job?
12:07Chouseryep!
12:07replacaChouser: using clojure at work, yay!
12:07stuartsierrabilly: it takes several seconds before slime-repl takes over, that may be what you're seeing.
12:07Chouseryes, exactly. it's in a bit of a probationary period here, so we'll see how it goes over.
12:08replacaChouser: are there other lisp heads there or is the whole lisp thing weird to them?
12:09Chouserlisp and java are both less than popular. ...got a bit of a hill to climb.
12:09replacaChouser: what's the default implementation environment?
12:10Chouserdifferent projects are using tend in different directions, but more common are ruby, php, and C++
12:10biillystuartsierra: it takes a few seconds to connect, which it does, but it will stay in the inferior lisp buffer indefinately until i hit return
12:10stuartsierrabiilly: huh, dunno then
12:11Chouserbut I'm on a smart team with open minds and minimal managerial overhead, so I'm pretty hopeful.
12:11replacaChouser: interesting. In my day job, I'm the PHB & I'm pretty hard-nosed about a single platform
12:12replaca(and in our case it's .Net, so no Clojure)
12:12replacabut I have pushed IronPython and other scripting stuff to try to crack the battleship
12:12Chouserwell, as I said, we'll see how this goes. This work will be classified as "prototype" until it can prove itself.
12:13Chouserit may get re-written in C++ if I can't prevail.
12:13Chouserin which case I'll have to cash in these parens for all the extra LOC I'll need.
12:13replacaChouser: well, I hope you do! It will be fun to see Clojure get more and more real world traction.
12:14replacaChouser: well, you already wrote the javascript thing, maybe you can just do a clojure to C++ converter
12:14replacathen noone will know better
12:14replaca:-)
12:14Chouserright
12:14Chousersure
12:18djpowellre: why clojure; I'm pretty much using clojure for the seq
12:18djpowellabstraction. being able to do sick things with multiple
12:18djpowellresultset-seqs is really cool. and the common interface of
12:18djpowelldatastructures rather than objects, makes stuff easy to test. and the
12:18djpowellinterative development of course is a big thing.
12:18djpowell(urgh - fill-mode - how did that happen...)
12:31hiredman~whose job is it to port clojure to c++
12:31clojurebotYou don't have to tell me twice.
12:31hiredmanbah
12:32hiredman~whose job is it to port clojure to c++?
12:32clojurebotthat's Kisu's job
12:34danlarkinuh oh, a lurker
12:38replacawell, now he has a job!
12:38replacaget to work, Kisu!
12:38hiredman~whose job is it to make sure everyone has a job?
12:38clojurebotthat's unlink's job
12:40kwatzheh, that's a clever bot feature
12:41hiredmanjob assignment is very useful in parallel distributed programming
12:42danlarkinha
12:55Chouser(.run #^RpcCallback done msg) works, but (.run done msg) produces: java.lang.IllegalArgumentException: No matching method found: run for class com.google.protobuf.RpcUtil$1 (NO_SOURCE_FILE:0)
12:56Chouser (supers (class done)) ==> #{java.lang.Object com.google.protobuf.RpcCallback}
13:08rhickeyChouser: is it overloaded?
13:09Chouseryes, there's a .run that takes Message, and one that takes Object
13:10Chouserthe 'done' object is probably being created by one for these: http://code.google.com/apis/protocolbuffers/docs/reference/java/index.html
13:11rhickeyis the actual class of done private/nested etc?
13:12Chouseruser=> (show done)
13:12Chouser=== static com.google.protobuf.RpcUtil$1 ===
13:12Chouser[ 5] run : void (Message)
13:12Chouser[ 6] run : void (Object)
13:13ChouserSo it's a static (?) nested class produced with generics
13:13rhickeyis there a reason you want reflection here?
13:14Chouserno
13:14ChouserI would have hinted this eventually for performance anyway
13:14rhickeysometimes generics /inheritance or access specifiers preclude resolving an overload without a hint - you could hint msg as well?
13:15rhickeyi.e. would that have made it go away too?
13:15Chouserno, I hinted the Message arg first, without success
13:17Chouser(.run done #^Message msg) ==> java.lang.IllegalArgumentException: No matching method found: run for class com.google.protobuf.RpcUtil$1
13:17rhickeyChouser: andthe type of msg?
13:19Chouser(class msg) ==> qdc.motu.Motu$GetLogIdsResponse
13:19Chouser(supers (class msg)) ==> #{com.google.protobuf.AbstractMessage com.google.protobuf.Message java.lang.Object com.google.protobuf.GeneratedMessage}
13:22ChouserI'm happy with my workaround, but if you want code to reproduce this I imagine it'd only be a couple lines + the protobuf.jar
13:22Chouserlet me know if you want that.
13:22rhickeyChouser: sure
13:32lisppaste8Chouser pasted "generics vs. hinting" at http://paste.lisp.org/display/80440
13:37rhickeyChouser: where can I get the jar?
13:39Chouserhttp://code.google.com/p/protobuf/downloads/list We're using 2.0.3
13:39Chouserhm, you may have to build the jar. I guess I could upload the one I have built somewhwere.
13:39rhickeymaking 2.1 now
13:39rhickeyick
13:40Chouser?
13:40rhickeyc++, make, etc
13:41technomancyrhickey: I'm trying out your sdb lib; looks pretty handy.
13:41rhickeytechnomancy: yay!
13:41technomancyit'd be nice if the dependencies could be automated, but it looks like the Java SDB lib is not available in any public repositories.
13:42technomancyI wonder if that's because of its license.
13:46technomancyrhickey: is the Amazon HTTP server endpoint hard-coded into the java lib?
13:47technomancyI was thinking about testing it out against MDB, which is supposed to be a free drop-in SDB alternative that you can run locally: http://gradvs1.mgateway.com/main/index.html?path=mdb
13:47technomancyguess I can always use /etc/hosts =)
13:49rhickeytechnomancy: if you make your own client you can set things up with AmazonSimpleDBConfig: http://s3.amazonaws.com/awscode/amazon-simpledb/2007-11-07/java/library/doc/com/amazonaws/sdb/AmazonSimpleDBConfig.html
13:49rhickeysetServiceURL
13:49technomancyrhickey: cool; will check that out.
14:00technomancyit looks like the -> form is kind of similar to doto, is that a fair statement?
14:00Chouserthey're both macros the insert stuff as the first arg of each form
14:00Chouserwhat they insert is different
14:00technomancythe main difference being that doto calls always affect the first argument, while the receiver of -> methods is updated
14:01Chouserwhat they return is also different.
14:01technomancyright; -> seems to work more like reduce in a way.
14:02technomancy</thinking-out-loud>
14:02Chouser'..' is also somewhat similar
14:03dnolen-> is great, you can read left right instead of inside out.
14:06Cark-> makes me think about monads
14:06Carksomehow
14:06liebkeI use doto when I'm working with methods with side effects, like updating a mutable java object, and -> when I'm working with functions on immutable data structures that return new values
14:08dnolen,(-> {} (assoc :k1 'v1) (assoc :k2 [0 1 2 3]) (update-in [:k2 0] inc))
14:08clojurebot{:k2 [1 1 2 3], :k1 v1}
14:10Chouser(-> protobuf.Mine/newBuilder (.setFoo 1) (.setBar "bar") .build)
14:12rhickeyChouser: the declaring class is not public, but run(Message) is found, matches, and dominates run(Object), so Reflector tries to find run(Message) declared in a public base interface/class, but only run(Object) is found in com.google.protobuf.RpcCallback
14:13liebkeChouser: does that work? Unless .setFoo and .setBar return the updated version of newBuilder, it doesn't seem like that would work. This is the kind of stuff where I use doto
14:14Chouserliebke: protobufs are immutable, and the builders return new instances with the values set.
14:14liebkeah, interesting!
14:14Chouseryes, I thought so.
14:15hiredmansounds familiar
14:15Chouserrhickey: weird. It would be illegal to call run(Message) because it's not public?
14:16rhickeyChouser: reflection needs a Method of an accessible class
14:16hiredmanthere was some paper about adding some ability to java (I forget what) that proposed sort of splitting constructors, so that the object was not created till the constructor was finished, but the constructor could set fields on a sort of proto-object
14:17rhickeyrun(Message) is a public method of a non-public class
15:13replacahiredman: have you considered having clojurebot tell us who made a change in addition to the rev and comment?
15:13replacaI often find myself wondering
15:18hiredmanN
15:18hiredmaner
15:18hiredmanI will look into it
15:23biillyi'm trying to add a remote javadoc; if javax. is already set, will javax.servlet be ignored?
15:25stuartsierrabiilly: I think so, yes
15:25biillywould the work-around be to install the javax.servlet docs as local?
15:27stuartsierraMaybe, or replace "javax." with more specific sub-packages.
15:28biillywill try, thanks
15:29cgrandbilly: I think that changing line 70 of javadoc.clj to: (rseq @*remote-javadocs*)) could do the trick -- I'll fix it
15:30replacahiredman: just an idea :-)
15:32hiredmanI think it is entirely possible, the only problem is clojurebot has a recuring anonymous function, so to change it's behaviour I would need to restart clojurebot
15:34replacaoh yeah, obviously no hurry at all
15:34replacaI can't believe that clojurebot is at 5 9s uptime yet :-)
15:34markusgustavssonA bit off topic - has anyone here used scons to build C++ code on linux? I found a #scons group but it seems pretty dead :)
15:36hiredmanreplaca: nah, I just tend to alter things while it is running, and then forget, and then restarting it becomes a pain
15:44replacahiredman: ahh, i see
15:51stuhood,(source map)
15:51clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
15:52stuhoodhmm, could have sworn that was in Mark V's presentation
15:53stuartsierrait's in c.c.repl-utils
15:53stuhoodmmm
15:53stuhoodthanks
15:54stuhood,(clojure.contrib.repl-utils/source map)
15:54clojurebotjava.lang.ClassNotFoundException: clojure.contrib.repl-utils
15:55grosoursplop
15:59hiredman~def map
16:04stuhoodhiredman: i was thinking you could use (source) to dump the definitions of all of the interesting functions in clojurebot
16:04stuhoodwhich would make restarts easier
16:05stuartsierraI think (source) reads from files, though.
16:05hiredmanyeah, it would have to
16:06hiredmanthat or decompile java bytecode to clojure source
16:06hiredmanwhich, would, uh, be :(
16:07Chouserdecompile, de-macroexpand, ...
16:07hiredmanyeah
16:07hiredmanthat would be a drag
16:07Chouserde-macroexpand might be fun. run it on your own code to discover macros you meant to use.
16:08danlarkinsounds like an idea my buddies and I had in college
16:08danlarkinwrite a program in APL that would write all other possible programs, until you had one that gave you the answer you wanted with the inputs you gave
16:09danlarkinneedless to say, we didn't pursue it very far
16:11hiredmansomeone wrote a clojure function that given an input, and an output, would search the fn's held by vars in all available namespaces for one that matched
16:12danlarkinthat's kinda neat
16:14durka42as long as all your functions are referentially transparent
16:14durka42is this function called i-wonder-what-this-button-does?
16:14hiredmanI forget
16:15hiredmanit was on the google group months back
16:36lisppaste8sh10151 pasted "DFS" at http://paste.lisp.org/display/80454
16:36sh10151I need a quick sanity check: is this a reasonable depth-first-search implementation?
16:36sh10151and by reasonable I mean it doesn't end up generating a lot of garbage
16:37sh10151not sure how the lazy sequences work exactly
16:38Chousersure
16:47devinusis knowledge of java required for working closely with clojure?
16:48gnuvince_devinus: it definitely helps.
16:48Chousereventually, yes. But I don't think you need much java knowledge to get started, and probably never deep particularly deep groking of Java.
16:53danlarkinHey Chouser, while you're here, did you see my error-kit + test-is email on the ML?
16:53Chouserno, sorry.
16:54Chouserhm, there's another error-kit message just now...
16:55sh10151Would it be reasonable to implement other state space searches using tree-seq's basic interface?
16:55sh10151e.g. a bfs tree-seq
16:55sh10151iterative deepening tree-seq
16:55sh10151a* tree-seq
16:56hiredman~def tree-seq
16:56hiredmanX|
16:56hiredman,tree-seq
16:56clojurebot#<core$tree_seq__4588 clojure.core$tree_seq__4588@e40293>
16:56hiredmanhuh
16:57hiredman,#'tree-seq
16:57clojurebot#'clojure.core/tree-seq
16:57hiredman,^#'tree-seq
16:57clojurebot{:ns #<Namespace clojure.core>, :name tree-seq, :file "clojure/core.clj", :line 2953, :arglists ([branch? children root]), :doc "Returns a lazy sequence of the nodes in a tree, via a depth-first walk.\n branch? must be a fn of one arg that returns true if passed a node\n that can have children (but may not). children must be a fn of one\n arg that returns a sequence of the children. Will only be called on\n nodes for whic
16:57hiredman~def map
16:57hiredmanwhy no tree-seq love
17:01hiredman~def update-in
17:04hiredman,(.contains (rule-set #(or (> 3 x) (< 3 x))) 3)
17:04clojurebotjava.lang.Exception: Unable to resolve symbol: x in this context
17:04hiredman,(.contains (rule-set #(or (> 3 %) (< 3 %))) 3)
17:04clojurebotfalse
17:04hiredman,(.contains (rule-set #(or (> 3 %) (< 3 %))) 2)
17:04clojurebottrue
17:04hiredman,(.contains (rule-set #(or (> 3 %) (< 3 %))) 4)
17:04clojurebottrue
17:05hiredman,(.contains (union (rule-set #(or (> 3 %) (< 3 %))) #{3}) 3)
17:05clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Boolean
17:06hiredmanbah
17:08durka42(doc rule-set)
17:08clojurebot"([rule]); "
17:08durka42~def rule-set
17:08hiredmanhttp://paste.lisp.org/display/80355
17:09hiredmanthe contains impl is broken
17:09hiredmanbut the idea is to be able to define sets using rules
17:09durka42it's a good idea
17:10hiredmanbut there are issues
17:11hiredmaneh? there was talk about how arity information for functions could be implemented
17:12hiredmanso an arg list of [foo bar & baz] would be (rule-set #(> % 2))
17:12durka42ah, i see
17:13Chouserdanlarkin: I don't know test-is very well, but I don't see a problem with that patch.
17:13Chouserdanlarkin: you have contrib commit privs?
17:13hiredmanbut how to print such a thing?
17:14danlarkinChouser: I do, but my patch there is based on David Nolen's work... I don't know, does he need to be a contributor too?
17:14hiredmanand rule-sets infect othersets, turning them into rule-sets
17:14Chouserdanlarkin: he needs to have signed the CA, not necessarily have commit privs.
17:15danlarkinChouser: oh, I see what you meant. In that case I do not have commit privs, I'm only a CA
17:15Chouseroh, ok. I was hoping you could just check it in. :-)
17:16hiredman~ping
17:16clojurebotPONG!
17:16danlarkindnolen_: submit your CA :)
17:16dnolen_heh :)
17:17danlarkinChouser: I've gotta run just now, but thanks for taking a look
17:17Chouserok, np
17:17danlarkinI guess when dnolen_ gets his CA in you can commit it
17:18Chouserdnolen_: let me know when that happens.
17:18dnolen_OK, will do that this week.
17:18dnolen_will do.
17:18Chouserthanks
17:18danlarkinthanks all
17:27lisppaste8hiredman annotated #80355 "fixed .contains" at http://paste.lisp.org/display/80355#1
17:27hiredman,(.contains (union (rule-set #(or (> 3 %) (< 3 %))) #{3}) 3)
17:27clojurebottrue
18:04technomancyso the first exception layer thrown by swank-clojure is *always* useless
18:04technomancy(unless you're debugging swank-clojure)
18:04clojurebotclojure is the brand
18:05technomancyor ignore it, rather
18:19ctdeanis there an existing function like (best f coll) that picks the biggest/best item from a collection?
18:20Chousukegreatest-by in contrib IIRC
18:20ctdeangreat, thanks
20:11unlink1If you have (f (g (h (i x)))) and any of f, g, h or i might return nil in case of failure, what is the idiomatic construct for having the nil bubble up the entire call chain?
20:49Chouserunlink1: I don't know of anything built in. Pretty sure I saw a macro for that, though.
20:50duck1123_Is there any new documentation yet on the changes to the ns macro? I'm not seeing much on the ML and I'm still getting errors I never got before
20:50Chouser(and x (i x) (h (i x)) (g (h (i x))) (f (g (h (i x)))))
20:50Chouser?
20:51dnolenduck1123_: seems like it's safer to stick with the stable 1.0 release until things get ironed out.
20:52unlink1Chouser: yeah, but without the reevaluation
20:53Chouserwell, your functions are all pure and memoizing, right? ;-)
20:53unlink1You may be thinking of defmacro- nilsafe
20:53unlink1in clojure.contrib.core
20:54unlink1(which is obviously unsuited here)
20:54unlink1Perhaps some sort of monad-based solution is apt here.
21:00duck1123_Ok, I'm pretty sure I'm using 1.0 now, but I'm still getting java.lang.ExceptionInInitializerError, any ideas?
21:00dnolendid you do a fresh checkout of contrib and built it with Clojure 1.0?
21:02duck1123_I'm pulling the one from the maven repository @ http://tapestry.formos.com/maven-snapshot-repository
21:03duck1123_so it looks like it's 8 days old
21:04duck1123_I think I'm just going to stop using that one and build my jars locally
21:19sh10151Got an API design question --
21:20sh10151can anyone see any issues with coding different traversal strategies using the same API as tree-seq?
21:20sh10151e.g. BFS, and more complicated searches such as iterative deepening and A* ?
21:34duck1123_does anyone know what "Caused by: java.lang.NoSuchMethodError: clojure.lang.MultiFn.<init>(Lclojure/lang/IFn;Ljava/lang/Object;Lclojure/lang/IRef;)V" means?
21:34duck1123_I'm getting that from compojure
22:15cadsI have created a semi-modular vector space system in clojure, and was wondering about fully modularizing it
22:18cadsI'd like have a function which takes a few user supplied basis functions and creates a system of derived functions, and binds them all in a new namespace, or something like that
22:19cadsbleh, I'm almost describing on object oriented kind of discipline :/
22:20cadswhat's the idiomatic way of doing something like this in clojure?
22:26slashus2I noticed that if you use clojure-1.0.0-RC1-SNAPSHOT.jar with a clojure-contrib.jar compiled with the latest svn version of clojure you get an error when using some of the clojure.contrib methods.
22:29cadsShould I use a struct to ecapsulate a system of functions: For example (defstruct vspace :n-vec :n-vec? :to-n-vec :dim :add :neg :sub :s-prod :dot :mag :l-k-norm :l-inf-norm :dist :l-k-dist :angle :cross-prod)?
22:30cadsWhere each holds a ifn, but the function that creates these structs only requires a few of the ifns, and generates the rest
22:31slashus2Is there a good reason for the errors?
22:37arohnercads: I don't understand enough about your problem, but it does sound reasonable to use a struct or map to hold a bunch of fns
22:37arohnerthe only real difference between a struct and a map is that 1) the keys of a struct are shared, for memory usage reasons and 2) you can add new keys to a struct, but you can't remove the original keys
22:38arohnerslashus2: a few contrib methods compile against clojure.core. a few days/weeks ago some internal APIs changed, so their api broke
22:39arohnerslashus2: recompiling should fix the problem
22:40slashus2Just making sure the broken backward compatibility was okay. If that is actually what it is.
23:18Qvintvsdoes anyone see something wrong with this program: http://pastebin.com/m31bcb6d0 it's supposed to make a list of all the numbers it finds in the "test.in" file. it ends up giving me an empty list.
23:21liebkeQvintvs: it seems to work for me
23:23stuhoodyea, works for me too
23:24Qvintvswhat test.in files were you using?
23:25liebkeI just used a rand png file
23:25stuhood,(print "1\n2\n3\n4\n5\n")
23:25clojurebot1 2 3 4 5
23:25stuhooder, you get the idea
23:27Qvintvsah, wow, ok, I just wasn't looking for the output properly