#clojure logs

2009-10-26

00:07rlbchouser: I think he's written a recursive func to do it -- see the link above.
00:07rlb(if I understand correctly)
00:09technomancyanyone want to test out a release candidate for slime that I'm going to submit to elpa?
00:09chouserah, I see.
00:09technomancyhttp://github.com/technomancy/slime/tree/elpa open slime.el and M-x package-install-buffer; do the same w/ contrib/slime-repl.el
00:09chouserdjork: you maybe be able to essentially wrap lazy-seq around the body of the function.
00:10chouserthen use cons instead of conj and () instead of [] -- and you get a lazy seq that won't overflow the stack.
00:14GenericUser1Hello.
00:15tomojtechnomancy: is it modified at all or just packaged for elpa/
00:16chouserGenericUser1: an appropraitly generic greeting. Welcome!
00:16GenericUser1I'm trying to learn clojure, and I'm having a bit of trouble figuring out the details of refs, agents, and vars. In particular, if I wish to refer to a ref from the value of another ref, is this safe to do?
00:17GenericUser1Thanks :)
00:17technomancytomoj: it's a slightly later version of trunk than the one that M-x clojure-install uses, but the only modifications I made myself were for elpa.
00:18GenericUser1To be a bit more concrete, I'm trying to model the states of various rooms, and I'd like to be able to keep a mapping of exits from one room to another, which may change at a later point in the room's existance.
00:18chouserGenericUser1: yes, a ref can contain a ref (though that would be a bit silly) or contain a collection ...
00:19chouseryes, a ref with a collection that includes another ref is perfectly safe.
00:19GenericUser1Ok. Is there any way I can stop the repl from evaluating circularly linked refs? :)
00:19chouserheh.
00:20chouserset your *print-depth*
00:21chousersorry, *print-level*
00:21chouser(set! *print-level* 15) is what I usually use, though you may find that to be too deep or too shallow depending on what you're doing.
00:21GenericUser1ok
00:22chouseranother option would be to store your rooms in a single top-level map, each keyed by some kind of unique identifier.
00:22chouserthen instead of a ref pointing directly to another room, it could point to that room's key, avoiding direct loops.
00:23GenericUser1Ok.
00:23GenericUser1Yes, that may be a nicer option.
00:23tomoj GenericUser1: I think there's an example of just that kind of program on github somewhere
00:24tomojyeah, http://github.com/technomancy/mire
00:24technomancyGenericUser1: gosh, that sounds awfully familiar... =)
00:25tomojI have a similar problem trying to make representations of directed graphs
00:25GenericUser1Hmm, thanks.
00:25GenericUser1technomancy: ?
00:26technomancyGenericUser1: the link tomoj pasted
00:26GenericUser1ah ;)
00:26technomancyit's a tutorial-type project of mine
00:28GenericUser1Does anyone else have problems with the API page in Firefox?
00:29GenericUser1It seems that the page rendering gets cut off about half way down the list
00:29tomojsomeone else complained about something like that before, too, I think
00:29tomojdoesn't happen to me in any browser
00:31GenericUser1I'm in Firefox 3.5.3 on Vista, currently, although I've had issues with it on several other computers (I can't remember their configurations though).
00:31GenericUser1Is there a good place to file a report about it?
00:32technomancytomoj: I've got some ideas about the next version of swank-clojure if you've got a minute for feedback
00:32technomancy(or anyone who's interested really)
00:34tomojsure
00:35GenericUser1What is the meaning of "Experimental" in the API docs with regards to watchers?
00:35technomancyI'm going to submit swank-clojure as an elpa package too so it can depend on clojure-mode and slime
00:35tomojGenericUser1: I guess it means it could change?
00:35technomancyand I'm trying to decide if I should get the Clojure code itself (Clojure, Contrib, and Swank) installed via git or some other mechanism
00:35technomancycurrently I'm leaning towards downloading jars into ~/.swank-clojure
00:36technomancybut maven deps are also an option
00:37tomojI dunno anything about maven
00:38technomancyI'm not really sure it supports this use case anyway
00:38tomojby "downloading jars into ~/.swank-clojure" do you mean cloning the git and building like clojure-install does?
00:38technomancy(downloading dependencies without actually having a project checked out on disk)
00:38tomojthat seems fine to me
00:38technomancyI'm thinking downloading pre-build jobs
00:38technomancy*jars
00:39tomojoh, I dunno anything about that either :(
00:42technomancytomoj: you mean you don't know if it's a good idea?
00:43tomojI don't even know what a pre-build jar is
00:43technomancyjust a jar that has been compiled by someone else
00:44rlbchouser: if you need to traverse a source collection and generate varying number of result items per-input, is that kind of lazy-seq approach one of the better ones in clojure?
00:44technomancythe only reason M-x clojure-install even performs a git checkout is that it was written before Clojure had turned 1.0
00:44tomojoh, I thought "pre-build" meant it hadn't been built yet, english is funny :)
00:45technomancyhehe
00:45technomancyI just want to reduce the number of working parts
00:45tomojyeah I have had problems before with git/ant
00:45technomancythis would also make it a non-issue that OS X refuses to honor $PATH for gui-launched apps since git wouldn't be involved.
00:45tomojand windows people have problems too I think
00:45technomancythat's like the #1 source of "bug" reports for me
00:46tomojand if I want to use edge clojure I can just dump my own jars into .swank-clojure?
00:46technomancyyeah
00:46tomojsounds good to me
00:47technomancymaybe have a defvar to tell it to look in a given dir so you don't have to manually drop the jars in there
00:49chouserrlb: depends on if you want a lazy seq or not, I suppose. If you don't, you'd have to convert your non-tail-recursive function into a tail-recursive one by adding an accumulator for your output collection (see "on lisp")
00:51chouserto avoid stack overflow, I mean.
00:53rlbRight -- I just didn't know if there was some clever clojure map-like function that I hadn't heard of yet.
00:53rlb(optionally destructuring map-like function)
00:54GenericUser1Is there a way to change how the print functions treat a value?
00:54rlb...and I ask because it seems like often there often is some clever clojure function...
00:55rlbanyway, thanks.
00:55piccolinotechnomancy: was changing the checkout command the right fix?
00:58technomancypiccolino: it should be, though I don't understand why "git checkout clojure-1.0-compatible" failed
00:59technomancypiccolino: did you catch the discussion above about removing the checkout/compile part and just downloading precompiled jars?
00:59piccolinoYeah, I don't either. Especially since it works for clojure itself. Is this not something that happens for you too?
00:59piccolinoI did see that. That sounds better, but I didn't know there was a pre-built release of clojure-contrib 1.0.
00:59piccolinoI asked about that in here about a week ago because I was trying to get a MacPorts portfile made for clojure-contrib.
00:59technomancywell I would build it and upload it myself; there's not an "official" one
01:00piccolinoOh, I see.
01:01GenericUser1Am I supposed to see stacktraces on exceptions?
01:02GenericUser1I keep getting relatively useless errors saying things like Wrong number of args passed to <some function> (NO_SOURCE_FILE:0)
01:04tomojGenericUser1: did you compile or just enter the functions into the repl?
01:05tomojclojure stacktraces seem to me to be generally more cryptic than some other languages
01:05tomojbut your files should show up with line numbers if you do it right (e.g. C-c C-k with slime)
01:05GenericUser1At the moment, I'm calling a function in the repl that I loaded from a file
01:05tomojhow'd you load it?
01:06GenericUser1from the command line (DOS cmd)
01:06piccolinotechnomancy: let me know if I can help at all. Maybe if you put up a pre-built jar I can use that for MacPorts as well.
01:06GenericUser1java -cp clojure.jar clojure.lang.Repl model.clj
01:06tomojhmm
01:06technomancypiccolino: I'll be sure to announce on the mailing list
01:06piccolinoThanks.
01:07piccolinoThe clojure mailing list, right?
01:07technomancypiccolino: yup
01:07piccolinok
01:07technomancyman... maintainership is a lot easier once you realize you can respond to patches with "this looks great; can you rebase cleanly on top of my latest?" =)
01:07technomancyinstead of merging yourself.
01:07GenericUser1I also get very cryptic errors when I screw up using derive
01:08GenericUser1For example, if I do something like (derive :foo :bar) instead of (derive ::foo ::bar), I get the error "Assert failed: (namespace parent) (model.clj:0)"
01:08tomojI don't even get stacktraces or NO_SOURCE_FILE at all with clojure.lang.Repl
01:09GenericUser1(Not that I'm any stranger to cryptic errors... I've spent a enough time dealing with templates in C++ ;))
01:10tomojare you happy using the repl from cmd? O_o
01:10chouserGenericUser1: (.printStackrace *e)
01:10technomancypiccolino: are you the David Santiago that emailed me about this contrib problem, or was that just a random coincidence?
01:10piccolinoOne and the same.
01:10chouserGenericUser1: (.printStackTrace *e)
01:10GenericUser1I've been going back and forth between cmd and Clojure Box emacs
01:10GenericUser1But I don't know emacs at all, so emacs is constantly getting on my nerves :)
01:10technomancypiccolino: ok cool, I will delete this email then. =) thanks for the heads up.
01:11piccolinotechnomancy: No problem. Just trying to help out a little.
01:11technomancypiccolino: yup... too many moving parts right now.
01:11tomojah
01:11technomancyhard to find a moment to sit down and make sense of it all right now though
01:11piccolinoYeah, I still can't believe how young clojure is.
01:11tomojGenericUser1: learning emacs is a good investment :)
01:12GenericUser1(When I keeping doing things like ctrl-z and it minimizes, and ctrl-f and it just moves forward one character, and ctrl-s and it tries to search instead of save... I get annoyed :p)
01:13GenericUser1Yes, I know I should learn it, and I'm slowly learning pieces, but years and years of programming in various Windows editors has trained me with lots of things that I haven't yet unlearned.
01:14GenericUser1*trained me to do lots of things that I havent' yet unlearned
01:14GenericUser1yay grammar!
01:14technomancyunlearning is often harder than learning
01:15GenericUser1indeed.
01:18piccolinoI also think Emacs could make a little more effort to blend in with what have become the widespread UI conventions over the past few decades.
01:18piccolinoBut then that's why I use Aquamacs.
01:19technomancybut that's why I browse with Conkeror. =)
01:20tomojI use conkeror too but I wish it were written in clojure
01:20tomojbeen investigating embedding gecko or webkit in java but I can't get anything to work
01:20GenericUser1Hrm
01:21technomancytomoj: it's useless without access to the DOM
01:21technomancyvery few if any engines expose that in anything other than JS or C++. =(
01:21tomojI would hope javaxpcom gives you that
01:21GenericUser1So, I have an agent 'john'... and when I do (@registry (:location @john)), it gives me the result I want, but if I do (-> @john :location @registry), I get the core$deref error
01:22technomancyah... possibly.
01:22GenericUser1What am I doing wrong?
01:25GenericUser1Oh... but if I don't deref registry, then I get it works again.
01:26tomojI bet it's trying to do (deref (:location @john) registry)
01:26GenericUser1Hmm... Does that mean that -> treats @registry as (deref registry) and is really doing something like (deref (:location @john) registry)?
01:26GenericUser1ah
01:27tomojbut a ref used as a function automatically derefs itself
01:27tomojmaybe this is why?
01:27tomojso e.g. you can do just (registry (:location @john))
01:27GenericUser1Ah
01:27tomojor even (registry (john :location))
01:28tomoj== (-> :location john registry)
01:28GenericUser1So, it auto-derefs a mutability type if it's used as a function?
01:28GenericUser1I've been wondering about that,
01:28GenericUser1since if I have something like (:location john), I get nil
01:28GenericUser1but (:location @john) --> correct answer
01:28tomojI think clojure.lang.Ref implements the interface for functions and invokes whatever the ref points to
01:29GenericUser1huh, ok. Thanks.
01:29tomoje.g.:
01:29tomoj(let [foo (ref 3)] (foo))
01:29tomoj,(let [foo (ref 3)] (foo))
01:29clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
01:30GenericUser1I have maps in my refs and agents
01:30GenericUser1,(let [foo (ref {})] (foo))
01:30clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: PersistentArrayMap
01:30tomojyeah, so invoking a ref/agent to a map will invoke the map
01:30GenericUser1,(let [foo (ref {:a :b})] (foo :a))
01:30clojurebot:b
01:30GenericUser1there
01:30GenericUser1ok
01:31tomojalso:
01:31tomoj,@john
01:31clojurebotjava.lang.Exception: Unable to resolve symbol: john in this context
01:31tomojerr
01:32tomoj,'@john
01:32clojurebot(clojure.core/deref john)
01:32tomojso -> sticks the previous value in the middle there and screws things up
01:33GenericUser1,(-> @john :location '@registry)
01:33clojurebot(clojure.core/-> (clojure.core/deref john) :location)
01:34GenericUser1I'm not really sure what I just did there. O_o
01:35GenericUser1Where did (clojure.core/deref registry) go?
01:36GenericUser1,(quote a b)
01:36clojurebota
01:36tomojyou quoted it
01:36GenericUser1Ah, I see.
01:37tomojso (quote (deref (:location (deref john))) (deref registry)) I guess
01:37GenericUser1I wonder when we'll see an obfuscated clojure contest :P
01:37GenericUser1Yeah, so quote's dropping the deref registry, and just returning the first thing
01:37GenericUser1,(quote (deref (:location (deref john))) (deref registry))
01:37clojurebot(deref (:location (deref john)))
01:37GenericUser1yep
01:38tomojthat is pretty odd
01:40tomojjust found this at imagine27.com
01:40tomoj,((fn [x] (list x (list (quote quote) x))) (quote (fn [x] (list x (list (quote quote) x)))))
01:40clojurebot((fn [x] (list x (list (quote quote) x))) (quote (fn [x] (list x (list (quote quote) x)))))
01:40tomojhah, crazy
01:40GenericUser1O_o
01:40arsatikicool
01:41GenericUser1Nice quine.
01:41chouser(-> @john :location (@registry))
01:41tomojaha
01:41chouser(-> :location (@john) (@registry))
01:42chousernot sure either of those are better than (@registry (:location @john))
02:41GenericUser1What's the proper way to specify custom exception types in clojure?
02:48tomojif you want a custom exception type I think you need to gen-class it
02:49tomojor proxy
02:49GenericUser1I assumed that was the case, but I can't seem to get it to work right. Could you give me a quick example? I keep getting errors about the class not existing.
02:50tomojwell gen-class only does anything when compiling
02:55GenericUser1How do I compile this then? :P
02:56GenericUser1If I try to do (compile 'model) I get an error about "can't find the path", and "model.clj" instead of 'model gives a type error (can't cast string), and I can't load the file (Can't find my custom exception class, because it hasn't been generated...)
02:57GenericUser1At this point, I think it'd be easier to just write the damned exception class in Java :P
02:57tomojwell
02:57tomojwhat's your classpath?
02:57G0SUB_hmm, how do I get new agents to work after I have called (shutdown-agents) once? do I have to re-launch the JVM?
02:58tomojif your file is model.clj, the path to the directory that model.clj is in should be in your classpath
02:58GenericUser1I'm just running everything in the same directory at the moment, with the one file model.clj from the command line
02:59GenericUser1starting the repl with the same command as before;
02:59tomojyes, but is that directory in your classpath?
03:00GenericUser1*shrug*
03:01GenericUser1I don't think I've explictly put it there
03:01tomojif you're doing like -cp clojure.jar, try -cp clojure.jar:.
03:01GenericUser1I just tried that, but same thing.
03:01GenericUser1or actually, I used ;
03:01GenericUser1I'm on Windows
03:02GenericUser1: gives me NoClassDefFoundError for clojure/lang/Repl :P
03:03GenericUser1I think I will just try to write the exception in Java and see if I can load that.
03:04tomojadding . to the classpath didn't help?
03:04GenericUser1It didn't seem to
03:04GenericUser1Unless I am misunderstanding what I was supposed to do after that
03:05tomoj(compile 'model)
03:05tomojthat gives some blah blah.clj not found?
03:07tomojmaybe the problem is that you're not supposed to have namespaces with only one segment?
03:07tomojI dunno
03:07GenericUser1java.io.IOException: The system cannot find the path specified (model.clj:5)
03:08GenericUser1I've tried it with and without namespaces
03:08tomojthat's odd
03:08GenericUser1(ns model) at the top
03:09GenericUser1line 5 of my file doesn't make much sense for the error either, since it's just " (dosync "
03:09GenericUser1Unless :5 is supposed to mean something else ?
03:09GenericUser1O_o
03:20GenericUser1Well, I finally got it, using java classes.
03:22GenericUser1I wrote an empty class 'CantMoveThatDirection' that extended Exception
03:22GenericUser1put it in package model
03:22GenericUser1then did
03:22GenericUser1(import '(model CantMoveThatDirection)) in my model.clj
03:22GenericUser1keeping CantMoveThatDirection in ./model
03:22GenericUser1no ns for model.clj at the moment
03:24GenericUser1I think I've had enough hacking on this for the time being though.
03:24GenericUser1Thanks for the help. :)
03:24GenericUser1cya.
04:51AWizzArdMoin
04:52AWizzArd~max people
04:52clojurebotmax people is 191
04:52AWizzArdoho :)
05:12elimisteveI think I've found an error but I'm not certain http://pastebin.com/m59b6f7b1
05:13elimisteveAt line 6, "user=>" should have shown up but didn't
05:14Chousukeelimisteve: I guess your erroneous string just confused the reader :/
05:18elimisteveChousuke: yes but I still think I should get the prompt back after the exception, which is what has been happening until this particular error. More here: http://pastebin.com/m1b4c451d
05:22Chousukeyeah, the reader is a bit weird I guess.
06:06esjanybody mind a noob question on lazy sequences and memoization ?
06:06esjif I have the following setue
06:06esj(def base (atom '[1 2 3 4 5]))
06:06esj(defn cumsum [coll]
06:06esj (reduce (fn [o, i]
06:06esj (conj o (+ (last o) i)))
06:06esj '[0]
06:06esj coll))
06:07esjIf I swap! the atom and deref cumsum is the entire lazy sequence reevaluated ?
06:07esjsay, (reset! base (conj @base 26))
06:07esj(nth (cumsum @base) 5)
06:08esjand then, in the case of a memoized cumsum, and the same swap! and deref, what is the behaviour ?
06:11esjtoo early in the am I guess.... wake up America !
06:15adityo~max people
06:15clojurebotmax people is 192
06:21tomojesj: if cumsum is memoized, it will return the cached result whenever you pass in something it's already seen
06:21tomojsince you're passing in a deref'd value, I don't see where the confusion lies
06:21esjwell, I just want to make sure
06:21tomojif you did (cumsum base), and cumsum was memoized, that would be really bad
06:22tomoj(and derefed inside cumsum)
06:22esjyes, I think I understand that
06:22esjin the un-memoized case it does traverse the the entire calculation ?
06:24esjI was just wondering, in the case of the memoized function, where, under the hood, Clojure noticed that @base was different, and hence the output of the function could be different
06:24tomojnaturally
06:24tomojthe memozied cumsum doesn't know it's being passed a deref'd atom
06:24tomojit only sees the value
06:24esjexcellent, this is terrific
06:25tomojI don't think there is any auto-memoization
06:25tomojso if you don't memoize cumsum it will do the full calculation every time
06:25tomoj(as far as I know)
06:25esjyeah, i figured it had to, or else it couldn't do the calculation
06:25tomojclojure can't do automemoization like haskell would in some circumstances because clojure doesn't know whether your function is pure or not
06:26esjthanks for your help tomoj
06:28esjhow about something like (last coll)
06:28esjhow does it know its at the last element ?
06:28esjok, that's a stupid question, I take it back
07:34avital,(+ 2 2)
07:34clojurebot4
07:37shmichaelGood afternoon I'm studying macros and have a question about the fundamentals. I wrote a simple macro that calls a function during macro expansion. I passed to it a parameter-less function, but it did not get called as expected. The code is as follows:
07:37shmichael,(defn j [] 0)
07:37clojurebotDENIED
07:37shmichael(defmacro log [f] (f))
07:38shmichael(log j)
07:38shmichaelI recieve an exception: Wrong number of args passed to: Symbol
07:38AWizzArdand (f) outputs a list?
07:39shmichaelno, a value
07:39AWizzArdYou need to quote that list...
07:39AWizzArdwhat if you do `(f) ?
07:39avitalAWizzArd: I think shmichael wants the macroexpansion of (log j) to be 0
07:39avitalshmichael: What do you get when you run (macroexpand '(log j))?
07:39shmichaelavital, you are correct
07:40shmichaelavital: I still get the exception
07:40avitalI'm not sure why it's treating f within the macro as a symbol instead of as a function
07:43shmichaelIf i do: (defmacro log [f] (j)) then the macro expand behaves correctly
07:44rhickeya macro gets passed unevaluated forms, so (log j) is passed the symbol j
07:45shmichaelIs there a way to "unsymbol" it?
07:46avitalI think eval will work
07:46avitalsomething like (defmacro log [f] ((eval f)))
07:46AWizzArdWhen you have (defn j [] 0) and (defmacro log [f] `(~f)) and then call (log j) ==> 0
07:47avitalAWizzArd: Yes, but the macroexpansion will still return (j) and not 0 as shmichael wants
07:48shmichaelusing ((eval f)) solves the problem
07:49shmichaelAWizzArd, avital, rhickey: Thank you
07:49AWizzArdThen maybe (defmacro log [f] (let [x# ((resolve f))] x#))
07:49shmichaelIs resolve preferable to eval?
07:49avitalAWizzArd: Oh yes, resolve also works, but why not just (defmacro log [f] ((resolve f)))
07:50avital,(eval '(+ 1 2))
07:50clojurebotDENIED
07:50AWizzArdshmichael: eval is expensive and should only be used when you write code at runtime.
07:50avitalAWizzArd: His eval is running within a macroexpansion - it happens during compile time so it doesn't really matter
07:52vyClojure complains that "Wrong number of args passed to: user$eval--2371$fn" for (swap! foo #(rand)) while (swap! foo (fn [_] (rand))) works without a problem. Shouldn't `swap!' allow functions with [& rest] arity?
07:53jdzRFC http://t-b-o-g.blogspot.com/2009/10/brians-brain-on-clojure.html
07:53avitalvy: the second arg of swap! must be a function that gets at least one argument i believe
07:53rhickeyvy: #(rand) is a function that takes no arguments, while (fn [_] (rand)) takes one and ignores it
07:53avitalI think a function defined as #(rand) implicitly has 0 arguments
07:54AWizzArdvy: does (swap! foo #(do % (rand))) work?
07:55vyrhickey: I didn't know #() was counting arguments inside its body. Yup, (swap! foo #(let [_ %1] (rand))) works without a problem. Thanks.
07:55avitaljdz: typo s/cojure/clojure/
07:55rhickeyvy: (fn [_] (rand)) is much clearer though
07:56jdzavital: thanks!
07:59tomojI would say (reset! foo (rand)) is even better
08:59AWizzArdrhickey: when I (deref *my-db*) and do this again, and no operations on *my-db* took place (reads are okay), will then = return instantly true?
09:00AWizzArdthat is, do the Clojure datastructures have some kind of version number under the hood that is used by =?
09:11tomojno version number necessary
09:11tomojthe value doesn't need to know it's the value of a ref
09:16chouserhttp://tinyurl.com/yhgdpyr -- Miditalk, a MIDI REPL from another era by our BDFL
09:19tomojAWizzArd: but it seems list equivalence, at least, is linear
09:20chouserAWizzArd: I believe = on collections starts with 'identical?' so if it's unchanged should be very fast.
09:21chouserno version numbers in collections
09:21AWizzArdok
09:21tomojseems very fast, but not constant time
09:21tomojoh, constant if it's the same value
09:21AWizzArd,(let [x (ref {:a 1, :b 2})] (identical? @x @x))
09:21clojurebottrue
09:21tomojer, identical value
09:22AWizzArdIn my case x may contain some million k/v pairs.
09:22AWizzArdAnd I need a diff. But before running the diff function I would like to see if it is needed.
09:24tomoj= on anything starts with java ==, it appears
09:24tomojso if it's the very same object, it will be very fast, as chouser says
09:24chouserAWizzArd: don't use = then. Start with 'identical?' and if that fails then just do your diff.
09:24tomojno need, I think
09:25tomojclojure/lang/Util.java L19 does this, it seems
09:26chouseryes, but if they're not identical it'll go off on a full walk of the collection looking for a difference (though I suppose it will short-circuit when it finds one)
09:26chouserany work it does there would be a waste, since the diff will have to do it again anyway
09:28tomojah, yes
09:28tomojI had this idea that collections kept some sort of hash or something so that non-identical but same-valued collections could be compared for equality quickly
09:28tomojI wonder where I got that idea, because it seems totally wrong
09:29AWizzArd99.9% of the operations on *my-db* are reads. So, an extremly fast check for equality is helpful. identical? does the job, good.
09:29AWizzArdAnd what is the L19 thing tomoj?
09:29tomojbasically = does an identical? check before it starts crawling the collection
09:30AWizzArdyes, i could use =, but it won't give me more information than a boolean value.
09:30tomojI just meant that = is already fast on identical objects
09:30AWizzArdThe only danger is that they are not identical.
09:31tomojright
09:31AWizzArdwhile a full check is perfectly fine when the map contains a few hundred elements it may not be so nice if it needs to crawl through 5gb of data.
09:31AWizzArdalthough this might average out on 2.5 gb then
09:32tomojdamn
09:33tomojwhat the heck are you doing with all that in memory?
09:34AWizzArdIt's the db.
09:34AWizzArda 12 gb server costs only 100 Euro per month
09:34ambientim wondering if I'm doing something wrong when im implementing my own type-system
09:35AWizzArdWhy should I use a lame sql db system when I can have everything in-ram and in Clojure? :-)
09:35ambientsomehow mixing multimethods and macros could also work
09:35tomojAWizzArd: the D in ACID?
09:35AWizzArdtomoj: full snapshots written on disk + transaction log.
09:36tomojdid you hack clojure's STM?
09:36tomojI didn't think that was possible
09:36AWizzArdWhy hack?
09:36tomojare you using watchers to write the snapshot?
09:37AWizzArdno
09:37tomojwhen, then?
09:37AWizzArdyou can have a (dosync ...) and then deref all your toplevel vars that contain the data.
09:37AWizzArdThis can be done within a millisecond. Then I have snapshots, and one agent can write them out to disk.
09:37tomojsure, but if the plug is pulled after the dosync but before the snapshot is written? :)
09:37AWizzArdClojure supports Multiversion Concurrency Control.
09:38AWizzArdtomoj: transaction log
09:38tomojsame problem
09:38fro0gmaybe slightly OT, but how does the IBM and Sun JVM compare?
09:38AWizzArdsame with the db
09:38AWizzArda relational db system may also have the problem
09:38tomojno, mysql for example is really ACID
09:39AWizzArdi can wait until my data is on disk for a transaction and only then proceed
09:39AWizzArdbut even mysql won't write it out and then check if everything was written correctly
09:40AWizzArdit will pass the data to the disk controller, and when the controller has some time and is in the right mood, it will write out the data.
09:40AWizzArdAfter the data was given to the controller there could be an electrical cut
09:41tomojwell
09:41tomojI don't actually know shit about mysql internals
09:41AWizzArdIf I wanted I can write out to disk, read it back in and see if all arrived and only then proceed.
09:41tomojbut there are certainly some databases that are ACID compliant
09:41tomojno, you can't
09:41AWizzArdyes, mine :)
09:41tomojbecause once the transaction completes, other readers will be able to read
09:41tomojunless you're single threaded?
09:42AWizzArdi don't have to update the main ref
09:42chouserneed a disk sync or close the file between write and read or the OS will trick you
09:42tomojotherwise you've got to have a lock that says "hey you can't read this yet because I haven't made sure it's on disk"
09:42AWizzArdThe db has a version number. The server takes a snapshot and remembers its current version.
09:42AWizzArdThe server operates on the snapshot and only writes data back when needed to the global db.
09:42AWizzArdAll other readers would get the old version.
09:43AWizzArdI can have many snapshots and then atomically update the db when all data arrived on disk.
09:43AWizzArdsnapshotting the whole db will take 1 msec
09:43AWizzArdand this is not needed if the version number is still the same
09:43AWizzArdalso I said, 99% of the operations are reads
09:44AWizzArdAnd those are much nicer with an in-ram db.
09:44tomojyeah
09:44tomojguess you don't need fancy relational crap?
09:44AWizzArdquery language: Clojure
09:44AWizzArdright, I want Clojure objects
09:45AWizzArdI don't say that my usecase is the right thing for every db job out there.
09:45tomojis this open source? :)
09:45AWizzArdBut it works for me.
09:45AWizzArdNo, not yet, but maybe next year.
09:45tomojah
09:45tomojI had one project where I wanted a whole bunch of clojure objects in memory all the time
09:46AWizzArdIt can be nice for *some* apps. I don't say that my solution is the silverbullet and will revolutionize how apps are written. For me it works.
09:46tomojhmm.. though now that I think about it after learning some couchdb, maybe couch would be better
09:46tomojI wonder how far I can push couch's mapreduce without making it explode
09:47tomojmy project is also almost entirely reads
09:48tomojwrites are like a whole bunch twice a year and then a tiny trickle the rest of the time
09:48tomojand for the two big writes a year, no one's reading while that's happening
09:49tomojmaybe I should just keep it all in memory after all
09:49AWizzArdIt's nice in those cases to not send requests over a socket, but instead just doing a hashmap lookup and have the final object delivered.
09:49tomojI wonder, how long does it take to start up, though?
09:49tomojI mean, to read in the db from the snapshot on disk?
09:50AWizzArdThis depends on many factors. If there is just one snapshot, without a transaction log, then the snapshot is read via (read).
09:51AWizzArdThe Clojure reader reads it in and everything is at the right place.
09:51tomojI wonder how long (read) takes to read a GB or so
09:51AWizzArdYou could write a hashmap to disk {1 1, 2 2, 3 3, ...} and try it.
09:52tomojI don't have any spare ram here, I'll try when I get to my bigger computer
09:52tomojyou should write a blog post or something about your system if it's not secret :)
09:57AWizzArdI think in-ram DBs will get more interesting, now that 4gb bars cost just 200 Euros.
09:57AWizzArdEspecially with Clojure it is so very cheap to work with snapshots.
09:58AWizzArdrhickey basically solved the hardest parts of the problem already.
09:58chouserI still think it would be interesting to have a diff algorithm that exploits the internal tree structure of the collections
09:59AWizzArdYesss
09:59AWizzArdsounds very useful
10:00chouserthis has been discussed before. one significant question is what this "diff" would look like -- how to capture all possible values and also describe dissocs
10:02tomojmaybe if I understood the trees clojure uses I would understand why that's useful
10:13chousertomoj: http://groups.google.com/group/clojure/browse_thread/thread/cc316de16fcba6c8/a74e652eb98693ce#a74e652eb98693ce
10:14tomojthanks
10:15rhickeyhack of the week: http://github.com/richhickey/clojure/commit/6362e0f2522c4f7b2b2e626016b291d4832bb58a
10:16rhickeyall host interop uses reflection. but method bodies in defclass* need to do host interop with themselves and instances of their own class, which doesn't exist yet
10:17rhickeyso, first generate a stub class that derives from the same interfaces and has same fields, but does nothing, hint 'this' to the stub, lop off stub prefix in generated bytecode
10:17chouserahaha
10:18AWizzArdhmm
10:18AWizzArdoh
10:18chousercompile-time reflection lives on!
10:18lisppaste8rhickey pasted "look ma, no reflection" at http://paste.lisp.org/display/89293
10:19rhickeychouser: it won't in cinc, but changing the Java was just too much to take on now
10:20rhickeybut note that all of the auto-interface implementing can happen in defclass and deftype macros, not in Java
10:20chouserwould it also have worked to create an object that implements the reflection interface and pretends to be like this stub?
10:20rhickeychouser: you can't because there are no interfaces for the reflection classes (Method etc), nor can you create instances of them!
10:21chousergah. ok.
10:21rhickeythe evils of concrete classes
10:21chouserin that paste you hinted 'this' in toString, but that's not necessary, right?
10:22rhickeyright, not needed just a test
10:22chouserI think you said previously that cinc would use info from .class and .jar files instead of compile-time reflection. Is that still the plan?
10:22rhickeyso the simple name of the class being defined will be an alias for the class being defined, in type hints, instance? etc
10:22chouserah, right, so you can do #^Foo other
10:23rhickeychouser: it will use a Clojure-based representation of type info, disconnecting it from its source
10:23rhickey#^Foo other, and self-type ctor calls will be very important
10:23chouserok, so it might use .class files, reflection, or a stub like this as needed
10:24chouserwell, not exactly like this, but info generated on the fly to solve this problem.
10:24rhickeychouser: exactly
10:25tomojI wonder how many tech talks are as philosophical as rhickey's. enjoying http://www.infoq.com/presentations/Value-Identity-State-Rich-Hickey
10:25rhickeyso all that's left on the Java side is: needed - deal with return type covariant bridges, planned - a true switch construct
10:26rhickeywith the former, definition of deftype and defclass macros can proceed, the latter will be used to optimize field lookups
10:27rhickeybut will be a generally awesome object-based switch, useful with any constant objects like strings/symbols/keywords
10:27chouserthe latter will be a implementation detail performance improvement, so is not blocking progress.
10:27rhickeychouser: right
10:28chouserso does that mean you're nearly out of excuses for avoiding the bridge methods?
10:28rhickeyfirst impls of lookup as simple as: (valAt [k] (condp identical? k :a a :b b :c c))
10:28rhickeychouser: I have the same excuse, pain, but nothing else to do first :(
10:30rhickeydefclass will be so much better than Java at (the better part of) Java
10:34AWizzArdCan I type-hint something as (primitve) bool?
10:34rhickeyboolean
10:34AWizzArdthx
10:46djorkdefclass scares me
10:46djorkit seems like it might encourage people to write Java-style OO in Clojure
10:48chouserif they don't understand how to use the power of multimethods, they'll just use them to dispatch on the type of the first arg anyway
10:49Chousukecan you actually define your own methods with defclass? or just the stuff that the interfaces define?
10:53AWizzArddjork: this OO style is not always very bad. And the alternative would be to use structs and dispatch on a :type slot. But this is not anywhere as efficient.
10:53Chousukedjork: I don't think you need to worry about that. As far as I can tell, you can only define immutable "data packages" and all the operations will actually be defined outside the class (as interfaces or protocols)
10:53djorkso it's more for Java-Clojure interaction
10:54Chousukedjork: so it's not much like java at all. :P
10:54djorki.e. integrating Clojure with existing Java code
10:54chouserno, it's for high-performance Clojure
10:54AWizzArdFor example, if you want to write a tokenizer, then in a production environment it would have to create millions of small token objects. This will be extremly much faster with simple native Java classes.
10:54Licenserwill there be High Availability Clojure te?
10:54Licenserto
10:54AWizzArdwhat chouser said
10:58djorkAWizzArd: I'm not sure I understand. Why would creating a class address that tokenizing problem better?
10:58Chousukedjork: the object will be a lot smaller than a structmap instance.
10:58djorkhmm
10:58Chousukedjork: and thus faster to create
10:58djorkI see
10:59djorkwell I'm all for a better Java than Java, and defclass appears to achieve that, but it just feels like *more Java* whereas the feeling I got from Clojure was *less Java*
10:59ChousukeI don't think it's so much about java than giving Clojure it's own way of defining such simple data structures
11:00Chousukedefclass should be fairly portable to any non-java host too.
11:00Chousukeits*
11:00tomojthe value-identity-state presentation makes me think that representing a directed graph as a bunch of refs which have lists of refs as their children is probably a bad idea
11:00tomojneed to find a good persistent way to represent graphs
11:01steigertomoj: why not use persistent hashmaps?
11:01AWizzArdActually I wrote a lexer and use a Clojure struct. But my tokens are throw-away objects, only needed for the parser. I then exchanged the token struct with a Java class Token and it got a great speedup, because instantiation was much faster.
11:01tomojsteiger: because the graphs might have cycles
11:01steigertomoj: if you ask me, i'd say it's a simple and elegant way to represent graphs. most importantly, simple
11:01steigertomoj: so what?
11:01Chousuketomoj: map of nodes to sets of nodes?
11:01djorkso structmaps are slow
11:01djorkbecause they are generic
11:02tomojso if there's a cycle... it won't work
11:02tomoj:)
11:02tomojmaybe I'm confused
11:03Chousuketomoj: give each node an unique identity that you use as the key?
11:03steigertomoj: {:1 [:2 3] :2 [:1]} . that would be a graph with a cycle
11:03tomojChousuke: yeah I guess that would work
11:04tomojand then you have to look up the data for a node in a separate place I suppose
11:04Chousukeyeah. or you can have {:1 [thenode #{:2 :3}] ...}
11:05tomojoh, and then to get a node's child you just look up the key and take first, I see
11:05tomojoh, except I need data on edges too, hmm
11:06tomoj{:1 [thenode theedge #{:2 :3}] ...} ?
11:06tomojno.
11:06tomoj{:1 [thenode #{[anedge :2] [anotheredge :3]}] ...}
11:07tomojsteiger: simple, eh? :)
11:07Chousukehmm, that's not so easy to look up :/
11:07steigertomoj: modeling graphs in computers needs planning. get a chalkboard and _think_ . it's pretty cool, designing that kind of stuff
11:07tomojpretty easy when persistence isn't desired, I think
11:07tomojI was thinking of finding some papers on graphs in haskell and porting stuff
11:08Chousukeif you need that then {:1 [node-data {:2 edge-data12 :3 edge-data13}]}
11:08AWizzArddjork: struct maps are Persistent and offer a great bunch of features. Java classes don't.
11:08steigertomoj: when i was doing a little graph library, i used {:node1 #{:node2 :node}} .... and i could add data about edges and node using metadata.
11:09tomojhmm, that's an interesting idea
11:10steigertomoj: something like: (def make-graph [graph] (something-to-check-the-entry-is-valid) (something-to-add-the-desired-metadata))
11:10steigerbut, of course, there are tons of other ways to do that
11:10steigerthat = represent graphs ;]
11:11tomojI feel like my node/edge data doesn't really belong in metadata in principal, but it sounds simple to work with
11:11tomojs/principal/principle/
11:12tomojmuch better than the mess of refs pointing to refs pointing to refs I've got now
11:13steigertomoj: yeah, i think refs are unnecessarily complicated to this kind of job
11:13tomojhuh there is a clojure.contrib.graph
11:13steigertomoj: yeah... the approach clojure.contrib.graph uses is quite interesting, have a look
11:13steigerquite creative
11:14steigertomoj: but don't give up, try to develop your own, too. clojure.contrib.graph has it's limitations ;]
11:17duncanmif i wanna have write a GUI project that can build into an executable JAR, but still get to implement it incrementally using SLIME, that means i'll have to write both an ant script and some sort of load script in Clojure, right?
11:19tomojfns for children, creative indeed
11:22ambientduncanm i can develop swing apps perfectly fine with Emacs, just don't add any functionality to terminate the process when the window closes
11:22duncanmambient: and when it comes time to deploy?
11:22ambient*shrug* :)
11:22ambientim sure i can make the whole thing a single JAR in that moment
11:23duncanmambient: do you write all your code in a single file?
11:23ambientdepends, how large it grows
11:23ambienti see no problem in deviding different functionality into their own files
11:24duncanmambient: then how would you load it using emacs, other than writing some load script that calls load-file
11:24ambientyou just call a function like (start-gui) and call dependencies in the file beginning like (ns my.gui.stuff (:use my.gui.stuff2)
11:25duncanmah, that's another way, cool
11:25tomojduncanm: curious, are you using swank-clojure-project?
11:26duncanmtomoj: i don't know of it
11:26tomojyou have clojure-mode?
11:26duncanmtomoj: i do, and i have SLIME
11:26tomojthen you should have either a swank-clojure-project or a clojure-project function
11:27duncanmtomoj: M-x shows me only swank-clojure-import
11:27tomojah, you probably need to upgrade
11:27tomojclojure-project is from the emacs-starter-kit I guess
11:27duncanmoh, i installed it using ELSA
11:27duncanmELPA
11:28tomojwell, if you upgrade, it makes it really easy
11:28tomojyou put all your dependency jars (including clojure.jar and clojure-contrib.jar) into lib/
11:28tomojand all your source clj files into like src/com/foo/bar/baz.clj for ns com.foo.bar.baz
11:28tomojand then swank-clojure-project sets up the classpath and everything for you
11:29tomojunless you like managing the classpath manually, then that would just be annoying, I guess
11:29duncanmtomoj: i think i have the latest version of clojure-mode
11:29tomoj"latest" = from git?
11:29duncanmi think so
11:29duncanmlatest is 1.5
11:30duncanmbut i don't have emacs-starter-kit
11:30tomojoh, swank-clojure-project is from swank-clojure
11:30tomojyou need to update swank-clojure I guess
11:31tomojif you don't use anything besides clojure and clojure-contrib, I guess it provides no benefit
11:32duncanmtomoj: i can't find this, i have the latest swank-clojure from GIT
11:33duncanmahh
11:33duncanmi see that defun now
11:33tomoj\
11:35tomojsteiger: seems if you use metadata you either end up keeping a map with node ids as keys or using a vector to hold the node data anyway
11:36tomojunless maybe you can ask a map to give you a certain key?
11:39tomojif you go with chousuke's representation above, then getting all the incoming edges for a node is slow, you have to search the whole graph :(
11:45ysmolskyi have kinda dumb question. slime gives me cool auto-completition. is there a way to get such functionality for usual clojure edit buffer? i mean abbr works okay and all, but completition for java would be great.
11:47tomojysmolsky: if you figure it out let me know
11:47tomoj:)
11:49duncanmtomoj: i don't get how M-x clojure-project works
11:49ysmolskyi see :)
11:49duncanmit wouldn't let me type at the Project Root prompt
11:51yurastomoj: anyway, are you satisfied with abbr completition you have for clojure atm? ;)
11:52tomojI don't have abbr completion
11:52duncanmtomoj: ahh, i'm using swank-clojure from someone else's github
11:52tomojor if I do I don't know how to use it
11:52tomojduncanm: I use technomancy's
11:52tomojI believe it's swank-clojure-project nowadays
11:52duncanmright
11:52duncanmi have jochu's
11:52tomojif it won't let you type maybe you don't have ido working?
11:53yurasyou should update all kind of modules like, slime, swank-clojure and clojure-mode
11:53yurasactually i make it work when i used clojure-install command from clojure-mode
11:53yurasit downloads all needed deps and configure things
11:55duncanmhmm
11:55duncanmi have emacs 23 on windows
11:55duncanmswank-clojure-project isn't working, or i don't know how IDO works
11:59duncanmtomoj: how do you accept the project root?
11:59duncanmthat's my project right now
12:00duncanms/project/problem/
12:00tomojtype to the root of your project and press enter
12:00tomoje.g. I type ~/clojure/foo-project/ RET
12:00tomojmaybe it doesn't allow you to choose that directory if it's not set up right
12:00tomojyou should have a lib/ and src/ directory at minimum
12:01tomojand clojure.jar (and maybe clojure-contrib.jar) need to be in lib/
12:02duncanmtomoj: enter isn't working
12:02duncanmit's something to do with locate-dominating-file
12:02duncanmRET isn't working
12:04tomojsomeone else had a problem like that before
12:04tomojdidn't hear a solution
12:04tomojI think I have emacs 23 somewhere around here, I'll try it
12:05tomoj(not windows though)
12:07duncanmtomoj: i took out the IDO part and now it works
12:07duncanmmaybe ido-* is broken on windows
12:08tomojsounds terrible
12:08tomojunless you have a replacement, I guess
12:09duncanmhmm
12:09duncanmswank-clojure-classpath's value is
12:09duncanm("c:/Projects/FileMonitor/src/" "c:/Projects/FileMonitor/lib/clojure-contrib.jar" "c:/Projects/FileMonitor/lib/clojure.jar" "c:/Projects/FileMonitor/lib/ij.jar" "c:/Projects/FileMonitor/test/")
12:09duncanmso that's correct - but when i try to load a file (C-c C-l) it still couldn't find it
12:09tomojwhat file did you try to load
12:09tomojalso try C-c C-k instead
12:10duncanmi have src files under "c:/Projects/FileMonitor/src/"
12:10duncanmbut it couldn't see them
12:10tomoja file that defines the namespace foo.bar.baz should be in src/foo/bar/baz.clj
12:10duncanmyeah, i have that
12:10duncanmand it's saying it couldn't find foo.bar.baz
12:11tomojwell, C-c C-l works fine for me, strange
12:11tomojbut try C-c C-k in a source buffer I guess?
12:11duncanmsame deal
12:12tomojC-c C-l works fine without swank-clojure-project?
12:12duncanmyeah
12:12duncanmwell, i didn't use the ns feature before
12:12tomojthat doesn't make sense to me
12:13tomojsince it's doing the same thing it was doing before, swank-clojure-project just sets the classpath... /shrug
12:13duncanmand my listing of swank-clojure-classpath looks correct?
12:13tomojyep
12:13duncanmif i have files c:/Projects/FileMonitor/src/com/example/Foo.clj
12:14ambienti use small text in clj files, like "foo.clj" myself
12:14tomojI wouldn't think that would matter
12:15duncanmhmm
12:15tomojwhat is the exact error when you C-c C-k
12:15duncanmtomoj: if i print out the classpath, it doesn't include my project dir
12:15duncanmuser> (println (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))))
12:15duncanm(#<URL file:/C:/Users/Duncan/.jars/clojure.jar> #<URL file:/C:/Users/Duncan/git/swank-clojure/src/main/clojure/> #<URL file:/C:/Users/Duncan/git/swank-clojure/src/main/clojure/> #<URL file:/C:/Users/Duncan/.jars/clojure-contrib.jar> #<URL file:/C:/Users/Duncan/git/fiji/ImageJA/ij.jar>)
12:15tomojdid you kill your old slime repl before doing swank-clojure-project?
12:15duncanmlemme start from scratch
12:15duncanmsigh, i'll restart emacs
12:15tomojyou need to ,sayoonara
12:16tomojswank-clojure-project wants to start a new repl and a new java process
12:16duncanmdum de dum
12:16duncanmstill no go
12:18duncanmoooh
12:18duncanmi was doing :use, maybe i should use :refer instead?
12:18tomoj:use should be fine
12:18duncanmtomoj: what did you suggest earlier? when i talking about load scripts?
12:18tomojanyway that definitely doesn't matter if it can't even find the file
12:19duncanmoooh
12:19duncanmi see this problem, maybe
12:19duncanmwhen i do C-c C-k, the top of the output says
12:19ambientduncanm i got emacs 23 on windows and i do this in my .emacs: (dolist (d (list "c:/code/clj/penumbra/src" "c:/some/more/stuff")) (add-to-list 'swank-clojure-classpath d))
12:19duncanmcd c:/Projects/FileMonitor/src/edu/harvard/connectome/
12:20duncanmso maybe it's going too deep into the directory tree
12:20duncanmUnknown location:
12:20duncanm error: java.io.FileNotFoundException: Could not locate edu/harvard/connectome/DownsampleImages__init.class or edu/harvard/connectome/DownsampleImages.clj on classpath: (FileMonitor.clj:1)
12:20duncanmahhh
12:20ambientsounds like the problem is in the classpath and how to set it right
12:21tomojand you have a src/edu/harvard/connectome/DownsampleImages.clj?
12:21duncanmyeah
12:22tomojthen your classpath seems fine to me
12:22tomojmaybe swank-clojure is setting it in the linux way
12:23tomojor some other windows problem is happening
12:23tomojI think those libraries are not tested much on windows
12:23duncanm(ns edu.harvard.connectome.FileMonitor
12:23duncanm (:import (javax.swing JFrame SwingUtilities))
12:23duncanm (:use DownsampleImages DownsampleXML)
12:23duncanm (:gen-class))
12:23ambientis it a windows problem when a software assumes that there's a UNIX-like filesystem? ;)
12:23duncanmthat's what i'm doing now
12:23ambienti always use the full name in :use, like amb.synth.engine etc..
12:24hiredmanambient: Yes.
12:24tomojyes, try with the full name
12:24Chousukethe naming isn't very idiomatic either :/
12:24duncanmoooh
12:24tomojyou can use a prefix for having two of them
12:24duncanmokay
12:24duncanmtomoj: so if i have edu.harvard.connectome.DownsampleImages, then that works
12:25duncanmaha, now it works
12:25tomojlike {:use [edu.harvard.connectome DownsampleImages DownsampleXML]) I believe
12:25Chousukeusually a list, but either works
12:25tomojand, yeah, we use lisp-case around here, not CamelCase :P
12:26duncanmseems like the only case that works is the full name, with no spaces
12:26duncanmi don't mind having n lines of :use's
12:26tomojoh, I think it's like
12:26tomojwell, hmm
12:27tomoj(:use (edu.harvard.connectome DownsampleImages DownsampleXML)) should work, right?
12:27duncanmtomoj: i like using lisp-case too, but i can't name my files that way, before DownsampleImages, it was downsample-images
12:27duncanmtomoj: yeah, but that precisely did not work
12:27tomojyou can't name files using hyphens?
12:27gerry_hello
12:27duncanmi supposed i could have foo-bar, but then the filename needs to be foo_bar.clj
12:27tomojwhy not foo-bar.clj?
12:28duncanmtomoj: it wouldn't find it
12:28hiredmantomoj: - is not legal in classnames
12:28gerry_will datatypes support inheritance just like oop?
12:29tomojhiredman: nor package segments?
12:29tomojit certainly is.. clojure.contrib.repl-utils for instance
12:29Chousukegerry_: what would you inherit? the fields? :P
12:29hiredmantomoj: the file is named repl_utils.clj
12:29duncanmambient: so the key thing is not to use setDefaultOperation and make it EXIT_ON_CLOSE?
12:29tomojhiredman: ah, I see
12:29gerry_chousuke: fields and methods
12:30hiredmanclojure maps '-' in namespaces to '_' in file names
12:30tomojgood to know
12:31duncanmnice, now i can do the work in SLIME, and still build it into a jar with netbeans
12:35gerry_Chousuke: if i want add fields to some datatypes been defined?
12:35Chousukehmm.
12:37ambientduncanm yes, i dont do that generally
12:37ambientduncanm instead i make my own window close listener and bind any operations i want to do into that
12:37Chousukewell, the classes won't have any methods, and can apparently only implement interfaces.
12:37Chousukeso you wouldn't be able to use defclass to derive from another class.
12:38gerry_Prototype-based oop such as javascript or Io seems not bad
12:38Chousukeany methods besides the ones the implemented interfaces require, that is.
12:38The-KennyI want a port of CLOS to clojure :)
12:38tomojwhy would we want prototype based oop?
12:38Chousukeclojure already has that anyway :P
12:38Chousukejust put stuff in maps :P
12:39gerry_hmm
12:40ambienti dont just use maps for classes, i also use them for type system :|
12:40gerry_can i just assoc datatype to get new datatype?
12:40gerry_or something like this?
12:49chouseryou could use macros to assemble larger datatypes out of smaller pieces.
12:54duncanmambient: ping?
12:54ambientack
12:55djorkI bet this question has been beaten to death, but: rhickey: what kind of setup do you use to write Clojure code?
12:55duncanmambient: i'm trying to redirect System.out to a JTextArea, and i'm just translating Java code to Clojure, but it's not working
12:55duncanmdjork: he uses emacs and clojure-mode, no slime
12:56ambientduncanm hmm well i've never done that. if it were me i'd just add a function that writes some more stuff into the JTextArea.
12:56ambienti dont know what you're trying to do
12:56drewrdjork: he uses emacs+clojure mode
12:57drewrwhoops, didn't see duncanm's response
12:57duncanmooh
12:57djorkcool
12:57drewrpromise!
12:57djork(glad there's so many rhickey fans in here):)
12:58drewrwhile we like rhickey, we're not so much fans of him as his work (which I think he prefers)
12:59rysI'm a big fan of his hair
12:59rysBut mostly Clojure
12:59arsatikiit must be nice to have a name like his, because then you never feel poor
13:01djorkindeed
13:05KjellskiHi there =)
13:09djorkKjellski: howdy
13:09djorkhow's the learning going?
13:09djorkI have been playing with your bacteria problem
13:10djorkwithout great success, I might add
13:10notallamai don't think i could easily go back to no slime.
13:11Kjellski... still problems with recur... but I´m trying hard... got time to look at a snipped``
13:11Kjellski?
13:11KjellskiIt´s not that easy right?
13:11djorksure
13:11djork:)
13:13Kjellskihttp://paste.lisp.org/display/89304
13:13Kjellski=)
13:14KjellskiMy problem is, that the populate should be called with an initially population and an initial day... like (populate [1] 1) ... but it will never stop... blowing the jvm...
13:14djorkyeah
13:14Kjellskinevermind the doalls in that other function ^^
13:16djorkheh
13:16KjellskiC´mon, tell me...
13:21falkorHi, Here is a silly question from a newbie: How can I execute a LazySeq (ie, make it a IFn)?
13:22KjellskiYou mean, get all values out?
13:22KjellskiThat would be a (doall lazy-seq)
13:22falkorlet me try...
13:23KjellskiBut be carefull with infinite definitions... ^^ they last long...
13:28qedim having some trouble understanding iteration in clojure
13:28qedi see these combinations of loop, recur, inc, dec, iterate, etc.
13:29djork_oops
13:29qedhow do i make the basic example of two nested for loops
13:29djork_Kjellski: out of memory on 100th day
13:30Kjellskidjork : damned ^^ got something running that´s not working... and we need some not stack consuming construction with letfn or so!?
13:31djork_something like that
13:31djork_proper tail-recursion would do the trick
13:31djork_although I ran out of heap not stack
13:31KjellskiJust combine, like (for [a b] (for [c a] ... )) ?
13:31Kjellski@ qed
13:32djork_Kjellski: I think he means nested for loops in another language
13:33djork_like two Java for loops
13:33qedim trying to decrement from 999, and increment from 901
13:33djork_in Clojure for creates a seq
13:33djork_and it also binds multiple seqs to iterate over
13:33djork_,(doc for)
13:33clojurebot"([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], :while test, :when test.
13:33qedit's one of the euler problems where i need to try combinations of multiplying 3 digit numbers
13:33The-Kennyqed: Show an example in some pseudocode.
13:35djork_,([x (range 1 10) y (reverse (range 1 10))] [x y])
13:35clojurebotjava.lang.Exception: Unable to resolve symbol: x in this context
13:35djork_oops
13:35djork_,(for [x (range 1 10) y (reverse (range 1 10))] [x y])
13:35clojurebot([1 9] [1 8] [1 7] [1 6] [1 5] [1 4] [1 3] [1 2] [1 1] [2 9] [2 8] [2 7] [2 6] [2 5] [2 4] [2 3] [2 2] [2 1] [3 9] [3 8] [3 7] [3 6] [3 5] [3 4] [3 3] [3 2] [3 1] [4 9] [4 8] [4 7] [4 6] [4 5] [4 4] [4 3] [4 2] [4 1] [5 9] [5 8] [5 7] [5 6] [5 5] [5 4] [5 3] [5 2] [5 1] [6 9] [6 8] [6 7] [6 6] [6 5] [6 4] [6 3] [6 2] [6 1] [7 9] [7 8] [7 7] [7 6] [7 5] [7 4] [7 3] [7 2] [7 1] [8 9] [8 8] [8 7] [8 6] [8 5] [8 4] [8 3] [8 2
13:35ambientis there any performance difference between (let [foo 1 bar 2] ...) and (let [foo 1] (let [bar 2] ...)) ?
13:35djork_sorry, too many for an example :)
13:36djork_,(for [x (range 1 3) y (reverse (range 1 3))] [x y])
13:36clojurebot([1 2] [1 1] [2 2] [2 1])
13:36qed(loop (for n=999; n < 901; n-- (for k=901; k<=999; k++ ( test-if-this-is-palindrome(n*k)))))
13:36qedi know i dont need that loop, but id like to use special forms instead of for loops
13:36qedlike fn/loop/recur
13:36The-Kennyqed: I think for is the thing you need.
13:36chouserambient: I think those produce the same bytecode
13:37ambientchouser thanks
13:37qedso it will multiply 999*901, 998*902, 997*903, etc.
13:38Kjellskimaybe this works for you? (for [n (reverse (range 901 999)) k (range 901 999)] (test-palin (* n k)))
13:39qedKjellski: where do you close the [
13:39qedbefore the k?
13:40qedoh nevermind
13:40Kjellski;9
13:40qedim getting used to this whole [] thing
13:40qedyou are defining sequences within []
13:40Kjellskiif you need, you could also place some commas in there, they are interpreted just like spaces...
13:40KjellskiThat´s it!
13:41chouser,(loop [i 5, v []] (if (zero? i) v (recur (dec i) (loop [j 5, v v] (if (zero? j) v (recur (dec j) (conj v [i j])))))))
13:41clojurebot[[5 5] [5 4] [5 3] [5 2] [5 1] [4 5] [4 4] [4 3] [4 2] [4 1] [3 5] [3 4] [3 3] [3 2] [3 1] [2 5] [2 4] [2 3] [2 2] [2 1] [1 5] [1 4] [1 3] [1 2] [1 1]]
13:41qedso could i also do: (for [n (range 901 999)] (for [k (999 901)] (test-valid n*k)))
13:41The-KennyI think he could also use the :when keyword
13:42chouserbut you rarely need such nastiness. use 'for' if it'll do for you.
13:42KjellskiWith a range in the k thing?
13:42falkor4argh.... network problems
13:42djorkfor + range = bliss, honestly
13:42djorkI see no need to do it recursively
13:42falkor4Sorry, I just lost track of the previous conversation
13:43falkor4Does anyone has any idea on how to execute a LazySeq?
13:43Kjellski,(doc doall)
13:43clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."
13:43djorkfalkor4: you can use doall doseq, etc
13:43djorkthere's another one that doesn't retain the head
13:44djorkdorun
13:44djork,(doc dorun)
13:44clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can be used to force any effects. Walks through the successive nexts of the seq, does not retain the head and returns nil."
13:44djork(testing...)
13:44djork~dorun
13:44clojurebotPardon?
13:45qedhow do i only print (* n k) when reverse-and-test is true?
13:45qedright now this loop tests those combinations, but just prints a ton of falses for me
13:45The-Kennyqed: Add a :when and the predicate afterwards to the binding-list
13:46The-Kenny(I was trying to suggest this, but emacs doesn't let me copy the text...
13:46KjellskiThe-Kenny : /agree
13:46The-Kennyqed: Like (for [a (range) b (range2) :when #(is-prime? (* %1 %2))] (* a b))
13:47qedwhy the lambda?
13:47The-KennyBecause my fictional is-prime? takes one argument
13:47The-Kennyand for passes both arguments to the fn
13:48somniumyou can also use a let binding before when
13:48somniumit makes it more readable sometimes
13:48falkor4As an example, if I do (let [x (concat '(println) '(1))] (doall x))
13:48falkor4I get nothing
13:48somnium:let [z (* x y)] :when #(is-prime? z)
13:49qedsomnium: this is inside the for loop?
13:49somniumyup
13:49qedin the binding of the foor loop
13:49The-KennyWow, I didn't know :let is supported there. Cool :)
13:49qedfor loop
13:49qedok
13:49somniumclojure's list comprehensions are amazing
13:49somniumdestructuring everywhere to boot
13:49The-Kennyqed: The last thing will only get executed if the predicate after :when is true.
13:50The-Kenny(Forgive me... my english isn't very good ;))
13:52qedokay i think i got this working
13:52qednow the only thing left is, i get it to print all trues, how do i get it to print the output from * n k, when it's true
13:52qedmore :when code?
13:52The-Kennyqed: Show what you have now.
13:52somnium,(doc complement)
13:52clojurebot"([f]); Takes a fn f and returns a fn that takes the same arguments as f, has the same effects, if any, and returns the opposite truth value."
13:52The-Kennyqed: For returns a list. You could just print this sequence.
13:53qed(for [n (reverse (range 100 999))
13:53qedoops, let me pastie this
13:57qed http://pastie.org/private/tfgbeacofcqgfxk8rowiq
13:58qed^^That's what I have so far
13:58qedit prints every instance where reverse-and-test is true
13:58The-Kennyqed: Just remove the reverse-and-test just before the last )
13:58The-Kenny(Just (* a b) in the body)
13:59The-KennyThe last part of the for will get executed for each element where the :when-predicate returns true and the result of the call is added to a list
13:59qedhow does apply work?
14:00qedlike (apply max (for...))
14:00qed,doc apply
14:00clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/doc
14:00hiredman~def apply
14:00The-KennyApply takes a fn and a list and will apply the elements of a list to the fn.
14:00The-Kenny(apply max [1 2 3 4 5 6]) == (max 1 2 3 4 5 6)
14:00hiredmannice
14:00hiredmannginx 404
14:01qedSo what does my for loop return to us then? a seq?
14:01The-KennyYes
14:01Kjellskijap
14:01The-KennyOf the palindromes, if your predicate is correct
14:01qedclojure.lang.LazySeq
14:02hiredman~for
14:02clojurebotfor is not a loop
14:02qedyayyy i got the answer!
14:02qedthanks for your help
14:02hiredman~botsnack
14:02clojurebotthanks; that was delicious. (nom nom nom)
14:02qedlol
14:02qedi think those noms would give us more happiness if they were capitalized
14:02qedNOM NOM NOM
14:02KjellskiAre you solcing challenges?
14:03qedKjellski: yeah
14:03KjellskiOn hacker.org?
14:03qedproject-euler.net
14:03Kjellski=) !Have fun! (=
14:03spuzqed: I thought I recognised that problem :)
14:03qedOriginally I had this really bright idea to just find what 999*999 was, and then descend from there, testing each result decrementing down for a palindrome
14:04qedunfortunately the palindrome i find doing that, is not able to be composed by multiplying 2, 3 digit integers
14:04qedso i had to brute force :(
14:05spuzqed: you can improve it a bit by only testing for each pair of numbers once
14:05The-Kennymemoize! :)
14:05Kjellskidjork: Got something running, also with attention to memory, but it´s just not spitting the right answer for 8 days ...
14:05spuzat the moment you have n = 100-999, k = 100-999, you could have n = 100-999, k = n-999
14:06qedonce i bind n in my for loop, and i use it immediately within the same binding?
14:06spuzyep :)
14:06qedlike [n (range 100 150) k (range n 200)]
14:06qedif i define n in terms of itself will it blow up?
14:06qed:)
14:07hiredmann is not a number there
14:07hiredmann is range
14:07hiredmanand range takes numbers, not ranges
14:07qed"Elapsed time: 2679.445 msecs"
14:08qed(the old way)
14:08qed"Elapsed time: 1347.57 msecs"
14:08spuzhiredman: I'm pretty sure my solution uses exactly that construct
14:08qed(spuz's way)
14:08qedspuz: thanks for that tip
14:08spuzand apparently it works for qed :)
14:08hiredmanah, I see
14:08hiredman(for ...)
14:08spuzyeah, it's not a let :p
14:09The-KennyA tribute to geocities: http://xkcd.com/642/ :)
14:12qedso quick question
14:13KjellskiDamned... just not getting it.
14:13qedhow does :when work there, it says "when" to add (* n k) to the new seq?
14:14KjellskiIt´s just executing the body, ":when" the condition is true...
14:15Kjellskidjork: http://paste.lisp.org/display/89310
14:16qedKjellski: thanks again man!
14:16Kjellskiqed: welcome...
14:17Kjellskiqed: you know, normally somebody is helping me... so this is the least =)
14:18qedhaha, well eventually ill be able to offer something back to the newcomers, but im struggling to keep my head above water right now
14:18qedsome of it seems to make perfect sense, but then other things, that seem like they should be so easy, look so different
14:18qedlet bindings and all of that are very new to me
14:18qedanyway gotta get back to work, lunch is over
14:18qedciao
14:18KjellskiFor me too, and then, for me it´s also my first lisp... ^^
14:18Kjellskivya
14:18Kjellskibye
14:19qedKjellski: same here, first lisp
14:33scottjhow do I change a struct-map into a normal map so I can dissoc?
14:33chouser(into {} m)
14:36scottjsorry, my stupid irssi was messed up and I didn't see that. did you just answer my q?
14:42piccolinoIs there some way in Slime to make the current expression get sent to the REPL? That is, so that it appears in your REPL buffer, and not in your minibuffer?
14:42piccolino(This is with Aquamacs and Clojure).
14:42KjellskiMaybe C-M-X or does it affect your buffer?
14:43Kjellskierr C-M-x
14:43chouserscottj: use 'into' to convert just about anything to a clojure persistent datastructure
14:43chouserscottj: like (into { } other-map)
14:43piccolinoKjellski when I do that command, it tells me the result in the minibuffer (eg, "nil"), but then the function is not defined when I switch to the REPL.
14:44Kjellskipiccolino: it is, if it is a function... but a call will give you the result...
14:44piccolinoHm, nope.
14:45piccolinoNot in "inferior lisp" or "Slime-repl clojure."
14:45KjellskiOkay, sorry... I´m using ClojureBox so maybe it´s something else here...
14:45KjellskiAre you sure you´re doing it on a (defn ... ?
14:45piccolinoYup.
14:46KjellskiForget everything I said. Sorry.
14:46piccolinoOh, how embarrassing.
14:46duncanmhmm
14:46piccolinoI forgot to qualify the function with the namespace when I was in the repl.
14:46duncanmanyone familiar with Swing here?
14:47piccolinoIt does work, thanks Kjellski.
14:47Kjellskipiccolino : welcome =)
14:48ambientanyone know how i can control in Emacs which buffer windows stay unchanged?
14:48ambientit annoys me greatly when a command like C-x C-b (list buffers) changes a random buffer window
14:49ambienti tried browsing emacs wiki but found nothing obvious solution to this
14:50tomojambient: if you find something ping me
14:51tomojmaybe #emacs would be more helpful
14:51piccolinoOK, next question: how can I make a repl use a namespace even though it can't find the file to load the namespace fun? So I don't have to type out everything with the full namespace?
14:52ambient(ns your.namespace) i'd think
14:52ambientat least has worked for me so far
14:52djork,(doc import)
14:52clojurebot"([& import-symbols-or-lists]); import-list => (package-symbol class-name-symbols*) For each name in class-name-symbols, adds a mapping from name to the class named by package.name to the current namespace. Use :import in the ns macro in preference to calling this directly."
14:52Kjellski,(doc use)
14:52clojurebot"([& args]); Like 'require, but also refers to each lib's namespace using clojure.core/refer. Use :use in the ns macro in preference to calling this directly. 'use accepts additional options in libspecs: :exclude, :only, :rename. The arguments and semantics for :exclude, :only, and :rename are the same as those documented for clojure.core/refer."
14:52piccolinoI tried use, it complains it can't load the file.
14:53tomojthen you must load the file
14:53hiredmanpiccolino: well, then you can't use it
14:53tomojor put it someplace so that clojure can find it
14:53hiredmanyou can just create the namespace
14:53hiredmanbut it will be empty
14:53tomojwell you could just (load "/full/path/to/file.clj"), no?
14:54djorkOK so about loading with use
14:54djorkif I have foo.clj
14:54djorkand . in my classpath
14:54hiredmandjork: you already failed
14:54piccolinoOK, "ns" worked, thanks ambient.
14:54djorkoh
14:54hiredman~namespace
14:54clojurebotTitim gan éirí ort.
14:54hiredman~namespaces
14:54clojurebotnamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
14:54djorkwell ok then :)
14:54tomojwhy is it that you can't use single segment namespaces?
14:55hiredmanyou can, they just don't behave well, so I discourage their use
14:55tomojah
14:55Kjellskidjork: there you are... ^^
14:56djorkhey
14:57djorkyeah I'm at work (doing non-Clojure 99% of the time)
14:57djorktrying to squeeze it in for server stuff
14:57KjellskiUrgh, sorry... ^^
14:57KjellskiJust go on ^^
14:57djorkheh it's find I use fun languages anywa
14:57djorkRails, ObjC
14:57djorkmy typing is awful today
14:58notallamais objC a superset of c?
14:58KjellskiBetter than mine, everyday.
15:00The-Kennynotallama: It's used in Osx. Things like classes, functors, message-passing etc. are the features.
15:01djorkObjC is fun. It's like Smalltalk bolted onto C.
15:01djork[foo messageWithArgument:bar andAnotherArgument:baz];
15:01djorklots of typing though
15:01The-Kennyheh, yeah.
15:02duncanmhmm
15:02duncanmi don't think i can bind *out* in the swing EDT
15:02notallamathat's always the way with c-like languages. they're verbose.
15:02djork[[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:[self context] sectionNameKeyPath:nil cacheName:nil];
15:03djork:)
15:03hiredmanduncanm: what do you mean?
15:03The-Kennydjork: don't forget to call release :)
15:04duncanmhiredman: i tried something like (SwingUtilities/invokeLater #(... (binding [*out* out-writer] ....))), but in my click handler, println still goes to the normal stdout
15:04Chousukethe interleaved message send syntax is one of ObjC's good points though :P
15:04duncanmhiredman: but i use (.println System/out "foo"), then it goes to my swing window
15:05hiredmanduncanm: pastebin some code?
15:05duncanmhiredman: sure
15:09duncanmhiredman: http://clojure.pastebin.com/d15eaac29
15:10duncanmhiredman: makes sense?
15:13Chousukeduncanm: I don't think the binding is in effect anymore after you've created the buttons.
15:13duncanmChousuke: so what can i do?
15:16Chousukeduncanm: capture the value of *out* in a local when the click proxy is created and rebind it in the body
15:16hiredmanpass out-stream around?
15:16duncanmeew, that's kinda lame
15:17Chousukeyou can also change the root binding :P
15:17hiredman~url
15:17clojurebotsomething
15:17hiredmanlisppaste8: url
15:17lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
15:17duncanmwhy is it that *out* is not dependant on System.out?
15:17duncanmhiredman: ah, i'll use that pastebot next time
15:18lisppaste8hiredman pasted "binding *out*" at http://paste.lisp.org/display/89315
15:18Chousukeduncanm: because System.out can't be rebound, I guess :P
15:18hiredmanyou can set System.out
15:18duncanmi did
15:18Chousukeyeah, but that's not what I meant.
15:18duncanmbut it doesn't affect println
15:18duncanmi suppose i can keep out-stream in the top-level
15:18Chousukeduncanm: the default root binding of *out* just happens to be System.out. that's all.
15:18Chousukethey're completely separate otherwise
15:18duncanmhow do i change the root binding?
15:19Chousukealter-var-root!
15:19hiredman:(
15:19Chousukeit's safe, and fine, too. as long as you do it only once...
15:19duncanmi can do it in my -main
15:19Chousukeif you build your logic around changing it and then setting it back, you should figure out some other method :)
15:19duncanmi'm not gonna set it back
15:20Chousukeshould be okay, then.
15:21Chousukebut hm
15:21Chousukewhy is your OutputStream proxy calling print?
15:21Chousukewon't that cause a loop?
15:21duncanmoh
15:21duncanmprint is a local fn
15:21Chousukeah, yeah. shadows the global ;/
15:22ChousukeI don't like pastebin's syntax highlighting at all... too low contrast.
15:23duncanm(alter-var-root *out* #(out-writer)) ;; that doesn't work
15:24notallamathere's a "!", i think.
15:24Chousukeit's an alter-style function
15:25Chousukeyou'll want (fn [_] out-writer)
15:25Chousukealso you'll want (var *out)* instead of *out*
15:25Chousukeoops
15:26djorkpastebin is pretty terrible :)
15:26Chousukeanyway, since it's an alter function, you're supposed to use it like (alter-var-root! #'*somevar* inc)
15:27djork(might I suggest http://gist.github.com/ for your paste needs)
15:28Chousukegists are great
15:28Chousukethey actually *highlight* code instead of just colouring it :P
15:29djorkyeah, seriously... I can *check out a paste*
15:30Chousukeheh
15:30Chousukeyou can actually commit too
15:31Chousukeclojurebot started as a gist
15:31hiredmanhttp://delicious.com/clojurebot/pastbin btw
15:31Chousukefull development history exists
15:31duncanmhmm
15:31ChousukeI just cloned it from the gist and pushed it on github at one point :P
15:32hiredmanI was using bzr, and had a script that would copy clojurebot.clj to the git clone of the gist, and commit and push
15:32hiredman:/
15:33Chousukeheh. do you use git nowadays, though? :P
15:33hiredmanyes
15:33Chousukegood. :)
15:34djorkhah hah
15:34Chousukevimperator moved onto hg at one point, and I actually tried to use hg
15:35ChousukeI found the lack of local branches disturbing.
15:35djorkSVN is fine. It's like the Honda Civic of version control.
15:35hiredmanmy dotfiles are all still in bzr
15:35ChousukeI can use git as an SVN client, so SVN is passable.
15:35technomancyhg has local branching now
15:36Chousukeyeah, I tried some extension, but... It just isn't git ;/
15:37Chousukegit lets me do whatever I want with my branches and commits and I kind of like that :)
15:39ChousukeThe hg worldview seems to be that commits and branches exist forever and are indestructible :/
15:39KjellskiBye for today... cya
15:40ChousukeI guess I could have adapted hg to my workflow if I had put in more effort but I finally just ended up importing the hg repo into a git one :P
15:41djorkgit wins whenever there is any question about workflow
15:43duncanmis there a standard technique for processing argument lists that are in the form of a plist?
15:43technomancyduncanm: (apply hash-map args)
15:44hiredman:(
15:45hiredmanyou could just use hash destructuring
15:45duncanmhiredman: yeah, what's the syntax for that?
15:45hiredmanclojurebot: destructuring
15:45clojurebotdestructuring is http://clojure.org/special_forms#let
15:52AWizzArdit's very useful
15:52AWizzArdi also ignored it several months
15:58duncanmsigh, doto doesn't work with set! and fields
16:01djorkhow do you mean
16:08duncanmdjork: you can't write (doto x (set! foo 1)) to mean (set! (.foo x) 1)
16:09somniumhow can you get to clojure metadata from .java?
16:09duncanmoh wait
16:10duncanmnah, you can't
16:11djorkthat doesn't make sense
16:12duncanmit'd be nice to have (doto x (set! .foo 1))
16:19tomojhmm?
16:19tomojsomnium: you can get to clojure metadata from java
16:19somniumI know its possible, I didn't find the right incantation while looking
16:20tomojjust call .meta() on it
16:20tomojyou will get an IPersistentMap back
16:20somniumok, trying to find a way to avoid reflection in a proxy class, that should do it
16:20tomojoh, I thought duncanm was talking to you
16:21tomojduncanm: what would that even mean?
16:22tomojoh, you mean assigning to a public field, I see
16:25djorkslutty types...
16:25rhickeyok, bridge method generation in place for newnew/defclass*
16:25djorkimplement setFoo and (doto x (.setFoo 1)) and you're done
16:32duncanmdjork: not when it's not my own class
16:32Chousukeduncanm: (-> x .foo (set! 1)) :/
16:32djorkew, who designed a class with important public fields... I need to know so I don't accidentally hire
16:33chouserrhickey: woohoo!
16:36stuartsierrachouser: what's woohoo?
16:38cemerickstuartsierra: "rhickey: ok, bridge method generation in place for newnew/defclass*"
16:38cemerickrhickey is rebuilding the foundation while we party in the rafters :-)
16:39stuartsierraheh
16:39stuartsierraAt the rate he's going, he's going to have to call it Clojure 2.0 instead of 1.1.
16:40technomancyhehe
16:45jasappsomnium: thanks for congomongo
16:55skillet-thieftrying to get slime working. I get into an *inferior-lisp* buffer with clojure,
16:55skillet-thiefbut no slime buffer. Am i missing something obvious?
16:56technomancyskillet-thief: did you install via M-x clojure-install or manually?
16:56somniumjasapp: hows it working for you?
16:56djorkskillet-thief: I'm going to guess that this is the second time you're starting Emacs after clojure-install.
16:56skillet-thieftechnomancy: manually
16:56djorkoh, wrong
16:57skillet-thiefclojure-install means going through elpa, right?
16:57technomancyskillet-thief: no, it performs git checkouts for you
16:57technomancyit's orthogonal to elpa
17:00skillet-thiefok, I'm going to try again with clojure-install and come back later. Thanks!
17:02djorkskillet-thief: just pay special attention to the post-install note
17:02technomancydjork: I learned my lesson; the next version will not require so much attention to detail to install. =)
17:02djork:)
17:03djorkit's not so baad
17:03djorkit's quite slick
17:03djorkit's just the note on the first line is easy to miss
17:03technomancyI do get a number of people who miss it though. I think I can do better.
17:03somniumI tried installing the latest but I couldn't figure where it put anything and wasn't in the mood to configure emacs :(
17:05The-KennyMy installation of swank-clojure is a bit fragile... I don't want to touch a file, it could destroy everything!
17:05technomancyjust wait, the next version will be simpler.
17:05technomancyas soon as I can get two hours to myself to finish it. (so maybe around mid-November)
17:05somniumheh
17:06spuztechnomancy: next version of what?
17:06technomancyswank-clojure
17:07djorktechnomancy: yeah I'm a little fuzzy on where it goes
17:08djork(too)
17:13yurasi want to build jsonrpc server using http as transport layer, and im not sure about choosing appropriate http lib for that. will jetty be okay? or should i go with something more simple like one of embedd into jdk http servers? im a bit newbie about java world, came from python :) please advise
17:13hiredmanI wrote an extremely minimal http server for clojurebot
17:14tomojso I think the best representation for my graphs is four maps, from node ids to seqs of outgoing edge ids, from node ids to seqs of incoding edge ids, from node ids to node data, and from edge ids to edge data
17:15yurashiredman: thanks, will check out now... i just dont want to reinvent the wheel and follow idiomatic way of clojure.
17:15tomojwhich is... weird
17:15hiredmanhttp://github.com/hiredman/clojurebot/blob/master/hiredman/http_server.clj
17:15tomojwhen I've used jetty with compojure it's been stupid simple
17:16duncanmis condt the right library to use to get a 'case' macro?
17:16tomojI really don't know anything at all about jetty, and yet I've used it successfully
17:16duncanmi don't see it in clojure-contrib
17:16chouserduncanm: cond and condp are built in
17:16yurastomoj: i know, but isnt to heavy for just simple jsonrpc lib, which is supposed to be easy reused...
17:16duncanmchouser: i want something that looks like case in Scheme
17:17hiredmanhttp_server.clj and factoid_server.clj allow for json queries of clojurebot's factiods over http
17:18yurashiredman: thank you very much, im almost there with your code
17:18hiredmanhttp://www.thelastcitadel.com/lab/clojurebot.html <-- generated by querying clojurebot via json
17:18rhickeycase-like switch thingy coming soon
17:18duncanmrhickey: oh? that's nice
17:19stuartsierraduncanm: condp (built-in) is very close to case; clojure.contrib.fcase is an alternative
17:19rhickeythe case I'm doing will have constant-time dispatch
17:21stuartsierraYeah, yeah, I'll constant-time dispatch YOU. :)
17:21chouser,(condp get :beta, #{:foo :bar} "classic", #{:alpha :beta} "greek", "other")
17:21clojurebot"greek"
17:22chouserduncanm: that's *not* constant-time dispatch, but might be close to what you want
17:23rhickeyScheme case is not guaranteed constant time anyway
17:24rhickeyand yes, the condp example is a good equivalent
17:26hiredmanI've been using (condp = …) a lot
17:33duncanmChousuke, if I use (-> x .foo (set! 1)), what's the syntax for setting .bar?
17:33duncanmi mean, .foo and .bar
17:33Chousukehm, I guess you can't :/
17:33duncanmyeah
17:33Chousukeyou need to make your own macro :)
17:33duncanmi'm always coming up with little syntactic things that i wanna change
17:33Chousukewell, you can :P
17:34duncanmlast time, it was having automatic proxy-ication
17:34duncanmbut rhickey shot down that idea ;-/, oh well ;-P
17:34Chousukeit's almost trivial to make a (set-fields! x .foo 1 .bar 2 .zonk 3)
17:34duncanmright
17:35duncanmi know syntax-rules and E-R macros from Scheme, but i haven't really looked into writing Clojure macros
17:35Chousukeyou just return plain lists of symbols and such
17:35Chousukeusually using syntax-quote
17:36eyerisWhen I evaluate my file via vim-clojure, all of the defns succeed, but the code that actually does something doesn't seem to be run.
17:37hiredmanduncanm: clojure macros are just functions that s-expressions and return s-expressions
17:37duncanmhiredman: sure, all lisp macros are like that ;-P
17:37duncanmhiredman: i just need to sit down and learn it, that's all
17:37eyerisFor example, at the bottom of the file, below the last defn, I can put (+ 1 2). I see the last defn is established, but it never evaluates (+ 1 2)
17:38Chousuke(defmacro set-fields! [object & fields] `(do ~@(map (fn [[field foo]] `(set! ~object ~(list field foo))) (partition 2 fields))) or something
17:38Chousukethough probably has problems with multiple evaluation
17:39Chousukealso I didn't count the closing parens :P
17:41Chousukealso it wouldn't work anyway.
17:41Chousukehm
17:42Chousukemoral of the story: don't write macros in irssi ;(
17:42chouserheh
17:43tomojeyeris: how do you know it never evaluates (+ 1 2)?
17:43eyeristomoj It is never printed in the preview window.
17:44tomojwell, I dunno anything about vim-clojure, but I would be somewhat surprised if it DID print anything
17:44tomojmaybe try (println (+ 1 2))?
17:44eyeristomoj: Why?
17:44maaclAll three Clojure Quicksorts at Rosetta Code (http://rosettacode.org/wiki/Quicksort#Clojure) are broken for large collections. How would one write one that works for large collections?
17:44tomojdoes it print out the result of every single form in the file when you compile something?
17:44tomojthat would be incredibly annoying to me
17:45eyerisYou're missing the point tomoj. It's a repl. The println is implicit.
17:45tomojit's not a repl if you're compiling a file...
17:45rhickeywanted - suggestions for alternative to 'expando' for talking about automatic extensible keys/assoc support for deftype/defclass
17:45eyerisI am not compiling a file.
17:46chousermaacl: broken in what way?
17:46eyerisrhickey: You just want a better name? Or a better implementation?
17:46tomojso, what do you mean "evaluate my file"?
17:46tomojyou're going form-by-form and sending those forms to the repl?
17:46rhickeyeyeris: name :)
17:46eyeristomoj: Nevermind man. This is a vimclojure thing. It works fine from the std repl, when compiling, etc.
17:46chouseraux-keys
17:46maaclchouser: they blow the stack - all use direct recursion
17:47tomojdoes "evaluate a file" in vimclojure mean "send every form in the file to the repl and print its result"? just curious, feel free to ignore me :)
17:47eyeristomoj: Yes, that's precisely what it means.
17:47tomojwow
17:48tomojwhy is that useful?
17:48eyeristomoj: It's useful so that you don't have to startup your program every time you make a tiny change.
17:49tomojI must be confused
17:49tomojI don't ever have to do that and I don't have that feature
17:50tomojoh well
17:50eyeristomoj: do you use emacs?
17:50tomojindeed
17:51duncanmoen thing that always bugged me about clojure is that the functions are read top-down, so I have to always order my functions carefully - is there something i can do so i don't have to do that?
17:51tomoj(doc declare)
17:51clojurebot"([& names]); defs the supplied var names with no bindings, useful for making forward declarations."
17:51duncanmtomoj: so i have to declare everything ahead of time?
17:52tomojI think maybe doing otherwise has unpleasant consequences?
17:52eyeristomoj: I think the emacs/slime equivilent is C-c C-l
17:52tomojmaybe it breaks the conflation of compile-time/eval-time or something?
17:52tomojeyeris: ok, but C-c C-l doesn't print out the result of each and every form in the file
17:52eyerisI'm not sure though. I've never felt comfortable in emacs.
17:53tomojthat's the puzzling part to me
17:53djorkmaacl: they need to be made tail-recursive and use the recur facilities
17:53eyeristomoj: M-x slime-eval-buffer?
17:53djorkI'm still too much of a n00b to do it myself.
17:54AWizzArdrhickey: "inject", "inject-keys"
17:54tomojeyeris: that prints out the result of only the last form in the file
17:54maacldjork: yeah I figured as much, but can really see how to do it since they all need to recur on both parts of the list
17:54tomojwhich, if it's something like (+ 1 2), is 3, yes
17:55djorkyeah, I don't really know the best way to do it
17:55djorkabove my head
17:55tomojeyeris: what does it print out when the last thing in the file is a def(n)?
17:55tomojsomething like "#'foo"?
17:55eyeris#'edu.wisc.uwsc.xlsmerge.gui/build-main-window
17:55maacldjork: same here
17:55tomojyeah, then that is pretty odd
17:56tomojhave you tried putting something that takes a really long time?
17:56tomojas in, maybe it's evaluating it but just not printing it for some reason?
17:56eyerisWhen it works, it's very quick.
17:56AWizzArdrhickey: "introduce", "extend", "grow", "enlarge"
17:57chouserrhickey: we're looking for a noun, right?
17:57eyerisI think it has something to do with the repl server not being able to create a Swing frame, but I don't know because I can't get an error out of it.
17:58tomojwhat do swing frames have to do with (+ 1 2)?
17:59eyeristomoj: (+ 1 2) evals properly when it is before the defns but not after the defns
17:59eyerisAll of the defns are involved with Swing GUI construction
17:59tomojand you're actually calling one of those functions somewhere up there?
18:00eyerisNope
18:00tomojdoesn't make sense that they would hang, then
18:00tomojto me, anyway
18:00tomojuntil they're called
18:01somniumwhat's the most straight-forward .java way to create a PersistentHashMap?
18:01rhickeychouser: something like :meta, for metadata
18:02chouserI like :aux
18:03chouser:extra :bonus :supplementary
18:04AWizzArdbonus sounds funny :-)
18:04Chousukesomnium: RT.map()?
18:04eyerisquit
18:04rhickeyI wonder how fine grained it should be, could just be based on interfaces
18:04rhickey(defclass name [fields] #^{:disable #{Seqable Associative}} [interfaces] & methods)
18:05AWizzArdCan the granularity be configurable?
18:05rhickeybasically there will be several auto-implementd interfaces you need to be able to turn off
18:05rhickeyAWizzArd: what does that mean?
18:06rhickeyhrm, interfaces list not a good place for that, since it might not be present. (deftype [a b c]) perfectly ok
18:07AWizzArdyou said it could just be based on interfaces.. what would be the alternative?
18:07rhickeyoops (deftype Foo [a b c]) perfectly ok
18:08rhickeyAWizzArd: :meta toggles IObj/IMeta, :expando-whatever toggles Associative+
18:08Chousukeso wait, you have both deftype and defclass?
18:08rhickeyChousuke: yes, deftype is a dynamically typed thing (think more powerful structs), defclass is a regular named class
18:09Chousukeah, okay.
18:11rhickeycould also be toggled by presence of explicit methods, but that's tricky since only some might be implemented, overlap between interfaces etc
18:11rhickeyalso, methods not required
18:11Chousukethat sounds like too much magic :/
18:12rhickeysomeone might want a very simple non-extensible struct-like thing without meta/lookup/extension at all
18:22AWizzArdChousuke: :aux or :aux-keys is good
18:23AWizzArdrhickey: yes, exactly such a struct with clojure syntax is what we need
18:42steigerChousuke, rhickey , what is this deftype/defclass about? does it have something to do to contrib's deftype?
18:42hiredman~datatypes
18:42clojurebothttp://www.assembla.com/wiki/show/clojure/Datatypes
18:43hiredmanI think those notes are already obr
18:53defnI need to find the 10001st prime. Anyone have any good lazy prime sieve code?
18:54defnls
18:57hiredmanclojurebot: sieve?
18:57clojurebotExcuse me?
18:57hiredmanclojurebot: the genuine sieve of eratosthenes
18:57clojurebotthe genuine sieve of eratosthenes is http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf
18:58hiredmanclojurebot: sieve is <reply>see the genuine sieve of eratosthenes
18:58clojurebotOk.
18:58LauJensenhiredman, check out cgrands blogpost re the same
18:59hiredmanLauJensen: hey, I kicked my euler habit, so I am not interested in lazy infinite sequences of primes
18:59LauJensenk
19:00defnheh
19:00defnit's a bad habit isnt it
19:01defncgrands post is old though, it uses lazy-cons
19:06somniumhmm, how would I go about calling the JSON parser in contrib from java?
19:06hiredmanyou get a hold of the var
19:07hiredmanso you need a symbol
19:07somniumimport clojure.lang.Symbol ?
19:07somniumgod I forgot how much I hate java
19:07hiredmanVar.find(Symbol.create("some.namespace.qualified.symbol"))
19:07hiredmanthen you need to deref the var
19:07hiredmanv.deref()
19:08hiredmanso you should have an IFn
19:08hiredmanfn.invoke(arg1, arg1, ...)
19:08somniumcool
19:08somniumI may make this mutable spaghetti speak a little clojure yet
19:09somniumany ideas on what kind of object would make a good proxy between struct maps on the one side, and mutable hash-map derivatives with string keywords on the other?
19:10hiredman~def c.l.LispReader
19:10technomancywhat's the converse of nth?
19:11technomancyconverse may not be the exact right word, but given an item and a collection, what's the position of that item?
19:11somniumit needs to be mutable for all nasty side effecty functions called on it by the java api, serialize clojure to json, and return IPersistentMaps to clojure
19:11somniumoffset?
19:13hiredman(get (nth (map vector coll (iterate inc 0)) n) 1)
19:13hiredmanwell
19:13technomancyI thought it was added to clojure core
19:13hiredmanhmmm
19:13technomancyor possibly somewhere in contrib, though I'm not finding it in seq-utils
19:14defnhow do i convert a massive biginteger, into a sequence of integers
19:14hiredmandefn: #euler or something
19:14somnium:)
19:15somniumdefn: treat it like a sequence of integers of course
19:17steigerOH
19:17steigeri was struggling with how to represent some adts (too much choices, no default one)
19:18steigeri'm glad to see the plans to datatypes
19:18steiger*plants to new datatype features
19:27timothypratleyI have some sort of classpath problem but not sure how to resolve it:
19:28timothypratleyuser=> (compile 'sandpit.button)
19:28timothypratleyjava.io.IOException: No such file or directory (button.clj:3)
19:28timothypratley(ns sandpit.button
19:28timothypratley (:gen-class))
19:28timothypratleyIt is finding button.clj to compile it, but then when not happy with the ns declaration
19:29timothypratleyAnd I can't see any reason why
19:51timothypratleyOh hmmm nevermind, no classes directory caused it.
21:03hircus_if I use struct-map to create a new map, is there a way to check which "interface" it implements?
21:03hircus_or is it wholly duck-typed?
21:07tomojhircus_: I was wondering that a couple days ago
21:07tomojit seems the reference to the structmap object is private
21:07tomojso afaik no way to get at it
21:08tomojif you have a reason to care about that sort of thing you should probably put a :type field in the metadata
21:08hircus_tomoj: ah, that's a bummer. true, that'd bloat the size a bit though
21:08tomoj(with the help of a make-foo function or such perhaps)
21:08tomojwell, hmm
21:08hircus_I guess I could gensym the type to make sure it is unique (but that'd make it non-serializable)
21:09hircus_probably ok in this context, actually
21:09tomojif you have (def foo [bar] (with-meta bar {:type 'foo}))
21:09tomojwhen you call foo on two different objects, are their metadata maps identical?
21:10tomojnope, they aren't
21:11tomojthat seems kinda strange to me, I would've expected the map that gets put into the metadata to be the map the reader read, which would be the same always
21:11somniumhircus_: what do you mean what interface?
21:12tomojmy completions on the slime repl suddenly don't work
21:12somniumhircus_: struct definition or interface as in IPersistentMap
21:13somniumhmm, anyone know where a definitive guide to gen class is?
21:13hircus_tomoj: they are identical when I tried it
21:13somniumfound almost contradictory versions on two wikis
21:13hircus_tomoj: user> (= (meta (foo x)) (meta (foo y)))
21:13hircus_true
21:13hircus_somnium: struct definition
21:13tomoj= is not identical?
21:13hircus_tomoj: ah, yes. == returns false
21:14tomojwell, that's because they're not numbers
21:14tomojyou're looking for identical?
21:14hircus_aha
21:14somniumwhy not use a macro to add the meta data automagically?
21:14hircus_so I can use identical? if I want to be anal, and have a private map
21:14tomojso that means every time you make a structmap with your {:type 'foo} metadata you have to allocate that map
21:14hircus_somnium: I'm going to do that, I'm just looking for a form that is small enough
21:14tomojsomnium: why a macro and not a function?
21:14somniumbetter performance would be one argument
21:15tomojI wonder if they'd be identical, then
21:15somniumbut I don't know, you could certainly use a function
21:15somniumfunctions always have to be called, and defstruct involves def so a macro seems appropriate
21:15tomojyeah
21:17tomojstill not identical, but in this case it makes perfect sense to me why they're not
21:19somniumI compiled my gen-class in slime, and no errors, but it couldn't the .class file. So I build it with ant and it blew up right away
21:20tomojaha
21:20somniumand I can't even find a confirmation of the right syntax
21:20tomoj(def foo ((fn [meta-map] (fn [bar] (with-meta bar meta-map))) {:type 'foo}))
21:20tomojI wonder if there's an easier way to do that
21:20somniumyou could comp them for less overhead
21:21somniumno nevermind, youre return a fn, I'm tried
21:21tomojof course this is almost certainly pointless except as an exercise :
21:21somniumthink of the fun it would be to implement that with anonymous class ;)
21:22tomojbut,
21:22tomoj,(let [foo ((fn [meta-map] (fn [bar] (with-meta bar meta-map))) {:type 'foo})] (identical? ^(foo []) ^(foo {})))
21:22clojurebottrue
21:39eyerisThe /api page doens't render properly in FF 3 (neither normal mode nor safe mode) for me. Does it work for anyone else?
21:39tomojyep
21:39tomojbut a couple others have complained of the same problem
21:39timothypratleymostly :)
21:39eyeristomoj what version do you have?
21:39tomojwell, if the problem is that it cuts off half way through or something
21:40ambientit's a firefox bug. sometimes the bottom of the page (or all of it) are black for long lists or pages of text
21:40eyerisRight, that's the problem I am having.
21:40eyerisI have 3.5.3
21:40tomojI dunno my firefox version right now - only have conkeror here
21:40tomojwill check in a bit
21:40ambientusually it works
21:40eyerisambient: It never works for me on the /api page.
21:40tomojsometimes it causes a bug in conkeror too, strangely
21:40tomojbut not a rendering bug
21:41ambient3.5.3 also
21:41ambientworks fine atm
22:03manby-aceis there a way to get a list of the methods that a java object implements from clojure?
22:04tomoj(require '[clojure.contrib.repl-utils :as repl])
22:04tomoj(repl/show the-java-object)
22:04tomojthat's for looking for your own convenience
22:04tomojfor getting a list you can work with programmatically I guess you'd use java reflection or something
22:06manby-acetomoj: thanks very much, that's exactly what I need - just for the repl.
22:07tomojif you're using slime there's a fancier way, too
22:08tomojthough, now when I try it it doesn't show methods, only fields
22:10manby-acecheers - I am - will investigate further
22:11arohneris anyone using a graph / charting library in webapps?
22:11arohnerI need something that will print a graph (like graphviz) to a web page, and haven't found anything good yet
22:12jasappincanter?
22:12arohnerincanter is more of a statistics library, and it uses jfreechart to draw
22:12arohnerAFAIK, jfreechart doesn't have anything for showing a graph / tree
22:14Flox_arohner: JGraph is LGPL since a few weeks: http://www.jgraph.com
22:16arohnerFlox_: interesting, thanks
22:16Flox_arohner: sorry - missed the bit about "web apps". JGraph also have a JS lib called mxgraph, but it is not free.
22:16arohnerFlox_: can it serve a png?
22:18Flox_arohner: I would guess so, but I haven't used it lately (just about 10 years ago, when it was not completely free...)
22:19arohnerFlox_: thanks anyways
22:28Flox_About the Firefox / API page rendering problem: It works if you disable some CSS scripts via the "Web Developer" extension. Alas, I do not yet know exactly which style (combination) causes the effect.
22:30ambientthe bugs appears only like 5% of the time, and usually when i dont have time to debug :)
22:32Flox_arohner: I might soon need to serve some graphs too, so I'd be keen to learn what worked for you! Good luck!
22:32Flox_Good night all!
22:42djorkis there any logic to choosing a namespace?
22:42Licensersomnium: what clojure version do you need for your mongodb driver?
22:43somniumLicenser: Ive been using recent 1.1
22:43somniumdidn't test against 1.0
22:43Licenserah that explains :)
22:43somniumis it broken?
22:43Licenseryes
22:43Licenserbecause clojure/walk does not seem to be there
22:43somniumI have a 1.0, will it not build at all?
22:43somniumreally
22:43somniumwell, it won't be needed shortly
22:43tomojdjork: java standard is to start with reverse domain name
22:43djorkwell yeah
22:44djorkbut what if I don't have a domain name
22:44tomojdunno
22:44somniumwas talking with eliot at mongo today, and almost have a .java proxy class
22:44Licensersomnium: nice!
22:44tomojif your project has a unique enough name it's not so bad to just use it, I guess
22:44tomojcompojure does this for example
22:44somniumhe hacked in an interesting hook, that didn't quite work, but he set me on the right track (I hope)
22:44somniumits a bit of a compromise
22:44Licenser^^
22:45somniumits a mutable thing that can take keywords and handle json
22:45somniumbut its definitely not clojure, mutable like jelly :)
22:45Licenser^^
22:46somniumit will be performant, most db transactions won't alter records, if youre doing number crunching just cast them I guess
22:46somnium(shrug)
22:46Licenser:)
22:47Licenserhmm when I build a jarfire for a clojure project, it won't automatically include all the needed clojure framework files right?
22:49somniumit depends on the build.xml
22:49somniumI try to keep them slim, you could end up with five clojure jars in your lib dir if youre not careful
22:50somniumhe got it so you can put keywords in as values, but that's kind of useless
22:51somniumclojure.walk is sloooow, got to get rid of it, good for macros but not running thousands of little hashmaps
22:51Licenser^^
22:51Licensersomnium: I want to get it work first of all, I don't yet worry about slow or fast
22:52somniumall the tests passed before I pushed, I swear
22:52somniumwill put a note about 1.1 I guess, but I only think two people besides me have tried it so far :)
22:53Licenserwooh so I'm the second beta tester :P
22:53Licensererm alpha tester
22:53somniumpre-alpha tester :)
22:54Licenseromega tester?
22:55somniumgamma at least
22:57Licenserheh
22:57Licenserstill breaking narf
22:57LicenserI guess I also need the mongodb java driver?
23:00Licenserhrm, it's really not easy to get your driver to work somnium :P
23:00Licenserjava.lang.ClassNotFoundException: clojure.core$_EQ___4369 <- not good
23:00LicenserI guess
23:00djorkn00b question: what's the best way to set up a "main" entry point for a clojure project
23:01somniumyeah
23:01somniumbut, its in deps
23:01Licenserfor me it's 4341 in the end
23:01Licenserodd very very odd
23:01somniumLicenser: hmm, you have bleeding edge clojure jar somewhere?
23:01Licenseryes I just downloaded and ant'ed it from github
23:02Licenserthat is what I'm using
23:02somniumgit clone .... cd congomongo... ant -Dclojure.jar=path/to/that/clojure.jar
23:02Licenserbut seriousely i know that isn't a congomongo problem, how the hell did that happen?
23:02Flox_arohner: I just read up on JGraph: The license is now BSD (used to be LGPL for the renderer and proprietary for the layouter, which is now included - see http://www.jgraph.com/forum/viewtopic.php?f=13&amp;t=4472). PNG / headless seems possible (http://www.jgraph.com/pub/jgraphmanual.pdf, pp. 95ff.)
23:02somniumhrmm
23:03somniumwhat error are you getting?
23:03Licenserclass not found: java.lang.ClassNotFoundException: clojure.core$_EQ___4369
23:03Licenserhe does not found EQ
23:03Licenseroddly enough my cloure package implements only clojure.core$_EQ___4341
23:03somnium...
23:04somniumyikes,
23:04Licenseryes I find that very very odd
23:04Licenserbut with recompiling it works
23:04somniumlet me push my clojure jar and see if that works for you
23:04somniumit worked?
23:04Licenseryes
23:04somniumsweet
23:04Licenserbut I wonder, does that mean I've to have the exact smae clojure jar to make other people's jar work?
23:04Licenserthat would be a very new definition of unportable :P
23:04somniumwell, I guess edge isnt very stable
23:05somniumclojure's been moving fast though, always new toys
23:05Licenserbut EQ isn't that new
23:05somniummaybe its an AOT thing? no idea, I can barely read java anymore
23:05somniumhttp://pastie.org/671153
23:06somniumlook at this crap, just to get a function out of contrib to use in java
23:06Licenserheh
23:06LicenserJava sucks, but java sucked before clojure existed :P
23:07somniumtrue, but I wouldn't be writing java now if it weren't for clojure :/
23:07Licenserteehee
23:12Licenserthe one thing that realy makes me cry with clojure are the horribly bad exceptions
23:13Licenserit's as bad as java just a bit worst since you've a gazillion lines of stacktrace :/
23:14Licenservery helpful texts like: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException
23:22Licenserhmm I see another problem but it seems to be a mongodb prolem
23:23Licenserno it's not
23:23Licensersomnium: why is the driver casting integers to floats? :P
23:23Licenserthat is a bugy bug
23:32somnium?
23:33somniumwhat produced it?
23:35tomojif I pass an array of Objects to a java method which is overloaded to accept both Object and Object[], is it possible the Object one is called?
23:35somniumLicenser: did you run the tests?
23:35tomojis type-hinting the way to solve this?
23:36Licensersomnium: if I fetch from my collection he gets float backs and nope, no clue how to o.O
23:37somniumsame as build, just add test at the end
23:37somniumplenty of integers not getting cast over here, can you past what produced the bug?
23:37Licenserahh sneaky
23:40Licensersomnium: all passed
23:40tomojto answer my own question, yes
23:40Licensertomoj: glad we could help *hides*
23:40tomoj:)
23:41tomojI was getting a very strange error on a pretty much direct port from working java
23:42tomojbecause, I guess, clojure can't tell that when you pass an Object[] in, it shouldn't call the method that takes an Object
23:42somniumwtf is up with java exceptions, why won't they just let world end to see what breaks?
23:42tomojin my case that's exactly what they did :)
23:43hiredman,(ancestors (class (to-array [])))
23:43clojurebot#{java.io.Serializable java.lang.Object java.lang.Cloneable :clojure.contrib.generic/any}
23:43Licensersomnium: java exeptions were introduced to toss the russions of the track back in the cold war, sadly the scientist who came up with that plan commited suicide shortly after when he tried to compile some java code and only got cryptic expetions
23:43somniumthis attempt at java has driven me back to netbeans
23:44tomojhuh
23:44tomojhow did that :clojure.contrib.generic/any get there
23:44hiredman,(doc derive)
23:44clojurebot"([tag parent] [h tag parent]); Establishes a parent/child relationship between parent and tag. Parent must be a namespace-qualified symbol or keyword and child can be either a namespace-qualified symbol or keyword or a class. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to, and modifies, the global hierarchy."
23:45tomojoh, I see
23:45tomojI always figured ancestors just meant superclasses/interfaces
23:45hiredman,(doc supers)
23:45clojurebot"([class]); Returns the immediate and indirect superclasses and interfaces of c, if any"
23:45tomoj:)
23:45somniumhiredman: I was able to get to contrib.JSON with your help, but I can't figure out what exception to throw and where to put return on the invoke :(
23:46hiredmanI finally knocked me reader back into shape
23:46somnium,(isa? String "foo")
23:46clojurebotfalse
23:46hiredmansomnium: Exception
23:46somniumI love that
23:46hiredmanreturn on the invoke?
23:46hiredmanoh
23:46somniumyeah
23:46hiredmaninvoke returns an Object
23:46somniumhmm
23:47hiredmanso you have to cast it to whatever
23:47hiredmanIPersistantMap or something
23:47somnium#$%^ ... java
23:47somniumI just need a string
23:47somnium20 locs to call one function and return a string
23:47hiredmanso you are generating json?
23:48somniumyeah, I need to override mongo's json parser
23:48djork,(class "foo")
23:48clojurebotjava.lang.String
23:48djorkwait...
23:48tomoj,(ancestors "foo")
23:48clojurebotnil
23:48tomojhuh?
23:48somnium(class (class "foo"))
23:48somnium,(class (class "foo"))
23:48clojurebotjava.lang.Class
23:48hiredman,(ancestors (class "foo"))
23:48clojurebot#{java.io.Serializable java.lang.Object java.lang.Comparable java.lang.CharSequence :clojure.contrib.generic/any}
23:48djork,(isa? String (String. "foo"))
23:48clojurebotfalse
23:48djorkHAH
23:48hiredman,(isa? String (class "foo"))
23:48clojurebottrue
23:49hiredman,(doc isa?)
23:49clojurebot"([child parent] [h child parent]); Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy"
23:49tomojoh, it's for classes, yes, of course :)
23:49Licenser,(isa? String (new String "a"))
23:49somniumthe docs for isa? and derive were seriously designed to confuse in my opinion
23:49clojurebotfalse
23:49somnium(instance? String "foo")
23:49djorkso "derived" does not mean the instance but the class
23:49hiredmanthere is no type inheritance relationship between the java class String and the String instance "foo"
23:49somnium,(instance? String "foo")
23:49clojurebottrue
23:49djorkok there we go
23:49Licenser,(doc isa?)
23:49clojurebot"([child parent] [h child parent]); Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy"
23:49hiredmanit doesn't say "derived"
23:50hiredmanit says "derive"
23:50somniumhiredman: I understand that only because I understand it
23:50hiredmanwhich is a specific function
23:50somniumnot because it was even remotely intuitive or obvious
23:50LicenserI find that very confusing
23:50somniumits a bit like emacs
23:50hiredman*shrug*
23:50djorkoh well, now I know the difference between isa? and instance?
23:51Licenserisa? does not what you expect, instance? does
23:52hiredmanhttp://en.wikipedia.org/wiki/Is-a
23:52hiredmanit's a technical term
23:53LicenserI still didn't expected that :p
23:53somniumhttp://pastie.org/671207 <- ok I'm an idiot, what do I need to make this compile? its the last line of code
23:53hiredmanif you know the term, you do
23:54hiredmanyou need to return a string in the catch
23:54somniumof course
23:55hiredmanI've been reading and re-reading java a lot lately
23:55somniumits odd that the compiler would find 'println "The world ended."' so satisfying
23:55hiredmanand doing some IFn invoking from java
23:55hiredmanI finally sorted out a big tangle in my reader
23:56somniumI really want to be using gen-class but I can't find any comprehensive examples
23:56hiredmanreally?
23:56somniumwell, I followed to, and the first one was broken, and then I got frustrated and decided to finish this java file
23:56djorkClojure - because it's still faster than Ruby
23:57somniumhiredman: if you could point to any real usage in the wild or examples I would love it