#clojure logs

2009-02-10

00:46whirlycottwondering if someone can give me a nudge with a question
00:46whirlycotti have a map
00:46whirlycottstrings are keys
00:46whirlycotti want the vals to be functions
00:47whirlycotti'm having trouble deciphering the syntax for getting a value from the map and then calling that function....
00:48offby1pity I don't know enough clojure to answer.
00:53ayrnieuwhirly, you didn't ask a question.
00:53whirlycottthe question is: what's the syntax? :)
00:53whirlycotti can get stuff from a map
00:53whirlycott(duh)
00:53whirlycottit's getting the function out and calling it that is stumping me
00:53ayrnieu,(({"a" (fn [] 1), "b" (fn [x] (+ 2 x))} "b") 4)
00:53clojurebot6
00:54whirlycottok, that's using an anonymous function
00:54ayrnieuyou get it out the same way you get anything out of a map. You bind it to a name the same way you do anything-- one way: (if-let [f (some-map ...)] (f arg1 arg2) "no function!")
00:54whirlycottwhat if the function has been defined with defn in the current ns or another ns?
00:55ayrnieuthen you just name it in the map.
00:55whirlycott(defn hello [username] (println ("Hello, " username)))
00:55whirlycott(def *routes* { "key", hello } )
00:55ayrnieu,(({"a" +, "b" println} "b") "hello")
00:55clojurebothello
00:55whirlycotthow do i call the function pointed to by "key"?
00:56ayrnieuyou put it at the head of a list, the way you call any function.
00:57whirlycott((*routes* "key") "phil")
00:57whirlycottjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0)
00:57ayrnieu,(let [ops {"+" +, "-" -, "*" *, "/" /} this-op (ops "*")] (this-op 2 4))
00:57clojurebot8
00:57ayrnieu,("not a function" 2)
00:57clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
00:58whirlycottwhy am i seeing a comma before your opening paren?
00:58ayrnieuyou said you mapped strings to functions. You've pulled a string out of the map, there.
00:58ayrnieuclojurebot responds to initial comams.
00:58whirlycottk
01:04whirlycottso could you put my hello fn as a key in the map? that's my problem, as you have helped me understand it
01:05whirlycott(a val, not a key, i mean)
01:05ayrnieu,(let [ops {"+" +, "-" -, "*" *, "/" /} this-op (ops "*")] (this-op 2 4))
01:05clojurebot8
01:05whirlycottk, gotta stare at that for a sec :) many thanks for your help ayrnieu
01:05ayrnieuthat binds ops to a map of strings to functions, and then this-op to a function taken out of ops by its string key, and then applies this-op to two arguments.
06:05antirealist /quit
07:13AWizzArdIn my (ns XYZ ...) I have a (:require [clojure.contrib.sql :as sql]). When I (compile 'XYZ) I get this error: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.contrib.def$defvar__1337 (sql.clj:18)
07:14AWizzArdin sql.clj I find at line 18 the NS setup, and in line 19 it says: (:use [clojure.contrib.def :only (defalias)])
07:14AWizzArdIs that a problem for compilation?
07:16AWizzArdI commented out that require and now I get a complaint for the next I have: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.contrib.seq_utils$flatten__1375
07:18AWizzArdseems that all my requires produce an error during compilation
07:19AWizzArdany ideas?
07:19AWizzArdDo I first need to compile clojure.contrib to .class files?
07:31HolcxjoYou don't have the clojure-contrib .jar file in your classpath?
07:32AWizzArdit is in my classpath
07:33AWizzArdAnd when I (load-file "/.../XYZ.clj") then everything works fine.
07:34HolcxjoOh, I see that clojure-contrib.jar contains only .clj files...
07:34HolcxjoSo, I am officially out of my depth here...
07:36AWizzArdRight, only CLJs in there. So, I don't know if that is enough. I thought they can maybe get compiled on-the-fly.
07:37HolcxjoSeems, one has to provide the clojure.jar for the ant build for ant to compile the files as well...
07:39HolcxjoSo, how does one set a property with ant?
07:39Holcxjoant -Dclojure.jar=../../clojure.svn/clojure.jar
07:40HolcxjoNow it compiles the files as well...
07:40rsynnottHey, I'm currently calling a clojure function from a Java app by using RT.getVar and using 'invoke' on the result
07:40rsynnottis this reasonable, or is there a better approach?
07:41Holcxjo... and the .jar file contains the .class files -- I guess that is what you want
07:41rhickeyrsynnott: RT.var + invoke is fine
07:42AWizzArdwell, now it seems even more strange.. when I have a .clj file with only the (ns ... (:gen-class)) and no functions in there, but only a few (def)s, then it compiles.
07:43AWizzArdBut as soon I put just one (defn foo []) inside, it complains: java.lang.ClassNotFoundException: my.namespace.XYZ$foo__1400
07:46rsynnottrhickey: thanks
07:47rsynnottisn't there some way to fake a java class, as well?
07:47HolcxjoAWizzArd: Problems with compile-path and classpath not being consisteny?
07:49AWizzArdHolcxjo: I do (binding [*compile-path* "something/in/my/classpath"] (compile 'my.namespace.XYZ))
07:57AWizzArdrhickey: when the minimal example of compilation from http://clojure.org/compilation doesn't work as long the (defn ..) is in the file and produces a java.lang.ClassNotFoundException: clojure.examples.hello$_main__1258 what source of problem could there be?
07:58AWizzArdbut as soon the defn is (comment)ed out it compiles
07:58jdzyour classes directory is not in classpath
07:59jdzmake sure the directory exists before you start java
08:00AWizzArdI see. But why can it then produce .class files as long there is no defn?
08:00AWizzArdAnd is there a way to let Clojure throw a different exception?
08:11rsynnottoh, by the way, is java 1.5 okay, or would 1.6 be better?
08:16AWizzArdAbout commercial development with Clojure: in its current version (compile ...) produces a .class file with the name of each function. Are there obfuscation tools that can safely (and automatically) rename those .class files, and change all references to them in a whole project?
08:25Chouserrsynnott: 1.5 is ok and officially supported, afaik.
08:28ChouserAWizzArd: it can *produce* class files either way, but functions have to be loaded again in order to be used in subsequent expressions. It's then that the incorrect classpath becomes a problem.
08:29Chouserrsynnott: what did you mean by fake a java class?
08:35rsynnottChouser: looks like :gen-class is what I'm looking for, actually
08:40rsynnottthough it seems that java classes have to be available when a java file using them is compiled; is that correct?
08:41rsynnott(I haven't used java for about 5 years...)
09:18notyouravgjoeli'd like to create a sequence with n 1's in it. Is there any good way to do this?
09:19notyouravgjoelnvm, just thought of how easy it was
09:21gnuvincenotyouravgjoel: replicate
09:22notyouravgjoelthankss
09:23AWizzArdDoes anyone of you know an obfuscator that actually works for .class files generated by Clojure?
09:43Chouserl.;'hf.g'f/b'
09:45Chouserhm, sorry about that.
09:50cemerickI have a class with two constructors -- one that takes all Objects, another of the same arity that takes specific types. In pre-AOT clojure, I was able to create instances of this class without a problem; with current clojure, I'm now getting a "More than one matching method found" exception when loading code that references those constructors.
09:51cemerickTwo interesting things there: (a) it looks like clojure has gotten pickier (or more strict) about args going into methods that have ambiguous overloads (i.e. I suppose pre-AOT clojure may have just been falling back on the all-Object overload)
09:52cemerick(b) in the code that's failing to compile right now, all of the arguments are either literals (booleans, in fact) or proxied instances, so the args should align perfectly with the non-Object constructor.
09:52cemerickany thoughts on the above?
09:53cemerickAWizzArd: proguard doesn't work?
09:56AWizzArdcemerick: I hoped someone has already made positive experiences with an obfuscator (+clojure) and can suggest one
09:57cemerickAWizzArd: well, proguard is the best open-source one out there. We've used it for years with pure java stuff (and the classfiles it generates even distill nicely into .NET assemblies via ikvm)
09:58cemerickI've not tested it with clojure classfiles yet
10:02AWizzArdmsg cemerick Hallo :)
10:02AWizzArdsorry, forgot the /
10:42cemerickrhickey: not sure if you were here when I talked about it earlier, but I'm pretty sure I've hit a bug related to resolution of overloaded same-arity methods
10:43cemerickor, I suppose it could be an issue with how gen-class is emitting type information for constructors/methods, although that seems less likely...
10:44rhickeycemerick: missed it
10:46cemerickrhickey: so, I've got a gen-classed lib with two constructors -- one that accepts 4 Objects, another that accepts 4 other arguments (three booleans and a defined interface type, specifically). I have other code that attempts to create an instance of the generated class with three literal booleans and a proxyied instance of the interface type; clojure is emitting a "More than one matching method found" exception on loading that code.
10:47cemerickcemerick: FWIW, this is code that was running and working well using pre-AOT clojure.
10:48cemerickalso FWIW, I double-checked that clojure can properly resolve references to overloaded constructor impls written and compiled from Java -- that works as expected still
10:49cemericksame-arity overloads, that is
10:52Chouseroh, so it's only clojure code calling clojure-generated constructors?
10:53Chouser...that causes a problem?
10:54cemerickChouser: I'm not sure I can say 100% that it's only a problem when calling clojure-generated constructors, but yeah, that's the current idea.
10:54kefkaIn Clojure, how does one write a transaction so as to ensure that if any read variable changes, the transaction restarts?
10:54kefka,(def *x* (ref 0))
10:54clojurebotDENIED
10:55kefkaOk, so the example I was going to show can't be done.
10:55kefka(i.e. if any read variable is changed from outside)
10:56rhickeycemerick: these ctors are explicitly specified or gotten from superclass?
10:57cemerickrhickey: explicitly specified via a separate gen-class form -- no subclassing going on, only implementing
10:57rhickeycan you paste your :constructors clause?
11:00kefkaThe issue is that I want a transaction to restart any time something it reads changes
11:01rhickeykefka: ,(doc ensure)
11:01rhickey,(doc ensure)
11:01clojurebot"([ref]); Must be called in a transaction. Protects the ref from modification by other transactions. Returns the in-transaction-value of ref. Allows for more concurrency than (ref-set ref @ref)"
11:01cemerickrhickey: yeah -- scratch my last comment, it's subclassing PSM (as usual for me, I guess :-) )
11:01lisppaste8cemerick pasted "rhickey: constructors clause" at http://paste.lisp.org/display/75198
11:02kefkarhickey: Thanks. Cool.
11:03kefkarhickey: So ensure seems somewhat like a lock. Is there any danger of deadlock?
11:04cemerickrhickey: ah -- interestingly, the all-object constructor doesn't show up in Netbeans when I import the lib's class in Java. Don't know if that's at all helpful.
11:04rhickeykefka: no deadlocks w/STM
11:05rhickeycemerick: you have those semicolons in there?
11:06cemerickrhickey: no, that's just how they printed out from my macroexpand
11:06cemerick"they" being the reference to the Object[] class
11:07rhickeycemerick: and the failing call looks like what?
11:08kefkarhickey: Cool. I figured that was the case.
11:08cemerick(CharAttrsStruct. (proxy [Font] [] ...) false false false) (where CharAttrsStruct is the class with the 4-arg constructors)
11:08rhickeycemerick: several dupes in the ctors list
11:09cemerickrhickey: dupes, in that the all-object ctor shadows the others?
11:10rhickeytriple of [clojure.lang.IPersistentMap clojure.lang.PersistentStructMap$Def [Ljava.lang.Object; clojure.lang.IPersistentMap]
11:11cemerickrhickey: well, that's the signature of the superclass' constructor...
11:12rhickeywhy 3 times?
11:12cemerickonce for each of the subclass' constructors?
11:14rhickeyisn't this :constructors clause user written?
11:15cemerickrhickey: no, it's emitted by a macro into a separate gen-class form
11:15rhickeywell, it's the same question, why 3 times?
11:16rhickeyDid you try: (CharAttrsStruct. (proxy [Font] [] ...) (boolean false) (boolean false) (boolean false))?
11:19cemerickrhickey: no, adding explicit boolean calls doesn't change the result
11:22rhickeycemerick: (map #(vec (.getParameterTypes %)) (.getConstructors CharAttrsStruct))
11:22cemerickrhickey: there are three references to the PSM's constructor sig because there are three constructors in the subclass -- :constructors is a map, after all
11:24rhickeycemerick: sorry, right
11:24lisppaste8cemerick annotated #75198 with "rhickey: result of (map #(vec (.getParameterTypes %)) (.getConstructors CharAttrsStruct))" at http://paste.lisp.org/display/75198#1
11:25cemerickso, that verifies what Netbeans was reporting via its code-completion -- no all-Object constructor
11:25rhickeycemerick: and if you hint Font as well as the booleans?
11:25cemericksorry, scratch that :-/
11:26cemerickrhickey: no dice, same error with all four args explicitly hinted
11:26cemerickthough, they're three literals and a proxy --- shouldn't clojure have those types available anyway?
11:35rhickeycemerick: yes, the problem is neither 4-arg ctor subsumes the other and the call still matches both
11:36cemerickrhickey: OK -- but shouldn't the most-specific match be chosen?
11:37lisppaste8cemerick annotated #75198 with "rhickey: what's the difference between the current situation and this?:" at http://paste.lisp.org/display/75198#2
11:37cemerickClojure does well in choosing the right constructor in that pasted java code, which is analogous to the current situation (I think)...
11:39cemericke.g. (Foo. 5 "") chooses the "typed" ctor
11:39rhickeycemerick: it's not, due to primitives, Integer is derived from Object, as is String, so Integer+String subsumes
11:39cemerickhrm. Isn't everything derived from Object?
11:39rhickeycemerick: no
11:40Chousukecemerick: primitives aren't objects at all :/
11:40cemerickRight, well, their boxed versions are. But, I'm wading out past my depth.
11:40rhickeycemerick: your best hope is an exact-match-wins, which may require hints
11:41cemerickrhickey: I guess I'm wondering why this worked pre-AOT?
11:45rhickeycemerick: primitives used to trump Object, but that was tightened up for numerics inlining, a long time ago iirc
11:47cemerickrhickey: yeah, we were off HEAD for a long time, relatively speaking. What's the general solution then, if hinting to the 9's doesn't work (as I tried 10 min ago)?
12:08rhickeycemerick: try svn 1264
12:09clojurebotsvn rev 1264; added exact-match-wins in getMatchingParams
12:10cooldude127how can i find out from inside clojure what rev i'm running on?
12:10cooldude127is there a way?
12:12cemerickrhickey: same exception, I'm afraid. Everything's still hinted.
12:15danlarkincooldude127: nope
12:15cooldude127fine, fine, i'll go to the stupid terminal and run git log ;)
12:16Chousukesome version information could probably be added after a real release is made :/
12:16cooldude127clojurebot: latest?
12:16clojurebotlatest is 1264
12:17cooldude127woohoo! git is only one rev behind!
12:17Chousukelike, have a global variable be 1.0 for 1.0, and 1.0+SVN or something for SVN releases after that, but prior any other version
12:18cooldude127it's not a huge issue right now, it's just kinda would be nice to be able to know from the repl just how far behind i am
12:20Chousukewith SVN it's a bit problematic that the revision number increases with any commit; even if in some other branch than trunk.
12:20Chousukeso you could have 1264 and 1265 be identical as far as trunk is concerned :/
12:20cooldude127boo svn
12:21Chousukeand even worse, 1266 could actually be "behind" 1265 if the branch has more advanced stuff and something just gets backported.
12:22Chousukeergo, revision numbers make no sense. :)
12:22cooldude127yeah
12:25rhickeycemerick: try 1265
12:25cooldude127woah now 1264 isn't the latest!?
12:25cooldude127this crazy rapid development ;)
12:25Chousukeclojurebot is a bit lagged I guess
12:25cooldude127clojurebot: latest?
12:25clojurebotlatest is 1264
12:25Chousukeit just polls the server.
12:25cooldude127yeah looks like it
12:25Chousukeevery... 5 minutes?
12:26Chousukesomething like that anyway
12:26cooldude127yeah
12:27cemerickrhickey: same-same w/1265
12:28cemerickrhickey: would it be helpful if I produced a simple testcase for you?
12:29cemerickI can imagine that this feels like pushing on rope.
12:29clojurebotsvn rev 1265; added inlining on remaining coercions
12:32rhickeycemerick: what is your fully-hinted call?
12:32cemerickrhickey: ah, wait, wait, 1265 does work (a clean ant build was needed, it turns out)
12:32rhickeyvoila
12:33cemerick:-)
12:33cemerickrhickey: so, now my question is, why doesn't false/true automatically get hinted "properly"?
12:34cemericknote that I don't have to hint the proxy instance, FWIW
12:34kylesmithI just fixed a bug where I was accidentally trying to deref nil. That obviously gave me a null pointer exception, but could there be a more specific error message?
12:34rhickeycemerick: false/true are Booleans, not booleans
12:35cemerickoh, that's an interesting detail
12:35durka42kylesmith: that's basically the definition of a null pointer exception. how much more specific could it be?
12:36rhickeymy 2 cents - any method that takes Object and a primitive and doesn't do the same thing when passed the boxed version of the primitive as an Object is broken
12:37rhickeyi.e. your Object/Object/Object/Object ctor
12:37danlarkinkylesmith: just be glad you didn't SEGFAULT!
12:37kylesmithdurka42: the idea is that a npe can happen anywhere in javaland, but it would make debugging a lot easier if you knew the npe was from deref'ing nil
12:37kylesmithdanlarkin: true..
12:38Chousukekylesmith: you'd have to make deref check for null :/
12:38durka42kylesmith: true. but (deref nil) is just a java method call. you can also do (.printStackTrace *e) and see deref at the top of "caused by"
12:38cemerickrhickey: well, note that the impl. of those two ctors (the all-object and the specifically-typed one) are both implemented the same -- the latter is provided only to offer code completion to java tooling
12:39cemerickso the only issue is convincing Clojure that it should simply latch onto the Object ctor, and allow the primitives to be boxed (maybe?)
12:39durka42i wonder if names like clojure.core$deref__3595.invoke can be munged back into clojure function names
12:39durka42even if it was only semi-deterministic
12:39alinpopahi to all from here
12:39durka42because then a stacktrace parser could make clojure traces much more readable
12:40alinpopaI just need some small help here, please
12:40kylesmithactually, (.printStackTrace *e) says nothing about deref for me...
12:40Chousukedurka42: well, that's "deref" I suppose /:
12:40Chousukedurka42: the problem is anonymous functions.
12:40durka42yeah
12:40durka42and macros which expand to them
12:40durka42kylesmith: (.printStackTrace (.getCause *e)) ?
12:41Chousukeisn't there already a stacktrace pretty printer in contrib though.
12:41alinpopaIs there a clojure way to create threads beside of natural Java way ? (new Thread)....
12:41alinpopamaybe something like actors model ?
12:41kylesmithi suppose I could make a function "my-deref" that just checks for nil and calls deref
12:41Chousukealinpopa: you can use futures if you have a very recent SVN checkout
12:41Chousukealinpopa: or agents
12:41durka42Chousuke: yes, although it doesn't do any name munging
12:42kylesmithdurka42: yep, just says "java.lang.NullPointerException". is my clojure messed up?
12:42durka42kylesmith: you could try clojure.contrib.stacktrace/print-cause-trace, i would think deref should be in there somewhere
12:42alinpopaChousuke: thanks
12:42ayrnieualin - http://github.com/ayrnieu/clj-actors/tree/master gives you self-aware agents that receive keyword messages with arguments, that can loop, etc.
12:42alinpopaChousuke: Agents are someway equivalent to actors ?
12:42Chousukenot quite.
12:42Chouserwhoa. self-aware agents!?
12:43Chousukeagents are one way, in that you don't explicitly communicate back from agents to the caller.
12:43durka42all agents are self-aware
12:43alinpopamaybe there is somewhere on the web where to read some diffs between agents and actors ?
12:43Chousernew chart for anyone interested: http://tinyurl.com/clojure-classes
12:43lisppaste8durka42 pasted "kylesmith: this is what i see" at http://paste.lisp.org/display/75206
12:44ChousukeChouser: still not too much of a mess :)
12:44alinpopaayrnieu: I'll look at that, thanks
12:44ChouserChousuke: it's getting worse. dot is doing what it can, but... :-)
12:46kylesmithOkay, (.printStackTrace (.getCause *e)) works in the terminal, but doesn't in slime/emacs. Looks like I might have a fubared setup.
12:48ChouserI think there's a slime keystroke to show the next cause
12:48Chouserslime helpfully hides the root cause in a lot of cases apparently.
12:51kylesmithwell, this is all fine and dandy, but getting back to my original point: would it be possible for deref to just check for nil beforehand and give a better error message?
12:52teHey all
12:52technomancyte: hi
12:54danlarkinkylesmith: can't you catch NPE and then it'll be the same thing?
13:00technomancyduck streams is the closest thing to an HTTP library that ships with contrib, right?
13:07tehey technomancy
13:07tetechnomancy: do you have the URL for concourse?
13:14technomancyte: I don't have it public, but if you're interested I could try to push it to github later today.
13:14technomancyit doesn't actually *do* very much at all, but I know examples for compojure are scarce.
13:39Lau_of_DKGood evening everyone
13:39kotarakHi Lau.
13:44danlarkinHi Lau!
13:47kylesmithI just uploaded bsptree.clj to the group. I blatantly misuse atoms (among other things), so some feedback would be nice.
13:48kylesmithspecifically, if anyone could improve it's performance, that would be great
14:14tetechnomancy: would you please? ( pass it to github ) -- You said it. I need example code in clojure that do things besides math.
14:15tetechnomancy: Furthermore, I think compojure looks like a nice way to learn clojure while producing something
14:15tei have to run, but you can PM me a link to the code if you get the itch
14:15tetechnomancy: thanks!
14:15technomancyte: if you just want example code, check out mire
14:16technomancyit's not web-based, but it's a lot more interesting
14:17Chouserrhickey__: should IPersistentMap promised Counted even though it doesn't provide an implementation for count() itself?
14:20Lau_of_DKChouser: Have you started working on the STM yet ?
14:21Chouserwhat do you mean? Trying to patch it or something?
14:21Lau_of_DKI remember rhickey_ said, at one point, that the STM was the only part of Clojure that you hadn't begun patching your way through yet
14:22Lau_of_DKSo I was just wondering, when do you start? :)
14:22hiredmanLau_of_DK: I think he meant for clojurescript, Chouser hasn't implemented stm for clojurescript
14:23Lau_of_DKhiredman: I dont think thats what he meant
14:23hiredmanOk
14:24ChouserEither way, the answer is no, I have not. :-)
14:24ChouserSTM is still a magical mystery to me.
14:25ChouserIt would almost be a shame to understand it, like learning that the tooth fairy isn't real, and it's just Dad leaving you a quarter..
14:25technomancyheh.
14:25Lau_of_DKChouser: You actually believed in fairies?
14:26Chouserin our house he wasn't a traditional fairy. His name was Thumbkin, and he left behind a quarter and a tiny little note.
14:28Lau_of_DKOh ...
14:30technomancyLau_of_DK: I got concourse on github if you're interested: http://github.com/technomancy/concourse/tree/master
14:31Lau_of_DKOf course I am, thanks technomancy
14:32kotarakIs that similar to doodle?
14:32technomancyLau_of_DK: are you interested in hacking it or just reading the code?
14:33Lau_of_DKtechnomancy: I'd like to help hack it together, but time-wise Im not able to involve myself with more project atm :( But I'll enjoy watching your progress
14:33mrsolo_is there a something simliar to ruby splat for clojure?
14:33ayrnieuwhat's ruby splat?
14:34mrsolo_foo(*see) where see is an array
14:34mrsolo_then argument gets plug into functionall
14:34ayrnieu,(apply + [1 2 3])
14:34clojurebot6
14:34kotarakmrsolo_: (apply foo see9
14:35technomancyLau_of_DK: ok, cool. well I'm not really going to be working on it for a while, but te was interested
14:35mrsolo_right how that going to work with map? for example i like to map + '((1 2 3) (4 5 6))
14:35Lau_of_DKtechnomancy: Its a very good way to get a little familiar with compojure
14:35mrsolo_etc.. can't figure out an easy way to peel the outer ()
14:35ayrnieu,(map #(apply + %&) '((1 2 3) (4 5 6)))
14:35clojurebotjava.lang.ClassCastException
14:36kotarakmrsolo_: ,(apply map + [[1 2 3] [4 5 6]])
14:36ayrnieu,(map (fn [& rst] (apply + rst)) '((1 2 3) (4 5 6)))
14:36clojurebotjava.lang.ClassCastException
14:36Chouserkotarak: right
14:36kotarak,(apply map + [[1 2 3] [4 5 6]])
14:36clojurebot(5 7 9)
14:37mrsolo_,(apply map + [[1 2 3] [4 5 6] [7 8 9]])
14:37clojurebotjava.lang.NoClassDefFoundError: clojure/core$map__3634$fn__3649
14:37technomancyLau_of_DK: yeah, but I'm focusing on mire for now.
14:37ayrnieuoh, duh.
14:37ayrnieu,(map #(apply + %) '((1 2 3) (4 5 6)))
14:37clojurebot(6 15)
14:42mrsolo_thanks.. (5 7 9) is the desired result
14:42hiredmanhah
14:42Lau_of_DKtechnomancy: mire?
14:43technomancyLau_of_DK: http://github.com/technomancy/mire/tree/master (a multiplayer text adventure)
14:44Lau_of_DKAh yes -Giving WoW some competition ?
14:44hiredman,(#(map + (first %) (second %)) '((1 2 3) (4 5 6)))
14:44clojurebot(5 7 9)
14:44ayrnieu,(apply map + '((1 2 3) (4 5 6)))
14:44clojurebot(5 7 9)
14:44technomancyLau_of_DK: more like zork. =)
14:45mrsolo_need to work for '((1 2 3) (4 5 6) (7 8 9) ....) as well :-)
14:45durka42,(apply map + '((1 2 3) (4 5 6) (7 8 9)))
14:45clojurebotjava.lang.NoClassDefFoundError: clojure/core$map__3634$fn__3649
14:45hiredmanayrnieu's should
14:45durka42say what
14:45hiredmanhuh
14:46ayrnieuWFM.
14:46orrozhow does compose work in clojure?
14:46hiredman,(doc comp)
14:46clojurebot"([& fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."
14:46hiredmanlisppaste8: url?
14:46lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
14:46Lau_of_DKtechnomancy: I remember playing a MMORPG called Valhalla when I was a kid, I'd connect through a dial-up connection to this BBS type terminal where I could play with others - It was fantastic fun, because you had to visualize all the scenarios instead of having them painted on your screen - It was a pay-per-the-hour-service though, so it wasnt much fun until I ... got a password from one of the admins :)
14:47ayrnieuMUDs are still around -- as are IF games.
14:48technomancyLau_of_DK: nice
14:48hiredmanhttp://paste.lisp.org/display/74521 <-- fun for comp and partial
14:52orrozhow do i compose a function out of map and map like in haskell
14:52orroz(map . map) (\x -> x*x) [[1,2,3],[4,5,6]] -> [[1,4,9],[16,25,36]]
14:53hiredmanyou want partial application
14:53gnuvince,(map (fn [x] (map #(* % %) x)) [[1 2 3] [4 5 6]])
14:53clojurebot((1 4 9) (16 25 36))
14:53hiredmannot composition
14:53hiredmaner
14:54hiredmanwait
14:54hiredman,(map first [[1 2][3 4]])
14:54clojurebot(1 3)
14:54gnuvince,(map (partial map #(* % %)) [[1 2 3] [4 5 6]])
14:54clojurebot((1 4 9) (16 25 36))
14:55hiredman,((comp (partial map #(+ % 1)) (partial map first) [[1 2][3 4]])
14:55clojurebotEval-in-box threw an exception:EOF while reading
14:55hiredman,((comp (partial map #(+ % 1)) (partial map first) [[1 2][3 4]]))
14:55clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: LazilyPersistentVector
14:55hiredman,((comp (partial map #(+ % 1)) (partial map first)) [[1 2][3 4]])
14:55clojurebot(2 4)
14:56hiredmanthe main issue to watch out for with composing map is map is arity 2
14:56hiredmanbut all functions (including map) return a single value
14:56Chousergnuvince's solutions are both good idiomatic Clojure.
14:57Chousercomp and partial are both much less commonly used in Clojure than in Haskell, I would imagine.
14:57hiredmanyeah
14:57hiredmanunless you are playing some kind of golf
14:58hiredmanmost people just use function literals
15:02technomancybut hasn't used it much
15:06drdoHello
15:06drdoare there no lambda's in clojure?
15:06ayrnieu,((fn [x] x) 2)
15:06kotarakdrdo: fn
15:06clojurebot2
15:07kotarak,((#(+ x x) 2)
15:07clojurebotEval-in-box threw an exception:EOF while reading
15:07kotarak,(#(+ x x) 2)
15:07clojurebotjava.lang.Exception: Unable to resolve symbol: x in this context
15:07kotarak-.-
15:07kotarak,(#(+ % %) 2)
15:07clojurebot4
15:07drdooh
15:07drdowhat does "fn" mean?
15:08ayrnieuit means 'lambda'
15:08drdooh right of course
15:08hiredmanfn means function
15:08drdohow could i not see it
15:08Hununicode names ftw
15:08drdo-_-
15:08ayrnieuftl.
15:08drdoHun: does it support unicode lambda?
15:09Huni have a symbol macro ? in my CL
15:09Hunoh, wrong one
15:09Hunwithout the stroke
15:09drdokotarak: what does that #() mean?
15:10ayrnieudrdo - it meas 'abbreviated syntax for lambda'
15:10kotarak#() is a shorthand notation for short fns
15:10kotarakclojurebot: #()
15:10clojurebot#() is not a replacement for fn
15:10drdofor fns of one argument and one expression?
15:10ayrnieu(defmacro ? (& rst) `(fn ~@rst))
15:10kotarak,(map #(+ %1 %2) [1 2 3] [4 5 6])
15:10clojurebot(5 7 9)
15:10ayrnieudrdo - for fns of any number of arguments and any number of expressions.
15:10hiredman,((? [x] (+ 1 x)) 2)
15:10clojurebot3
15:10kotarak#(foo %) is equivalent to (fn [x] (foo x))
15:10ayrnieu,((apply + %&) 1 2 3)
15:10clojurebotEval-in-box threw an exception:arg literal not in #()
15:11kotarak,(apply #(+ %&) [1 2 3])
15:11clojurebotjava.lang.ClassCastException
15:11ayrnieu,(#(apply + %&) 1 2 3)
15:11clojurebot6
15:12kotarakdrdo: http://clojure.org/reader has more information on #() and other reader related info
15:14drdoi actually think clojure might be the holy grail i've been looking for xD
15:24durka42wait, what's %&
15:24ayrnieu,(#(list %&))
15:24clojurebot(nil)
15:24ayrnieu,(#(list %&) 1 2 3)
15:24clojurebot((1 2 3))
15:25kotarakdurka42: (fn [x y & z] ..) <=> #(.. %1 %2 %&)
15:25durka42ah ok
15:25ayrnieu,(#(list %4 %&) 1 2 3 4 5 6 7 8 9)
15:25clojurebot(4 (5 6 7 8 9))
15:26durka42small steps closer to perl :p
15:26hiredman:(
15:29tomswcan I access previously-printed values on the clojure REPL (in Lisp I'd use *, **, ***)?
15:30ayrnieu*1 *2 *3
15:31tomswayrnieu: thanks :)
15:31ayrnieusimilarly, *e gives you the last exception. (.printStackTrace *e)
15:32leafwsuppose I want to list all files in a directory ... but I want to return that list as a lazy list. What is the proper idiomatic way to do that? With a let wrapping a function that works as a generator, or how?
15:33durka42how do you get the list one at a time?
15:33durka42java.io.File/listFiles gives you the whole array, doesn't it
15:33leafwdurka42: true
15:33hiredmanI don't think you will be able to do it lazy like
15:33leafwhum
15:33hiredmanwhy do you want lazy?
15:34durka42what if the dir changed while your function was lazing around in the middle of listing it?
15:34leafwtrue
15:35leafwfine, I am convinced. The directory contains 100,000 files, that's all.
15:35leafwwas thinking on how to avoid loading such list of strings. But there doesn't seem to be away with java.io.File
15:35leafwI woul have to ls >> list.files and then line-seq that file in.
15:36hiredmanare the file names well-formed according to some schema?
15:36leafwhiredman: yes, they are, but cannot be trivially called individually. There are many sets together.
15:37leafwhum actually, I could to the line-seq on the file by Runtime getRuntime exec "ls" ... that'd do it too.
15:37ayrnieuit looks like java7 may have a better directory interface.
15:37hiredmanyou could make a lazy-seq of names and then filter out non-existent files
15:38ayrnieuI assume that this is one of those situations where a library writer says "this underlying library is too hard to use! And for no good reason!"
15:39leafwayrnieu: or rather, they didn't anticipate ext3 supporting so many files per folder.
15:42tomswayrnieu: although it turns out I didn't want to do (def icon *1)...
15:43ayrnieutoms - why didn't you?
15:44Chouserhm... shortest path to a stackoverflow? (def x #'x) (x)
15:44Chousereh, I guess that's pretty unremarkable.
15:44Chouser,((fn x [] (x)))
15:44clojurebotjava.lang.StackOverflowError
15:45gnuvince,(throw (java.lang.StackOverflowError.))
15:45clojurebotjava.lang.StackOverflowError
15:45Chouserheh
15:45Chousergnuvince: thanks. I appreciate that.
15:45tomswayrnieu: because instead of returning the icon I created, icon returns whatever was last printed on the repl
15:46tomswayrnieu: which keeps changing
15:46ayrnieutomsw - that isn't what I observe. What version do you have?
15:47hiredmanyeah that is just not right
15:48hiredmantomsw: have you tried it and it doesn't work? or are you running this on your mental repl?
15:49tomswhiredman: it fits what I'm seeing on the repl. let me try again
15:49tomswayrnieu: how do I find out the version?
15:49hiredman* *e etc are relatively new features
15:49hiredmanlike a two or three months old I believe
15:51hiredmanso if he has them at all his version can't be that old
15:51tomswayrnieu: I can't reproduce it, but I can see what I did on the repl and it doesn't make sense:
15:53drdohow do i test for nil?
15:53ayrnieu,(nil? nil)
15:53clojurebottrue
15:53drdothank you
15:53tomswayrnieu: (def icon *1) .then. (def mon (fn [l] (. l setIcon icon))) .then. (maplabels (fn [l] (. setIcon icon)))
15:54tomswayrnieu: at which point I got an error. When I then evaluated icon I got #'user/mon
15:55tomswbtw, this is a much nicer way to learn java than java :)
15:55ayrnieuI think you can't see your version from within clojure, but you can just checkout the svn repo and build from trunk.
15:55ayrnieuthis is also what I've found :_)
15:56tomsw(I'm really reaching for the stars tonight) - is there an equivalent of import java.awt.* ?
15:58Chousertomsw: no, there's not.
15:58tomswImage
15:59kotaraktomsw: but you can save the common prefix (import '(my.package Class1 Class2)) ....
16:00tomswkotarak: thanks, I've been using that. The "Image" was me at the wrong prompt trying to find out why Image.SCALE_DEFAULT wasn't found
16:00kotarakImage/SCALE_DEFAULT
16:01kotarak(in case that is a static field)
16:01durka42question about the import prefix thing, does it nest?
16:01kotarakdurka42: no, not that I am aware...
16:01durka42hmm, that's unfortunate
16:01durka42i could write a wrapper around it
16:02hiredmanthen you would have to wrap ns
16:02hiredman:(
16:03tomswis there any shorthand for (fn [obj]
16:03tomsw(. obj method arg)
16:04Chouser#(.method % arg)
16:04Chouser,(#(.replace % "." "/") "foo.bar.baz")
16:05clojurebot"foo/bar/baz"
16:05tomswChouser: neat. What's the % for?
16:05durka42% is the parameter in an anonymous function
16:05cemerickhas anyone else noticed that test-is drops swallows exceptions?
16:06durka42,((fn [x y & z] (list x y z)) 1 2 3 4 5 6)
16:06clojurebot(1 2 (3 4 5 6))
16:06kotarak,(macroexpand-1 '#(.replace % "." "/"))
16:06clojurebot(fn* [p1__1604] (.replace p1__1604 "." "/"))
16:06durka42,(#(list %1 %2 %&) 1 2 3 4 5 6)
16:06clojurebot(1 2 (3 4 5 6))
16:06kotarak,(macroexpand-1 '#(.replace %1 %2 %3))
16:06clojurebot(fn* [p1__1617 p2__1618 p3__1619] (.replace p1__1617 p2__1618 p3__1619))
16:08leafwis there any function that returns a sequence of increasing numbers?Or should I roll my own
16:09kotarak(iterate inc 0)
16:09leafwiterate! thanks
16:12leafwdoes pmap works as intended by default or do I need extra libs?
16:13ayrnieuit does not require extra libs.
16:13leafwthanks.
16:13leafwyeah, isn't that nice
16:16hiredmanyay, java.util.concurrent
16:17gnuvince"yay" and "java" in the same sentence: a year ago, I wouldn't have believed it was possible.
16:18leafw:)
16:18leafwRick is the kind of guy that "reads Knuth so we don't have to" as the python devs claimed.
16:18tomswpython, yuk, give me java
16:19ayrnieugnuvince - clojure makes it possible.
16:19leafwjava, yuk, give me clojure.
16:19gnuvinceayrnieu: that's what I'm implying ;)
16:20tomswleafw: that's what I meant. I'm trying to make myself employable after working with CL, by learning java
16:20tomswleafw: imagine my dismay - until I found clojure
16:21leafwclojure is young.
16:21gnuvinceThat's the cool thing: I'm learning the Java standard library bit by bit without having to forsake my programming soul.
16:21tomswgnuvince: +1
16:21leafwyeah
16:21Chousergnuvince: I'm with you there.
16:21leafwby the way: what is the difference between mod and rem
16:22leafwaren't they the same
16:22gnuvinceleafw: negative numbers
16:22gnuvince,(mod -3 2)
16:22clojurebot1
16:22leafwah I see
16:22Chouser,[(mod -2 5) (rem -2 5)]
16:22clojurebot[3 -2]
16:22gnuvince,(rem -3 2)
16:22clojurebot-1
16:22leafwthanks.
16:22cemerickclojure-contrib doesn't yet have its own google group and such, right?
16:22gnuvinceIt's a bit odd that div has not yet been added to complement mod
16:23Chouser,(map #(mod % 3) (range -9 9))
16:23clojurebot(3 1 2 3 1 2 3 1 2 0 1 2 0 1 2 0 1 2)
16:23Chousercemerick: that's correct, afaik
16:24kotarakdoes it need one?
16:25gnuvince,(map #(rem % 3) (range -9 9))
16:25clojurebot(0 -2 -1 0 -2 -1 0 -2 -1 0 1 2 0 1 2 0 1 2)
16:25Chouserdoes mod look right?
16:26Chouserruby: (-9..9).map{|x| x % 3} => [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]
16:26gnuvinceBug apparently
16:27Chouserpretty sad, if the only difference between rem and mod is negative numbers, and it gets the negative numbers wrong.
16:27gnuvincefile a report
16:28Chouseryessir
16:28visage_Hey all. I do not really have much history with lisp-styled languages, but I am looking to convert my scientific computing work to clojure. I recognize the benefits that a functional language offers from my work with SML and the benefits of a dynamic language and metaprogramming from work with Ruby. I know most people consider parentheses paralysis an unfounded concern (in fact, it has its benefits), but does anybody find the prefix
16:28gnuvincefind the prefix...?
16:28visage_err, as in (+ 1 2) instead of 1+2.
16:29visage_I was trying to translate a bunch of lengthy formulas into clojure and couldn't keep them straight
16:29gnuvinceYour phrase cuts off at "find the prefix"
16:29visage_Oh, sorry
16:29visage_(cont.)...notation cumbersome when they are trying to translate fairly lengthy inline mathematical formulas? I am trying to determine whether clojure is really the language for me before I make the jump.
16:29visage_I really like what clojure has to offer as a language in general, but am having a bit of trouble crossing this conceptual gap when it comes to this sort of coding specifically.
16:30gnuvincevisage_: I guess it's a question of habit.
16:30drewrvisage_: You may need to break your formulae into smaller components to make them easier to read.
16:30hiredmanyou can also write an infix macro that lets you use infix notation
16:30visage_...all very valid and very good answers
16:31hiredmanineffect making a dsl for math
16:31visage_well...consider me a convert then!
16:31gnuvincevisage_: the other benefits of Clojure's syntax can probably outweigh the awkward moments of converting a formula
16:31technomancyand you don't have to think about precedence rules at all
16:32technomancyI guess if you *like* precedence rules then this could be considered a disadvantage, but it's hard to argue against regularity.
16:33gnuvinceWell then go for Haskell and write only operators and mix and match the precedence!
16:33ChouserI do agree that when doing math and comparisons is when I'm most likely to feel the prefix notation to be awkward.
16:33Chouserfor object, method, and function calls, I find Clojure's syntax quite natural.
16:34gnuvinceMind you, I'm into math homeworks these days, and I suck at reducing expressions because of precedence
16:34durka42i catch myself writing (< 3 x) when i mean "is x {less than three}?"
16:35Hundurka42: it helps to think of < and > as injecting
16:35Hunthink of running them with 3 args
16:35Hunthen it's easy
16:35Hunits true iff the args are preordered
16:35ayrnieu(st 3 isLessThan x)
16:35hiredmanmaybe an infix macro for contrib's math lib?
16:37durka42would it have to be a macro
16:37ayrnieuit wouldn't.
16:37Chouserif you want to allow parens for grouping, it would
16:38ayrnieuhowever, a macro would more naturally let you-- right.
16:38Chouser...but then again, if parens are for grouping, then how would you call functions? :-P
16:38ayrnieuyou could group with vectors, instead.
16:38Chouserwhich is a fascinating solution.
16:39leafwis pmap eager or do I have to call dorun on it?
16:39ayrnieu,`(1 + sqrt(2) + [3 - 2])
16:39clojurebot(1 clojure.core/+ sandbox/sqrt (2) clojure.core/+ [3 clojure.core/- 2])
16:39ayrnieupmap is not eager.
16:40leafwthanks.
16:40hiredmanpmap does stay a few steps a head of consumption though, doesn't it?
16:40Chouser(inf 1 + (Math/sqrt 2) + [3 - 2])
16:40ayrnieuit does.
16:42Hunthere exist lots of infix-macros from CL and before. i don't know anybody that uses them
16:42hiredmanmaybe alias the unicode sqrt symbol to Math/sqrt
16:42ChouserHun: that's been my impression too.
16:43cemerickany ideas why test-is reports only the first 5 frames of caught exceptions' frames?
16:43Hunsooner or later you always want to escape
16:44drdowhat does a pair mean in clojure?
16:45ayrnieuwhere do you see 'a pair'?
16:45drdo(cond & clauses)
16:45drdoMacro
16:45drdoTakes a set of test/expr pairs.
16:45Chouserdrdo: generally just alternating values
16:46drdoI'm trying something like (cond #{(true . 2)}) without much success
16:46ayrnieu,(map #(cond (even? %) :even (odd? %) :odd) (range 10))
16:46clojurebot(:even :odd :even :odd :even :odd :even :odd :even :odd)
16:46Chouserdrdo: no dotted pairs in Clojure
16:46ayrnieudrdo - Clojure doesn't have dot notation for cons pairs.
16:46drdook
16:46Hunthere is no cons
16:46drdouser=> '(2 . 2)
16:46drdo(2 . 2)
16:46ayrnieu,(map #(.getName %) (.getMethods java.util.Iterator))
16:46clojurebot("hasNext" "next" "remove")
16:46drdowhat is this then?
16:46ayrnieu,(length '(2 . 2))
16:46clojurebotjava.lang.Exception: Unable to resolve symbol: length in this context
16:46durka42a list of 2, ., and 2
16:47ayrnieu,(count '(2 . 2))
16:47clojurebot3
16:47drdoi see
16:47kotarak,(cons 1 nil)
16:47clojurebot(1)
16:47Hun,(cons 1 2)
16:47clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
16:48Hunso no `real' cons here
16:48drdoi see
16:48durka42(doc cons)
16:48clojurebotReturns a new seq where x is the first element and seq is the rest.; arglists ([x seq])
16:48durka42,(cons 1 [2])
16:48clojurebot(1 2)
16:48drdothe documentation is somewhat misleading
16:48drdofor cond
16:48drdo"Takes a set of test/expr pairs." , i assumed "set" to mean a real Set
16:49ayrnieuwhat other word could it possibly use?
16:49Hunhow could it possibly work on a set data structure?
16:49ayrnieu"Takes a list" "Takes a sequence" "Takes a ..."
16:49drdoayrnieu: an example below that would clarify
16:49kotarakThere was someone complaining about "pairs". I guess there is no non-misleading description....
16:50Chouserdocs for such things are tricky. it's not a seq, and a "pair" is not a thing. :-P
16:50ayrnieudrdo - yes, an (exdoc foo) with examples would be nice.
16:50ChouserI've stumbled around trying to write the docstring for several such beasts.
16:50drdo:)
16:50durka42~examples
16:50clojurebotexamples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
16:51durka42how does condp work?
16:51kotarak(condp = x :a 5 :b 6 :c 7)
16:51ayrnieuit's helpful to realize that docstrings aren't documentation.
16:51kotarakdurka42: is equivalent to (cond (= x :a) 5 (= x :b) 6 ...)
16:52drdoso it's like a "switch" from most other languages
16:52drdoexcept that you can specify the comparison
16:52ayrnieuit's more like a switch than cond is, yes.
16:53durka42,(condp #(= (class %1) %2) 3 Integer "int" String "str")
16:53clojurebotjava.lang.IllegalArgumentException: No matching clause
16:53Chouserayrnieu: except that docstrings are just about the *only* documentation.
16:54durka42,(condp = (class 3) Integer "int" String "str")
16:54clojurebot"int"
16:54kotarakdrdo: yes and it can do (condp some coll #{:a :b :c} :>> #(println "first" %) #{:x :y :z} :>> #(println "else" %))
16:54durka42why didn't the first one work?
16:55ChouserI think the first arg to the predicate is each text value
16:55kotarak,(condp instance? 3 Integer "int" String "str")
16:55clojurebot"int"
16:55Chouser,(condp #(= (class %2) %1) 3 Integer "int" String "str")
16:55clojurebot"int"
16:55hiredmanat least in java classes always are capitalized so you can differ between a Integer and a integer
16:55kotarak,(condp some [1 :b 2] #{:a :b :c} :>> #(println "first" %) #{:x :y :z} :>> #(println "else" %))
16:55clojurebotfirst :b
16:56kotarak,(condp some [:z :b 2] #{:a :b :c} :>> #(println "first" %) #{:x :y :z} :>> #(println "else" %))
16:56clojurebotfirst :b
16:57drdoanother thing i've noticed is that the exception string isn't very helpful most of the times
16:57hiredmandepends
16:57hiredmanyou get familiar with what throws what exception
16:58Chouserthe stack trace is probably more often helpful than the exception itself.
16:59drdohow can i get a stack trace?
17:00Chouser(.printStackTrace *e)
17:00Chouserdrdo: or are you using slime?
17:00drdodoes slime work with clojure?
17:00Chousersome people seem to think so.
17:01Chousershoover: ?
17:02shooverI'm shaking my head at you!
17:02shoover(and smiling a little)
17:02Chousershoover: :-) got your presentation ready?
17:02shooveras I see the gauntlet is thrown down, my presentation visuals will be entirely in emacs and firefox
17:02ayrnieudrdo - http://github.com/jochu/swank-clojure/tree/master
17:03Chousershoover: well, maybe you'll win me over, then.
17:03durka42speaking of firefox, are applets still broken on os x?
17:03cemerickChouser: we won't let them take you, man! :-P
17:03shooverkotarak: 404
17:03cemerickI've got my trusty wooden stake right here ;-)
17:04technomancydrdo: try my clojure-mode fork; it should help with configuring slime
17:04Chouserdurka42: Last I knew, my applets still didn't work in os X. I'm not sure none do, though.
17:04kotarakoops--- embarrasing.... http://kotka.de/OmniWithPreview.tiff
17:04technomancydrdo: http://github.com/technomancy/clojure-mode/tree/master
17:04hiredmannice
17:05kotarakhiredman: wait a bit, this version is not yet released.
17:05kotarakCurrently working on getting things half-way stable.
17:05kotarakConsider it a teaser. :)
17:05hiredmandoes the omnicompletion depend on gorilla?
17:06kotarakYes.
17:06hiredman:(
17:06kotarakBut the Ruby stuff will be gone.
17:07hiredmanI guess that is a plus
17:07kotarakI hope so....
17:07kotarakAlthough Windows still makes problems.....
17:07hiredmanI like slime.vim just sending stuff to a repl using screen
17:08hiredmanbut omnicompletion...
17:08kotarakThat is relatively simple, but will always clutter your history.
17:08hiredmankotarak: history of what?
17:08kotarakgorilla works in parallel to the repl. So the history will really only what you typed there.
17:08kotarakYour screen repl.
17:08kotarakUnless you work in a different one.
17:09hiredmaneh?
17:09kotarakOk. Never mind.
17:09hiredmanplus I can switch which repl I send stuff to with a simple variable change
17:11hiredmanbut yeah, maybe the writting is on the wall and it is time to figure out gorilla
17:13hiredmandoes gorilla work ok with non-gui vim?
17:13shooverChouser: to answer your question, I'm not ready. I'm getting there, and excited to impart some new ideas on the unsuspecting masses of the Indianapolis .NET community
17:14kotarakhiredman: In general it should.
17:14Chousershoover: well, you've got time yet. I'm looking forward to it.
17:14kotarakhiredman: although I never tested....
17:16durka42it works
17:16durka42the repl does anyway
17:17hiredmanI do a lot of clojure at work on a windows machine ssh'ed into a freebsd machine
17:17durka42so does omnicompletion
17:17kotarakhiredman: the connection can also be forwarded via ssh.
17:18hiredmanugh, I wouldn't want to
17:19hiredmanwould rather have everything on the unix side
17:19kotarakhiredman: whatever you like
17:19durka42autoclose.vim does not even pretend to work in the console
17:19durka42or mine anyway
17:20hiredmanI use surround.vim
17:21hiredmanI think
17:21hiredmanacutally
17:21hiredmanI have both in ~/.vim/ somewhere
17:32kotarakAehm. I just noticed a strange problem.
17:33c|phello all
17:33kotarakWhen starting gorilla from the src/classes directories, everything works.
17:33c|pi like how this channel is logged, makes for a good read during programming class when im not doing anything
17:33kotarakBut when starting the same code from a jar I get an exception.
17:34kotarakjava.lang.IllegalStateException: Var clojure.core/*1 is unbound.
17:34hiredman...
17:34kotarakIs there some easy explanation for this?
17:35hiredmanis using a jar the only change you made?
17:35kotarakYes.
17:35kotarak*1 should be bound via Var/pushThreadBindings.
17:35kotarakAnd indeed it works, when not using the jar.....
17:36Chouser*1 is bound by clojure.main/repl, so if your code is getting called outside that, *1 won't be bound.
17:37kotarakThe code looks like this (try (Var/pushThreadBindings { ..... #'*1 (something ...} (thunk) (finally (save *1 away "Exception here!") (Var/popThreadBindings)))
17:37kotarakSo my understanding is, that *1 should be bound inside the try.
17:38kotarakand finally...
17:39Chouserhm
17:41kotarakhere is the actual code: http://bitbucket.org/kotarak/gorilla/src/tip/src/de/kotka/gorilla/repl.clj
17:42kotarakline 147 is the problem....
17:42kotarakbut only when executing from a .jar ......
17:43Chousercompiled, or from .clj (in the .jar)?
17:46kotarakCompiled, I guess. Both are in the .jar. But even when not using the .jar the cp is src:classes. So the compiled should be used in both cases, no?
17:46kotarakCan also try the different combinations. Just a sec.
17:46Chouserif the .class file is available and newer than the .clj, it should use the .class (whether from a .jar or not)
17:48kotarakI tried only .class files from the directories and only .clj from the directories and both work.
17:49kotarakJust a sec. Will build special jars.
17:52kotarakHuh? Obviously something strange is going, since I use gen-class. So I need actually AOT compilation.
17:53kotarakWhy did src only work then? Have to check again. Sorry for the noise.
17:53visage_This might be a stupid question, but does clojure have a library manager like Ruby's 'gem'?
17:54technomancyvisage_: no. the closest thing so far is ties
17:54technomancy~ties
17:54clojurebotties is http://www.bitbucket.org/achimpassen/clojure-ties/wiki/Home
17:55visage_okay, thanks
17:55technomancyvisage_: most people just bundle dependencies right now. it works since there aren't that many clojure libs... but in the future I suspect a package manager will become more important.
17:56technomancy(ties is not actively developed, btw)
17:56visage_After rails, I blame ruby's success on gem. Having a package manager makes things so nice
17:56Chouserisn't that the OS's job, though?
17:56technomancyChouser: the OS can't keep up
17:56Chouserhm.
17:57danlarkinaye, easy_install/PyPI for python is super useful
17:57technomancyChouser: since devs can generally handle more hiccups, they are willing to put up with more of their own "test to make sure it works with the latest version" than your average apt-get user
17:58technomancyChouser: but I suspect you could build a clojure-specific package manager as a thin layer on top of apt-get. the difficult part is getting buy-in from library maintainers; no system can succeed without that.
17:59visage_It can get more complicated, though. Gem allows users to specify which library version to load, et cetera.
17:59technomancyyeah, you wouldn't get multiple-versions-at-once with apt-get
17:59hiredmangems are really annoying in my experience
18:00kotarakChouser: thanks for your thoughts. Proxy generates also classes in classes/clojure/proxy/... These .class files were not included in the .jar file. The proxy in question was used before *1 was bound by Var/pushThreadBindings. => Exception => second Exception in the finally clause were *1 is used......
18:00hiredmanmy OS has a package manager, I don't need another.
18:00kotarakSo the second Exception shadowed the first...
18:01technomancyhiredman: then you're stuck with 6-month to year-old packages.
18:01technomancyplus the added burden of every library maintainer creating a .deb, an .rpm, and whatever the deuce macports uses... it just won't happen
18:02hiredmantechnomancy: oh, you mean I am stuck using software that is stable and has been released?
18:02hiredmanhow terrible
18:02technomancyhiredman: well considering it excludes everything that's ever been written in clojure, I'd say that's pretty lousy
18:02hiredman*shrug*
18:02Chousukehiredman: gems are just CPAN envy ;(
18:02hiredmanugh
18:02hiredmanCPAN
18:02hiredmanall of it
18:02ChousukeCPAN works well though.
18:02Chouserkotarak: ah. wow.
18:03Chousukeit's too much work to package all of it
18:03ChousukeI guess that's the rationale behind gems and whatnot as well
18:03technomancyI'm just plain not going to ever build an .rpm for my libraries.
18:03hiredmanugh
18:04hiredmanwho whould ever want to do that?
18:04technomancyif I only target a single format, I'll be much more inclined to actually make a release.
18:04hiredman(build an rpm)
18:04ChousukeI don't really mind them being outside package management either, as long as they know their place.
18:04technomancyhiredman: not everyone is lucky enough to have apt-get installed on their box... or so I hear.
18:05ChousukeI could actually install it, but I prefer macports :P
18:05dreishhiredman: So what's your solution when your lib requires libs A, B, and C, B requires D, E, and F, etc.? Just tell people to spend a weekend hunting for dependencies?
18:06technomancyanyway, the point is that nobody can agree on a single OS-level packager, so coherence is just not going to happen
18:06hiredmanactaully, outside of openoffice, I dunno of any opensource project besides the freebsd project that builds packages of opensource software for freebsd
18:07Chousukeperhaps that is because building packages for freebsd is easiest if you're part of the project?
18:07Chousukeyou don't really build packages anyway; just ports :/
18:08hiredmanChousuke: packages are built for every release
18:08hiredmanfor a very large part of ports
18:09hiredmanso pkg_add -r will fetch a precompiled package and install it
18:09hiredmanso, uh, ports has no problem with people just providing a source tarball
18:10hiredmandreish: Sure.
18:10hiredmana weekend
18:10hiredmanpfft
18:10hiredmanin the README "this requires version X of lib Y from url Z"
18:11technomancy"...which requires version X` of Y` but conveniently fails to give a URL for download"
18:11technomancy"and then X` depends on X``, but not the latest version; that will blow up..."
18:11technomancyad nauseum
18:12dreishI guess that's when you tell people they're using the incorrect OS. ;-)
18:13hiredmananyway, I am not happy with gems or ant or maven
18:25lisppaste8Chouser pasted "infix fn" at http://paste.lisp.org/display/75230
18:25Chouserdon't shoot me or anything.
18:26hiredmancute
18:26Hunshoot!
18:30ChousukeChouser: that last infix example is perverse.
18:35ChousukeChouser: maybe put it in contrib next to macro-apply in the evil stuff section? :>
18:36Hunthat reads like the evil that haskellers do
18:36Hunlives on and on...
18:36durka42what is the point of a fn that calls a macro?
18:36hiredmanI could just alias � to partial and use that in place of my pl macro
18:37hiredmanor comp
18:37hiredmanor whatever I was using it for
18:38Hundurka42: what is the point of a fn using numbers?
18:38Hunthe concepts are orthogonal
18:38durka42no, i mean
18:38Chousukeinteresting though that the infix thingy isn't even a macro.
18:38durka42oh, i see
18:38durka42wait why the indirection then
18:39Hundurka42: so that the args don't have to be quoted
18:39durka42to allow destructuring by infix*
18:40ChousukeHun: I don't think it's for that
18:40Hunthen i understood that wrong
18:40Chousukebecause it's a function you can actually do (infix (+ 5 7) * [3 + 4])
18:41Chousukeit's a function of functions and values into a value :(
18:42ChousukeI think if someone were in my room with me right now they could hear my mind making a boggly sound.
18:42ayrnieuI had that problem, but I got it resealed.
18:54Chousukehmm, that infix thing seems to actually be trivial to transform into a macro
18:55Chousukeno, wait, my mistake :(
18:55Chousukehmm...
18:55Chousukeno, wait, it actually works.
18:57lisppaste8Chousuke annotated #75230 with "macrofied" at http://paste.lisp.org/display/75230#1
18:57Chousuke(infix (+ 5 7) * [3 + 4]) expands nicely into (* (+ 5 7) (+ 3 4)) at least :)
19:06durka42er
19:06durka42#<CompilerException java.lang.NoClassDefFoundError: clojure/lang/Agent (REPL:59)>
19:06durka42that's not good
19:22ChouserChousuke: yeah, that's probably better. faster at runtime and only groups on literal vectors, not expressions that return vectors.
19:23Chousukeit was surprisingly easy though, given your function solution
19:23ChousukeI'm tempted to believe there is some situation where it blows up.
19:24Chouser(infix 5 + 2 * 3 < 6 + 6)
19:28Chousukeadding < to the ranking seems to have no effect :/
19:29Chousukethis is not the time to wonder about that though. must sleep.
19:31ozy`haskell copes pretty well with allowing user-defined operators, without knowing operator precedence at compile time
19:31ozy`er, at parse time, I mean
19:32ayrnieuoh? How interesting.
19:33ozy`you can even modify operator precedence in local scopes, as we just discovered in #haskell :p
19:34durka42that sounds...confusing
19:36ozy`it helps that unary operators aren't allowed
19:37ayrnieuyou have to see features like that in the context of Haskell's community, which is something like Perl's community in the garden of Eden: detached from all shame or need to do any work.
19:38ayrnieuwhat would you do in that circumstance? Why, you'd golf your programs forever, and react to pointlessly cryptic code with joyful curiousity.
19:40Chouserthat's a beautiful line.
19:44clojurebotsvn rev 1266; IDeref print method honors *print-level*, patch from Chouser
19:45lisppaste8Chouser annotated #75230 with "fix for macro version" at http://paste.lisp.org/display/75230#2
19:48durka42next: allow (infix Math/sqrt 9)
19:50durka42wait, that already works with binary fns
19:50durka42ha
19:50durka42(infix 3 Math/atan2 5)
19:53durka42(infix "%s = %d" String/format (into-array Object ["nine" 9]))
19:54ozy`now that's just gratuitous
19:54ozy`,''(quote)
19:54clojurebot(quote (quote))
19:59clojurebotsvn rev 1267; catch method redef in proxy, patch from jbondeson
20:23hiredmanclojurebot may need a qdb feature
20:23hiredmanjust so I have a place for what ayrnieu said
20:35erohtaris there an official version of clojure?
20:36hiredmanclojurebot: svn?
20:36clojurebotsvn is http://clojure.googlecode.com/svn/trunk/
20:36hiredman^-- official
20:38erohtarhiredman: is there trouble with slime/swank with the latest version?
20:39hiredmandunno
20:40hiredmannot an emacs user
20:40hiredmanclojurebot: emacs?
20:40clojurebot"Learning Emacs and SLIME was just about the most painful computer experience I've ever been through."
20:41erohtarhaha, okie - thanks!
20:53erohtarany idea why i get this error - clojure.lang.MultiFn.<init>(Lclojure/lang/IFn;Ljava/lang/Object;)V (NO_SOURCE_FILE:0)
20:53erohtaroops
20:53erohtarjava.lang.NoSuchMethodError: clojure.lang.MultiFn.<init>(Lclojure/lang/IFn;Ljava/lang/Object;)V (NO_SOURCE_FILE:0)
20:55Chousererohtar: what are you trying to do?
20:55Chouserwe'll be most able to help you if you paste your code and the full stack trace
20:55Chouserlisppaste8: url
20:55lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
21:23erohtarlet me do that
21:24lisppaste8erohtar pasted "clojure-json trouble" at http://paste.lisp.org/display/75236
21:25erohtarchouser: that generates a stack trace on the latest clojure
21:25erohtarCaused by: java.lang.NoSuchMethodError: clojure.lang.MultiFn.<init>(Lclojure/lang/IFn;Ljava/lang/Object;)V
21:25erohtar at org.danlarkin.json.encoder__init.load(Unknown Source)
21:25erohtar at org.danlarkin.json.encoder__init.<clinit>(Unknown Source)
21:25erohtar at java.lang.Class.forName0(Native Method)
21:25erohtar at java.lang.Class.forName(Class.java:247)
21:25erohtar at clojure.lang.RT.loadClassForName(RT.java:1512)
21:25erohtaretc etc
21:26danlarkinI guess I should update clojure and check it out hm
21:26erohtarthat would be awesome :D
21:26erohtari know it works on svn rev 1195
21:26erohtarwhich is way old
21:28hiredman(require '[org.danlarkin.json :as json])
21:28hiredmanis what that should be, I believe
21:29danlarkinok I just updated and rebuilt clojure and (require '(org.danlarkin [json :as json])) worked for me
21:32hiredmandanlarkin: oh
21:32erohtarhmmm
21:33erohtarlet me experiment some more
21:34danlarkinerohtar: does it work if you just fire up the REPL and paste that in?
21:36erohtardanlarkin: no
21:38danlarkincan you paste the whole stacktrace to lisppaste?
21:48ayrnieuhttp://groups.google.com/group/comp.lang.lisp/browse_thread/thread/0d05837df1efe075#
21:54clojurebotsvn rev 1268; added Counted interface and counted? predicate implement stack/heap safe count in RT stack-safe count in ASeq/Cons, patch from Chouser
22:04clojurebotsvn rev 1269; repl read refactoring, patch from scgilardi
22:08notyouravgjoelare there any datastructures that have 0(1) seek time?
22:08notyouravgjoelat least, those that are native to clojure?
22:09danlarkinhash maps are pretty close
22:10Chousermaps and vectors are effectively O(1)
22:10hiredmanby native to clojure, you mean those provided by clojure.lang?
22:10notyouravgjoelyeah
22:11danlarkinoh yes vectors too
22:11notyouravgjoelthat is, I don't need to start using the java stuff
22:12ayrnieunotyour - http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/
22:13notyouravgjoelthanks
22:14hiredmanthe datastructures from clojure.lang are java stuff
22:14clojurebotsvn rev 1270; improved Maven integration, patch from hlship [issue 70]
22:14notyouravgjoelsure, I mean using the (. ...) methods
22:14Chouserwell, they're written in Java, but they're pretty clumsy to use from java
22:15notyouravgjoelright
22:15hiredman:P
22:16ayrnieunotyour - there are already functions to deal with Java arrays, and you can write functions to prettify them for your purposes.
22:20notyouravgjoeloh i see; would they be faster than vectors, then?
22:20ayrnieuthat depends on what you're doing.
22:21notyouravgjoelI'm creating a constant datastructure, and I'm trying to get fast access time
22:22Chouseran array should do very nicely
22:22ayrnieuif you can't describe the problem better than that, you should use vectors and worry about this after your profiler leads you back this way.
22:23ayrnieuuntil.
22:23Chouseryeah, ignore me. do what ayrnieu says
22:23notyouravgjoelah, thanks
22:23notyouravgjoelI'm not sure what exactly you're looking for in a description
22:24ayrnieuwell, think of your data structure as a mathematical function with a domain and a range.
22:25ayrnieuimmediately you realize that you should have something to say about the domain and the range. Are you mapping (range 100) exactly to (range 100)? Then you don't need a data structure, just the identity function.
22:26ayrnieuif you're mapping arbitrary objects to arbitrary objects, then a hash makes more sense than a Java array.
22:27notyouravgjoelit maps integer edge weights between nodes i and j, using 2d colletions
22:27notyouravgjoelwhich is why arrays do seem fairly intuitive
22:34clojurebotsvn rev 1271; fixed ensure to use deref
22:35gnuvince_Lots of activity tonight
22:35stimuliHi
22:37ayrnieuhttp://compulsiontocode.blogspot.com/2009/01/bowling-with-clojure.html
22:39stimuliI think rules of bowling are harder than the clojure
22:40ayrnieu,((fn [[x1 x2 x3 & rst]] [x1 x2 x3 rst]) '(30 60 90 120 150 180 210 240 270 300))
22:40clojurebot[30 60 90 (120 150 180 210 240 270 300)]
22:44ayrnieuthat doesn't quite get you to his purposes.
22:44ayrnieustimuli - I think code kata doesn't count unless the result is somewhat idiomatic.
22:45hiredmanyeah
22:45stimulitrue
22:50notyouravgjoelaside from YourKit, any suggestions on profilers?
23:02stimuliI'm prolly going to want a good profiler soon myself
23:03stimulihttp://java-source.net/open-source/profilers
23:03stimuliI haven't used any of those ....
23:19blbrownthe eclipse clojure plugin is not working all that well...so far
23:35technomancyso is it right that you can't have circular dependencies between namespaces?
23:46arohnertechnomancy: you're not supposed to
23:47arohnerthere's a bug that you don't get an exception when you do have a circular dependenc
23:47arohnerhttp://code.google.com/p/clojure/issues/detail?id=3&amp;colspec=ID%20Type%20Status%20Priority%20Reporter%20Owner%20Summary
23:48arohneryou used to get an exception when clojure detected a circular load, and rhickey disabled that to make AOT work. The bug I just linked is the bug to re-enable the exception