#clojure logs

2009-08-29

06:49tomojis the person that built eugene around?
06:50tomojhuh, I can't find it on github now
06:51fsmIf anyone is interested, performance is up 30-35% in code running on leopard vs snow leopard
06:57tomojwow
06:57tomojwhy?
07:02fsmI don't have a leopard install to test for the reason, but i was running java 1.6 on both
07:03fsmpossible causes are better scheduling causing better cache usage, maybe the jvm has been tweaked for speed, maybe running in 64 bit affects it, ...
08:32gerryxiaohello
08:34gerryxiaohow to use java someclass.class.getResource method in clojure?
08:36gerryxiaosomeclass should be main class of my application, but clojure not recognize it
08:40gerryxiaoi have to compile it to get that class, but complier complained can't find that class
08:43Chousukesomeclass.class gets you the Class object of SomeClass, rright?
08:43Chousukeis getResource a static method of Class?
08:44gerryxiaoyes
08:44Chousukethen you want Class/getResource
08:45gerryxiaooops not static method
08:47gerryxiao(.getResource (class someclass) args)
08:48Chousukejust (.getResource SomeClass args)
08:48Chousukeif ti can't find the class, check your classpath
08:48gerryxiaonope, in java, is Someclass.class.getResouces(..)
08:49gerryxiaonot SomeClass.getResource(..)
08:51Chousukeyeah, but in Clojure SomeClass.class is just SomeClass
08:51Chousuke,(.getCanonicalName String)
08:51clojurebot"java.lang.String"
08:52gerryxiaoand this someclass is main class of my application, my main clojure file is cgogame.clj, so it should be cgogame class, but it not work
08:52gerryxiaook, i try (.getResouce Class args)
08:53Chousukeyou have the (ns ...) and :gen-class declaractions in place?
08:54Chousukedamnedlag. impossible to type :
08:54gerryxiaoChousuke, this class isnot compiled yet
08:54Chousukeit needs to be.
08:55Chousukeyou won't have a class until it's compiled.
08:55gerryxiaobut compiler complained can't init it
08:55Chousukeare you sure you need a class though?
08:55Chousukemaybe just a proxy would do
08:56gerryxiaoproxy what, my main class?
08:56Chousukewhy do you need to generate a class in the first place?
08:57gerryxiaomaybe i don't understand java correctly
08:57Chousukewell, in java you would of course make a class, but that's not always the case with clojure.
08:57gerryxiaoin java, when i make one class named test, then i can use this class name in class def, is it right?
08:58ChousukeDoes that matter? are you coding in Java or in Clojure?
08:59gerryxiaoi need call java lib, this method seems need it
08:59ChousukeI have to say I don't have a good grasp of Java myself.
08:59Chousukeyeah, you can call java libs. But do you need your own class for it?
09:00Chousukeif all the library wants is an instance of some class implementing some interface, proxy will work just fine.
09:00gerryxiaoi'm programming one go game by clojure now, want to learn clojure
09:01gerryxiaoGUI of this game need much java swing stuff
09:01Chousukeah, yeah-
09:02Chousukeproxy works kjust fine for implementing swing GUI thingies
09:02Chousukeno need for genclassing
09:02Chousuke(doc proxy)
09:02clojurebot"([class-and-interfaces args & fs]); class-and-interfaces - a vector of class names args - a (possibly empty) vector of arguments to the superclass constructor. f => (name [params*] body) or (name ([params*] body) ([params+] body) ...) Expands to code which creates a instance of a proxy class that implements the named class/interface(s) by calling the supplied fns. A single class, if provided, must be first. If not provid
09:02Chousukehmm.
09:02Chousukemaybe you should read it from the website.
09:04gerryxiaoi knew it, and have wrote > 500 lines go game code, but sometimes get confused with java
09:05gerryxiaoswing need much proxy code to work
09:06Chousukeyeah.
09:06Chousukethough macros and functions in Clojure make it much more pleasant than writing it in Java
09:07ChousukeBut I can't really help now.I don't know what you want to accomplish :/
09:08gerryxiaoclojure code is concise,if i worte it in java. i need at least two times codes
09:09zakwilsonHas anybody come up with a Clojure wrapper library to make swing hurt less?
09:12gerryxiaohow to reduce compiled class files?
09:13Chousukereduce? hmm.
09:13ChousukeI don't think you need worry about them.
09:13Chousukeclojure produces one class for each function, so you end up with a lot, but they're all fairly small.
09:29gerryxiaodoes clojure support inline functions?
09:33Chousukeyeah
09:33Chousukethough in most cases you should just let hotspot do the inlining.
09:34gerryxiaoyou meant i dont' need care it ?
09:35Chousukewell, in most cases you won't
09:35gerryxiaonice
09:36Chousukeif you're writing performance-critical code you might have to use macros or definline instead of functions, but don't bother until it's necessary.
09:36gerryxiaook
09:45gerryxiaook, i have figure out the first question, i don't need that method to make it work, there is another method which don't need Class object.
09:45gerryxiaothx
09:47gerryxiaoi need twist java instead of clojure to make game work ,that's a bit annoying.
09:57gerryxiaohere is one snapshot of my clojure go game :http://imagebin.ca/view/bCB5BU.html,though it's still under alpha
09:58gerryxiaohttp://imagebin.ca/view/bCB5BU.html
10:02tomojnice
10:02tomojwhat java library are you using?
10:08gerryxiaodoes structmap support serialization?
10:08tomojno :(
10:16ChousukeSomehow that doesn't look like a beginner opening pattern.
10:17ChousukeI think this because I probably would not play like that, and I'm just 7k :P
10:22ankouhi, how do I use multimethods with structs? The class of every struct is PersisentStructMap, so I suppose I can't use class as dispatchfunction. Is there a way to create own types or is there a better dispatchfunction or something like that?
10:23Chousukeyou can use the type function
10:23Chousuke(doc type)
10:23clojurebot"([x]); Returns the :type metadata of x, or its Class if none"
10:23Chousukeor you can just use a key in the structmaps as the dispatch
10:24ankouhow can I add a :type to the metadata of every instance of a struct?
10:25Chousukeyou'll need a factory function.
10:25Chousukehmm
10:26ChousukeI wonder if instances of structmap could inherit metadata from the struct object.
10:26Chousukewould make using :type for them rather convenient.
10:26carknot everyone likes the "type as metadata" thing
10:27Chousukeright.
10:27carki'd rather have an normal slot for this
10:27Chousukemit might make more sense to dispatch on some other key.
10:27Chousukeor even multiple keys
10:28Chousukedon't be constrained by types :)
10:28carki think it's good practice to have either metadata or additional slot for the type, but leave it to the programmer to go either way
10:29Chousukeand if you use metadata for the type, then ordinary maps can't be used :/
10:31ankoumhm yeah, it would probably make more sense to dispatch on keys.
10:44ankouwhat is the license of clojure and clojure.contrib anyway? Since I need to distribute those in order to use them I suppose I should ask for the restrictions first. I saw that at least parts of the clojure.contrib library are published under the terms of CPL, can I use them from a GPL program? or a proprietary program?
10:45Chousukeboth are EPL
10:45carkankou : my understanding is that yes you can
10:46gerryxiaotomoj: mainly swing
10:46Chousukeif there is anything in contrib that claims to be CPL, that's a bug
10:46gerryxiaoi'm 4d in cgoban
10:46gerryxiaosometimes 5d
10:46ankouyes I meant EPL, german wikipedia redirects from EPL to CPL, what's the difference between these licenses?
10:46ChousukeEPL is the newer licence.
10:47ChousukeCPL should redirect to EPL :/
10:48Chousukebut my understanding is that you can write GPL clojure programs just fine.
10:48ankouBut still GPL incompatible, right? I find this GPL compatibilitystuff hard to understand. Is it possible to distribute a gpl program which uses a library, that is not gpl-compatible?
10:49Chousukeif the GPL required the libraries your program uses to be GPL, then GPL programs on windows would be impossible :/
10:50ankouat least the other way around holds true
10:50Chousukeyeah, if you link to GPL libraries then your program is a derivative work.
10:51Chousukebut Clojure is not a derivative work of your GPL code
10:53ankouI suppose that makes sense.
10:56Chousukehmm
10:57Chousuke"Based upon the position of the Free Software Foundation, you may not combine EPL and GPL code in any scenario where linking exists between code made available under those licenses."
10:57Chousukethat's rather weird
10:58Chousukecomplicated by the java notion of linking which happens at runtime :P
11:03carkankou : do you absolutely need gpl ?
11:04carkmybe epl might suit you just as well ?
11:04cark*maybe
11:04ankouwell I think it would be a major problem in general if it is impossible to write GPL code with Clojure?
11:16ankouChousuke: you can write GPL code on windows because GPL seems to have a system library exception.
11:17Chousukehm
11:17Chousukewonder if that'd apply to clojure
11:18Chousukewoop
11:18ankouat least not in terms of GPLv2, which explicitly excludes everything that is distributed with the GPL application
11:18Chousukeso hm
11:19Chousukecould you get around by simply not distributing clojure.jar?
11:19ankouThere is also another thing "If you want your program to link against a library not covered by the system library exception, you need to provide permission to do that. " however I don't really understand what they mean. http://www.fsf.org/licensing/licenses/gpl-faq.html#GPLIncompatibleLibs
11:22ankouIt seams that it is possible to change the GPL to have special exceptions but I suppose that wouldn't the usage of any GPL libraries, since I can't put the exception in their license.
11:24rhickeyankou: the GPL is not compatible with the EPL, that's the fault of the GPL
11:27ankourhickey: I don't think it is important whose fault this is. It is a fact that there is lots of GPL software and GPL librarys out there and that GPL is standard on linux systems and not beeing able to use them really is a major problem.
11:28rhickeyankou: I can't fix gpl
11:30ChousukeIs there a reason clojure is gpl-incompatible though? I know EPL is friendlier for commercial users, but that doesn't rule out dual-licencing for example.
11:32ChousukeAnd Clojure being a programming language I think excluding any licence is counterproductive.
11:32rhickeyChousuke: dual licensing means people can create derivative works that are GPL, i.e. that I and others can't use as freely as what they originated from. That's not my idea of a reciprocal license.
11:34Chousukethis just prevent people from using any GPL java libraries with Clojure. I don't know if that really will be a problem, but it'd be better if the problem didn't exist in the first place.
11:34Chousukeprevents*
11:34carka co-routine implementation would require a code-walking macro wouldn't it ?
11:34rhickeythe problem is with the GPL libraries, complaints should go to them
11:35rhickeyit is GPL that's preventing
11:35rhickeyEPL has not restrictions on the things with which it can be combined
11:36Chousukehmm. I suppose.
11:36ankourhickey: The incompatibility already existed when you chose the license, so it was your decision to make clojure GPL-incompatible and not the decision of the FSF
11:36rhickeyankou: that's silly
11:36carkthe fsf is annoying with its non-free free software
11:36rhickeyGPL is incompatible with the world, not the world with GPL
11:37carkthough they served a purpose, they are such zealots ... *roll-eyes*
11:37rhickeyIf you choose to use GPL software that's what happens to you, buyer beware
11:38rhickeyI chose a license that provides no restrictions on what it can be combined with, others chose licenses with restrictions on what they can be combined with. If you can't combine things, it's not my fault
11:39rhickeyuse libraries with better licenses
11:39ankourhickey: that's childish.
11:39rhickeyankou: yes, any child could figure it out
11:40rhickeyas adults, we make choices and have to live with them, choosing GPL means a lot of restrictions
11:41rhickeyin any case, Clojure is not going to become GPL or LGPL
11:41rhickeyI can't use that in my work, period
11:43ankourhickey: there are lots of other gpl-compatible licenses
11:45rhickeyankou: the GPL is not compatible with any other reciprocal license, AFAIK
11:45rhickeywhy should the GPL be the only reciprocal license in the world?
11:47rhickeyIf you really want to use a GPL library with Clojure, ask them to change it to LGPL, which drops the combining poison
11:47RaynesIf it's a library, it should probably be LGPL in the first place.
11:47rhickeyright,
11:48angermanhmm.. GPL+exception(you must license all your deriv work under EPL)
11:48angermanI wonder if that's legal :]
11:54tomojI hate this licensing crap :(
12:01rhickeythere would be no licensing issues if GPL didn't want to impose things on combined work. Every other license can be combined with every other, only impacting truly derived (not merely combined) work
12:05carkwasn't the original question about using clojure from a gpl program anyways ? i don't see how this would be restricted
12:07ankou<Chousuke> "Based upon the position of the Free Software Foundation, you may not combine EPL and GPL code in any scenario where linking exists between code made available under those licenses."
12:07ankouwhich is a quote from the EPL FAQ
12:09carkoh i see
12:20jkantz_are there any efforts under way to port CLOS to clojure or to make something CLOS-like for clojure?
12:23tomojjkantz_: what's wrong with clojure's multimethods?
12:27pluijzerI think there brilliant
12:28rhickeyjkantz: yes, I forget where it lives though
12:28jkantz_ok, nothing wrong with multimethods, just curious
12:29jkantz_wanted to look at it
12:29jkantz_s/it/code/
12:29tomojwhat would be the point of a CLOS-like thing for clojure?
12:29pluijzeris there an other language that uses Clojure style multimethods?
12:29tomojI mean, would it just attach metadata and generate appropriate dispatch functions for you implicitly?
12:31rhickeyhttp://code.google.com/p/explorersguild/wiki/XGModelAndGF
12:33jkantz_thanks
12:36arbschtpluijzer: fwiw, I've implemented simple prototypes of clojure-like multimethods in javascript and python
12:42rhickeyfn-tuple needs a better name: http://groups.google.com/group/clojure-dev/browse_frm/thread/155c8b9893d673bc
12:43rhickeyI've got a version that produces vectors
12:43pluijzerarbscht: any source of info about the python one?
12:46maaclHas anyone used the CouchDB clojure view server that comes with Clutch (http://github.com/tashafa/clutch) ?
12:46rhickeyHaskell has binary &&&, called fanout or both, not really good names here
12:48rhickey((comp a b c) x) => (a (b (c x)), ((??? a b c) x) => [(a x) (b x) (c x)]
12:49rhickeyjuxt?
12:49rhickeyfor juxtapose
12:49rhickeycompose/juxtapose
12:49rhickeycomp/juxt
13:04Chousukerhickey: that's a lot like Sean Devlin's fn-tuple idea.
13:05rhickeyit is exactly that idea
13:05rhickeyI pointed to the discussion
13:06rhickeyI just worked it up for inclusion, now just need a name
13:06Chousukeah, right. it had scrolled of my screen :)
13:07Chousukejuxt is a bit weird though. hm.
13:08ChousukeI guess combine is a bit too generic.
13:11rhickeyconjf ?
13:11rhickeyconjfn
13:12rhickeyadjoin
13:12rhickeyallfn
13:13rhickeyabut
13:15alrex021do Agents in Clojure provide any guaranty that the action in the transaction 'will' happen?
13:15rhickeynothing other than appose is as correct as juxt[apose]
13:16rhickeyappose?
13:17rhickeyalrex021: the actions are not themselves transactional, just held until the transaction completes
13:23ankouare there any finished projects written in Clojure?
13:25danlarkinankou: no program is ever finished :)
13:25arbschtankou: there are many live projects in production using clojure, if that's any consolation :)
13:26ankoulets say non-beta-release
13:26rhickeyhttp://www.flightcaster.com/
13:29alrex021are there any good examples of projects that make good use of Clojure's transactional API? (preferably OSS)
13:31alrex021flightcaster doesn't seem to utilize the Clojure's transactional API as they deligate the concurrency concerns to hadoop, cascade...
13:34alrex021so I heard on a recent podcast :)
13:34arbschtcompojure the web framework uses it to manage in-memory session state
13:37alrex021gr8, I'll have a look at compojure. I'm watching Rich's concurrency screencast and talks about the Ant concurrency example...is it available somewhere for download?
13:41ole3hello, is there a precompiled version of clojure?
13:42alrex021ok, I found the ant app on the clojure google-group files
13:44rhickeyjuxt/conjf/adjoin/abut/allfn/appose - anyone?
13:45arbschtalrex021: that might be out of date. see here instead http://github.com/weavejester/compojure/
13:49ole3ah, ok found the jar, sorry for the spam
13:53arbschtrhickey: 'gib'?
13:54rhickeyarbscht: meaning what?
13:56arbschtI see (gib a b c) as collecting a b and c in a 'gib' (notched structure), so when invoked with x, x is exposed to all the edges of the structure
13:57arbscht[(a x) (b x) (c x)] would be the "cut of the gib" of x, I guess
13:59rhickeyarbscht: I didn't get that at all from gib
13:59rhickeyanyways, it's up as juxt for now, final name TBD
14:00arbschttoo obscure then :)
14:23gkoWhat's the equivalent of CL return in Clojure?
14:30Chousukewhat does return do?
14:33ole3'return' returns from a block
14:33Chousukeah. then there's no way to do that in clojure that I know of.
14:34Chousukeusing return would mean you have side-effects somewhere.
14:34Chousukenot very clojurey I suppose :P
14:34ole3yes
14:35ole3:)
14:37Chousukefunny, though. Before I learned clojure I don't think I would have asked what a function called "return" does :P
14:38ole3return is not a function :)
14:39ole3return is a macro, witch it expands to return-from witch is a special form
14:39ole3nevermind
14:40Chousukeokay. operator, then :P
14:40ole3Are there many former cl'ers here?
14:44arbschtthere are some. I still use CL
14:52kylesmithI've used cl
15:04luisole3: former... pff. :)
15:40maaclHow does one write a function that takes a literal value (string) and returns a function that operates on this literal value?
15:41hiredmaneh?
15:46maaclIf I pass "hello" to the function the returned function must contain the literal value of "hello" not a var.
15:47angermanhow would I determine the substrposition of a re-match?
15:49hiredmanmaacl: contain?
15:49hiredmanclosed over locals are not vars
15:50rhickey,((fn [x] x) "hello")
15:50clojurebot"hello"
15:51hiredmanrhickey: he seems to be big on the word literal, os I assume he somehow wants the returned function contain "hello", which doesn't make sense, but that is what he sounds like he wants
15:51maaclah
15:54maaclI am using Clutch which is a library for using CouchDB. It contains a view server for CouchDB which takes a view function. This function cannot contain a external reference. Sorry if I mess up the terms
15:56cupertinochadWhat is the customary way to calculate an average time for an expression to be evaluated over a number of runs? Is there a standard function for this or a commonly used idiom? (time expr) gives me the time for one run, but those results are misleading.
16:02maaclhiredman: I am sorry if the question doesn't make any sense
16:15rhickeymaacl: do you have a link to the api you are trying to satisfy, or any code?
16:16maaclrhickey: sure http://github.com/tashafa/clutch/tree/master
16:16rhickeyclojure string literals get interned in compiled code just like Java's
16:17hiredmanare you sure clutch takes a function?
16:18hiredmanseems like it would take a datastructure that looks like the datastructure defining a function
16:18hiredmanand transform it to javascript somehow
16:19maaclhiredman: yes I believe so, if you see the link above - it is not transformed to javascript - clojure is use as the view-server
16:20maaclI am messing around with load-string to see if I can make it do what I want to
16:21hiredman:(
16:21rhickeymaacl: what did you try that didn't work, and how?
16:23hiredmanyeah, with-clj-view-server doesn't take functions
16:24hiredmanit takes a list '(fn [x] x)
16:25hiredmanwhich it serializes as a string
16:26maaclI tried this http://paste.lisp.org/+1UJJ
16:27hiredmandefinitely not going to work
16:27maaclI sort of figured that out
16:28hiredman:P
16:29hiredmanbacause what apears to be a function pased to with-clj-view-server is turned back into a string, then actually evaluated somewhere outside of that lexical scope
16:29hiredmanyou might need to write your own macro
16:29maaclhiredman: indeed, that is why I was looking for a way to get a literal value in there
16:30hiredman,(let [x 1] `(1 2 3 ~x))
16:30clojurebot(1 2 3 1)
16:32pluijzerI'm very new to clojure so pardon the simple question but do I need the java library to spawn threads?
16:32hiredmanthe java library?
16:33pluijzeryes?
16:33hiredmanwhat do you mean by "the java library"
16:34pluijzerdo I need methods from Java?
16:34hiredmannope
16:34maaclhiredman: ah
16:34hiredmansimplest is to just use future
16:35hiredmanmaacl: I think you are going to have to construct your own version of the with-clj-view-server macro
16:35hiredman,(doc future)
16:35clojurebot"([& body]); Takes a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block."
16:36pluijzerhiredman: thank you!
16:36hiredmanthere are also agents
16:37hiredmanyou can also do something like (.start (Thread. #(prn :foo)))
16:38pluijzerthank you I'll try that]
16:45Chouserrhickey: new's "this" apprears to be unhinted
16:47rhickeyChouser: completely - no-reflective self calls are todo, also more than a hint is required, all the code is compiled before this's class exists and thus there is no reflective type info for the compiler
16:47rhickeynon-reflective
16:48rhickeyso all use of this will require special handling in the compiler
16:48hiredman*head explodes*
16:49Chouserah. hm. I was able to work around it by hinting the interface that provids the interface I'm calling
16:50rhickeythat will work for everything other than self-calls to methods added in reify
16:50ChouserIt's not called 'reify' on github yet -- dunno if it's not ready or just an oversight.
16:50rhickeybut in the end shouldn't be necessary
16:51rhickeysuggestions for something-other-than-new still welcome, there's no code yet using reify
16:52rhickeyalso, you missed juxt discussion before
16:52Chousersaw it mentioned on the group
16:53rhickey:)
16:58Chouseryou're set against re-using "new"? Right now, that's *the* primitive for creating new instance of Java objects.
16:59rhickeyChouser: other than fn
16:59Chouserhm, and 'fn' I suppose
16:59Chouserbut if fn is defined in terms of newnew, we get that back
16:59Chouserhm, and every object literal.
17:00rhickeynew is the way you create an object given its class name, reify both creates code and makes an instance
17:01rhickeyplus reify has all the closing over stuff
17:01ChouserI also like how it read. Here I'm making a new Indexed Sequable IPersistentVector.
17:01Chouserhow it reads.
17:02ChouserI guess it emphasises the instance creation perhaps at the expense of the closing-over, class-defining behavior.
17:06rhickeyall discussions of new would have to be bifurcated right away on that
17:06Chouserand docs. Ok, I can see your point.
17:07Chouserimplementing Indexed is insufficient for destructuring.
17:08rhickeydue to?
17:08ChouserI have to implement IPersistentVector in order to get a nth method with a not-found arg.
17:10rhickeyoh, that should be fixed to be the same, using Indexed first, as in RT.nth(Object coll, int n)
17:11rhickeyI thought I did that
17:11rhickeyah, is that way in master
17:11Chouseroh!
17:15Chousergit cherry-pick 7ba336f5
17:15rhickeyChouser: do I need to do that?
17:16Chouseror I can push it, thought that might complicate merges later.
17:16Chouserthough
17:16ChouserI'm ok running a weird version of clojure for my finger tree stuff for now.
17:18rhickeyok
17:34cemerickwow, I'm glad I missed the licensing debate last november
17:40cemerickrhickey: you must do a great deal of mediation. I have zero patience for such discussions.
17:40cemerick...especially when I get some fool coming around saying we should open source product. :x
17:43ole3,(doc reify)
17:43clojurebotExcuse me?
18:26technomancy~(find-doc "absolute value")
18:26clojurebotPardon?
18:26technomancy,(find-doc "absolute value")
18:26clojurebotnil
18:27technomancywhat do you call that in Java-land?
18:31kylesmith,(Math/abs -1)
18:31clojurebot1
18:34technomancythakns
19:29krumholt_how can i use one of my .clj files in another .clj file?
19:33arbschtkrumholt_: if the directory containing foo.clj is in your classpath, you can (:require foo) in another namespace
19:33krumholt_arbscht, ok i allready have it thanks i was looking for (refer ..)
19:59ambientanyone know how I can autocomplete java libraries and methods in emacs with clojure-mode, slime, etc? and perhaps view some documentation
20:29kylesmithIs anyone attending this conference? http://www.lanl.gov/conferences/lacss/2009/agenda/workshops.shtml
21:00Chouseranyone know if any videos from ilc2009 are available yet?
21:01rhickeyChouser: not as far as I know
21:08ChouserI should have started with reify. more fun than a pile of functions on vectors.
21:14Chouseralso seems plausible that one could use some macros to produce collections of primitives without a whole lot more code.