#clojure logs

2011-01-15

10:49rrc7czI got the env var issue resolved. Here's the simple JRebel + Lein (just one line!): http://blog.robert-campbell.com/post/2760935713/clojures-gen-class-and-jrebel
10:53raekrrc7cz: very interesting!
10:55raekrrc7cz: have you posted this to the mailing list?
10:56fliebelWould the best way to move the last element of a vector to the front be (vec (cons (last coll) (drop-last coll))), or am I overlooking something? conj ads to the end.
10:57rrc7czraek: not yet. To be honest I'm not sure I have wrapped my head around the problem as much as I should have, so the terminology/lifecycle stuff might be incorrect. The solution works though, so maybe I will
10:57raekfliebel: vectors are not very good at pushings things to the front, so I don't think there is any better vector-based solution
10:57raekfliebel: have you looked into clojure.lang.PersistentQueue?
10:58Raynesfliebel: Probably. Vectors aren't designed for what you're trying to do there.
10:58raekqueues conj at the back and peek/pop at the front
11:04raek,(-> (into clojure.lang.PeristentQueue/EMPTY [1 2 3]) (pop) (conj :a) (pop) (conj :b))
11:04clojurebotjava.lang.ClassNotFoundException: clojure.lang.PeristentQueue
11:05raek,(-> (into clojure.lang.PersistentQueue/EMPTY [1 2 3]) (pop) (conj :a) (pop) (conj :b))
11:05clojurebot#<PersistentQueue clojure.lang.PersistentQueue@99bf014d>
11:05raek,(-> (into clojure.lang.PersistentQueue/EMPTY [1 2 3]) (pop) (conj :a) (pop) (conj :b) (seq))
11:05clojurebot(3 :a :b)
11:10fliebelraek: And what about stuffing items in at the wrong end?
11:11raekthen you need a deque. Maybe finger trees can solve that
11:12raek(if you only need to add and remove from the same end, then a stack (list or vector) is sufficient)
11:12fliebelI think I'll just stick to my vector.
11:13raekstack: add at A, remove at A; queue: add at A, remove at B; deque: add at A or B, remove at A or B
11:14raekA="first", B="last" *or* A="last", B="first"
11:38cheezeyhow can i catch ^C? (if possible?)
11:42raekthis is what I found: http://download.oracle.com/javase/6/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)
11:42raekyou should be able to pass it a (Thread. #(<do stuff here))
11:55fliebelWhy does the repl call equiv on my object when printing it?
12:11cheezeyraek: thanks
12:15fliebelWooo! I finished my persistent heap! https://gist.github.com/781061
13:24dakronecan anyone speak to the memory efficiency of contrib's datalog database?
13:34fliebelWhat is the CP for the global cake project? I just want to require a script in the current directory.
13:44rrc7czraek: this sucks, it doesn't work after all. It's _really_ weird: the stub class is compiled and reloaded fine. A newly added method will be present and the -fn will be defined. Somehow they aren't connected, however
14:04phenom_which clojure book would people recommend? halloway or fogus/houser? I'm more interested in the entperise application and concurrency domains
14:09rrc7czphenom: it's just my opinion, but I think halloway is a more hands on intro text, while fogus/houser is a good second/third book to help you think the clojure way, more high level topics, etc
14:11phenom_rrc7cz: how about rathore's Clojure In Action?
14:12rrc7czphenom: that was my least favorite. I own all four books
14:13rrc7czI like Luke's book Practical Clojure as a second/third book after Halloway. It's in the same style, but more coverage and detail
14:13rrc7czI think Halloway is still the best intro text. The Luke for more hands on details/coverage and Fogus/Houser for higher level topics
14:14rrc7czthat was my experience anyway
14:15fliebelHow can I make clojure.pprint do more nesting indention? Right now it's doing a few levels of nesting, and then just skyscrapers.
14:27currentBwhat's the best way to get a copy of an object, but without the meta info?
14:28currentB(by object i actually mean anything that could have metadata)
14:29mrBlisscurrentB: something like (with-meta obj nil)
14:33currentBmrBliss: thanks!
14:35tomojnote that there is no need to actually copy :D
14:37tomoj... or is there?
14:37fliebeltomoj: Everything that has meta is clojure is immutable, so I don't think so.
14:38tomojright, there is no need
14:38tomojstrange thing is..
14:38tomoj&(let [x (with-meta [] {:foo 3})] (identical? x (with-meta x nil)))
14:38sexpbot⟹ false
14:38tomojoh
14:38tomojof course
14:38tomojbut the actual data still won't be copied I guess
14:40tomoj&(let [x (with-meta (vec (repeat 1000000 0)) {:foo 3})] (time (when (with-meta x nil))))
14:40sexpbot⟹ "Elapsed time: 0.610729 msecs" nil
14:40tomoj&(let [x (with-meta (vec (repeat 10000 0)) {:foo 3})] (time (when (with-meta x nil))))
14:40sexpbot⟹ "Elapsed time: 0.536794 msecs" nil
15:02replacafliebel: ayt?
15:02fliebelyes
15:03fliebelreplaca: ^
15:03replacafliebel: pprint does it's nesting based on structure and most structures want either the whole element on the line or the lines are broken by subelement
15:03replacabut you can change this by changing the dispatch
15:03replacabrbv
15:03replacabrb
15:32bobo_when using (for can i get the current index or something? so i can alternate a true/false for example?
15:35zmyrgelhi, is it better to use == when testing numbers or just stick with = ?
15:41fliebelbobo_: map-indexed might help you.
15:42fliebelzmyrgel: I'd say == might be a tad faster for numbers, but I don't know, and unless you need it, I'd stick with = for clarity.
15:44fliebelIn other news, I just found out my heapsort is semi-lazy. Crazy applications for that appreciated :) http://pepijndevos.nl/sorting-obsession
15:49zmyrgelfliebel: ok. Well I need all the speed I can get
16:14replacatechnomancy: are you around?
16:45LauJensenIs anyone familiar with a JTable alternative which more freely supports embedded progressbars, checkboxes, buttons, etc etc
16:47bobo_LauJensen: http://blogs.sun.com/geertjan/entry/outlineview_sample maybe? if i remember correct it exists as a standalone jar, so you dont need the entire netbeans paltform
16:48bobo_not sure about progressbars, but cant se why it shouldnt work
16:48LauJensenThats an extended treeview, not JTable
17:12timmcWhoa... let* doesn't provide destructuring bindings?
17:12bmhHow can I access the request object from within a compojure route definition?
17:23gfrlog,(doc let*)
17:23clojurebotexcusez-moi
17:24companion_cubewhy does clojurebot speak french ?
17:24companion_cube,(doc fn)
17:24clojurebot"([& sigs]); (fn name? [params* ] exprs*) (fn name? ([params* ] exprs*)+) params => positional-params* , or positional-params* & next-param positional-param => binding-form next-param => binding-form...
17:25companion_cubeso it's only for special forms ?
17:38LauJensenIts my understanding that LGPL does not consume its host project as the GPL does - Correct?
17:38LauJensen(I know I should ask a lawyer, but anyway...)
17:40timmcLauJensen: I believe that is true, as long as you are only linking against it/calling it/etc.
17:40seancorfieldLGPL allows a library to be bundled without imposing LGPL on the whole bundle
17:43LauJensenPerfect, thanks guys
17:44UawdalIs there a built-in function to split a string at every instance of a certain character?
17:45LauJensenUawdal: (.split "h/e/y" "/")
17:45LauJensenThat returns a java array of ["h" "e" "y"]
17:45LauJensen&(vec (.split "h/e/y" "/"))
17:45sexpbot⟹ ["h" "e" "y"]
17:46UawdalAh cool, thanks LauJensen
17:46LauJensenFor those of you who have seen the awesome quaqua kit, is there an alternative available somewhere, which does not have the Apple restrictions imposed on it?
17:47tomojUawdal: there's also one in contrib
17:47tomojoh, wait, it's in core now
17:48tomoj&(doc clojure.string/replace)
17:48sexpbot⟹ "([s match replacement]); Replaces all instance of match with replacement in s. match/replacement can be: string / string char / char pattern / (string or function of match). See also replace-first."
17:49tomojoops
17:49tomoj,(clojure.string/split "h/e/y" #"/")
17:49clojurebotjava.lang.ClassNotFoundException: clojure.string
17:50tomojwell, it works
17:50tomojseems strange that it requires a regex
17:56bmhany compojure/ring users out there?
17:57tomojhave a question? just ask it
17:57LauJensentomoj: Java says (.split string regex) or (.split regex string) - clj.string uses the latter
17:57tomojyeah
17:58tomojI guess you can't support both with one function without reflection?
17:58bmhLauJensen: What seancorfield said about the LGPL is misleading. The GPL and LGPL attach with regards to linking, not distribution
17:58LauJensenbmh: How so?
17:59LauJensentomoj: sure you could
17:59bmhLauJensen: If I sent you a gzip file containing some LGPL source and some "all rights reserved" source, the fact that they were 'bundled' together is really irrelevant
18:00LauJensenk
18:01bmhIf it really matters, talk to a lawyer. This stuff gets muddy fast.
18:01LauJensenbmh: I am well aware, thanks
18:03bmhback to compojure: I want to access the request object from within defroutes
18:03UawdalThat's even simpler, thanks tomoj!
18:04seancorfieldbmh: 'linking' is open to some interpretation given the way LGPL is used on software these days that doesn't have an actual linker associated but i admit bundling was a loose term
18:04tomojUawdal: well..
18:04tomojyou have to require or use clojure.string
18:05tomoj.split works anywhere
18:05tomojbut an array-backed vector is nicer than an array
18:06Uawdalyep. I don't mind the require if it makes the code itself simpler
18:10bmhseancorfield: I think the next project I do, whatever it is, will be unlicensed. The edge cases and interactions between the whole zoo of licenses is just painful.
18:23dalejava.io representing EOF as -1 makes it kind of ugly to write a (case) for both EOF and which char was returned from (.read a-reader).
18:46UawdalAnyone know if tail recursion made it into jvm 7/8?
18:47mhi^zakwilson: You've convinced me of Clojure. ;]
18:47zakwilsonmhi^: glad to hear it [this is a continuation from another channel, for anyone else]
18:49dnolenUawdal: seems unlikely. in the meantime you can use lazy-sequences, trampoline and recur
18:51UawdalMy searching on invokedynamic shows a bunch of different people saying invokedynamic wont help all that much. Why'd they bother with that over tail calls?
18:51daleHow do you append an element to a list?
18:52companion_cubein general, do people who use clojure also use statically typed languages like scala ? or is it kind of uncompatible ?
18:52zakwilsonIs my impression correct that Moustache is more popular, or at least growing faster than Compojure?
18:53daleI guess (concat '(a b c) (cons 'd)) will work.
18:53daleOr (cons 'd nil) rather.
18:54zakwilsoncompanion_cube: I also use Haskell. I may also learn Scala to target Android because Clojure's performance on Android is still not very good as far as I know. From what I know of Scala, I would almost always prefer to use Clojure.
18:55companion_cubewell, it's different way of thinking
18:57zakwilsoncompanion_cube: Yes, it is, and I have sometimes missed static types in Clojure after using Haskell, but I've also ported a project from Haskell to Clojure because, among other things, the type system made it annoying to do what I wanted.
18:58zakwilsonMy other issues were that Haskell didn't do incremental compilation very well, and Clojure's map implementation is faster.
18:58UawdalI quite like Scala. I lean towards clojure mainly because I like small languages: Scala feels heavy next to clojure. But I could actually see my coworkers learning Scala, whereas Clojure scares people (unfairly) with the lisp syntax.
18:59companion_cubedo projects using both languages exit ?
18:59zakwilsonGet better coworkers.
18:59companion_cubeexist*
18:59zakwilsonI'm sure somebody somewhere has a project. I don't know of any though.
19:00zakwilsonI have a project that uses both Clojure and Haskell. There's just nothing like Parsec when you want to transform some structured text.
19:02companion_cubethere are parser combinators in scala too ;)
19:02Uawdalcompanion_cube: You can have both in a project, but they generally can't call each other directly. You would probably need Java inbetween, as they both talk to Java quite easily
19:03companion_cubesurely
19:03companion_cubethe problem would be for deployment, makes lots of .jar :)
19:04UawdalYeah. Both can be built with Maven, which could automate that somewhat
19:12zakwilsoncompanion_cube: somebody was working on a Clojure port of Parsec too.
19:23timmcIs there some reason I can call a self-recursive function in file A from file B, but not from later in file A?
19:26timmc(Different namespaces for the two files, and using (defn ...) for the functions.)
19:26nicknackHi all. I have a (probably stupid) question about primitives and 1.3:
19:27nicknackPeople seem unhappy about exception rather than promotion being the default. If Clojure is already catching overflow to throw an exception, why can't we jump into an alternative compilation that allows for promotion instead?
19:39timmcLemme see if I can get a simplified example.
19:39timmcLemme see if I can get a simplified example.
19:49timmcAugh, can't reduce it.
20:27dabdHow to import several classes from a Java package at once with 'import'? thx
20:29dabdwithout explicitly enumerating them...
20:30dnolendabd: no possible
20:30dnolens/no/not
20:30sexpbot<dnolen> dabd: not possible
20:30dabdI have a bunch of classes generated from WSDL files and it is a pain to list them all...
20:31timmcdabd: Is each one explicitly referred to in your code?
20:31dabd not all in the same file
20:32timmc(never mind, silly question)
20:34timmcIn other news, I'm still getting this darn "java.lang.IllegalStateException: Var timmcHW1.spatial/mondrian-oriented is unbound."
20:41timmcI have (defn mondrian-oriented ...) which is self-recursive, and (defn mondrian ...) below it. mondrian-oriented used to be called directly from another file, and there were no issues. :-(
20:41timmcAnyway, what do I need to do to get self-recursion in Clojure?
20:44tonyltimmc: that exception, do you call mondrian inside mondrian-oriented?
20:45timmcNope. mondrian calls mondrian-oriented with an extra argument.
20:45tonyland you get that exception after you compile the namespace?
20:46timmcCompilation works fine.
20:46timmcThis is a runtime error.
20:47timmcClojure 1.2.0, using Leiningen for building.
20:47timmchttp://lab.brainonfire.net/drop/mccormack_t_HW1.tar.gz <-- If you're curious. There's not a lot of code, and src/timmcHW1/spatial.clj is the file in question, used by gallery.clj, which is used by core.clj.
20:49tonylinteresting usually that exception comes up when a symbol is declared but not bind to a value
20:54tonyli think (defn mondrian-oriented ...) has an extra parenthesis at the end, it should be 6
20:55timmcBut how would that...
20:56tonylI was thinking a missing paren since it would make the defn not ended, but yeah and extra paren would not do that
20:56timmcUnless another earlier function has too few?
20:57tonylmaybe
20:57tonyli am looking
20:57timmctonyl: Woah! I think that's it.
20:57tonylthe extra parenthesis?
20:58timmcbounded-random had too few parens
20:58tonyloh nice, those are hard to fine
20:58timmcUgh, I need to stop using gEdit for sexp languages.
20:58tonyli need to set up my text editor to color match those parens
20:58timmcIt's just so lightweight!
20:59tonylyeah i like it too
20:59timmctonyl: Thanks for your help. I can finally move on to my logic bugs now. :-P
20:59tonylthose are the fun ones :P
21:01timmctonyl: You know why my reduction didn't work? Every time I deleted functions and emptied out the bodies of others, I would always end up with balanced parens. >_<
21:01tonylhehe
21:02tonylit happens
21:03timmcSo... why did it compile, if mondrian-oriented was declared inside another function? Does defn put stuff into the top-level scope?
21:05raekyes
21:05raekunlike 'define' in Scheme
21:05timmcfantastic
21:06timmcby which I mean AAIIEEEE
21:06Scriptortimmc: afaik, defn is just combining def and fn
21:06timmcAnd now I have a reduced testcase that demonstrates this.
21:07Scriptorwait, never mind
21:07Scriptordefn *always* puts the function in the top level scope?
21:08pdk`if you need to create a function in a local scope
21:08pdk`you could use stuff like letfn
21:09timmcScriptor: That's what I'm seeing.
21:27timmcOK, I put up a minimal testcase that shows the "bug": http://www.brainonfire.net/blog/parens-defn-hoist-runtime-error-clojure/
21:34timmcHopefully the next person to Google that error string in frustration will hit my blog post and be enlightened.
23:47phenom_so what's the best clojure ide ?
23:47phenom_emacs ?
23:48Mimisbrunnrphenom_: emacs is the best ide
23:49Scriptorand operating system :p
23:49Mimisbrunnrhear hear
23:49Mimisbrunnrphenom_: use what you are most comfortable with that supports clojure. Emacs is nice because of SLIME
23:52timmcI wish I could use Emacs' hilighting and indenting and whatnot in a regular GUI with modern keybindings and menus.
23:52timmc("modern" not being a slight towards Emacs here)
23:52Mimisbrunnrmodern keybindings?
23:53timmcC-c for copy, etc.
23:53Scriptoris Emacs' highlighting and indenting that good?
23:53MimisbrunnrScriptor: yes
23:53timmcScriptor: Yeah, compared to everything else I've enountered.
23:53Mimisbrunnrtimmc: you can change them to that
23:53timmcMimisbrunnr: That would require learning how to configure emacs.
23:54Mimisbrunnrtimmc: you aren't using emacs until you are configuring it =P
23:54Scriptorhmm, learning new keybindings isn't all that hard
23:54timmcSure it is.
23:55Mimisbrunnrtimmc: what do you usually edit with?
23:55Scriptorafter enough time it becomes natural
23:55Scriptorat least, that's what happened with vim :)
23:55timmcMimisbrunnr: gEdit.
23:55MimisbrunnrScriptor: it's the "enough time" part that is' a bit
23:55Mimisbrunnr*bitch
23:55timmcIt is lightweight and convenient.
23:56Mimisbrunnrhow do you do editing without a gui?
23:56timmcEclipse has a decent Clojure plugin, but Eclipse wants to be a full Development Environment, not just an editor.
23:56timmcMimisbrunnr: I rarely do. Sometimes vim, usually nano.
23:56Mimisbrunnrahh
23:57ScriptorMimisbrunnr: editing without a gui is pretty easy, especially since a lot of terminals provide good integration with the mouse and the clipboard
23:57Mimisbrunnrthat would be my problem with gEdit. I usually don't have a gui and generally switch systems enough that Gnome is everything but portable