#clojure logs

2009-12-18

00:20scottj_Am I missing something or does clojureql not have an equivalent of limit?
00:21polypusdoes the order of definition of defmethods have any effect on dispatch?
00:28alexykhow do you compare strings?
00:30alexyk,(< "a" "b")
00:30clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
00:30kylesmith,(.compareTo "a" "b")
00:30clojurebot-1
00:31alexykthx!
00:32alexykwhere does compareTo come from?
00:32alexykah, ok .
00:33chouserpolypus: no, I don't think so.
00:33chouserpolypus: if there's any ambiguity, it must be resolved with 'prefer'
00:34alexykI compare pairs of form [string vector], by longer vectors first, then ties broken by alphabetic order of strings. This works but is ugly: (sort (fn [[k1 v1][k2 v2]] (let [len1 (count v1) len2 (count v2)] (if (> len1 len2) true (if (< len1 len2) false (.compareTo k1 k2))))) coll) ; ways to improve?
00:34polypuschouser: ty
00:38chouseralexyk: did you try a default sort?
00:39alexykchouser: it does the opposite: by keys and small lengths
00:39chouserah
00:39alexykI'd reverse it. but then alphabetic order is broken
00:39chouseryes
00:43chousermaybe (sort (fn [[k1 v1][k2 v2]] (let [len1 (count v1) len2 (count v2) c1 (compare len1 len2)] (if (zero? c1) (compare k1 k2) c1))) coll)
00:43chouserhardly better though, if it even works
00:43alexykchouser: cutier
00:46chouser(sort-by (fn [[k v]] [(- (count v)) k]) coll) ?
00:48polypus,(doc prefer)
00:48clojurebotI don't understand.
00:48chouser,(doc prefers)
00:48clojurebot"([multifn]); Given a multimethod, returns a map of preferred value -> set of other values"
00:48chouser,(doc prefer-method)
00:48clojurebot"([multifn dispatch-val-x dispatch-val-y]); Causes the multimethod to prefer matches of dispatch-val-x over dispatch-val-y when there is a conflict"
00:48chouserthere it is. sorry.
00:49chouseralexyk: you saw that sort-by?
00:49chouserbiab
00:49alexykhah
00:49polypusno worries. i was wondering about the conflict bit. are you explicitly told by clojure aout conflicts?
00:50polypuss/aout/about
00:50alexykinteresting -- will try after re-vectoring seconds, they were seqs and it takes forever for counts to get retaken every time
00:58defnhow do you use 1.1.0 with technomancy's swank?
01:10scottj_defn: copy it to ~/.swank-clojure/clojure-1.0.0.jar I think
01:11defnwish there was a way to choose
01:11defnor a var to set
01:36chouserpolypus: yes, Clojure will complain when a multimethod is called if the dispatch result is ambiguous.
01:48alexykis ArraySeq usually counted?
01:50alexykI did (->> ... (frequencies) (sort) as the second component above, and it takes forever to sort with my comparator above taking (count <of that>). Should I have added ... (vector)?
01:51alexykWithout (vector), the type is ArraySeq; with (vector), it's PersistentVector. On both toy examples say counted? => true. I wonder what happens when they come from lazy data.
01:51alexykI have 3.5 million pairs with those seconds, and it takes more than an hour already to sort.
02:06polypuschouser: ty
03:07defnis freenode still acting weird?
03:40triyoI see there is a bean function, is there a to-bean function of some sort that does the opposite?
04:01LauJensen1triyo: Did you look in contrib, there's a jmx module I think
04:02LauJensen1http://github.com/richhickey/clojure-contrib/blob/master/src/clojure/contrib/jmx.clj
04:03triyoLauJensen1: hmm, that mbeans. :)
04:04LauJensen1oh, sorry
04:04triyono wrorries
05:45octei was looking at http://github.com/richhickey/clojure/blob/1.1.x/changes.txt but i don't see anythign about defmulti.. didn't the signature for it change?
05:45octebetween 1.0 and 1.1
06:07triyoI'm confused, when is the right time/place to use the "do" form?
06:12fanaticowhen you're calling a function for its side effect, and want to return a different value.
06:13Raynestriyo: In places like an if expression, where you want to call functions for side effects, but want to return a different value than the one those functions return.
06:15triyofor example like this snippet: http://gist.github.com/259443 its nothing but full of side-effects... should there be a do there
06:15Raynes,(if false 3 (do (+ 2 2) (* 3 3) 5)) ; Useless example.
06:15clojurebot5
06:16triyoRaynes: if expression is the only place where I do know how to use it and where it makes sense
06:16RaynesIf I don't /have/ to use it, I don't.
06:17triyoRaynes: for example, would you use it in my snippet gist above?
06:18triyoaround the doto all way to the end
06:18RaynesNope.
06:19triyook, thats the same feeling I had.. just trying to make sure I don't use it unnecessarily.
08:25fliebelWhy doesn't Clojure have objects?
08:26fogusIt has objects all over the place ;)
08:28fliebellike?
08:29fogusDo you mind rephrasing the question? Do you mean to ask why it's not object-oriented?
08:29fliebelYou mean because every seq is in fact a java class?
08:29fliebelyea, that is more or less what I mean
08:31fliebelI understand it's not good from the functional immutable point of view, but I guess it would make java interop a lot easier.
08:33karmazilladot-syntax is simple, calls into java are wrapper free, and it's easy to implement interfaces with proxy
08:33fogusRH has talked about this in many places, so I probably would not do him justice in paraphrasing. However, the basic point is that traditional OO is not conducive to concurrent programming.
08:34fogusfliebel: What do you see as the hard points on interop?
08:36fliebelfogus: Nothing specific… It's just that for me it's a pain to work with those java libraries. And since Clojure has almost no stdlib on its own, for almost any non trivial task you would have to do some java stuff…
08:39fogusfliebel: Without knowing your problem-space it's tough to know how interop is failing you, but I do not agree that interop is required outside of toy problems. There are countless examples of very tough problems solved by Clojure core libs alone.
08:41fliebelfor example, this simple command: Runtime.getRuntime().exec("ls") translates into (.exec (java.lang.Runtime/getRuntime) "ls") and then I still have to find out how to create a reader to get the output…
08:42fogusfliebel: Maybe I'm being dense, but I'm not sure how Clojure being OO helps in this case
08:43fliebelfogus: not in this case, but then I never tried to write a Clojure applet…
08:43karmazillafliebel: there's shell-out in contrib
08:44fogusWhat he said ^^^^^^
08:45fliebelkarmazilla: I know...
08:46chouserI think Clojure not being object *oriented* is more about the idiomatic way to solve problems than it is about the lack of any particular feature.
08:47fliebelOkay, it might be a bad idea to go oo, but I do think java interop is a pain, at least for me it is.
08:49karmazilla"Runtime.getRuntime().exec("ls")" is more about Java inter-operating with C, isn't it?
08:51karmazillaso it's more like Java being a pain (and this pain leaking through in Clojure) than Java interop per se.
08:53fliebelkarmazilla: that might be part of the problem...
08:57fliebelbut why can't it be like ((java.lang.Runtime.getRuntime) exec "ls"), or whatever… just some more java-ish(without changing order and thinking about dot vs slash.)
09:01fogusfliebel: Clojure as a Lisp follows the prefix notation -- in the case of interop that function position is a method. It's a uniform syntax
09:04RaynesClojure isn't supposed to be 'javaish'.
09:04RaynesIt's quite a bit Clojureish.
09:17murbankDo chunked sequences make expressions no longer strictly lazy? So (take 5 (expensive-io-function-returning-seq)) might make more expensive io evaluations than strictly necessary?
09:25chousermurbank: possibly, but it's generally controlled by the seq-generator.
09:25chouserso if expensive-io-function-returning-seq knows it is expensive and laziness is important, it can simple return a non-chunked seq and all is well.
09:48murbankchouser: Are new "primitive" sequences chunked by default?
09:49chousermurbank: only a few are so far. seqs of vectors being the most notable. also 'range'
09:51murbankchouser: But the intention is that many more are to be added right?
09:51chouserI'm not sure. I wouldn't expect line-seq to go chuncked, for example. But I don't know of any specific plans one way or another.
10:14fliebelWhat is the correct way to send off some function for which I don't care about the return value? I guess it's something like an atom, agent, ref, whatever, but I don't really understand those.
10:22chouserfliebel: perhaps 'future'
10:23rhickeyyes, future, just ignore its return
10:25fliebelthanks
10:36rhickeyyay
10:36stuartsierrareadme typo: missing colon after "To Run"
10:39chouseralso in readme, under Futures "They are away" should be "a way"
10:39stuartsierrachouser: you mean changes.txt, right?
10:40chouserer. right.
10:41stuartsierrarhickey: mind if I fix up the formatting in changes.txt? Stuff like breaking lines at 70 characters.
10:42rhickeystuartsierra: no, go ahead, thanks
10:42stuartsierraok
10:48rhickeystuartsierra: could you also add that add-watcher and remove-watcher are gone, but can be implemented in terms of add-watch and remove-watch?
10:48stuartsierrarhickey: sure
10:48rhickeythanks
10:49chouserRepl and Script are missing from Deprecated
10:51stuartsierrachouser: ok, will mention that too
11:07stuartsierraCan I associate a commit with multiple tickets?
11:11chouserI think so. Just list them all in the commit msg
11:11stuartsierraok
11:12stuartsierrarhickey: done, #229 ready to test
11:55efarrarhello
11:55rhickeystuartsierra: your patch file seems to include some of my patches
11:56stuartsierraoh, drat, I patched from master, didn't I
11:56rhickeyah, yup
11:56stuartsierraok, trying again...
11:56rhickeyI've touched 1.1.x, so make sure you have the latest
11:57stuartsierragot ti
11:57stuartsierragot it
11:58stuartsierrarhickey: ok, new patch up
12:04rhickeystuartsierra: applied and pushed - thanks!
12:04stuartsierraYou're welcome!
12:41cemerickstuartsierra: I must be missing something about the complexity of integrating JUnit <-> clojure.test. Isn't it just a matter of generating one JUnit testcase that straps up clojure.test?
12:43stuartsierracemerick: If you only want a single pass/fail for all your Clojure tests, yes.
12:44cemerickoh, you're aiming for full correspondence in the resulting report
12:45stuartsierraOtherwise, what's the point?
12:46cemerickwell, the OP in that thread was just looking to have the clojure tests invoked as part of the default test run. I didn't think proper correspondence was an objective.
12:46stuartsierraI suppose so.
12:46chouserI'm useing clojure.test inside a junit suite in clojure
12:47stuartsierrachouser: how?
12:47chousertop-level java file for the annotation stuff
12:48chouserthen a macro that does gen-class for one junit test per clojue.test fn
12:48stuartsierraAh, I see.
12:48chouserthe reports aren't terribly pretty
12:48chouserI've been hoping to look at the new junit stuff for clojure.test
12:48stuartsierraIt's in 1.1; haven't played with it much myself.
12:48cemerickI guess I have really low expectations for test reporting. :-)
12:49jasappdoes anyone know if there is anything like CL's hyperspec-lookup for clojure?
12:49the-kennyjasapp: (doc fun)
12:50stuartsierraNot quite the same.
12:50stuartsierraThere's a javadoc lookup function in contrib.
12:51jasappI have the javadoc lookup, and it's nice
12:51jasappI was just looking for something similar for clojure
12:51stuartsierra(doc f) gets you the same thing as the Clojure API docs, except for special forms.
12:51clojurebotExcuse me?
12:52jasappok
12:52jasappI'm not sure why I didn't think of that
12:52replacajasapp: find-doc also exists
12:52replacawhen you don't know the exact form
12:52cemerickthis is interesting: http://code.google.com/p/terrastore/
12:52replaca*symbol name
12:53replacarhickey: are you in channel?
12:54rhickeyreplaca: yup
12:55replacarhickey: so I was thinking that since autodoc doesn't support branches yet, I could do a stopgap by putting the 1.1 doc up on tomfaulhaber.github.com/clojure and then we'd have poor man's branch support
12:55replacahow's that sound?
12:56replaca(not that master and 1.1 have diverged yet) :)
12:58rhickeyreplaca: the API doc was always advertised as being about the latest, I'm ok with that until we have branch support
12:59rhickeywe can work on putting metadata for :introduced-in for 1.2+
12:59hiredman_I thought the api was always advertised as being about the release
13:00replacarhickey: ok, cool. I'll relax about that then. I think I'm about a month away from branch support (I'm doing some cleanup and trying to turn autodoc into a library that others can use right now)
13:00replacahiredman_: I'm not sure we made any declaration at all :)
13:00chouserreplaca: I noticed that the namespace is in both the path and the fragment of the doc urls
13:01rhickeythe clojure.org API page always said latest
13:01replacachouser: I don't understand what you mean?
13:01hiredman_ok
13:01replacachouser: oh, yeah I do. Yeah, that's probably unnecessary
13:02replaca"for historical reasons"
13:02replaca:-0
13:02replaca:)
13:04replacarhickey: I should probably add some words to the top of the API page emphasizing that this documents the master branch
13:06rhickeyused to say: "It is generated from the source and reflects the current SVN version."
13:06replacaI'll add similar verbiage for the moment
13:14rowthllastlog changes
13:14rowthgah, sorry
13:19replacarhickey: how about :introduced-in and :modified-in so that we can reflect APIs that have changed reasonably (:modified-in could be a vector)
13:21rhickeyreplaca: they sound fine, if somewhat verbose
13:22replacarhickey: yeah, I have no strong opinion on the names. whatever feels easiest to you when working on core.clj
13:41bagucodetechnomancy: ping
13:55StartsWithKgen-class will lift all constructors from the base class, is this feature of any use to any one?
13:56hiredman_lift?
13:56StartsWithKcopy contructor signatures to gen-classed class
13:56technomancybagucode: pong
13:57StartsWithKi was doing a sketch for joint java-clojure compiler (like the one groovy has) so first step is to generate .java stubs for all gen-class classes
13:57StartsWithKthen i would compile java side with them, remove stubs and recompile clojure part
13:58StartsWithKthis way in the same compile module you can have java side using clojure generated classes and clojure depending on java side
13:59StartsWithKthe problem is constructor lifting, i can't generate the stub if the base is still in .java file
13:59hiredman_hmmm
13:59StartsWithKat least i can't generate correct constructors
13:59bagucodetechnomancy: hey. I just sent you a bunch of github noob messages :) I'm curious about some common practices and stuff.
14:00technomancybagucode: this is a pretty good overview of how I like to keep feature work in a separate branch until it's ready: http://wiki.github.com/dchelimsky/rspec/topic-branches
14:01hiredman_gen-class in generally is kind of distasteful, I'm not sure why it does the lifting, must be something to do with the init stuff on the clojure side
14:01StartsWithKso, maybe lifting could be removed in favore of explicit constructor declaration
14:01StartsWithKjoint java -clojure compiler imho is bether option to have
14:01technomancybagucode: thanks for the patches; I hope to have time to look at them soon.
14:03StartsWithKyes, and i think there were several reports of gen-classes class not working, it happened i think when lifted constructor clashed with custom declaration or something like that
14:05chouserAren't the ctors are lifted so you can dynamically add functionality?
14:05bagucodetechnomancy: Thanks. I'll read up on that link. My master now is just the first change I did to compile.clj to support native code. I didn't want to touch that again until you had a look at it and maybe merged it to leiningen proper so I made a new branch for the generic os detection support and passing of jvm flags to a forked process. Guess I got that right then :)
14:06chouserStartsWithK: like :init and :post-init
14:06technomancybagucode: sounds like a winner.
14:06StartsWithKchouser: i don't know why is it doing it, but, couldn't you have same effect with manual lifting
14:06stuartsierraYes, the gen-class'd constructor needs to call init, set up state, etc.
14:07StartsWithKhmm
14:08StartsWithKbut still, :constructor could be made explicit and mandatory in all cases
14:08stuartsierraThat would be a nuisance.
14:08StartsWithKfor what?
14:08stuartsierraMe. ;)
14:08StartsWithKi't looks like most gen-class is used to generate beans or similar things for servlets and such
14:09StartsWithKand they need default ctor to work
14:10StartsWithKif one could simply drop bunch of java scala and clojure file in same src/ dir and just complile them without any extra work on his part
14:10StartsWithKthat would be a huge benefit for ide makers
14:11stuartsierraNot gonna happen any time soon.
14:11StartsWithKgroovy can do that, and they now have joint java/scala/groovy compiler, scala has joint java/scala compiler
14:11StartsWithKonly thing stoping clojure from this is ctor lifting
14:12stuartsierraDo they generate stub .java source? That's the part that sounds weird to me.
14:12StartsWithKstuartsierra: goovy generates stubs, scala generates bytecode
14:12StartsWithKr*
14:12StartsWithKmy java/clojure compiler works like groovy implementation
14:13StartsWithKits a three stage compilation, but is fully automatic and transparent for the user
14:13hiredman_I think the real issue is that clojure's compiler is same world and loads all the code it generates
14:14stuartsierraYes, so you always have to compile Java code first.
14:14StartsWithKhiredman_: not a problem realy, only thing needed is to load .clj manualy, macroexpand while counting gen-class and gen-interface (deftype in new branc) as special forms
14:14StartsWithKthen collect bodies of gen-class declarations
14:15hiredman_StartsWithK: well then do that
14:15hiredman_if it is such a not a problem
14:15stuartsierraBut gen-class is a function - it can be called anywhere, any time.
14:15StartsWithKstuartsierra: yes, java must be compiled first
14:15StartsWithKits a macro, and it will not do anything if *compile-files* is not true
14:16stuartsierraBut how can you do macroexpansion without evaluating code?
14:17chouserwe have a dependency chain like this java -> clojure -> java -> C++
14:17chouseris that what you're looking for?
14:17StartsWithKi can't, but i don't need to do much, most thing are simple ignored (like (new Foo) will never be called)
14:18StartsWithKchouser: something like that, but lets saj Foo.java will use Bar that is gen-classed, and Baz.java will use Bar, and you have them in the same lib
14:18hiredman_if clojure's compiler did not try to load java classes it would be possible to compile clojure first
14:19StartsWithKjoint compiler will resolve that without any problems
14:19stuartsierraBut what you're proposing is not really a joint compiler, just running separate compilers in a particular order.
14:19StartsWithKwell that is what joint compiler does
14:20stuartsierraI think a joint compiler would have to understand both Java and Clojure syntax, so it can resolve symbols in both languages.
14:20StartsWithKhiredman_: it can work, no code will be executed, only evaluated, but the problem is, you can't know ctor of a class that is not compiled jet, so stub can't be generated
14:21StartsWithKnot realy, it only needs to provide all the classes from both laguages when they are doing there compile phase
14:22StartsWithK(in compiled form or as stubs)
14:22chouserwait, you're trying to make gen-class work on a class that doesn't exist yet?
14:22chouserI mean, extending a class that doesn't exist yet
14:22StartsWithKyes, yes
14:22chouserthe ctor is the least of your problems.
14:22StartsWithKit will be compiled by the java compiler
14:23StartsWithKctor is my only problem :)
14:23chousergen-class generates a method for every public method of every class it's extending
14:24StartsWithKuff
14:25StartsWithKwith the same signature as the base?
14:26StartsWithKthen that is not the problem i think
14:26StartsWithKas all publics from base would be visible any way
14:26StartsWithKbut ctors would not be lifted
14:26chousernot if base doesn't exist
14:27chouserhow do you discover the public methods of a non-existant class?
14:27chouserconversly, why is the solution we're already using insufficient such that all this effort is required?
14:27StartsWithKi don't, but i dont care, it must be in class path, on it must be in javac stage compiled with other classes
14:28StartsWithKi only need to generate stub "public Foo extend Bar .." as a string and save it in .java file for javac consumation
14:28StartsWithKclass*
14:35StartsWithKthis is http://is.gd/5sFXc explanation of hov groovy will do it, process is simple and it works on clojure if stub that is generated dosn't lift any ctors from the base class when :constructors in not defined
14:36chouserif you have each module declare its dependencies, then there is no problem at all, things just get built in the right order.
14:36stuartsierraMixed-language projects are hard enough *without* cyclical dependencies.
14:36StartsWithKsure, if you want to place Foo.java in one module bar.clj in another and Baz.java in third and do manula dependency resolvig that way
14:37headiushttp://weblogs.java.net/blog/forax/archive/2009/12/18/tailcall-anyone
14:38StartsWithKstuartsierra: yes, so maybe it could get easier with things like this
14:38headiusshould take you guys about 5 minutes to toss the extra bytecode in
14:38stuarthallowaygroovy: undisputed champ for those who like cross-language cyclical dependencies :-)
14:39StartsWithKcircular dependency can't be resolved in any language, so it will fail as usual
14:39StartsWithKjoint compiler is not a wizzard
14:40technomancyheadius: yow! what are the chances of that getting mainlined?
14:40headiusI feel like there's a good chance
14:40chouserheadius: how many -to-JVM-bytecode compilers do you have your fingers in?
14:40headiusgiven the pushback to late 2010
14:40technomancytalking with John Rose at JRubyconf made me think odds weren't good, but that seemed to be only due to a lack of manpower. if the code's there and working...
14:40headiuschouser: um...three or four of my own making, is that what you mean?
14:40headiustechnomancy: exactly
14:41chouserheadius: heh. yeah.
14:41headiusit wouldn't just be useful for FP either...we could eliminate pure overhead" stack frames from our call stacks with it
14:41StartsWithKstuarthalloway: scala suports joint java/scala compilation too
14:41headiusreflection could emit wide opcodes to remove themselves from backtraces
15:03somniumis there a particular function/method to call that coverts '? to _QMARK_
15:05hiredman_somnium: it's in the compiler
15:05chouser,(clojure.lang.Compiler/munge "true?")
15:05clojurebot"true_QMARK_"
15:05somniummunge!
15:05somniumawesome, thanks
15:05hiredman_what does the "wide" bytecode instruction do?
15:05stuartsierraThe most important function after "foo".
15:14hiredman_clojurebot: unix?
15:14clojurebotTitim gan éirí ort.
15:14hiredman_clojurebot: unix is<reply>it's a UNIX system! I know this!
15:15hiredman_clojurebot: unix is <reply>it's a UNIX system! I know this!
15:15clojurebotIk begrijp
15:15clojurebotThis is a test.
15:16scellus,(sort [5 4 3 2 1 Float/NaN 1 2 3 4 5])
15:16clojurebot(1 2 3 4 5 NaN 1 2 3 4 5)
15:17scellus(not totally unheard of, python is similar)
15:19doublindirectionhow does clojure handle uncaught exceptions? they do not seem to "bubble up" to the repl
15:19hiredman_I really don't understand Compiler.java
15:20chouserdoublindirection: I think they do bubble up to the repl. what are you seeing?
15:20hiredman_doublindirection: it depends on the context
15:20hiredman_threads/agents/etc
15:21doublindirectionnothing unless I add a (try catch) and printing it
15:21doublindirectionbut it is happening in a thread ...
15:21the-kennydoublindirection: Exceptions aren't thrown across threads
15:21the-kennyThey pop up in the *inferior lisp* buffer if you use swank-clojure
15:22the-kennyExceptions in the repl-thread pop up in the repl
15:22hiredman_,(future (throw (Exception.)))
15:22clojurebot#<core$future_call$reify__7719@1f87b38: :pending>
15:22hiredman_
15:22the-kenny,(throw (Exception.)
15:22clojurebotEOF while reading
15:22the-kenny,(throw (Exception.))
15:22clojurebotjava.lang.Exception
15:22doublindirectioni looked in *the inferior lisp*, nothing there
15:23doublindirectionbut it has to do with the threading
15:23chouserright, exceptions aren't printed by default except in a repl thread.
15:24chouserso if you start your own thread and throw something there, you won't find out about it automatically.
15:24chouserdepending on how you start the thread, clojure may have some handy ways for you to find out about the exception.
15:25the-kennychouser: Huh? Exceptions thrown in some thread pop up in my *inferior lisp*
15:25doublindirectionthe thread is a jms onMessage handler, who knows what happens
15:26chouserthe-kenny: I don't use emacs. But if you do (def x (future (throw (Exception.)))) you see that exception?
15:26the-kennychouser: wait
15:27doublindirectionexception does not show in my emacs
15:27the-kennychouser: No, but (.start (Thread. #(throw (Exception.))) pops up in *inferior lisp*
15:27the-kennyMaybe futures are handled differently?
15:28chouserthe-kenny: hm, I guess you're right.
15:30hiredman_you can set an exception handler for threads
15:30hiredman_possibly the execturor future uses sets one
15:34Licenser_aloa
15:38jweissi am looking for some macro examples that might help me - i write test automation software which requires me to support lots of different versions of our product. so my code (java) inevitably has lots of subclasses and overrides. i imagine the (a?) clojure way to do this is just patch the code with a macro? is there another way?
15:39stuartsierrajweiss: Dynamic binding.
15:42jweissstuartsierra: what about the case in java where i just want to override one line of a method, so i abstract it out into a protected method and override that method?
15:43defndoug mcillroy patented macros
15:43defnhe also could set file permissions with a magnet and a pin
15:45stuartsierrasame thing, just override a function with a different binding
15:46jweissstuartsierra: i was hoping not to have to give these functions names. since they wouldn't be their own function if it wasn't for the needing to override it
15:47hiredman_defn: asm macros maybe
15:47cp2defn: what a noob, real programmers use C-x M-c M-butterfly
15:47jweisswas thinking of a form like (deprecated x y z) where x y z are the things i'm changing
15:47jweissor maybe deprecated is not the right name, but you get the idea
15:47the-kennycp2: Hah... I love to hang out with people who understand this joke :D
15:48cp2^_^
15:48stuartsierrajweiss: Well, you can't really change something unless you can refer to it...
15:49jweissstuartsierra: yeah i meant i'd mark it my enclosing it in another form, and then a macro could replace the form with a new one
15:49jweisss/my/by/
15:49stuartsierragot to go
15:50jweissk
15:52defncp2: hehe check out: http://www.cs.dartmouth.edu/~sinclair/doug/
15:52defnDoug McIlroy can address 8 terabytes of RAM with only 32 bits
15:53defnand RE: ASM macros: Doug McIlroy thinks asm is for sissies.
15:54the-kennyEmacs can save files where bits have three states: 0, 1 and something between.
15:57cp2hehe defn
16:00Licenser__has someone has made any experience with clojure and sockets?
16:01alexykchouser: you da man
16:02KirinDave_Licenser__: Like, raw sockets or just network stuff?
16:02alexykthe sort-by of the pairs finished in 300 secs, while sort with comparator in 5500 secs
16:02Licenser__KirinDave_: 'just network stuff' so to say :P
16:02jweiss,(doc source)
16:02clojurebot"clojure.contrib.repl-utils/source;[[n]]; Prints the source code for the given symbol, if it can find it. This requires that the symbol resolve to a Var defined in a namespace for which the .clj is in the classpath. Example: (source filter)"
16:02KirinDave_Licenser__: The Peepcode is fairly good.
16:03alexykapparently sort-by calls its by only once per element, effectively performing Schwarzian transform?
16:03KirinDave_Licenser__: Also, I wrote an example bit of code that's smaller. Let me get the link for you.
16:03Licenser__KirinDave_: there is one about clojure & network?
16:03Licenser__All examples I found were so simple and trivialized that they were kind of useless or even wrongisch
16:03hiredman_http://github.com/hiredman/clojurebot/blob/master/hiredman/http_server.clj
16:03KirinDave_Licenser__: The peepcode stuff uses duck-streams to write a simple MUD.
16:03hiredman_server socket
16:04Licenser__hiredman_: yes it is pretty cool but the client part isn't :P
16:04KirinDave_Licenser__: http://kirindave.tumblr.com/post/272596413/clojure-chat-server-1
16:04hiredman_Licenser__: huh?
16:04chouseralexyk: I'm surprised it was that much faster.
16:05Licenser__well I find it at times very unnice to read from the socket, I've had the problem that line-seq's on a socket keep spitting out nil's and prevent the socket from closing
16:05chouseralexyk: sort-by *could* do a Schwarzian transform, but looking at it's definition I don't think it currently does.
16:05hiredman_Licenser__: well they would
16:06Licenser__yea I found that ugly .P
16:06hiredman_anyway, http_server has only serversocket, no client stuff
16:06alexykchouser: I also used it to sort by a function of the vector, and it was still very fast, hence I thought it only computes the by once, vs sort which apparently evaluates it for every comparison. But it's all speculation.
16:06hiredman_which is why I said "huh?"
16:06Licenser__I had so much fin defining a network connection by reducing over the seq of lines it spits out - I found it beautiful but it didn't worked as I wanted .P
16:07hiredman_well, you are computer programmer, make it do what you want
16:07Licenser__hiredman_: it's my plan :P just I learned that in clojure realms there are a lot people that have more experience so I see if someone knows tons of more stuff then me - especially when it gets all javaish like sockets :P
16:08Licenser__it helps against triplicated code but if most peopel played with server sockets I'll just make something nice to work with the reading part ^^
16:08alexykI have a general question: so far, I keep all my clojure code as repl snippets, with def vars all around, reflecting a data mining session. Now if I want to place it into a maven dir structure and e.g. compile, it tries to eval each top level thing. Which is silly. How can I refactor things to (a) still allow easy copy-paste into repl in the same way (b) keep lein compile or mvn compile's dirty little hands off my def's?
16:09Licenser__alexyk: create a mdef macro that does nothing when in marvin and works as def if not?
16:10hiredman_alexyk: that is what def is
16:10somnium`Licenser__: marvin?
16:10Licenser__I like the robot!
16:10somnium`:-)
16:10hiredman_if you want to def something, and not have the code run until you call it, that is called a "function"
16:10hiredman_there is a special "defn" form for that
16:11chouseralexyk: it's not silly, it's optimization. You're doing all your computation at compile time, saving the end-user from having to do any at all!
16:11alexykah, somnium! Q for you: I hate java.util.Date, can there be a flag in congomongo to convert all dates to joda-time upon receipt from mongo-java?
16:11hiredman_chouser: nah, he will do it at compile time and at runtime
16:12somnium`alexyk: yeah, but you have to kind of hack on the driver
16:12chouserhiredman_: oh. I guess you're right. :-/
16:12alexykhiredman_: so if I replace a def by a defn, i.e. creating a parameterless fun, will it run as (fenvar) ?
16:12alexyk(funvar) I meant, kind of
16:13hiredman_alexyk: have you gone all this time without writing functions?
16:13somnium`alexyk: i.e, proxy a Transformer and fire it into bytes
16:13alexykhiredman_: a few, but I rarely need them so far
16:13hiredman_well start writing
16:13somnium`alexyk: actually, could probably wrap it in a macro to make it stupid simple
16:13alexykhiredman_: the question is, I have a series of interactive computations I check.
16:13alexykI need to see and refer to them by names.
16:14hiredman_write a function to check them
16:14alexykthink R.
16:14somnium`alexyk: Ill look into it
16:14alexykit's a statistics session...
16:15alexyksomnium`: yeah, I was so aggravated by juDate/effin' Calendar so that I'm now mapping all juDate's into joda-time DateTimes upon fetch.
16:15alexykwhich is clearly duplication
16:15alexykmongo people said they don't want any external deps, hence no joda-time, but it's "easy to serialize any type of your own"
16:15chouseralexyk: I suppose you could have a macro that emits a 'def' but without a body if *compile-files* is ture.
16:16alexykchouser: interesting
16:16alexyksomnium`: another issue: even if you fetch :only [:x], you get :_ns and :_id, which I always dissoc around fetch.
16:17alexykis there a flag to supporess :_ns and :_id?
16:17alexyksuppress
16:18alexykKirinDave_: how do you insert gists into tumblr?
16:18the-kennyalexyk: There's a "embed" function on the gist site
16:18the-kennyYou can just copy the html and insert it into the post
16:19somnium`alexyk: mongo *always* adds those keys, need them for save/update
16:19alexyknice
16:19the-kennyalexyk: But they don't show up without javascript
16:19somnium`alexyk: could patch :only to take them off I suppose, but cant stop mongo from sending them
16:19alexyksomnium`: well I often don't plan upon returning the stuff to mongo, saving a transform as a new collection
16:20alexyksomnium`: erally would like a flag :really-only or something, meaning no return to mongo
16:20alexykand hence no ns/id
16:20somnium`:really-only, I like it
16:20alexyk:)
16:22alexyksomnium`: basically it would just drop ns/id, saving a (map #dissoc (fetch :coll :only [:x]) :_ns :_id) wrapper
16:22hiredman_why not put the id stuff in metadata?
16:22somnium`hmm, maybe a :no-mongo-keys flag?
16:23alexykhiredman_: interesting angle
16:23alexyksomnium`: sure... and also "mongo-as
16:23alexyk-metadata
16:23alexykthen :) for a choice
16:23somnium`hiredman_: no way to make metadata play nice with the .java driver :(
16:23doublindirectionis there a way to specify "throws SomeException" with :gen-class :methods?
16:24hiredman_somnium`: but you already have a clojure layer betweeb clojure and the java right?
16:24somnium`Im kind of hacking on a clojure version but am handicapped by my total unfamiliarity with nio
16:25alexykI can see how, if you really want to pu
16:25alexyk
16:25hiredman_the clojure layer can do a transform
16:25alexykupdate mongo, you grab metadata back
16:25somnium`hiredman_: yes, but for performance it tries not to do much, just expose the api sanely
16:25somnium`but it would be possible
16:25somnium`alexyk: the fork is in your hands
16:25alexyksomnium`: after the PhD is in my hands next year :)
16:26alexykthen I can even juggle with forks
16:26alexykfor my clojure is hard at work with what is got... :)
16:27somnium`oh well, mongo is still kind of alpha until it gets concurrent reads anyway :)
16:28somnium`alexyk: at least Ill be able to claim congo's been used by academics once you get your degree
16:29alexykI thought about sharing with Haskell, which got no mongo srivers yet. But it has for couchdb and tokyo cabinet, but without JSON and shell, I can't fathom those beasts no more.
16:29somnium`?
16:29Licenser__Hmm running in open doors here, but did everyone ever think about making a good documentation system for Clojure?
16:29somnium`how can you do anything with couchdb but not JSON?
16:29alexyksomnium`: after 6 months in scala, I added clojure, we'll see how it morphs. So far. clojure is best for data mining, and mongo is my store, with 100 gb of graph transforms.
16:30Licenser__I mean the doc strings are nice for hints but in the long run they can't replace a real documentation
16:30alexyksomnium`: I mean, with a shell. I didn't look too deep into it, but I need a mongo-liek shell to inspect, not a curl client.
16:30somnium`ah
16:34jweisscan someone recommend a way to write a clojure function like (defn myoldfn [] (do (mythis) (mythat) (myother) ) and then write mynewfn so that it reads basically as "call myoldfn but instead of mythat do myanotherThing"?
16:35jweissi'd like to keep the original function's steps written in order, in the fn, for readability
16:35alexyksomnium`: are there any shells for couchdb or tokyo cabinet comparable to mongo?
16:35Chousukecouldn't you parametrise myoldfn on mythat? :/
16:36jweissChousuke: yeah, but then the steps are written out of order
16:36jweissi want to keep it readable
16:36Chousukeout of order?
16:36Chousukebtw, the do in your example is redundant.
16:36jweissit would execute in the right order or course, but mythat would be actually defined outside the function
16:37Chousukedefn bodies already have an implicit do
16:37jweissChousuke: sorry was just pseudocode
16:37Chousukehmm
16:37Chousukewell, you can use binding I suppose
16:37jweissChousuke: i can't think of a way to do that and still keep the original fn as just a straightforward list of things to do
16:38KirinDave_alexyk: "How do you insert gists into tumblr?"
16:38KirinDave_alexyk: You use the raw HTML view.
16:38KirinDave_It's very bad that they let you do it, tbh
16:38KirinDave_But you can put any script tag in.
16:38jweissoh wait Chousuke i think i get it
16:38Chousukejweiss: aren't you overdoing it a bit though? :/
16:38alexykKirinDave_: I use markdown plugin for MarsEdit and Tumblr, usually
16:38jweiss(defn mynewfn (binding mythat (fn ... )))
16:38KirinDave_alexyk: I do not.
16:39jweissChousuke: yeah maybe
16:39KirinDave_alexyk: I just use the web interface (mostly the bookmarklet) for 90% of my stuff
16:39Chousukejweiss: if the issue is with the order of defns, you can always declare a function first and define it later
16:40jweissChousuke: no that's not it, but in my domain i'm constantly sort of "patching" functions but i still need to keep the old ones around, and it gets totally unreadable
16:40alexyksomnium`: I tried googling for "couchdb shell"and only curl I see
16:40jweissfactoring out tiny bits into smaller fn's
16:40alexykso a non-starter for me
16:40Chousukejweiss: hm.
16:40jweisswas hoping macros or bindings could let me keep the original function looking basically the same
16:41jweisswithout copy/pasting
16:41KirinDave_So, is there documentation anywhere on the cont-m monad?
16:41KirinDave_I really am having trouble understanding it.
16:41KirinDave_And the base documentation is kinda sparse
16:41Chousukejweiss: so you want a template for a function and then create functions based on replacing parts of that function?
16:42jweissChousuke: yep
16:42Chousukejweiss: maybe you could make a function that takes a map of functions as a parameter.
16:42jweissso somehow i need to mark the forms that need replacing
16:42dysingerKirinDave Jim Duey has some tutorials on it.
16:42Chousukejweiss: and then just pass in different function maps to it.
16:42Chousukeyielding new functions.
16:42KirinDave_dysinger: Could you point me to a link?
16:42dysingerhttp://intensivesystems.net/tutorials/cont_m.html
16:43KirinDave_Damn
16:43jweissChousuke: but again, that still involves taking the template apart too, doesn't it?
16:43KirinDave_I just cannot navigate that guy's site.
16:43KirinDave_I keep going to it and failing to read it.
16:43Chousukejweiss: well the "template" would become a function that takes the values from the map and does something with them
16:44jweissChousuke: yeah but i was hoping that my original unpatched template would remain intact. to do what you're saying, i'd have to refactor it
16:44jweissand pull out all the parts that get overridden
16:45jweissand put them into that map
16:45Chousukeyeah.
16:45Chousukeyou can also make the "generic" parts into a macro
16:46Chousukethen your original function is just one expansion of that macro.
16:47jweissChousuke: hm, that might be ok, at least macroexpand should show me an easier to read fn
16:48ChousukeI can give only very general advice, but when writing a macro you're basically designing a new syntax for writing these functions (whatever they are)
16:48Chousukeso make the most out of it
16:51somnium``alexyk: Im not too familiar with couch, Ive only used futon
16:52jweissChousuke: seems like i need the source fn here
16:52alexyksomnium``: is futon as convenient as mongo client?
16:52somnium``alexyk: but Im sure there are people here who are quite knowledgeable
16:53somnium``alexyk: its a web app, not really comparable I guess
16:53alexykknowledgeable people: does couchdb have a shell where you can easily inspect data?
16:53alexyk:)
16:55danlarkinGreetings clojurecrats! I'm back with another connundrum: why do these following two expressions not behave the same?
16:55danlarkin,(let [f #(compare (:x %1) (:x %2))] (= {{:x 1 :name "juan"} 1} (sorted-map-by f {:x 1 :name "dan"} 1)))
16:55clojurebottrue
16:55danlarkin,(let [f #(compare (:x %1) (:x %2))] (= (sorted-map-by f {:x 1 :name "dan"} 1) {{:x 1 :name "juan"} 1}))
16:55clojurebotfalse
16:57hiredmanI wonder if clojars could have an rss feed
16:58Chousukedanlarkin: why does the first one return true... huh. weird.
16:59hiredmannon-semetrical equality
16:59hiredmanit happens
16:59danlarkinit shouldn't! (imo)
16:59hiredmancorrect
17:01chouseralexyk: I just put together a down-and-dirty, mutable-array-based schwarzian transform sort, and I can't get it to beat clojure's sort-by
17:02danlarkincan't figure out why = isn't commutative from a quick browse of the java code
17:03chouseralexyk: which is interesting because the keyfn I'm testing it on is the one I gave you, where it's creating a 2-element vector for every call.
17:04Chousukedanlarkin: did you check both sorted-map and the persistent map?
17:04technomancyis there a trick to creating a clojure map from a java.util.Map?
17:04Chousuketechnomancy: (zipmap (keys themap) (vals themap)) perhaps?
17:05Chousukemaybe even just (into {} themap)
17:05technomancyChousuke: oh wow; into works great
17:05technomancythanks
17:05chouserI would have that that was sufficiently expensive for the transforming sort to win
17:05technomancythat'll clean things up nicely
17:06alexykchouser: in my case, vectors are really vectors of pairs, and I sort by e.g. sum of the second elements. E.g. [["bob [[1 1] [2 3] [3 2] [4 2]]] ["alice [[0 2][3 2][5 5]]] ...]
17:07danlarkinChousuke: well PersistentTreeMap doesn't implement equiv or equals, so that'd fall back to APersistentMap
17:07hiredmanfyi Properties implement java.util.Map
17:07alexykhence sort-by, blazing fast on such 3.5 million pairs, is just: (sort-by (fn [[k v]] [(- (apply + (map second v))) k]) sper-days)
17:08alexykchouser: following your trick
17:09danlarkinChousuke: and clojure.core/= uses clojure.lang.Util/equiv for comparison, which uses IPersistentCollection.equiv
17:09danlarkinand that's where I lose it
17:09alexykI was really surprised by speed, unless the map/fn is computed only once
17:11hiredmanI think you are following the wrong direction
17:11hiredmanI would check the equiv on sorted maps
17:12danlarkinbut it's when the non-sorted map comes first that = is wrong
17:13somnium``alexyk: what is the average num of keys in the maps youre crunching?
17:13somnium``alexyk: the ones coming from the db I mean
17:14hiredmandanlarkin: but sorted-map was added later so it's equivilance semantics are more likely to need some adjusting
17:14alexyksomnium``: from 1 to 30,000 currently
17:14alexykeach element, 3-10 million elements per coll
17:14alexykbrb
17:15hiredmanhuh
17:15hiredman~def sorted-map
17:16somnium``alexyk: egads, youre storing objects with 30,000 keys?
17:16hiredmanhmmm
17:18danlarkinthe counts don't even have to be the same:
17:18danlarkin,(let [f #(compare (:x %1) (:x %2))] (= {{:x 1 :name "juan"} 1} (sorted-map-by f {:x 1} 1)))
17:18clojurebottrue
17:19chouser,(map first (sorted-map-by #(compare (:x %1) (:x %2)) {:x 1 :name "dan"} 1))
17:19clojurebot({:x 1, :name "dan"})
17:19chouser,(map first (sorted-map-by #(compare (:x %1) (:x %2)) {:x 1 :name "dan"} 1 2 3 4 5))
17:19clojurebot(2 {:x 1, :name "dan"})
17:19chouseroh, wait.
17:19somnium``is there a summary of performance characteristics for ArrayMap vs. StructMap vs. HashMap vs. DynamicType anywhere+ (creation, look-up, etc.) ?
17:19chousersorry, I was off the tracks there.
17:21chouserah, there it is.
17:21danlarkinright, so I think the problem must live in APersistentMap:
17:21danlarkin,(let [f #(compare (:x %1) (:x %2))] (.equiv {{:x 1 :name "juan"} 1} (sorted-map-by f {:x 1} 1)))
17:21clojurebottrue
17:21chouser,(get (sorted-map-by #(compare (:x %1) (:x %2)) {:x 1 :name "dan"}) {:x 1 :name "anything at all"})
17:21clojurebotjava.lang.IllegalArgumentException: No value supplied for key: {:x 1, :name "dan"}
17:22chouser,(get (sorted-map-by #(compare (:x %1) (:x %2)) {:x 1 :name "dan"} 1) {:x 1 :name "anything at all"})
17:22clojurebot1
17:22danlarkinah ha
17:22chousersorted maps use the comparator to find the value
17:23chouserperhaps they should do a final equality check of the key before succeeding?
17:23chouseror perhaps not. I dunno.
17:23danlarkinwell it seems like they ought to
17:24danlarkinat least it seems tome that the current behavior is wrong
17:24chouserwell, this seems wrong too but has been ruled Not A Bug:
17:24chouser,{:a 1 :a 2 :a 3}
17:24clojurebot{:a 1, :a 2, :a 3}
17:25danlarkinyeah but that's in such a corner case
17:25chouserusing a comparator for sorted-map-by that claims two values are equal when they are not seems like a corner case too, doesn't it?
17:26danlarkinI don't want the comparator to be used for equality, just sorting :)
17:26Chousukeisn't the sorting ... right.
17:26reifywhat clojure-contrib branch is recommended for clojure 1.x ?
17:27chouserreify: master, I think. for now. :-)
17:27reifyi get these errors when compiling clojure-contrib with a clojure-1.1.jar: java.lang.NoSuchMethodError: clojure.lang.RestFn: method <init>()V not found (PrettyWriter.clj:17)
17:28chouserreify: "ant clean" first
17:29reifyi swore I did that, thanks, that worked
17:30chouserreify: that's my job: telling you what you already know.
17:30chouser:-)
17:31danlarkinso my workaround right now is to make sure the order to clojure.core/= always puts the sorted-map first... do you think this is worthy of escalating? (I do)
17:32chousersure. I just wouldn't be shocked if the answer is "well, don't do that"
17:32danlarkinI hate those answers :(
17:33alexyksomnium``: sorry, each object has usually one key. The value may be a longish vector or submap, tho.
17:34hiredman~RestFn
17:34clojurebotGabh mo leithscéal?
17:34hiredman~clojure.lang.RestFn
17:34clojurebotant clean and rebuild contrib
17:35somnium``alexyk: congo creates hash-maps by default, but would be pretty easy to add an array-map flag for smallish maps.
17:37chousertechnomancy: is it too hard to make your comparator only return 0 when keys are equal?
17:38chouserexcept I've gotta run, so we can pretend that was rhetorical. :-)
17:38danlarkinchouser: I assume you meant me :)
17:38somnium``does the reader decide between array-map/hash-map by just counting key-value pairs?
17:38chouserdanlarkin: right! sorry!
17:38chousertechnomancy: sorry!
17:39chousersomnium``: reader always uses array-map, I believe. assoc/dissoc count keys and switch formats appropriately.
17:39chouseruh. except I'm wrong.
17:39somnium``hmm
17:40somnium``? :)
17:41chouserwell, I do have to go. Ignore what I said. :-P
17:48mabesis there a way to require/use all of clojure/contrib? I would like to use (find-doc) on all of it...
18:28joshua-choiHey, is there a better way to add an object x to the beginning of a vector v than (vec (cons v x))?
18:29hiredmanI don't imagine so
18:30hiredmanyou could implement your own type of vector that allowed adding to the front some how
18:31hiredmanfor key 0 return x else return element key - 1 from vector v
18:32joshua-choiWell, I'm not sure I want to go that far
18:32joshua-choiI'm worried that with vec and cons, though, creating a sequence from a vector, and then a new vector from the sequence would be more inefficient than may be necessary
18:32Chousukeyou could pester chouser to finish the finger tree implementation and make a deque :P
18:32hiredmanvectors were not designed with effecient adding tothe front in mind
18:33joshua-choiYeah...maybe I should try to change my logic so I don't have to add to a vector's beginning, ugh
18:34chouserthere's a PersistentQueue if you just want to always add to the right and take from the left.
18:34joshua-choiIn clojure.core?
18:34hiredman,(conj clojure.lang.PersistentQueue/EMPTY 1)
18:34clojurebot(1)
18:34hiredman,(conj clojure.lang.PersistentQueue/EMPTY 1 2)
18:34clojurebot(1 2)
18:35hiredman,(peak (conj clojure.lang.PersistentQueue/EMPTY 1 2))
18:35clojurebotjava.lang.Exception: Unable to resolve symbol: peak in this context
18:35hiredman,(peek (conj clojure.lang.PersistentQueue/EMPTY 1 2))
18:35clojurebot1
18:35joshua-choiI had no idea that this data structure existed
18:35Chousukeit's not very well documented :/
18:36hiredmanI think rhickey has some (evil?) mastermind plans for queues
18:39joshua-choiAh, I just came up with a way to avoid adding to a vector's beginning; I guess that's best
18:39joshua-choiI've got another question though
18:39joshua-choiAccording to http://gnuvince.wordpress.com/2009/05/11/clojure-performance-tips, using destructuring in let (and so, probably fn too) is pretty slow
18:39joshua-choiThat post was from earlier this year; is it still the case?
18:40joshua-choiShould I avoid destructuring lets in loops, etc?
18:42the-kennyjoshua-choi: Only if you have a real bottleneck at this point in your code
18:42danlarkinjoshua-choi: measure and THEN optimize :)
18:42the-kennyfirst: write it beautiful, if it's to slow, write it faster
18:42the-kennys/to/too/
18:44joshua-choiYeah, that makes sense
18:44joshua-choiI have no idea have to measure though
18:44joshua-choiI'm not experienced with profiling Clojure, or anything for that matter
18:45hiredmanit's a complex macro
18:45the-kennyjoshua-choi: Just write your code.. if you don't notice that the code is too slow, there's no need to change the code for more speed
18:49ubiianyone using clojure for web development?
18:50the-kennyubii: Yeah, some people here. Just ask your question :)
18:51ubiiwhat framework(s) are most folks using and how production ready are they?
18:51the-kennyubii: I think compojure is the most prominent framework here. http://clojars.org is running on it
18:53mtmchouser: you're to the point of picking a title and cover for the book? Sounds like you're almost done... (rubs hands gleefully in anticipation)
18:54ubiiout of the frameworks that I look at so far, compojure looks the most interesting
18:55tomojcompojure is changing currently I think?
18:55ubiiin what way?
18:56tomojbeing refactored I think
18:56ubiiah
18:56tomojdunno how far away that stuff is from master
18:57ubiione thing that I am trying to get a better grasp on is the server side of things, such as how to best deploy multiple sites on a single server
18:59tomojI guess that kind of thing is java's problem
18:59ubiias well, as which web/app server(s) to, in order to maximize scalability
18:59ubiiunderstood
18:59tomojI don't know much about that yet either
18:59hiredmanyou can always proxy requests via apache
19:00tomojI asked before whether there is a need to run multiple instances of the application on a single server (like we have in ruby), and the answer was 'no'
19:01tomojI guess because java can actually do threading
19:01hiredmanyeah, there isn't, but it makes it easier
19:01hiredmanmakes it
19:01tomojwait, what?
19:01tomojthat only sounds harder to me
19:01hiredmancompojure has the run script right? for developement that launches with jetty?
19:02hiredman(it's been a while)
19:02hiredmanso you do that once per site, each site gets a port, set up the forwarding in an apache config
19:02ubiiif for example, say I have different sites, running on the same server, do each of them run under their own JVM?
19:02hiredmanit's not perfect by along shot, but it is dead simple
19:03tomojright, that sounds easy
19:03tomojI meant how like with ruby we might proxy apache/nginx to multiple running copies of the application even on the same server
19:03tomojonly have to do one here, I think
19:09ubiijust trying to get some idea of what type of memory resources each site might require, using something like compojure
19:09hiredmancompojure has a google group
19:12ubiinp, I can pop on #compojure and ask
19:14ubiiwas just trying to get a feel for what most folks were using and how to best setup multiple sites up on a single server
19:14ubiithx
19:55defnhow do you get a coll you turned into a transient back?
19:55hiredman(doc persistent!)
19:55clojurebot"([coll]); Returns a new, persistent version of the transient collection, in constant time. The transient collection cannot be used after this call, any such use will throw an exception."
19:56defnawesome thanks
19:58defnwhat is [b] in clojure?
19:58Chousukea vector of one element?
19:58defn,(doc chunk)
19:58clojurebot"([b]); "
19:58Chousukeaha. :D
19:58hiredmanyep
19:58Chousukegood documentation. don't ask me.
19:59Chousukeit means the function takes one argument, named b :P
19:59Chousukewhatever that is.
19:59defnbahaha
19:59defngoddamnit
19:59hiredman,(alter-meta! #'chunk assoc :arglists _
19:59clojurebotEOF while reading
19:59hiredman,(alter-meta! #'chunk assoc :arglists _)
19:59clojurebotjava.lang.Exception: Unable to resolve symbol: _ in this context
19:59hiredman,(alter-meta! #'chunk assoc :arglists '_)
19:59clojurebot{:ns #<Namespace clojure.core>, :name chunk, :file "clojure/core.clj", :line 446, :arglists _}
19:59hiredman(doc chunk)
19:59clojurebot"_; "
19:59defnah i see
20:02defnmap and filter use the chunk stuff
20:02defncool
20:04ericlavigneJust installed NetBeans+Enclojure but Clojure isn't one of the options for new project types. Have I configured wrong, or should I be creating a Java project and putting Clojure source in it?
20:54devlinsfIs is possible to get bug fixes in for 1.1?
20:55hiredmanI would imagine so
20:55devlinsfI have a fix for 128
20:55devlinsfjust posted
20:56devlinsfCan someone review?
21:18hiredman// int WIDE = 196; // NOT VISITED
21:18hiredman:(
21:21devlinsf???
21:22hiredmanWIDE is the bytecode the experimental jvm uses to annotate tail calls
21:23hiredmanand WIDE is commented out in the source of Opcodes.java in the asm library
21:27devlinsfOh
21:28devlinsfSo no TCO?
21:29hiredmanI don't know the asm lib too well
21:32hiredmanuncommenting it and trying to use wide just gives me a NPE
21:32devlinsfHmmm
21:34alexykhow do I take last N elements of a collection?
21:35devlinsfcurrently not supported
21:35alexykgrrr
21:35devlinsfI'd do this
21:36devlinsf(defn take-last [n coll] (drop (- (count coll) n) coll))
21:36devlinsfGonna talk about that fn for 1.2
21:36alexyknice
21:36devlinsfWe'll see where it goes
21:36hiredman,((comp first drop-while) (comp (parial = 6) count) (iterate rest (range 10)))
21:36clojurebotjava.lang.Exception: Unable to resolve symbol: parial in this context
21:36hiredman,((comp first drop-while) (comp (partial = 6) count) (iterate rest (range 10)))
21:36clojurebot(0 1 2 3 4 5 6 7 8 9)
21:37hiredmanbleh
21:37alexykmay call it tail as well
21:37hiredman,((comp first drop-while) (comp (partial not= 6) count) (iterate rest (range 10)))
21:37clojurebot(4 5 6 7 8 9)
21:37devlinsfYeah, expect there already is drop-last
21:37hiredman,((comp first drop-while) (comp (partial not= 6) count) (iterate rest (range 1000)))
21:37clojurebot(994 995 996 997 998 999)
21:37devlinsfmaybe alias it as tail?
21:37alexykand alias take as head
21:38alexykunless it's taken
21:38devlinsf~head
21:38clojurebotNo entiendo
21:38devlinsfNOpe
21:42defnalexyk: you coulkd just reverse it
21:42defncould just*
21:43alexyktrue too
21:43defn,(take 10 (reverse (range 0 21)))
21:43clojurebot(20 19 18 17 16 15 14 13 12 11)
21:43defni like reverse the most -- seems easiest to understand
21:43defnim not sure about its effect on performance, though
21:43alexykdefn: then reverse again
21:44hiredmanalso the worst O
21:44devlinsfhiredman: true
21:44hiredmanclojurebot: the most horrible thing?
21:44clojurebotmost horrible thing is http://tinyurl.com/b65o8e
21:44alexykhiredman: yours is Greek to me :)
21:45alexykwhat's comp first drop-while do?
21:45devlinsf(first (drop-while ...
21:47alexykright, still it's puzzling.
21:48defnthe loop seems ugly
21:48defnerr, look ugly in *my* opinion
21:48alexykhow do you limit the size of output by clojure repl?
21:48defnlooks*
21:48defnalexyk: good question, id be interested to know that
21:48alexyktrying to depuzzle hiredman's stuff from the tail produced a sea of numbers
21:49jasappalexyk: do you mean *print-length*?
21:49alexykah
21:49jasapp(set! *print-length* 10)
21:49hiredman(iterate rest (range 3)) => ((0 1 2 ) (1 2) (2) () ...)
21:49devlinsf\me wants to slap the "lisp w/o parens" crowd
21:50devlinsfThere
21:50jasappI've always wondered how to do that
21:50devlinsf/me
21:50jasappsweet
21:51jasappheh
21:51defnjasapp: nice
21:51defnthanks
21:51alexykhiredman: what's ...? I'm afraid for my repl
21:52jasappit just prints ...'s
21:52hiredmanit goes on forever
21:52hiredmanhmmm
21:52hiredmanactually
21:52defnclojurebot: sotto voce is <reply>shhhh!
21:52clojurebotAlles klar
21:52hiredmannuts, mine depends on count
21:53hiredmanso mine is n*n'ish
21:53alexykyeah, it's darn many numbers it generates
21:53jasappI thought most structures held their count somewhere
21:53hiredmannot seqs
21:54defn,(doc ref-max-history)
21:54clojurebot"([ref] [ref n]); Gets the max-history of a ref, or sets it and returns the ref"
21:59alexykhmm:
21:59alexyk.(doc take-last)
21:59alexyk,(doc take-last)
21:59clojurebot"([n coll]); Returns a seq of the last n items in coll. Depending on the type of coll may be no better than linear time. For vectors, see also subvec."
22:00devlinsfHmmm?
22:00alexykrhickey beamed it from the future
22:00alexykhot-loaded erlang-style into clojurebot by the firedman of 2012 :)
22:01devlinsfStill confused
22:01alexykme too
22:01jasappthat makes three of us, at least
22:02alexykI found it by trying to load devlinsf's take-last into the current ns, got confict with clojure.core/that
22:02devlinsfI could swear this wasn't there yesterday....
22:02devlinsfOh well
22:02devlinsfMusta made a mistake
22:41joshua-choi,(syntax-quote conj)
22:41clojurebotjava.lang.Exception: Unable to resolve symbol: syntax-quote in this context
22:42joshua-choiIs there a form for syntax quoting, like (quote x)?
22:44hiredmanthere maybe a dummy stubbed out in core, but syntax quote is currently a reader macro, so having it won't work like that
22:45joshua-choiI see
22:46joshua-choiBut, I could do
22:46joshua-choi,(first `(conj))
22:46clojurebotclojure.core/conj
22:46joshua-choibut it looks messy
22:47joshua-choiIs there a better way?
22:47hiredman,(resolve 'conj)
22:47clojurebot#'clojure.core/conj
22:47joshua-choiExcellent; would that work in macros?
22:47hiredmanyou could also just
22:48hiredman,`conj
22:48clojurebotclojure.core/conj
22:49joshua-choiWell, it's in a function: it's an argument whose value (a symbol) needs to be resolved
22:49hiredman
22:49hiredmanactually resolve resolves to the var
22:50hiredmanresolved or namespace qualified?
22:50hiredmanresolve resolves, and ` namespace qualifies, not resolves
22:50joshua-choiWell, namespace qualified, but like syntax quoting—which implies sort of resolving, right?
22:51hiredmanmaybe "quasi-resolving"
22:52joshua-choiI need it in a function that looks like this: (f [name] [(keyword name) (something name)]) so that (f 'conj) -> [:conj 'clojure.core/conj]
22:54hiredman,(ns-map *ns*)
22:54clojurebot{sorted-map #'clojure.core/sorted-map, read-line #'clojure.core/read-line, re-pattern #'clojure.core/re-pattern, keyword? #'clojure.core/keyword?, val #'clojure.core/val, ProcessBuilder java.lang.ProcessBuilder, chunked-seq? #'clojure.core/chunked-seq?, Enum java.lang.Enum, find-protocol-impl #'clojure.core/find-protocol-impl, SuppressWarnings java.lang.SuppressWarnings, *compile-path* #'clojure.core/*compile-path*, max-k
22:54hiredmanhmmm
22:55hiredmanare you sure you want the namespace qualified symbol and not the var?
22:55joshua-choiWell, the var would work too, come to think of it
22:56joshua-choiYes, using var works! Excellent, thanks for the help
22:56hiredman,(reduce #(conj %1 (keyword (name (key %2))) (val %2)) {} (ns-map *ns*))
22:56clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
22:57hiredman,(reduce #(conj %1 [(keyword (name (key %2))) (val %2)]) {} (ns-map *ns*))
22:57clojurebot{:StackTraceElement java.lang.StackTraceElement, :unchecked-inc #'clojure.core/unchecked-inc, :ArithmeticException java.lang.ArithmeticException, :import #'clojure.core/import, :deliver #'clojure.core/deliver, :symbol #'clojure.core/symbol, :vals #'clojure.core/vals, :print-doc #'clojure.core/print-doc, :select-keys #'clojure.core/select-keys, :re-matcher #'clojure.core/re-matcher, :rand #'clojure.core/rand, :deref #'cloj
22:57hiredmananyway, resolve will get you the var