#clojure logs

2010-03-02

00:29bradbeveridgeis Java's ZipInputStream really slow, or am I using it wrong?
00:29bradbeveridgeclojurebot: pastebin?
00:29clojurebotexcusez-moi
00:31bradbeveridgehttp://clojure.pastebin.com/zR9di5K0
00:39zaphar_psbradbeveridge: I've never tried to benchmark it so I don't know
00:39bradbeveridgeok, I was using it wrong
00:39bradbeveridgeI thought getNextEntry would throw
00:39bradbeveridgeit returns null, so I would have been sitting in an infinite loop for a while ;)
00:39bradbeveridgeit has native like perf
00:40zaphar_psheh
01:54scottjAnyone else get the error "Wrong number of arguments to task uberjar" when running "lein.bat uberjar" in Windows?
02:40sparievscottj: yep, I got this too, lein 1.1.0 seems to fix the problem - http://groups.google.com/group/leiningen/browse_thread/thread/a43ded3d659da915#
02:57scottjspariev: thanks
03:11LauJensenMorning crew
03:12TheBusbyevening
03:21sparievMorning
03:27vyIsn't there an "if" in Clojure?
03:27bsteuber,(doc if)
03:27clojurebotExcuse me?
03:28vyThere is cond, if-not, if-let, but no if?
03:28bsteuberthere is
03:28bsteuberat least it was there yesterday :)
03:28TheBusby,(doc if)
03:28clojurebotHuh?
03:29TheBusbyPlease see http://clojure.org/special_forms#if
03:29bsteuber,(if 5 :true :false)
03:29clojurebot:true
03:29danleiit's a special form
03:39ordnungswidrigI think more idiomatic when, however
03:48esjwotcha
03:57LauJensenordnungswidrig: huh ?
03:59ordnungswidrigLauJensen: hmm, I think I meant: "I think more ideomatic than 'if' is when"
04:03LauJensenI dont think they vary in levels of idiomacy, but if is for 2 bodies, when is for 1, different uses
04:15esjidiomacy, nice word.
04:19ordnungswidrigLauJensen: you're right.
04:28a_strange_guyhi there, could anyone help me with swank-clojure?
04:29a_strange_guyi want to use it without the swank-clojure.jar
04:31a_strange_guybu i cannot configure my classpath so that it will find the (not compiled) source checkout
04:33AWizzArdMoin guys
04:33a_strange_guymoin moin
04:34AWizzArdYou want to use the code files directly, but not the compiled .jar file.
04:34a_strange_guycorrect
04:35AWizzArdAnd does the path of those source files show up in your (System/getProperty "java.class.path") ?
04:36a_strange_guyI tried (S/gP "j.c.p")
04:36a_strange_guybut no, the won't show up
04:36a_strange_guyonly .jar's
04:40AWizzArdThen the CP needs to be set correctly.
04:41AWizzArdFor some reason the "/path/to/swank-clojure/" thing was not added.
04:43a_strange_guyswank-clojure-classpath = (append '("/opt/swank-clojure/src") (swank-clojure-default-classpath))
04:44a_strange_guybut when inferior lisp starts
04:44a_strange_guythere are only jars on the CP
04:45AWizzArdThen the append did not work as expected.
04:45a_strange_guyappend works as expected
04:46a_strange_guyswank-clojure-classpath must be a list of strings
04:47AWizzArdin my (custom-set-variables ...) I have: '(swank-clojure-extra-classpaths '("/hg/clj/" "/hg/clj/config/" "/hg/lib/clj/swank-clojure/" "/hg/lib/clj/clojure-contrib/clojure-contrib.jar" ...))
04:50a_strange_guysame here
04:56a_strange_guyit seems to work now
04:57AWizzArdgrats :)
04:57a_strange_guylooks like swank-clojure.el got scared ^^
04:57AWizzArdyay
07:08eevar2(doc slice)
07:08clojurebotTitim gan éirí ort.
07:18eevar2(doc partition)
07:18clojurebot"([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items."
07:31nipraHi, I'm getting the error ``slime-goto-location-buffer: Search failed: " clojure/core.clj$"'' for slime-edit-definition for any clojure.core or contrib symbol. For other symbol (in some other ns) it's working fine.
07:41powr-tocnipra: does swank know where to find clojure?
07:43niprapowr-toc, yes. I'm using swank-clojure-project to fire up the repl.
07:45powr-tocnipra: I don't use that function, I find starting an external clojure program that starts swank, and then using M-x slime-connect works better... I find this gives you better control over the vm startup and classpath
07:45powr-tocwhether this helps you or not is another matter :-\
07:47powr-tocIt sounds like your clojure-src-root isn't being set properly though
07:48niprapowr-toc, earlier I was using emacs starter kit. It was working fine. It broke after my moved to my old setup.
07:48bsteubernipra: I use swank-clojure-project with leiningen and finding source works fine
07:48powr-toc(check out clojure-mode.el file for info...) I set this by calling (clojure-slime-config "~/path/to/clojure") from my .emacs, but I've heard this method is deprecated...
07:50powr-tocbsteuber: I use lein too, but for the project I'm working on I have to be very careful with my classpath and classloaders, so starting clojure with a custom start script, and then connecting to it suits me better
07:51bsteuberthen I guess this setup gives some classpath issue
07:52bsteuberso it can find the compiled code but not the clojure source
07:52bsteuberdoes that sound reasonable?
07:53niprabsteuber, yes
07:54bsteuberso maybe check the clojure.jar you find in (get (System/getProperties) "java.class.path")
07:55bsteuberwhether or not it includes the source
07:57AWizzArdIs there (in contrib) a tool to generate permutations?
08:02AWizzArdOkay, clojure.contrib.combinatorics offers a fn “permutations”.
08:05LeafwAWizzArd: I have the impression that almost anything I'd want is buried somewhere in c.c
08:06esjif i define a function: (fn my-fn [& xs]) and then proceed to call it (apply fn some-giant-collection) I run the risk of blowing the stack right ?
08:06Leafwesj: why not map?
08:07Leafw Isee, the args
08:07Leafwsorry
08:07Chousukeesj: depends on what you do to the args
08:07esjhow so ?
08:07Chousuke,((fn [& args] (first args)) (iterate inc 1))
08:07clojurebotEval-in-box threw an exception:java.lang.OutOfMemoryError: Java heap space
08:07Chousukehm, opps
08:07Chousuke,(apply (fn [& args] (first args)) (iterate inc 1))
08:07clojurebot1
08:08ChousukeI meant to add that, of course :)
08:08esjhmm
08:08Chousukeso you can apply a function even on an infinite collection
08:08esjso the & binding doesn't break the laziness
08:08esjwow
08:12esjI guess my question directly is this: I am writing a library for time series. The CRUD functions currently expect collections, but I note that in clojure it is more idiomatic to have a multimethod a' la ([x]) and ([x & xs]) so am thinking about converting my code to that. However as my collections can potentially be pretty big, I'm worried about nasty effects.
08:12esjFor instance http://github.com/esj/esjtools/blob/master/src/esjtools/timeseries.clj line 82
08:13esjam I just making up issues to worry about ?
08:13AWizzArd,(apply + (range 1000000))
08:13clojurebot499999500000
08:14AWizzArdesj: how giant is your coll?
08:14AWizzArdIt obviously fits into RAM...
08:14esjyeah
08:14AWizzArdyou have 128 gb ram? ;)
08:14esjactually....
08:15esjwhat I was concerned about was expanding the call beyond the call stack
08:15esjbut clearly that doesn't happen, which is nice.
08:15AWizzArdYou can (apply fn coll-of-10-mio-objs)
08:16esjthanks.
08:16AWizzArdI am not sure, maybe ram is the only practical limit *shrugs*
08:18esjso the question now is, how exactly is the argument list created ?
08:18esjRTFC time I guess
08:18AWizzArdWhat do you mean?
08:18AWizzArdIs it not your code which creates the argument collection?
08:19esji mean the function calling semantic in Clojure itself. In my mind when you call a function the PC and all the arguments get put on the call stack. Clearly this is not happening here.
08:20esjor the apply example you gave above would try to put 1e6 vals on the stack, and it would overflow
08:21esjinstead Clojure hands you your answer, with a sly grin.
08:22a_strange_guyesj: there is no call stack beyond 20 args
08:22rhickeyesj: but apply only takes as many args as you pass. If you pass a fn and one collection, that's 2 args
08:22esj,(doc apply)
08:22clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
08:23esjmislead me to believing it was expanded out
08:23a_strange_guyapply passes a seq to the Fn
08:23esjaha - thanks gents. Now I understand.
08:24a_strange_guyand the Fn itself calls next &fist to pop the args of
08:24rhickeywell, it goes to the meaning of & in arglists. Obviously variadics (+ in this case) are somewhat special
08:25esjgotcha
08:25esjsorry, that could be misconstrued. I mean that I understand.
08:26rhickeyif the compiler needs to form the collection matching & more, then it will have to evaluate what you have passed. But in the case of apply, you have already created the collection
08:27chouserapply accepts a seq on the end. fns using & accepts a seq on the end. 'apply' does the work of fixing up the point at which the input switches to a seq to match what the fn is expecting
08:27rhickeyfns using & don't accept seq on end really
08:27rhickeyi.e. not via direct calling
08:28esjyeah
08:28rhickeybut the logic of the function is in fact applied to a sequence
08:29rhickeyso & in arglist say - please form a sequence of any additional args passed, after evaluating them. apply short-circuits that
08:30rhickeytricky part about apply is any intervening args between fn and argseq
08:32a_strange_guywhy?, they seem just to be consed onto the seq
08:32a_strange_guyor will that go away?
08:33rhickeya_strange_guy: nothing's going away
09:12rhickey_fogus_: where is that?
09:13_fogus_rhickey: The print magazine
09:13rhickeyah
09:13_fogus_A co-worker just handed it to me
09:13_fogus_The logo gets center-stage on the cover
09:13ohpauleezyeah, I just read the write up
09:13ohpauleezer, the synopsis of the issue
09:14ohpauleezonline
09:24opqdonutdo C-M-{up,down} work for others in clojure-mode?
09:25opqdonutI tend to get "Containing expression ends prematurely" or "Unbalanced parentheses" around square brackets
09:36chousersomebody make me stop optimizing this! It's fine. I just need to stop.
09:41stuartsierraheh
09:42rhickeychouser: I thought Clojure was too fast for you?
09:42rhickey:)
09:43chousershaddup ;-)
09:43chouserit's a bit addictive, moving things from runtime to compile time... O(n) to O(1)
09:44chouserhehe. user$eval__2146$eval$reify$reify__2188$eval$reify__2208$eval__2210$fn__2218
09:45stuartsierrablerg
09:45stuartsierraSooner or later we're going to have to do something about fn names.
09:46chouserthat's a fn generated by an eval called in the method of a reify from code eval'ed in a reify method...
09:46stuartsierrayikes
09:48a_strange_guybig question: ... WHY?!
09:48MaddasNot because it is easy, but because it is hard!
09:49chouserjust a stack of stuff generated, usually at compile time, to make runtime access type-specific and fast.
10:00djpowellwhat's the story with binary compatability of aot compiled libs with different clojure releases? I know that there isn't any, but is this something that clojure should address at all, or do there need to be any recommendations for library authors or anything?
10:01ordnungswidrigInsn't there a limit on method name length in the jvm?
10:02djpowell64k i think
10:02djpowellthat might lead to ugly stack traces though
10:04djpowelleg - perhaps leiningen should have an option to re-aot compile namespaces of libs with the version of clojure that is in use
10:05stuartsierradjpowell: only recommendation re AOT is to avoid it unless necessary; not a great solution
10:06djpowellyeah - i noticed that compojure currently aot compiles all of its namespaces. i don't know whether it needs to or not
10:21chouserbah. that's *slower*. grrr.
10:22stuartsierraha
10:27chouseroh, it was re-eval'ing each time. that's not right..
10:38zmilahow to know what parameter type expects given function?
10:39zmila,(doc file-seq)
10:39clojurebot"([dir]); A tree seq on java.io.Files"
10:39zmilawhat is "dir"?
10:40stuartsierrazmila: the argument to file-seq
10:40zmilai look into source, "dir" is "root" in tree-seq
10:41chouserthe docstring could be a bit more specific.
10:41chouser,(file-seq ".")
10:41clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.io.File
10:41chouserthere's a hint -- it wants a java.io.File
10:41chouser,(file-seq (java.io.File. "."))
10:41clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission . read)
10:42zmilaho, thanx, it's File object
10:52a_strange_guydoes anyone know what the #^ reader macro does exactly?
10:52a_strange_guydoes it add or replace metadata to forms
10:52Chousukehmm
10:52a_strange_guyseems to do that or the other sometimes
10:53a_strange_guy(meta (quote #^foo (+ 5 6)))
10:53a_strange_guy,(meta (quote #^foo (+ 5 6)))
10:53clojurebot{:tag foo}
10:53ChousukeI don't think it matters, since forms can't have metadata before they're read :P
10:53a_strange_guythey have line numbers
10:53Chousukethat's added after reading
10:54a_strange_guy,(meta (quote #^{:foo "bar"} #^foo (+ 5 6)))
10:54clojurebot{:foo "bar"}
10:54chouserheh. didn't know that was supported at all
10:54chouserI mean, that it worked. I'm pretty sure it's not "supported"
10:54Chousukethat's probably undefined behaviour, yes :P
10:55a_strange_guyi was just thinking because there are so many case with:
10:55bobo_any easy way to add a jar to slime/swank/emacs thingy? compojure.jar to be exact
10:56a_strange_guy#^{:macro true} or #^{:private true} etc.
10:56a_strange_guythat you could make #^:keyword == #^{:keyword true}
10:57Chousukehm
10:57Chousukethat wouldn't be so bad.
10:57a_strange_guythen (def #^:private #^macro ..)
10:58chouserI think I'd prefer to have options elsewhere in the forms that need them
10:58a_strange_guyor even (def ^String ^:private)
10:59a_strange_guycame to my mind when looking at #^{:unsynchronized-mutable true}
10:59Chousukethat's verbose on purpose
10:59Chousukeso that you won't use it :P
10:59chouser(defn sillyquote {:macro true} [x] `'~x) ; works today
11:00a_strange_guykeywords seem already reserved but unused
11:00a_strange_guy,(meta (quote #^:foo bar))
11:00clojurebot{:tag :foo}
11:03technomancybobo_: place it in lib/ and do another M-x swank-clojure-project to restart your session
12:46technomancyClojure just passed CL to become the #19 on the github high score chart: http://github.com/languages/Clojure
12:46bsteuberany ideas about an exception "java.lang.String cannot be cast to clojure.lang.Named" when compiling a project with lein?
12:46chousersomething is a string when it should be a keyword or symbol
12:47bsteuberic - wasn't sure about what Named means
12:50chouserlook for [N] here: http://tinyurl.com/clojure-classes ...because that's, you know, easy. :-P
12:50chouserit would be nice to have a way that lists everything currently known to implement X
12:51bsteuberwow - what a graph :)
12:51RaynesYay!
12:51arohnerchouser: is there a way to iterate through all known classes?
12:51chouserit's old and probably out of date, but a lot of it is still correct
12:51bsteuberthe strange thing is that I don't even get a source file name in the exception
12:51bsteuberso I'm wondering if anything gets compiled at all
12:51arohner(filter #(contains? (ancestors %)) magic-class-list) should do it
12:52chouserarohner: not a good way. You could iterate through classes imported into a given namespace, or walk through .class files in a given .jar or directory. :-/
12:53bsteuberI think Java doesn't provide a nice way to list all classes of a package
12:53stuartsierrabsteuber: it doesn't provide any way at all
12:54bsteuberwell, you can parse your classpath :)
12:54bsteuberbrowse
12:54chouser,(filter #(instance? clojure.lang.Named %) (vals (ns-imports *ns*)))
12:54clojurebot()
12:55chousernope
12:55chouser,(filter #(isa? % clojure.lang.Named) (vals (ns-imports *ns*)))
12:55clojurebot()
12:55chouser,(import [clojure.lang Symbol Keyword])
12:55clojurebotclojure.lang.Keyword
12:55chouser,(filter #(isa? % clojure.lang.Named) (vals (ns-imports *ns*)))
12:55clojurebot(clojure.lang.Keyword clojure.lang.Symbol)
12:55chouserThere! so as long as you know the answer ahead of time, you're all set.
12:55arohner,(identity *ns*)
12:55clojurebot#<Namespace sandbox>
13:25arohnerI have a question: I have some code that looks like (defn my-fn [] (sql/transaction (foo) (bar) (baz))) . I want the return value of the function to be the return value of (bar). Is there any way to do this with a let or anything else "normal"? Do I have to resort to e.g. an atom?
13:26tomojis there not an official clojureql in clojars?
13:26tomojarohner: I don't understand
13:27tomoj(defn my-fn [] (let [bar (bar)] (sql/transaction (foo) bar (baz)) bar))
13:27arohnertomoj: but then the call to (bar) happens outside the transaction. (bar) has to be called inside the transaction
13:28danleiarohner: if the order of execution of (foo) (bar) and (baz) is important, you can just do all three of them in a let, otherwise tomoj's solution will suffice
13:28tomojoh, I see
13:29arohnerso then I do (defn my-fn [] (transaction (let [foo (foo) bar (bar) baz (baz)] ???) bar)
13:29arohnerbut that last bar is outside my let block, because the let is inside the transaction
13:29tomojso return bar from the let block?
13:30arohnerah, it does look like contrib.sql/transaction promises it returns the value of the last expression
13:30arohnerthanks
13:39dakroneis there a more idiomatic way of doing this, ww is (["foo" 1], ["bar" 0], ["baz" 3]), I want {"foo" 1, "bar" 0, "baz" 3} : (reduce merge (map #(hash-map (first %) (second %)) ww)) ?
13:39chouser(into {} ww)
13:40dakroneahahaha, that's much better :) thanks chouser
13:40chouser:-)
13:40dakronelisp makes it very easy to make doing simple things very difficult
13:40dakroneit's an amazingly-obfuscatable language
13:41danleiarohner: btw, (nitpicking) don't say "let-block", there is no such thing as a block, everyting is an expression
13:42chousereh
13:43hiredmanwhat is the diff?
13:54danleihiredman: you mean the difference between a block and an expression?
13:57hiredmansure
13:57hiredmandoes block have a formal definition?
13:58hiredmanhttp://en.wikipedia.org/wiki/Block_%28programming%29 <-- has a scheme example
13:58stuartsierra"any expression where the hanging indent doesn't line up with the first argument" ;)
13:58danleiwell, in procedual languages, there usually is a distinction between statements, expressions and blocks (in C-like syntax stuff between { }). I don't think this distinction exists in Lisps and using that terminology might convey the impression, that there is such a difference in lisps.
13:58hiredmanok
14:05ChousukeI'm not sure if calling let expressions blocks is a bad thing
14:05Chousukethey can contain more than one expression
14:06stuartsierraMaybe anything with an implicit "do"
14:07danleimaybe not a bad thing per se, but it sounds a bit strange to me. surely one can use terms like "block of scope", but "block" like in {} doesn't fit in my opinion.
14:07danleibut it's just my opinion
14:08danleiAnd I haven't heard it used like this in a Lisp context before
14:08danlei"let block", hm ...
14:08danleipretty sure that sounds strange to me
14:08arohnerwell, I'm the guy that also got flack for calling Ruby Dictionaries hash-maps
14:09stuartsierraCommon Lisp talks about blocks, if I recall
14:09Chousukecommon lisp actually has its own definition for a block :)
14:09Chousuke"block n. a named lexical exit point, established explicitly by block or implicitly by operators such as loop, do and prog, to which control and values may be transfered by using a return-from form with the name of the block."
14:09stuartsierrasheesh
14:09Chousukenot very well applicable to clojure
14:09RaynesDoes it really matter?
14:10Chousukewell, as long as you don't talk about lisp statements it's fine :P
14:10danleiwell, CL has features of imperative languages, like the "prog" feature and stuff. but ok, don't wanna argue about that. let's just say I think "let block" sounds strange.
14:12RaynesI think 'muffler' sounds strange, but my car still needs one.
14:17danleiIt's not about the muffler, it's more akin to the question "is clojure for a loop"
14:17danleibut, enough about that.
14:18stuartsierra~for
14:18clojurebotfor is not a loop
14:18wthiddenHas the java static method interop syntax changed in 1.2.0? I'm using class/static method interop and the interperter is confusing this with a
14:18danlei:)
14:18wthiddena namespace expression
14:18chouserwthidden: nope, hasn't changed
14:19stuartsierrawthidden: that usually means you haven't imported the class name
14:19stuartsierraor you mistyped the class name
14:19wthiddenhmm.. so (def dbconn (DBusConnection/getConnection 1)) should be valid, if DBusConnection is a valid class?
14:20wthiddenwith static method getConnection of course.
14:20chouserif you've imported DBusConnection, yes
14:23wthiddenhmm it seems my (:import '(org.freedesktop.dbus.DBusConnection)) form on my namespace was not "importing" as i expected....
14:25stuartsierrawthidden: replace the last . with a space
14:25stuartsierraand remove the quote
14:26danleiI'm still wondering if the #:...{} representation of types will be made readable ... (throwing an error if the type is not defined)
14:26wthiddenstuartsierra: yes.. i re-read the spec... quoting it is bad..
14:27chouserdanlei: I think some mechanism for readable deftypes is planned, but I don't know if the syntax will be anything like what deftypes currently print
14:27danleichouser: ok, thanks
14:27stuartsierradanlei: it opens a whole can of worms, though. literal objects, compile-time objects, ...
14:28chousermmmm worms
14:28wthiddenstuartsierra: hmmm if i replace the last '.' with a spec, i get a class loader error, but with the last '.' still there it does not complain.
14:28wthidden*space
14:28danleistuartsierra: maybe that's a naive question, but couldn't it be handled like [] or {}?
14:28stuartsierradanlei: Maybe, but the compiler knowns what the class of [] should be.
14:29stuartsierradanlei: If the compiler encounters #:... or whatever, it has to create an instance of a totally unknown class.
14:29stuartsierraProbably doable, just tricky.
14:29danleistuartsierra: since the compiler in lisps is part of the language, is that a problem?
14:30stuartsierradunno
14:30danleiI haven't thought through the implications, I'm just asking
14:32Chousukeyou mean the reader. hm
14:34danleireader sees #:Foo{:x 1} and calls (Foo 1), compiler compiles it like anything else?
14:35Chousukesomething like that.
14:36chouseris there really no way to implement my own IKeywordLookup with deftype?
14:37chouseror even ILookup?
14:39chouseranyway, reify is fine, but using it to close over 3 values appears to take 60% longer than closing over 1 value.
14:39rhickey_(deftype T [] clojure.lang.ILookup (valAt [k] :foo))
14:39rhickey_(:fred (T))
14:39danleiis there javadoc online for the clojure classes and interfaces implemented in java?
14:42chouserrhickey_: ok, thanks. That works for me too, but I'm getting a java.lang.ClassFormatError: Duplicate interface name in my real code.
14:43programblehello all o/
14:43programblei have a question:
14:45programblesay i have 2 sequences (right term?), and i want to create one sequence out of these
14:45programblesay
14:45programble'(1 2 3)
14:45programbleand
14:45programble'(3 4 5)
14:45programbleand i want '(1 2 3 3 4 5)
14:45danlei(into [1 2 3] [4 5])
14:45programblethanks
14:46programblewait...
14:46programblei actually have
14:47chouseroh, my deftype was macro-generated and I had (valAt ...). Using (~'valAt ...) fixes it.
14:47programbleim trying to implement quicksort as a beginner exercise
14:47programbleso really i need
14:47programbleto create a sequence/list/whatever from a list, a number and another list
14:48chouser,(concat [1 2 3] [4] [5 6 7])
14:48clojurebot(1 2 3 4 5 6 7)
14:48programbleah
15:02dakroneis there a (distinct ...) for hash-maps that filters by key? or should I just manually do it
15:02hiredmanuh, what?
15:03dakronesomething like (distinct {:a 1 :a 2}) -> {:a 1}
15:03dakronethrow out all recurring keys
15:03hiredmanhash maps can't have recuring keys
15:04programblelol
15:04dakrone,(keys {:a 1 :a 2})
15:04clojurebot(:a :a)
15:04hiredmanthat is not a hash map
15:04hiredmanand it is operator error
15:05hiredmanarray maps don't check for duplicate keys for performance reasons, but the behaviour of duplicate keys is undefined
15:05Chousuke,(apply hash-map '(:a 1 :a 2))
15:05clojurebot{:a 2}
15:05Chousukeat least that works :)
15:05dakroneyou're right, I was assuming (into {} ...) would put duplicates in, it doesn't
15:05chouser(into {} {:a 1 :a 2})
15:05chouser,(into {} {:a 1 :a 2})
15:05clojurebot{:a 2}
15:06dakronethanks
15:07dakronehiredman: if it threw an exception, would the preferred usage be to wrap (into ...) with a try/catch if we wanted it to remove duplicates?
15:08hiredmandakrone: don't use map literals with duplicate keys
15:09hiredmanunless you try hard, that is the only way to produce a map with duplicate keys
15:09chouserhiredman: does it check only at read time?
15:09hiredmanwrapping in a try/catch would not catch the exception, because the reader would throw the exception
15:09hiredmanchouser: yes
15:09hiredmanit doesn't touch array map
15:09chouser,{3 :a (+ 1 2) :b}
15:09clojurebot{3 :a, 3 :b}
15:10hiredmanmm
15:10hiredmanthat is unfortunate
15:10dakroneso, I have a list like (["bobby" 1/3] ["fire" 1/2] ["truck" 1] ["city" 1/2] ["truck" 1] ["state" 1/2] ["colorado" 1/3]) that I'm collapsing into a {}, how would I get around that then?
15:11dakronemap (distinct? val) over all of it and filter it before?
15:11hiredmanget around what?
15:11chouserwhat do you want it to do? does (into {} your-seq) not do what you want?
15:12dakroneduplicate keys, I thought you were saying it would throw an exception since there are 2 occurrences of the "truck" key?
15:12kotarakhiredman: chouser: comes from the fact, that the reader makes a map containing "3" and "(+ 1 2)" as keys. The + call is not evaluated by the reader.
15:12dakronechouser: no, (into {} ..) works great, I'm trying to understand if hiredman's change would affect it
15:12hiredmankotarak: I think we both know that
15:13chouserdakrone: hiredman has a non-standard patch that throws exceptions. But it wouldn't throw in your case, and won't be applied to clojure anyway.
15:13chouserdakrone: ie, you're safe.
15:13hiredmanchouser: oh, your words are like razors to my wounded heart
15:13radsis there a way to get ring/compojure to auto reload files rails-style?
15:14dakronechouser: okay, thanks for the clarification
15:14chouserhiredman: :-) sorry.
15:14chouserjust being realistic here.
15:15hiredmanclojurebot: ticket #87
15:15clojurebot{:url http://tinyurl.com/y92lmv8, :summary "GC Issue 83: PersistentArrayMap trust the reader (map literals) too much", :status :test, :priority :low, :created-on "2009-06-17T20:36:09Z"}
15:15kotarakrads: the reload-middleware delivered with ring?
15:15hiredmanwell, my patch also throws a nicer exception for {:a}
15:15chouserhiredman: oh yeah, I keep forgetting about that ticket.
15:15hiredman,{:a}
15:15clojurebotjava.lang.ArrayIndexOutOfBoundsException: 1
15:16radskotarak: looks good, thanks
15:19jasappwho works at sentry data systems here?
15:20chouserjasapp: I do
15:20jasappahh, that's right.
15:20jasappI've got an interview with them tomorrow
15:20chouserjasapp: applying for a job?
15:21chouserexcellent!
15:21jasappI think I'm talking to Ben Mahan, and Cyrus Keck
15:22jasapproughly, how many developers do they employ?
15:23programblei cant get the clojure REPL to work with jline.
15:24programbleit gives me a ClassNotFound clojure.main
15:24programblei am runnign the command java -cp ~/Stuff/clojure/jline-0_9_5.jar:~/Stuff/clojure/clojure-1.1.0/clojure.jar jline.ConsoleRunner clojure.main
15:25chouserjasapp: about 20 developers I think, not including technical analysts and other technical folk.
15:26jasappinteresting, that's good to know
15:27chouserprogramble: are you on a unix?
15:27chouseroh, you must be. your problem is with the ~, but I'd recommend just using rlwrap instead
15:27programblechouser: yes
15:27programble...
15:27programbleexplain
15:28chouserjava classpath doesn't support ~
15:28programblehuh
15:28programbleit seems to support one ~ though
15:28programblebecause
15:28chouserwell, your shell is expanding the first one
15:28programbleah
15:28programbleso, whats rlwrap?
15:28chouserpeople seem to have better results with rlwrap though. it's a separate program.
15:29chouserrlwrap java -cp :~/Stuff/clojure/clojure-1.1.0/clojure.jar clojure.main
15:29chouserbut skip that :
15:29programblek thanks
15:30programblegreat, it works :)
15:30clojurebottwitteronia is where shaq lives
15:41radsis there a way to get ring's reload middleware to reload a namespace and all of it's child namespaces?
15:49arohnerrads: you can use (require 'foo :reload-all) . That works in general, I don't know if it will work with ring
15:50arohnerbut I use it all the time on compojure
15:50arohnerthat reloads 'foo, and everything required in foo. It won't necessarily reload foo.bar unless foo requires foo.bar
15:54radsarohner: turns out ring does the same thing but with just :reload. I made a new fn that uses :reload-all instead and it works fine
15:56radsalthough it is kinda slow since it reloads *everything*, not just my code. might just be best to add all of my namespaces
15:59programbleis there an equivalent of haskell's zipWith in clojure?
15:59dakroneprogramble: (reduce ...)
15:59dakrone,(reduce + [1 2 3])
15:59clojurebot6
16:00hiredmandakrone: I don't think so
16:00hiredmanprogramble: map takes multiple collections
16:00dakroneis that not what zipWith does?
16:00hiredmandakrone: nope
16:00the-kennydakrone: Isn't that foldl?
16:00hiredmanreduce is a fold
16:00kotarakdakrone: I think reduce is foldl or foldr, can't remember those
16:00hiredman,(map + [1 2] [3 4])
16:00dakronehiredman: okay, I'm wrong, sorry programble
16:00clojurebot(4 6)
16:01programblezipWith takes a function and two lists, the function is called with the first item of the first list and the first item of the second list, etc
16:01programbleoh, map works
16:01programblenvm
16:01hiredmanright
16:01kotarakprogramble: even with more lists
16:01kotarak,(map vector [1 2 3] [ 4 5 6] [ 6 7 8])
16:01clojurebot([1 4 6] [2 5 7] [3 6 8])
16:05programblehow can i convert int to char and back?
16:05programblelike a -> 97
16:05hiredman(char 97)
16:05Raynes,(char 97)
16:05clojurebot\a
16:05programbleand back?
16:05Rayneshiredman: I win.
16:05hiredman,(int \a)
16:05clojurebot97
16:05Raynes(int \a)
16:05RaynesYou got that one. :(
16:07programblehrm...
16:08programbleand how can i go to and from a /string/ and int
16:08programblelike
16:08programblebetween string and list of ints
16:09hiredman,(String. (make-array Byte/TYPE [97 99 100]))
16:09clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Character
16:09icemazeHi everyone. Can anyone help me with a Java-clojure problem?
16:09hiredman,(String. (into=array Byte/TYPE [97 99 100]))
16:09clojurebotjava.lang.Exception: Unable to resolve symbol: into=array in this context
16:09hiredman,(String. (into-array Byte/TYPE [97 99 100]))
16:09clojurebotjava.lang.IllegalArgumentException: argument type mismatch
16:09hiredmanBLEH
16:10hiredman,(String. (into-array Byte/TYPE (map byte [97 99 100])))
16:10clojurebot"acd"
16:10icemazeEheh, I see you already have a lot of those ;)
16:10chouser,(apply str (map char [97 99 100]))
16:10clojurebot"acd"
16:10chouser,(map int "acd")
16:10clojurebot(97 99 100)
16:11Rayneschouser: Beat you to it in another channel. :p
16:11programblelol
16:11programblei answered my own question actually
16:11radsis there a way to restart a jetty server running in a swank repl without restarting the whole repl?
16:14icemazei'm having a problem loading java classes, can anyone give me tips on how to solve this problem?
16:15icemazei have a .class file, which is generated by ANTLR, and i'd like to instantiate the class inside it
16:15Raynes"My computer broke. How do I fix it?" :>
16:15icemaze(I'm using the enclojure plugin under netbeans, it this helps)
16:15nDufficemaze, ...and does your classpath include an appropriate entry?
16:16icemazeThis is a good question: I think Netbeans adds the project's directory in the classpath but I'm not 100% sure. What can I do to verify this?
16:17icemazeMaybe Netbeans does so for pure Java projects only
16:19kotarakicemaze: try (System/getProperty "java.class.path") in the Repl. This should give you a clue, what is on the classpath.
16:19icemazeThanks. I'll try it.
16:20icemazeYes: "...../build/classes", that's where the .class is (this is under a "clojure.lang.LazySeq", hope it's ok)
16:22hiredmanwhat?
16:22clojurebotwhat is short for ,(doc ...)
16:22icemaze(The error I get when compiling is: "Unable to resolve classname: TLexer")
16:22programblehuh
16:22hiredmanwhat do you mean: under a "clojure.lang.LazySeq"
16:22programblewhat zip
16:23programbleno?
16:23clojurebotda da king of the road
16:23hiredmanzip?
16:23clojurebotzipper is http://clojure.org/other_libraries#toc5
16:23hiredmanclojurebot: knock it off
16:23clojurebotClojure ranked #21 on 8/14/2009
16:23programblewtf?
16:24icemazeyes, it doesn't make much sense. Wait, I'll copy what I get:
16:24dakroneis it possible to define a multimethod using regex for an argument as the dispatch? if so, can someone point me to an example of what that looks like?
16:24icemaze"[some normal paths]:clojure.lang.LazySeq@3081b84b:#{#<ClassPath /usr/share/clojure/clojure.jar....."
16:25icemazemaybe the enclojure plugin is messing this up
16:25hiredmansounds right
16:25hiredmanI mean
16:25hiredmanyes, the plugin is messing that up
16:25icemazemh, ok
16:26icemazeI'll report a bug then
16:26hiredmanit looks like it is relying on very old behaviour of .toString on lazy-seqs
16:26hiredmanwhich changed eons ago
16:26icemazethat's strange: I donwloaded the plugin from github, it's the jan-2010 version
16:26hiredman*shrug*
16:27icemazethank you for your help!
16:29hiredmanhmm
16:30hiredmanwell, even with the old .toString behavior you wouldn't get a valid classpath
16:32icemazeMy environment is a little odd: arch linux + Netbeans 6.8 + clojure v1.1.0.
16:32icemazeIf it was a common bug, I would already be reported.
16:33hiredmanyou'd be surprised
16:58dakrone,(contains? ["foo" "bar" "baz"] "foo")
16:58clojurebotfalse
16:59dakronewhat's the right way to see if a vector has a string in it?
16:59Chousuke,(some #{"foo"} ["foo" "bar"])
16:59clojurebot"foo"
16:59hiredman,(doc contains?)
16:59clojurebot"([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'."
16:59Chousukethat's one way
17:01dakroneis there a method that returns boolean? otherwise I can wrap (if (some #{} []) true false)
17:02chouserwhy do you need a boolean?
17:02dakronechouser: passing into a java method that can't reflect if it's not boolean
17:02Chousukedakrone: you can use boolean to cast it to one
17:02Chousuke,(boolean "foo")
17:02clojurebottrue
17:03brandonwinteresting how contains? doesn't work on strings. i thought it recursively generates a set
17:03dakroneChousuke: cool, that does it, thanks!
17:03Chousukebrandonw: it doesn't test for membership, it tests whether a collection contains a *key*
17:03hiredmanbrandonw: did you read the docstring?
17:03Chousukeoops
17:03chouser,(.contains ["foo" "bar"] "foo")
17:03clojurebottrue
17:04Chousukehm
17:04dakroneit's confusing to share the same name as the java method
17:04Chousukeyes it is :P
17:04hiredmancontains? does work on strings
17:04chouser,(contains? #{"foo" "bar"} "foo")
17:04hiredman,(contains? "foo" 1)
17:04clojurebottrue
17:04clojurebottrue
17:04chouserthere. now we're fully muddled.
17:06dakronehiredman: does (contains? "foo" 1) work because it does something like (get "foo" 1)?
17:06ska2342contains? is broken by design. It's behaviour is documented (with the exception of lists) but it does not do what the name suggests under all conditions. Nah, me no friend of contains? ;-)
17:06hiredmandakrone: no
17:06dakronehiredman: how does (contains? "foo" 1) work?
17:06Chousuke~contains?
17:06kotarak,(some #{false} [true false true])
17:06clojurebotcontains? is for checking whether a collection has a value for a given key. If you want to find out whether a value exists in a Collection (in linear time!), use the java method .contains
17:06clojurebotnil
17:06hiredman(> (count x) n)
17:06kotarakBeware the boolean.
17:06hiredmanwhere x is the string and n is the number
17:07Chousukebut yeah, it's horribly named :P
17:07chouserI think the relationship to 'get' is sound.
17:07chouser,(get "foo" 1)
17:07clojurebot\o
17:08ska2342chouser: I think most people would expect (contains? "foo" \o) to work. Not?
17:08dakroneconceptually that is very difficult to wrap my head around
17:08brandonwohhh it was distinct? i was thinking of
17:09brandonwnot contains?
17:09Chousukedakrone: contains? would make more sense as has-value-for-key? or something
17:09chouserif you pretend 'contains?' is named 'has-key?', your instincts may serve you better.
17:09dakronechouser/Chousuke: yea, those make more sense to my brain
17:10dakronethanks
17:10ska2342chouser: what about lists? ;-)
17:10Chousukeit's probably the number one faq about Clojure. besides "how do I get slime to work?" or something :P
17:10chouserska2342: holds ok, I think. do lists have keys? no. so contains? always returns false.
17:11ska2342chouser: OK, got me. Nevertheless, I'm not convinced. Whatever...
17:12chousernot convinced that 'has-key?' is a better name? or that the functionality of 'contains?' should exist at all?
17:12drewrI always do (when (:foo m) ...) or similar
17:13drewrdon't think I've ever used contains?
17:13chouseryeah, it's hardly ever needed, except when you need to detect keys that have nil or false values.
17:13ska2342chouser: has-key would be a better name, the functionality as expected by users should exists with the given name. However the distinction between lists and vectors and other iterables or instances of Counted feels weird
17:13bhenrywhat would you use if you really wanted to know if a string contained a substring?
17:13chousereven then 'find' is often better.
17:14hiredmanclojurebot: jdoc String
17:14kotarakska2342: does performance promises help here? O(1) on vectors vs. O(n) on lists?
17:15hiredmanbhenry: I would read the javadoc for String
17:15chouseror use clojure.contrib.string
17:16kotarakdrewr: your approach works if you can guarantee that there are no nils and booleans in your collections. If you can't, you have to (when (contains? m :foo) ...)
17:16chouseror (when-let [[_ v] (find m :foo)] ...)
17:17ska2342kotarak: no. contains takes special care of several counted things (e.g. String) but not Counted and PersistentList extends Counted so it's O(1). Or am I mistaken here?
17:17drewrkotarak, chouser: usually when I have a nil as value I still want the predicate to be false
17:17technomancyis there anything like the namespace function that returns the namespace itself instead of the name of the namespace?
17:17technomancywow, that was a mouthful =)
17:18dnolenwell looking the source of core.clj contains? is used 12 times. Source also points out that it searches the collection in constant time.
17:18kotarak,(the-ns 'sandbox)
17:18clojurebot#<Namespace sandbox>
17:19technomancykotarak: the namespace function takes a symbol and returns its namespace
17:19technomancyrather than taking a namespace name
17:19technomancy,(namespace reduce)
17:19chouser,(the-ns (symbol (namespace `map))) ;-(
17:19clojurebotjava.lang.ClassCastException: clojure.core$reduce__4509 cannot be cast to clojure.lang.Named
17:19clojurebot#<Namespace clojure.core>
17:19dnolen,(find-ns 'user)
17:19clojurebot#<Namespace user>
17:20dnolen,(find-ns (symbol "user"))
17:20clojurebot#<Namespace user>
17:20chousertechnomancy: symbols and keywords only know their namespace name. they don't actually point to the namespace object, I think.
17:20bsteuber,(namespace 'reduce)
17:20clojurebotnil
17:20technomancychouser: I see. feels a bit like an implementation detail leaking out, but I'm just being extra picky.
17:20bsteuber,(namespace `reduce)
17:20clojurebot"clojure.core"
17:20Chousukesymbols are just names
17:20technomancycalling (the-ns (symbol )) is not a big deal
17:20Chousuke,(namespace 'foo.bar/blah)
17:20clojurebot"foo.bar"
17:21Chousukethe namespace doesn't have to actually exist :P
17:21technomancyChousuke: ah, good point. that's a good explanation
17:21kotarakchouser: ad find... what's the difference to get?
17:21technomancyI find that property to be very useful in other situations.
17:22chouserfind returns a key/value pair, or nil if not found
17:22kotarakah. it returns the map entry.
17:22kotarakk
17:25hiredman,(doc the-ns)
17:25clojurebot"([x]); If passed a namespace, returns it. Else, when passed a symbol, returns the namespace named by it, throwing an exception if not found."
17:42RaynesShouldn't args surrounded in double quotes on the command-line be treated as a single argument? Calling a clojure application with "meow meowz" results in two args instead of one. I'm not sure that should be expected behavior.
17:44RaynesMost other languages treat arguments surrounded in double quotes as a single argument.
17:49chouserRaynes: windows?
17:49RaynesNo.
17:49Raynesprogramble: Not windows, right?
17:50programble...no
17:50programblei feel dirty after the mention of windows
17:50Raynes:p
17:51Rayneschouser: This isn't a bug, is it?
18:07pcapriottiis it possible to recursively define a lazy-seq in clojure?
18:08pcapriottisomething like the following haskell: fib = 0 : 1 : map (uncurry (+)) (zip fib (tail fib))
18:11pcapriottithe-kenny: that would be in clojure: (def fib (concat [0 1] (map + fib (rest fib))))
18:12pcapriottibut fib is unbound inside the declaration of fib, so that doesn't work
18:15the-kennypcapriotti: hm.. not sure if it's helpful, but fibs is defined in contrib as: (map first (iterate (fn [[a b]] [b (+ a b)]) [0 1]))
18:17pcapriottithe-kenny: yeah, that was just an example... of course in this case there's no need to define it recursively
18:25danleipcapriotti: (def fib (lazy-cat [0 1] (map + fib (rest fib))))
18:28bsteuberdanlei: nice
18:28bsteuberso lazy-seq does the trick, as fib is defined when the body is finally evaluated
18:28pcapriottidanlei: oh, cool, lazy-cat does the right thing
18:28programblemy cat is lazy
18:28programblesorry, just needed to make that joke
18:30rickmodeI've got a newbie question: I'm starting to hack a compojure app. I started the app using lein new my-app. Now, do I compile the hello world and use slime-connect in Emacs, or can I somehow use the SLIME in Emacs? I'm trying to do the latter but my SLIME (fired up with M-x slime) doesn't know about compojure.
18:30pcapriottinow, is it possible to do that without creating a global binding?
18:30pcapriottilike: (let [fib ??])
18:31bsteuberrickmode: swank-clojure-project is your friend
18:31bsteuberor lein-swank
18:32rickmodebsteuber: OK, so using M-x slime is just for fooling around, but when working on a project you connect your Emacs with the running project via M-x slime-connect. Do I have that right?
18:32rickmode(I know it works, I'm asking the best-practice)
18:32the-kennyrickmode: Or you fire the repl for the specific project up in emacs with M-x swank-clojure-project
18:32bsteuberyeah - though you also have M-x swank-clojure-project
18:32bsteubertoo slow :)
18:33the-kennyI personally use swank-clojure-project, so I don't have to remember port-numbers etc.
18:33bsteuberme 2
18:34bsteuberalso, it is just one single step compared to starting the server by hand and connecting from emacs
18:34dnolenrickmode: M-x slime, M-x slime-connect are both for real work. M-x slime-connect is more useful in conjunction with lein swank (you don't have to configure your classpath)
18:34powr-tocI tend to use a shell script to start a jvm with my vm settings and classpath... as you'll probably have to specify this in production anyways
18:34powr-tocthen connect with slime-connect
18:35bsteubertrue, slime-connect gives you more options
18:35bsteuberbut as long as I don't have a reason to do so I'll stick with the most lazy version
18:35rickmodeOK so I've created my app with lein new my-app. Next is what? (I'm missing a step - using M-x swank-connect-project is polling for something...)
18:36bsteuberyou can look in your *inferior-lisp* buffer to see the error
18:36powr-tocbsteuber: fine advice :-)
18:36bsteuberbut probably you need to run lein deps
18:36bsteuberto get clojure and contrib
18:37bsteuberalso you need to add the swank dependancy to your project.clj
18:38bsteubere.g. :dev-dependencies [[swank-clojure "1.1.0-SNAPSHOT"]]
18:38bsteuberdammit, my IRC client always gives me a smiley for :d
18:39programblelol?
18:40rickmodebsteuber: OK I got the dev-dependency, and it's still polling. So when I fire up my Emacs, I don't have an inferior-lisp or slime. Do I need to fire up M-x slime first?
18:40bsteuberby the point it's polling you should have that buffer
18:41bsteubermaybe rerun lein deps after adding the dev-dep?
18:42rickmodebsteuber: heh - it was there... I'm still Emacs challenged (my foray into Lisp started just over a month ago as I started reading PCL, following along with Aquamacs/SLIME/SBCL)
18:44bsteuberI'm using emacs for some years now and still don't have clue about most stuff ;)
18:44bsteuberfunctional programmers are just too lazy xD
18:44dakronetoo much emacs in here :), any other vim users get a useable folding method around (defn ...) they care to share?
18:46rickmodebsteuber: i've spent the last couple months looking for my ultimate web dev environment rather than pick something easy and go with it. That's how lazy i am.
18:47rickmodeSo I"m getting issues in my *inferior-lisp*: Could not locate swank/swank__init.class or swank/swank.clj on classpath: (NO_SOURCE_FILE:0)
18:47rickmode(BTW: where do we paste in this channel?)
18:48bsteuberand I spent a year trying to invent my own lisp instead of reading about clojure :)
18:48rickmodeegad... you aren't pg in disguise are you?
18:48Maddasdakrone: I use vi emulation in Emacs instead ;)
18:48bsteuberI guess most use github gists, but I guess you're free to do what you like
18:48bsteuberlol
18:49bsteuberrickmode: ok so you're sure there's a swank-clojure jar in lib?
18:51hiredmanlisppaste8 is a bot that used to help with pastebin stuff, but it seems to be dead
18:51bsteuberbut no, I'm not pg lol
18:51dnolenrickmode: compojure is pretty easy and certainly no worse going than setting up and configuring a working python web development environment or even a PHP one.
18:51Rayneslisppaste sucks anyways.
18:53hiredmanit had irc integration
18:53hiredmanI dunno of any other pastebin that does
18:54rickmodednolen: I agree. I noodled with Python and Django for a bit. Liked it. Looked at Ruby on Rails. There seems to be one way for library writers to create libraries (with all the monkey patching and such) and another for mortals to use Ruby. I didnt' like that. Tried CL - loved the language, then wasted a few weeks building a web stack. (I ranted about this on my blog.) Went back to Django and... decided to look at Clojure. I had discarded the Clojure route
18:54rickmodeinitially because of the JVM dependency.
18:55danleirickmode: link to that rant?
18:55bsteuberme two - having to use Java all the time at university kind of gave me a trauma
18:56bsteuberso I didn't want a lisp that is connected to it somehow
18:56rickmodedanlei: http://rickmode.com/2010/02/21/common-lisp-pain/
18:56powr-tocrickmode: the JVM is a pretty awesome piece of kit
18:56danleirickmode: thanks
18:56lancepantzis there a way i can remove one of the into #{} functions in this? http://www.pastie.org/850851
18:57rickmodeI started with Clojure Friday night. I was totally sold after the first video on blip.tv.
18:57lancepantzi'm using the filter to compact nil values
18:57dnolenrickmode: at first JVM dependency seems lame. But then you realize there's a quite lot of good software written for the JVM. Also that it's the only thing remotely near the speed of C++ without the suckiness (IMO).
18:58hiredmanlancepantz: for has a lot of keyword modifiers
18:58hiredmanmaybe :when or :while
18:59dnolenexcept for maybe Haskell, but I'm attached REPL style development, and not convinced about types.
18:59bsteuberactually, having to deal with some aborted c++ project for a few months made me love Java again
18:59rickmodednolen: well the problem in java is that there is so much boilerplate that to keep things anywhere near DRY you need a library or framework. So then there's the framework explosion. The mess gets so big Ant can't keep up. So then there's maven. Ugh. Well at least I can code happily now and cherry pick the best bits. If Clojure really takes off, hopefully the crufy java bits will fall away.
18:59bsteuberwell, not love, respect
19:00lancepantzhiredman: can i use them to change the returned datastructure though?
19:00powr-tocrickmode: I think clojure has a good chance of avoiding the whole framework composability problem... It seems like a return to simple API's
19:00danleirickmode: feel your pain (regarding cl). I think it's best to always check out heads by hand, and not use asdf-install at all (am not a friend of clbuild either)
19:00hiredman:when (not (nil? v))
19:00hiredmanor just :when v
19:01rickmodebsteuber: Ya... C++ is even harder. The object-orgy is worse there than java. Actually I was against Java from the beginning because only the compiler writers could write something like string contatention ala "foo" + "bar". Tha'ts lame. But at this point I appreciate what Java got write. The inner classes are cool (but closures are better). The gc is cool. The packaging system is really good.
19:01hiredmanor just remove the inner into
19:01lancepantzi see
19:03rickmodedaniel: My biggest problem is that I would look at, say UCW.. and no docs at all. Then Weblocks - looks *really* good, but then I can't get 3 of 4 demos to run due to busted dependencies. Anyway CL does feel like stepping back to the early 90's. The library ecosystem is a bit of a wasteland. I want to stand on the backs of giants, and that isn't possible as a new CL coder.
19:03bsteuberrickmode: platform independence (more or less) is great
19:03Raynesrickmode: That was one hell of a rant. :>
19:04bsteuberthe java guis always said they wanted to drag the c++ crowd halfway to lisp - and I thing they did a good job concerning the environment, gc etc.
19:04bsteuberso clojure is the next logical step
19:05rickmodeugh gotta run - i'll be back with more questions later... thanks for the help so far guys
19:05powr-tocpersonally I think Java did a lot of good for the industry... It popularised garbage collection, and made VM's acceptable... As a language it was pretty unambitious, but it did a lot of things well... Now Clojure makes the JVM awesome.
19:06danleirickmode: I absolutely agree regarding documentation/libraries, but as far as the language itself is concerned: There's a lot to learn there. Even if there are warts and things which feel really old nowadays (e.g. in the pathname system), it's one of my favorite languages. Many of those things, clojure gets right, but some things I miss from CL.
19:06lancepantzhiredman: got it, thanks for your help
19:07danleirickmode: so I'm all for learning both of them ;)
19:07bsteuberI don't miss much from CL
19:08danleiwell, I said "some" ;)
19:08RaynesI see nothing in CL that I would miss if I learned it.
19:08bsteuberbut I had been a haskell convert before finding clojure :)
19:08danleiRaynes: condition system, debugger ...
19:09bsteuberdanlei: but those will hopefully be possible in clojure with the new &env stuff, not?
19:10danleibsteuber: clojure is young, and I think those things will be done in the future. I've great expectations ... I mean, it started in 2007, right?
19:10danleithat's just 3 years
19:11Raynes2, actually.
19:11danleior 2, yesw
19:11bsteuberwhat I miss in clojure is static type inference
19:12bsteuberin haskell, this really made up for 80% of my tests
19:12danleibsteuber: have a look at Qi or typed scheme
19:13danleiI'm more of a dynamic typing guy (but still, I check out haskell ... slowly ;)
19:13bsteuberI think dynamic typing with a type-time inference engine would be awesome
19:13bsteuberbut that could be done on top of clojure
19:14bsteuberthe term type-time might be confusing :)
19:14bsteuberbut I will have a look at Qi and typed scheme
19:17danleibsteuber: I think if you're coming from haskell, you'll prefer Qi, last time I checked typed Scheme, there was no type inference
19:17bsteuberqi looks nice
19:17bsteuberbut I want it on top of clojure :)
19:17danlei:)
19:20bsteuberbtw. did a standard prolog-in-clojure evolve yet?
19:21bsteubershould not be hard with all the CL examples
19:21powr-tocbsteuber: There's a datalog implementation in contrib
19:22dmiles_afkCL in cojure comming soon?
19:22bsteuberpowr-toc: the difference was depth vs breadth first, right?
19:23bsteuberbetween prolog and datalog, I mean
19:23powr-tocbsteuber: Not entirely sure... I've not had a chance to look at datalog
19:23bsteuberdmiles_afk: why would you want CL in clojure? there are already CL implementations for the JVM
19:24bsteuberso many thing I should look at :)
19:25dmiles_afkah yes indeed.. i just wondering
19:26dmiles_afki seen a few lisps on jvms.. but would be nice since people seem to be liking clojure alot.. and to do both at the same time w/o marshalling would be good
19:29bsteuberI guess it would be a hard job to get the interop right without much marshalling
19:30bsteuberbut I don't care anyways - left CL behind forever :)
19:31bsteuberI'll need to get some sleep now - have fun everybody
19:42rickmodeso I got swank-connect-project working. I had to add [swank-clojure "1.1.0"] to my :dependencies. it didn't work as a :dev-dependency as that doesn't cause the swank-clojure*.jar file to be copied to the lib directory. Is this right?
19:42rickmodeer... sorry I mean swank-clojure-project (not swank-connect-project)
19:54RaynesDamn freenode and it's security measures.
20:32zaphar_psis there some reason that printing to stdout wouldn't show up in a clojure app?
20:32zaphar_psit works from repl
20:32zaphar_psbut when I run the app nothing shows up on the terminal
20:32zaphar_psI'm assuming *out* has been changed somehow?
20:32programblezaphar_ps: try adding (flush) after your println or printf or whatever
20:34technomancyrickmode: putting swank-clojure in dependencies will work, but if another project relies on yours it will include it
20:34technomancyrickmode: putting it in dev-dependencies should work; I've never heard of that failing to get copied to lib/
20:34zaphar_psprogramble: nope still no dice
20:35programblei dunno, im just guessing lol
20:35programbleim a clojure n00b
20:35technomancyzaphar_ps: I have had issues with *out* not being bound correctly when using clojure.main -e
20:35technomancynot sure what the solution is, sorry. =\
20:35zaphar_pshrmmm
20:36zaphar_psthis isn't using clojure.main specifically
20:36zaphar_psit's using my own main method
20:36zaphar_psI'll add some logging to see if I can see what *out* is bound to
20:39tomojhave there already been "I heard you like * so I put clojure in your clojure so you can * while you *"s?
20:40programblelawl
20:40tomojwith a picture of rich talking about cinc
20:40programbleI heard you like recursion so I put clojure in your clojure so you can recurse while you recurse?
20:40technomancy"so you can lazily persist while you lazily persist."
20:44zaphar_psit looks like it's bound to something
20:44zaphar_psis there anyway to tell if it's bound to stdout or not?
20:46hiredman,(identical? System/out *out*)
20:46clojurebotfalse
20:47zaphar_psthis is incredibly frustrating
20:48hiredmanhow are you starting the app?
20:49hiredmanwhat happens if you (.println System/out "foo") ?
20:50zaphar_pshiredman: java -cp foo.jar foo.class <args>
20:50zaphar_psand doing (.println System/out "foo")
20:50zaphar_psalso has no output to the terminal
20:50zaphar_psit's weird
20:50hiredmanare you sure the code you think is being run is being run?
20:50zaphar_pslogging indicates it is
20:51zaphar_psoh wait... doh!!!
20:51zaphar_psI'm using a wrapper script and capturing the output
20:51hiredman:(
21:00rickmodetechnomancy: swank-clojure gets copied iff it is before leiningen/lein-swank
21:18jcromartiewhat the heck is this guy talking about when he says "functions are inherently non-deterministic"
21:18jcromartiein regards to FP
21:20hiredmanopposite date
21:21hiredmanday
21:26jcromartiehttp://rebelscience.blogspot.com/2007/10/half-century-of-crappy-computing.html
21:28hiredmanjcromartie: I think if you read "procedure" for function
21:29jcromartieyeah but he specifically mentions "FP"
21:31hiredmanare you talking about in the comments?
21:31DeusExPikachuI want to be able to manage launching "jobs" in different threads. What's the cool way to do this? So storing future objects in a map in a reference in the var mapped to symbol *threads*. Should I be using executors?
21:31hiredmanexecutors are cool
21:32DeusExPikachus/so/I am currently
21:32jcromartiehiredman: comments by the author
21:32hiredman*shrug*
21:35rickmodejcromartie: could be something related to real-time programming where you need predictable time guarantees? (Java/JVM languages can't be used for this sort of real-time stuff, AFAIK).
21:36hiredmanit can, you just can't use the gc
21:36jcromartieyeah, I don't see how a pure function written in C would be non-deterministic
21:36hiredmanno allocation
21:37jcromartiehmm
21:37hiredmanI've heard tell of people tuning java apps to get them to that point
21:37rickmodejcromartie: in real-time stuff you can't just code such that you *think* it is deterministic, it needs to be formally provable
21:38jcromartieI see
21:38rickmodeit's been a while since I heard of this stuff - i prolly have the details mixed up
21:38rickmodehiredman: ya i've heard there is a real-time version of java, but i'm pretty sure it isn't the usual sun jdk
21:42DeusExPikachurickmode, or maybe hardware specific like for phones or azulsystems
21:43gravityIs there a way to define multiple vars in one call? Like let allows when you have multiple parameters in the argument list?
21:44jcromartiegravity: you mean like def them to the same thing?
21:45gravityjcromartie: Yes, exactly
21:58jcromartiegravity: well if you haven't done so yet, you could use a macro
21:58jcromartiebut it's a strange question
22:04zaphar_psgravity (let [foo "bar" bar foo bleh bar] ...)
22:04gravityjcromartie: Yeah, it's sort of a strange condition. I'm trying to figure out a way to restructure the idea so I don't need to do something so bizarre.
22:05zaphar_psthat sort of does what you want
22:05zaphar_psunless you need it defined for the whole namespace
22:05gravityzaphar_ps: I'd like for things to be accessible outside the namespace, yeah.
22:05gravityIt's for a complex data structure
22:05zaphar_psahh multiple nodes all sharing the same item?
22:06gravityRight
22:06gravityOr referencing the same item
22:06zaphar_pscouldn't use refs for that
22:06gravityIn the simplest case, a graph with two nodes each linking to the other.
22:06zaphar_psI mean couldn't you use refs for that
22:07gravityDon't I still need to def them?
22:07jcromartieno
22:08zaphar_psno you couldn't? or no you don't need to def them?
22:08zaphar_ps:-)
22:10zaphar_psactually I'm not sure refs would help either
22:18brandonwcould anyone point out what i am doing wrong here? http://pastie.org/851077
22:18brandonwtrying to make a lein plugin for nailgun that applies classpath. macros just own me at the moment, though.
22:19brandonwactually: http://pastie.org/851078 is what i last have tried
22:20brandonwunquoting addr-port when constructing the array to send to the main method of NGServer
22:25hiredmanit says addr-port and you are just passing an ip address
22:25hiredmanunquoting inside and an unquoted part is not going to work
22:25brandonwthe arg is parsed in NGServer
22:25brandonwcan be ip, port, or ip and port
22:26brandonwall as one arg
22:26brandonwoh right, i forgot to take the unquote off before the into-array
22:27hiredmanwhat is the error?
22:27brandonwthat's the hardest part: i'm not sure exactly how to debug something like this
22:27brandonwi create the jar, put it in another project's lib directory to test it
22:27brandonwit also has the nailgun dep specified
22:28hiredmanif that is the case you may want to start smaller
22:28brandonwhold on, i screwed up a paren somewhere...
22:28hiredmanworking on code you can't debug is a bad idea
22:28hiredmana recipe for pain and frustration
22:29brandonwerr
22:29brandonwnevermind, it works...
22:29brandonwi swear i had tried that combination before...
22:30brandonwthat's pretty sweet :) i can actually contribute something now
22:30brandonwi'm sure a lein-nailgun plugin would be useful for vimclojure users
22:30brandonwthat is, one that applies the project's classpath
22:36jcromartieI guess it's bad to use (decorate) in compojure with big chunks of routes?
22:36jcromartielike (defroutes foo ...) (decorate foo with-bar) (defroutes bat foo ...)
22:37jcromartieif foo is something like a login handler, the you can never use a 404 handler,right?
22:38jcromartieI mean with-bar
22:38tomojwhy not?
22:38jcromartieif with-bar is something like with-account that returns an "unauthorized" response
22:38tomojI'm not asking because I think you're wrong, I'm asking because I don't understand
22:38tomojah
22:38tomojso, the 401 will come in instead of 404
22:38jcromartieyeah
22:38tomojor the 401 will redirect to a login page
22:38tomojinstead of being a 401
22:39jcromartieright
22:39tomojhmm
22:39tomojhave you seen webmachine?
22:39jcromartienope
22:39tomojI would like it if we had a webmachine in clojure
22:39tomojhttp://bitbucket.org/justin/webmachine/wiki/BigHTTPGraph
22:40tomojhttp://blog.therestfulway.com/2009/05/video-slideshow-introducing-webmachine.html
22:40tomojI haven't used it
22:40jcromartiehm, yeah
22:40tomojbut my understanding is that it takes care of all the http details for you
22:40tomojand lets you hook into any point in the http graph easily
22:40tomojand hopefully in a sensible way so that you can do what you're wanting to do
22:41tomojI think a set of clojure middleware could do that, maybe with some extra functions and macros
22:41tomojer, compojure middleware
22:46brandonwhmm. not quite yet after all. the server seems to start okay, but vimclojure has trouble connecting to it
22:47tomojdidn't someone already work on a lein plugin for that?
22:48brandonwi don't know. i only see one lein plugin on clojars, and it doesn't apply the classpath at all
22:48tomojhave you seen this? http://lisp4fun.blogspot.com/2010/02/leiningen-and-vimclojure.html
22:49brandonwyes, but the way they apply the classpath is kind of hacky, and doesn't use lein
22:49brandonwwell, not really hacky i guess
22:50brandonwit works and it won't ever fail
22:50brandonwa lein plugin would be a tiny bit easier, though (and more portable)
22:50brandonwand it is a good exercise in learning more about clojure :)
22:50tomojwell, good luck
22:51tomojI got this idea to build a framework that turns chunks of clojure namespaces into a command line tool with an embedded repl
22:51hiredmanclojure -> sh compiler!
22:52cp2clojure -> brainfuck
22:52tomojyeah, but I don't want to bother with nailgun
22:52tomojand the jvm startup time is too big
22:52tomojI'm envisioning something more like irb or the mongodb js console
22:52tomojbut customizable with whatever code you want to use interactively
22:53hiredmanthat sounds ridiculous
22:53tomojwhy?
22:53clojurebotwhy not?
22:54tomojI admit my judgement is impaired
22:54tomojthe ec2 command line api tools are terrible, so I want an ec2 console with embedded clojure
23:07brandonwokay, got it working, but now i have to test clojure versions
23:07brandonwturns out, the lein plugin needed to have the clojure and clojure-contrib deps specified
23:08brandonwhave to make sure that if i specify a different version than the plugin requires, that the different version is used
23:09brandonwkind of wondering if i am doing something wrong, though-- the lein-swank plugin didn't need to specify clojure versions. i assume that is because swank-clojure specifies them
23:12brandonwah, the vimclojure jar i am using requires clojure 1.1 i think
23:13brandonwit seems kind of unstable to have swank-clojure and vimclojure not specify the version of clojure that they need
23:13brandonwwhat if the version you are using in your project is not compatible with the version required by the plugin?
23:35fanaticoAny reason types don't support vararg-style constructors?
23:35brandonwhmm, how exactly does one contact a group owner on clojars?
23:41dakronebrandonw: good question, I've been searching github to hope they have the source up so I can send them a message
23:58brandonwdoes the version of clojure that swank-clojure requires force you to use that same version in your project?
23:59RaynesNo.
23:59tomojwith lein repl, it does, doesn't it?
23:59brandonwhow does it manage that?
23:59RaynesYes.
23:59tomojwith emacs slime-connect, it doesn't