#clojure logs

2009-05-05

00:08ctdeanlaters folks, and grats on the v1.0 release
01:37hiredmanclojurebot: make a note of http://scienceblogs.com/goodmath/2006/11/the_c_is_efficient_language_fa.php it is yet another article about picking c or c++ for performance being naive
01:37clojurebotAck. Ack.
01:38hiredmaner
01:38hiredmannuts
01:38hiredmanclojurebot: make a note of http://scienceblogs.com/goodmath/2006/11/the_c_is_efficient_language_fa.php yet another article about picking c or c++ for performance being naive
01:38cp2nuts!
01:38cp2you're gonna love my nuts
01:39cp2slap your troubles away
01:39hiredman...
01:39cp2what ?
01:39hiredmanI have to keep pasting urls or I'll never beat lisppaste8
01:40cp2heh
01:41cp2hiredman: interesting article
01:47hiredmanthe comments are also interesting and lively
01:48cp2yeah, i read a couple
02:05replacahiredman: did you have better luck with the new json doc?
02:06hiredmanoh, sorry I have not tried
02:07hiredmanyes, it works
02:10danlarkinthree cheers for clojure-json!
02:13hiredmanclojurebot: three cheers
02:13clojurebotExcuse me?
02:14hiredmanclojurebot: three cheers is <reply>hip hip, hooray! hip hip, hooray! hip hip, hooray!
02:14clojurebot'Sea, mhuise.
02:14hiredmanclojurebot: three cheers for clojure-json
02:14clojurebothip hip, hooray! hip hip, hooray! hip hip, hooray!
02:29replacaahh, I'd wandered off to fix autodoc bugs.
02:30replacaYay, glad to hear it's working.
03:27jdzHappy birthday, Clojure!
08:45Chouserthe value of an agent can change while in a transaction, right?
08:45rhickey_Chouser: sure
08:45Chouser(dosync (= @foo @foo)) is guaranteed true of foo is a ref, but not if foo is an agent.
08:45AWizzArdright
08:46Chouserok, thanks.
10:00AWizzArdIf I want to retry something that can throw an Exception a few times, how can this be then done idiomatically? Currently I try to recur inside the catch, but that is not allowed.
10:16__macDefine "a few times". If it's not many, you could just call the function again instead of using recur?
10:22tWipIf you're retrying something (I'm guessing IO) so many times that it blows the stack... something is wrong
10:24AWizzArda few times, such as 3
10:24AWizzArdTrying to connect to a listener, sending an email, whatever.
10:24__macThen just call it regularly would be easiest solution I guess?
10:24__macPassing a try count or something like that
10:24AWizzArdProbably a macro could be nice here (retry 3 ...) where ... is the body.
10:25danlarkin_dotimes
10:26danlarkin_you could wrap that, possibly
10:26danlarkin_or look at it, anyway
10:26__macIsn't that always a fixed number of times?
10:31AWizzArdYeah, I would want to break out of the dotimes if the action succeeds.
10:32cgrandAWizzArd: what do you want to do if the nth retry fails? propagate the exception?
10:33AWizzArdyes
10:37cgrandyou're right: a macro seems the way to go
10:39cgrandcheating: (defmacro retry [n & body] `(try-or ~(repeat n `(do ~@body))))
10:39__macLook at with-open in core. It does self-recursion with a catch on each level
10:40AWizzArdbtw, I just discovered an area where Clojure is a bit too static:
10:40__macOr rather a finally but it's the same concept
10:40AWizzArd(def x (if-not (resolve 'x) 0 (inc x)))
10:41AWizzArdwhen the compiler discovers the (inc x) it will complain that it doesn't know x. Although that part of the code can never be reached as long x isn't bound.
10:42AWizzArdI guess that is an underlying Java mechanism, which is conservative in its static type checks.
10:42AWizzArdwell, JVM mechanism
10:44rhickey_AWizzArd: you expect it not to compile code that might not be reached due to a runtime state?
10:45AWizzArdThe general mechanism is okay in principle. Anyway, if it were more dynamic here that would result in perfectly correct code.
10:45rhickey_Clojure resolves names at compile time - that makes it fast, waiting until runtime would be slow
10:46AWizzArdDuring tests with load-file in the repl it would init the var for the first time, and on reloads have a different strategy.
10:46RaynesWell, that was stupid.
10:47RaynesI did this in a Scala console in NetBeans: (1 to 1000000000).foreach(println)
10:47Raynes:\
10:47AWizzArdBut I understand that compilers are not advanced enough and prefer the case that is easier to implement.
10:48AWizzArd... and compiler writers prefer ...
11:00lisppaste8__mac pasted "retry macro suggestion" at http://paste.lisp.org/display/79703
11:01__macAWizzArd: Posted retry suggestion :)
11:01__maceh I mean "pasted" ofc
11:03AWizzArd__mac: looks good
11:04__macIt will always run the body once, so n = 1 means one REtry not one try
11:06__macThat was fun. First clojure code I have written in a long time. Been awfully busy in java land :( hopefully the people around me will soon see the light
11:21AWizzArd,(* 1 2 3, 1 2 3, 1 2 3, 1 2 3, 1 2 3)
11:21clojurebot7776
11:39AWizzArdIs there something like (binding [*out* /dev/null] ...) Binding *out* to nil results in a NPC.
12:00cemerickAWizzArd: a no-op printwriter is a simple thing
12:05kadaver_how do I regex "\\"
12:06kadaver_i want to pass \ to split
12:06kadaver_, (.split "path\to\file" "\\")
12:06clojurebotjava.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^
12:06kadaver_, (+ 3 4)
12:06clojurebot7
12:06kadaver_, (.split "path\to\file" "\")
12:06clojurebotEOF while reading string
12:07kadaver_, (.split "path\to\file" "/")
12:07clojurebot#<String[] [Ljava.lang.String;@d961db>
12:07kadaver_, (.split "path/to/file" "/")
12:07clojurebot#<String[] [Ljava.lang.String;@1ce49c9>
12:07drewr,(into [] (.split "foo\\bar\\baz" "\\\\"))
12:07clojurebot["foo" "bar" "baz"]
12:07kadaver_so i want to do it with backslash
12:07Chouser,(seq (.split #"\\" "foo\\bar"))
12:07clojurebot("foo" "bar")
12:08drewrHm, I'm surprised those both worked.
12:08kadaver_how can you do it with reversed args?
12:08kadaver_,(into [] (.split "foo\\bar\\baz" "\\"))
12:08clojurebotjava.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^
12:08Chouser#"" produces a regex.Pattern object, which has a split method
12:08kadaver_,(into [] (.split "foo\\barbaz" "\\"))
12:08clojurebotjava.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^
12:08kadaver_why \\\\?
12:08drewrChouser: Ah, you're right.
12:08kadaver_,(seq (.split #"\\" "foo\\bar"))
12:08clojurebot("foo" "bar")
12:08kadaver_,(seq (.split #"\\" "foo\\bar\\file"))
12:08clojurebot("foo" "bar" "file")
12:09Chouserkadaver_: #"" has different quoting rules than "", specifically for this kind of pattern.
12:10AWizzArdcemerick: how does a no-op printwriter look like?
12:10Chouserin a #"" a backslash and whatever follows it are put directly into the pattern, so the regex engine sees \\ and knows that's a literal backslash.
12:10AWizzArdIt seems the constructor of those printwriters always need an argument.
12:11Chouserin "", a backslash is interpreted by the reader, so \\ becomes a single \ inside the string. But the regex engine interprets \ and whatever follows it, for patterns like \s and \w. So in order to get the regex engine to see \\ you have to say "\\\\"
12:11Chouserit's like emacs. terrible.
12:11cemerickAWizzArd: probably just a proxy of java.io.PrintWriter, with overrides of all of the print*/write methods to do nothing.
12:12AWizzArdoh, I hoped for a very short solution
12:12cemerickmaybe *out* could be a writer, which would make things simpler, but IIRC, *out* is a printwriter.
12:12AWizzArd(binding [*out* (EmptyWriter.)] ...)
12:12cemerickwell, that's what it would look like once you write EmptyWriter :-)
12:13AWizzArdsure
12:13AWizzArdUnder Linux one can maybe have a (PrintWriter. "/dev/null")?
12:13AWizzArdBut I don't know if Window also has such a null device.
12:13cemerickoh, printwriter takes a Writer itself, so it actually is quite easy. Writer only has three abstract methods.
12:14HolcxjoDOS had a nul: device..
12:15chessguy_workclearly, DOS was the best OS ever
12:16unlink1You must never have used Windows 3.11. Far more win than DOS.
12:16chessguy_workoh man, i was so mad when windows 3.11 came out
12:16chessguy_workof course, i was like 8 at the time
12:17drewrChouser: Emacs's regexps quote that way for a reason.
12:17AWizzArdIt seems that under Windows (binding [*out* (java.io.PrintWriter. "NUL")] (println "Hallo")) does the job.
12:17cemerickheh
12:17cemerickjust making a no-op writer seems way simpler than worrying about the proper /dev/null device/path/etc
12:18AWizzArdcemerick: probably
12:19AWizzArdat least Apache has it already: http://commons.apache.org/io/apidocs/org/apache/commons/io/output/NullWriter.html
12:20kadaver_so anyone want to swap code with me and comment on each otehrs code? I have a 400 LOC mp3player that I'd like to be, well cleaner. it's pretty modular and easy to change but the could is a bit ugly imho.
12:20chessguy_workso, i was reading "on lisp" the other day, with all the crazy ` and `, and ,@ stuff. does clojure have that kind of quoting/unquoting for macros?
12:21AWizzArdchessguy_work: yes
12:21chessguy_workis the syntax the same?
12:21chessguy_worki can't find a reference for it
12:21AWizzArd, is in Clojure ~ and ,@ is in Clojure ~@
12:21clojurebotjava.lang.Exception: Unable to resolve symbol: is in this context
12:21AWizzArdbasically they are nearly compatible
12:22AWizzArdanaphoric macros are a little bit different in Clojure
12:22chessguy_workhow so?
12:22AWizzArdthe symbol you want to make available in the body must get a ~' in a let
12:22AWizzArdbut the advantage is that Clojure macros are more hygienic by default
12:23chessguy_workerr, what does hygienic mean? sorry, new to the macro scene. i've heard that word before, but never seen it defined
12:23AWizzArdIn CL it could be `(let ((it ,object)) ,@body) while in Clojure it should be `(let [~'it ~object] ~@body)
12:24AWizzArdIt means that Clojure would complain when you do `(let [something ~object] ...)
12:24AWizzArdSo, you can not accidently overwrite vars
12:24chessguy_workoh so variable capture is a little harder to do by accident?
12:24AWizzArdexactly
12:24AWizzArdYou must gensym them first. In Clojure this is easier. Just append a hash.
12:25AWizzArd`(let [my-var# ~object] ... (println my-var#) ...)
12:25unlink1Anyone know of a Java syntax highlighter for Clojure which has terminal output?
12:26unlink1Sort of like pygments.
12:27cgrandunlink1: pygments on Jython :-)
12:28unlink1Good point. I'll just use python and unix pipes.
12:28unlink1i.e. pygmentize
12:28orerohi. I'm trying to understand the purpose of clojure.contrib. can someone tell me what's the difference between contrib and any other third-party libraries?
12:29unlink1contrib is a collection of semi-officially sanctioned libraries which are candidates for inclusion in core
12:29orerounlink1: does that mean most of contrib will end up in the core someday?
12:30AWizzArdorero: no
12:30replacaorero: look here for an overview: http://code.google.com/p/clojure-contrib/wiki/OverviewOfContrib
12:30chessguy_worki think what it means is that they are "candidated for inclusion in core"
12:30chessguy_workjust a guess
12:31AWizzArdA limited set of parts of contrib will go into core, maybe it will be like this for many years.
12:31AWizzArdBut typically those tools will stay in Contrib.
12:31kadaver_java.sql.SQLException: Failed to start database 'C:/clojure/progs/mp3player/mp3.db', see the next exception for details. (NO_SOURCE_FILE:0)
12:31kadaver_ok how do I see the enxt exception?
12:32oreroAWizzArd: was there anything in contrib that ever moved to core?
12:33hiredmanyes
12:33oreroso essentially, contrib is like any third-party library without the licensing issues if Rich wants to take it and put in the core, right?
12:34danlarkinand it's sorrrrrt of like a standard library
12:35orerook, thanks.
12:36chessguy_work,users
12:36clojurebotjava.lang.Exception: Unable to resolve symbol: users in this context
12:37chessguy_worki'd be curious to track the number of users in this channel. i bet it's increasing rapidly
12:38danlarkinit was, then it slowed down a month or two ago
12:38chessguy_workinteresting, wonder why that is
12:40hiredman~max users
12:40clojurebotHuh?
12:40hiredman~max people
12:40clojurebotmax people is 164
12:40unlink1clojure -e "(source $1)" | pygmentize -l clojure
12:41danlarkinvery nice
12:42unlink1A useful companion to (if (= (count *command-line-args*) 0) (println "usage: clojuredoc name") (let [arg (first *command-line-args*)] (let [v (resolve (symbol arg))] (if v (print-doc v) (println (format "no documentation found for '%s'" arg))))))
12:42t345I like it that Clojure naturally parses XML and possibly also JSON into a tree to be consumed and am researching how to achieve the following
12:43t345I want to query any url aka web services and present the tree in a way to a Java using developer so that he can select nodes from the tree
12:43t345then he can tell me which nodes he is interested in and I will return the value/node if asked
12:44t345this is going to be used in an Eclipse RCP based telephony application modeler/builder
12:44t345the developer of such an application shall be able to assign the selected nodes to variable which are used in the telephony application
12:45t345any idiomatic proposals?
12:47t345parsing xml into a tree is easy, I just need to find a way to support http proxies, too, but that's another topic and not related.
12:48t345what representation would be best for consuming from Java? or should I just implement a callback-based API which delivers more and more nodes and so on.
12:49danlarkinwhy don't you just return whatever you parse from the xml, why make it overcomplicated?
12:50t345danlarkin: let's recheck what structure it is when consumes from Java....
12:51danlarkinhuh?
12:52t345danlarkin: the list/tree I get if I eval (clojure.xml/parse "http/....")
12:52t345danlarkin: if I retrieve that when I call the clojure code from Java. what will be the reprentation. that's what I'm checking
13:04danlarkint345: and what is your conclusion?
13:04t345danlarkin: not sure yet
13:04hiredman,(class (into {} (map vector (range 20) (range 20))))
13:04clojurebotclojure.lang.PersistentHashMap
13:05t345danlarkin: it's a type from clojure.lang naturally
13:07danlarkinyes, a map
13:07t345danlarkin: PersistentStructMap which is defined in core.clj
13:08danlarkinnot exactly
13:08t345it's in the jvm part I guess
13:08t345checking
13:08unlink1What can I do to reduce the startup time of Clojure
13:08danlarkinit doesn't matter where it's defined
13:08t345danlarkin: it's a Java source file
13:08t345danlarkin: makes sense
13:09unlink1I'd like to use it for command line scripting, but a minimum of 1 second execution time essentially makes it unacceptable for that purpose.
13:09danlarkinI'm just suggesting that you return the map instead of invent a convoluted callback scheme which serves the same purpose as a map but with less usefulness
13:10hiredmanunlink1: nailgun
13:10t345danlarkin: is it always this specifc map type or do I have to rely on it being of a super type?
13:10danlarkint345: rely on the interface
13:11t345danlarkin: yep, IPersistentMap
13:11hiredman,(ancestors (class {}))
13:11clojurebot#{java.util.concurrent.Callable clojure.lang.AFn clojure.lang.IObj clojure.lang.IFn java.lang.Runnable java.lang.Object clojure.lang.Associative clojure.lang.IPersistentMap clojure.lang.Counted java.io.Serializable clojure.lang.APersistentMap clojure.lang.IPersistentCollection java.lang.Iterable clojure.lang.Obj clojure.lang.IMeta java.util.Map clojure.lang.Seqable}
13:11t345danlarkin: thanks so far
13:11kadaverme I still don't get why anyone would use Clojure over Haskell.
13:12gnuvincekadaver: why is that?
13:12rsynnottthey're not very similar languages, at all
13:12kadavereh
13:12hiredmangnuvince: because no one will talk to him about his mp3player
13:12kadaverclojure is a weak haskell
13:12gnuvincehmm
13:13hiredmanso he is resentful and trolling for attention
13:13gnuvincekadaver: ok
13:13kadaverhaskell does everything clojure does much better
13:13t345kadaver: I use it to have a saner language for all the $DAYJOB stuff I have to do ontop of the JVM
13:13kadaverand did it long before clojure
13:13t345kadaver: that's a pointless discussion
13:13danlarkindon't feed the troll! run!
13:13gnuvinceHaskell's Jon Harrop it seems
13:14t345gnuvince: how do you come to that conclusion? curios
13:14danlarkinhahaha, google actually has a suggested search of "Jon Harrop troll"
13:15gnuvincet345: Jon Harrop is well known to barge in on the Lisp and Haskell communities, and pimp OCaml for no particular reason.
13:15unlink1nailgun is pretty awesome actually.
13:18t345danlarkin: actually
13:18t345danlarkin: I don't have to be asked which nodes to return
13:18RaynesWhat kadaver said applys to just about every Haskell person I've talked to. They all think Haskell is superior to Lisp in general. It's annoyingly arrogant.
13:19t345danlarkin: that can be done in the rcp app
13:19danlarkint345: just return all nodes, the java program should "ask" the map itself
13:19t345Raynes: Haskell's type system is meant to solve anything, prevent babies being killed and produce endless amounts of water with lazy infinite types
13:20t345danlarkin: had the insight a minute ago when I asked myself how be asked what to return
13:20t345danlarkin: so beatiful
13:20t345danlarkin: I can now concentrate on how to configure the http proxy for the underlyng http code.....
13:21gnuvinceRaynes: there's a difference between somebody prefering Haskell over Lisp and having actual reasons than just going on about how Haskell does everything better than Clojure.
13:24kadaverjump on the love bandwagon
13:27opqdonuti'm coding clojure at work and would much rather be hacking haskell ;)
13:28opqdonutimo clojure's biggest problem is that it tries to embrace purity but pure code somehow still becomes very verbose and clunky
13:28opqdonutalso there are some minor annoyances, like not being able to tell from which struct-map template a map was made
13:29opqdonutwould be useful in emulating algebraic data types (another feature i miss)
13:30unlink1Any way to get nailgun to listen on a UNIX socket? I don't want any user on the machine to be able to attach to my server.
13:30opqdonutbut a great language still, and much nicer in gluing stuff together than haskell
13:35unlink1ha. Before you download it, be aware that it's not secure. Not even close. Although there are means to ensure that the client is connected to the server from the local machine, there is not yet any concept of a "user". Any programs that run in Nailgun are run with the same permissions as the server itself. You have been warned.
14:30jonafancongrats on 1.0
14:30cp2thanks, i worked so hard on it :)
14:31jonafanme too
14:32Raynesgnuvince: I prefer Clojure, but I don't hate on Common lisp.
14:35kadaverframe.add(new BasicArrowButton(BasicArrowButton.NORTH));
14:36kadaverhow would I create that?
14:36kadaverBasicArrowButton.NORTH
14:36kadaveroh wait
14:44twismquick questoion (maybe)...
14:44twismhow would you create a simple REPL script
14:44twism?
14:45twismthe most basic loop read print back to *out* (no eval needed)
14:46hiredman,(doc clojure.main/repl)
14:46clojurebot"([& options]); Generic, reusable, read-eval-print loop. By default, reads from *in*, writes to *out*, and prints exception summaries to *err*. If you use the default :read hook, *in* must either be an instance of LineNumberingPushbackReader or duplicate its behavior of both supporting .unread and collapsing CR, LF, and CRLF into a single \\newline. Options are sequential keyword-value pairs. Available options and their d
14:47twismhiredman: im not going to use it to eval clojure
14:48twismlet me rephrade the question
14:48twismrephrase*
14:48twismhow would i get user input from a clojure script
14:48hiredmansame as java
14:48hiredman*in* is bound to System.in by default
14:48hiredmanactually
14:49twismah
14:49hiredman*in* is bound to System.in wrapped in a LineNumberingPushbackReader
14:49hiredmanbut whatever
14:49twism(defn run [& args]
14:49twism (loop [input (read-line)]
14:49twism (print input)
14:49twism (recur (read-line))))
14:50hiredman(map println (repeatedly read-line))
14:50twismgod
14:50twismi have along way to go
14:51twisman that would work if i started the script using clojure.main?
14:51twismand*
14:52hiredman,(doc read-line)
14:52clojurebot"([]); Reads the next line from stream that is the current value of *in* ."
14:52heltavjava.lang.NullPointerException (NO_SOURCE_FILE:0)
14:52heltavwhat is the cause of such an error normally? not the most helpful errormessage...
14:53hiredmantwism: not really
14:53hiredmanread-line doesn't block
14:54hiredmanso you don't want to use it like that
14:54hiredmanheltav: trying to call a method on something that is nil
14:54twismjust found that out when it kicked me out
14:54hiredman,(.toString nil)
14:54clojurebotjava.lang.NullPointerException
14:54hiredman,(nil 1)
14:54clojurebotjava.lang.IllegalArgumentException: Can't call nil
14:54hiredmanoh
14:57twismhiredman: thanks for all the help... what do i need to do to have read-line block?
15:03duncanmif i have a Java API that takes a List<Foo> is there a way to convert an ISeq into one of those?
15:06heltavhmm i have big let, can you somehow println in a let?
15:07stuhoodheltav: println returns nil, so you can bind the result of println to a variable you don't care about
15:07hiredmantwism: last time I dealt with it I just used a blockingqueue
15:07opqdonutlet [_ (prn someting)]
15:07opqdonutor something to that effect
15:07hiredmanor you can use doto
15:07hiredman(let [x (doto (something) prn)] ...)
15:08stuhood~def c.l.PersistentList
15:09stuhoodduncanm: if the object extends ASeq, then it will implement the List interface for you. have you tried just passing in the seq?
15:12hiredmanhttp://gist.github.com/107140 my gui repl thing, uses a blockingqueue and clojure.main/repl
15:14twismhiredman: thanks man
15:17hiredmanclojure.main/repl is kind of annoying, it takes a map, but doesn't
15:18hiredmanso you call it like (clojure.main/repl :read some-read-function :print some-print-function)
15:18cp2schroedinger's repl
15:18hiredmaninstead of (clojure.main/repl {:read some-read-function :print some-print-function})
15:19hiredmanbecause obviously it just does something like (defn repl [& args] (let [args1 (apply hash-map args)] ...))
15:19twismi was just looking at that and was thinking of leveraging that instead of rolling my own read-evl-print-loop
15:19hiredmanwhich *someone* thinks is cute
15:19cp2hah
15:46t345is there MAven support for clojure? or ideally something cool like Scala's simple-build-tool
15:47durka42for the most part ant and maven work as per java
15:51t345I use Mave at dayjob. the dependency stuff is good but it's slow as a tool to call often
15:51t345Ant is, well not bad, but also using too much RAM and stuff for the job it does
15:51t345anyway, no problem
16:13t345what is the difference between clojure.jar and clojure-slim.jar? is that latter only missing the sources?
16:15drewrt345: Yes.
16:16t345hard to imagine as clojure-slim is 526k and clojure is 1400k
16:16t345wow
16:16stuhooddrewr: what does that mean in terms of runtime performance? should -slim load faster? or do they both contain the compiled versions
16:17t345clojure-source.jar is 278k
16:18t345there's another difference, think
16:18t345stuhood: I don't think so
16:18drewrstuhood: No runtime perf difference. Just a matter of how big you want your distribution to be.
16:19drewrThe JVM will load the compiled classes and not look at the cljs. It's merely for reverse engineering convenience.
16:20t345is it enough to supplu clojure-contrib.jar within -cp to be able to use it from the repl?
16:20t345I am failing to do so
16:22marklar1is it possible to compile and load multiple files in slime when some files :use others? I keep getting FileNotFoundExceptions for their .class files, so I'm guessing it has something to do with the classpath
16:36stuhoodmarklar1: do you have *compile-path* on your classpath?
16:38t345there is speed difference between using clojure-slim or clojure
16:39t345the repl starts up faster with clojure and is slower with clojure-slim
16:39t345might have to do with some of the inner classes not being there and probably first bein generated
16:39t345interesting
16:39marklar1stuhood: no, I don't. I'll look into that, thanks
16:42stuhoodt345: ah yea... i think we had things mixed up
16:43stuhoodt345,drewr: based on the contents of the jar, the -slim jar is smaller because it contains the source of 'core.clj, main.clj', etc, rather than all of the .classes that those files compile to
16:43stuhoodt345,drewr: so -slim loads slower because it executes those files at runtime, rather than doing AOT compilation
16:45stuhoodclassic speed/size tradeoff
16:46drewrstuhood: Ah, you're right. I had it backwards.
16:48eeecan you index into strings the way you can in python?
16:49eee"abcdefg"[5] == 'f'
16:49Cark,(get "abc" 2)
16:49clojurebot\c
16:50eeeoh cool
16:50eeenow what's the easy way for a n00b to find that?
16:50eeeso I can help myself more
16:50eeethanks for the help, too
16:51Carkget works for maps, a vector is a map of indexes to characters
16:51Carka string is "kind of like" a vector =P
16:51eeecool
16:52Carki mean a vector is a map of indexes to elements =/
16:52eeei knew that at one point
16:52eeebut took a break
16:52eeeso get is for maps
16:53stuhoodeee: anything with a key and value: which includes vectors and strings
16:53eeemakes sense
16:53eeenice generalization
16:54eeeer abstraction
17:13eeeI wonder when to use (dorun) vs. (doseq)
17:13Carkhow about doall =P
17:14eeeok
17:14eeei have a let
17:14eeethat called a function
17:14eeeand got back a list
17:14eeeand I want to run through the pairs in that list
17:14eeeand put them in a structure
17:14eeeoh, and I guess that's also a problem because the structure is immutable
17:15Carka reduce or a map then
17:15eeeoh
17:16eeei don't want to return a list
17:16eeei have my own java datastructure that i wrote for clojure
17:17twismqq.. is there a way to turn a clojure function to its source?
17:17eeetwism, it's java byte code
17:17eeenot java
17:17twismhmm
17:17twismi think i've seen it done before
17:18eeei think i need reduce
17:18Carkeee : so you use reduce, start with your empty data structure
17:18eeeor areduce
17:18eeeok
17:18twism(fn [x] (+ 5 x)) -> "(fn [x] (+ 5 x))"
17:18Carkif it gets too hairy, use loop and recur
17:19twism(magic-fn (fn [x] (+ 5 x))) -> "(fn [x] (+ 5 x))"
17:19eeealready in a loop-recur
17:19twismi coulda sworn i've seen this doen before
17:19eeebut I think it is straight wd
17:20eeeso if my function is (.insert heap "abc" 3)
17:21eeewhere "abc" 3 is the pair to insert
17:21Carkah you need destructuring
17:21eeei need to like quote that or put a hash on the front?
17:22eeei'll just have a list of pairs
17:22eeefor the destructuring part
17:22eeei'm just at the syntax part right now.
17:22Cark(reduce #(.insert %1 (first %2) (second %2)) (MyStructure/EMPTY) (get-pairs))
17:23Carksomething like that =P
17:24eeewow
17:26eeewow you didn't even need a let to get the pairs
17:27twisma macro that does this is cool too
17:29eeeso awesome how java can sit right in the clojure code
17:30t345eee: sample?
17:31t345eee: did I read it correctly that you mixin java syntax? or are you taling about calling java functions?
17:31eeethat's all I meant
17:32eee(let [loaded-heap (reduce #(.insert %1 (first %2) (second %2)) heap (get-transitions current-state))]
17:33twismgot it.. bind StringWriter to *out* and pr the function as a list (since everything is a list)
17:34t345what's wrong about (clojure.contrib.json.read/read-json "http://www.google.com/ig/api?weather=Berlin&quot;)
17:34ozzileeHey all. I'm writing an aplication wherein I want a function to do one thing during development, and something different when deployed. I'd like to select the behavior at compile-time with a macro, rather than at evaluation, but I'm not sure how to go about it.
17:34t345I have clojure-contrib.jar in -cp but I never can get further than java.lang.ClassNotFoundException: clojure.contrib.json.read (NO_SOURCE_FILE:3)
17:35Chouserozzilee: ah, I've been meaning to blog on that.
17:35eeewhat about just a switch in the main
17:35ozzileeChouser: Well hurry up! :-)
17:35Chouseryeah, not gonna happen right now. Let me see if I can remember what I did...
17:36Chouseryou need a macro to call like (if-devel foo bar), right?
17:37ozzileeChouser: Yeah, something like that would be ideal.
17:37Chouserthen: (def devel true) (defmacro if-devel [a b] (if devel a b))
17:38Chouserit looks almost like you don't need if-devel, since it's so simple, but really you do.
17:38t345ok the url is not json but that's not the point :)
17:39Chouserheh, I suppose you could write ifdef
17:40ozzileeChouser: Hmm. Okay, I think I can run with that, thanks :-)
17:40Chouser(defmacro ifdef [i t e] (if (resolve i) t e))
17:41Chouser(def devel? true) (ifdef devel? foo bar)
17:41eeecrud . . . what i really need is ............ #(.insert %1 %2 (get-score %2))
17:42Chouser...but then you'd have to comment out (def devel? ...) rather then setting it to false.
17:42Chouserjust like #ifdef in C
17:42ozzileeChouser: Hmm. I have a namespace that only exists in development mode, I suppose I could write a macro that looks for that namespace, yeah?
17:43Chousersure
17:44Chouser,(find-ns 'devel)
17:44clojurebotnil
17:55eeehow do I get to the snippet web thing
17:55eeeto make asking my question easier?
17:59ozzileeeee: paste.lisp.org
18:00replacalisppaste8: url?
18:00lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
18:01eeei tried this
18:01eeehttp://pastebin.com/d743be6be
18:02eeeso my problem is that
18:02eeeloaded-heap
18:02eeedoesn't exist
18:02eeebecause that reduce
18:02eeejust made it
18:02eeeso I can use let
18:02eeeahead of time
18:03eeebut is there something fancy I can do?
18:05replacaeee: what is the result you're looking for? are you recurring on three variables?
18:05eeeyeah
18:05eeethe second
18:05eeeand third
18:05eeedependent on the first
18:05eeecan you do that?
18:06eeeor do I need to do the reduce in a let?
18:06replacathat's kind of what let's all about
18:06eeeok
18:06replacaso yeah, you need to wrap recur in a let and do the reduce there
18:07eeegot it
18:07replacabut maybe you only want to recur on the heap itself
18:08replacaand just compute min and max at the top of the loop
18:08replaca(unless you already have them coming in)
18:08eeei'll show yah
18:08lisppaste8eee pasted "a-star" at http://paste.lisp.org/display/79728
18:08eeehttp://paste.lisp.org/display/79728
18:09eeewow, it knew
18:10replacayeah, that looks good
18:10eeethanks
18:14eeei can really see the power of this
18:16eeeyou can't really convince people that clojure is a good thing. it looks foreign. folks just have to try it
18:17eeeand you guys are great
18:17eeetalk to ya later
18:28triddellCompojure question: Does anyone know if it is still necessary to create routes to serve static files in the latest compojure?
18:29dnoleni think it is but it's pretty easy, just make a folder called public (where you start compojure) and add this route:
18:29dnolen(GET "/*" (or (serve-file (:* params)) :next))
18:29dnoleni put it as my first route.
18:31triddelldnolen: ok, thanks
18:32dnolennp
18:36triddelldnolen: I'm trying out compojure on google app engine and the app engine dev server wouldn't serve the static files... but including a public folder and this route worked!
18:37dnolentriddell: great! :)
18:38triddellbut I don't think this route will be necessary when the app is run on the appspot servers (according to the blog post I'm working from) in case someone else refers to this answer, thanks again :-)
18:39unlink1I'd like to introduce a new field to clojure.lang.RT corresponding to the current working directory, so that that can be set by the client (say as a command line option). This would allow loading scripts via nailgun to work as expected.
18:41unlink1or at least as a parameter to loadResourceScript
18:41unlink1Then clojure.NGMain (or whatever) could set this appropriately
19:41dysingerbowchicka
20:02eeehi
20:03eeei'm sending in functions as parameters. now to use the function-params, do I have to do anything special or just make them the first arg of a parenthetical?
20:03Chouserjust as you say
20:04eeecool
20:04eeeso I think I just made a-star generic
20:04eeenow just gotta learn about namespace
20:05eeeChouser, do you know anyone that does clojure talks, including for pay?
20:06ChouserWell, Rich does Clojure talks. I don't know if when or how much he might charge.
20:06ChouserIs that what you mean?
20:06eeeyeah
20:06eeesome folks I know are interested
20:07eeeyou talk to him a lot?
20:07ChouserI've done a Clojure talk, as have Stuart Halloway, Shawn Hoover, and a few others.
20:07ChouserDo I talk to Rich a lot? Not particularly. Mostly what is logged here. :-)
20:08Chousereee: where are you?
20:08eeeok, so I've logged that I'm interested
20:08ChouserThere's a clojure tutorial set on youtube, I think, as well as on peepcode (I think).
20:09powr-tocDoes anyone else find that there biggest barrier to getting stuck-into clojure is assembling the basic project structure and dependencies together?
20:10eeeTOTALLY
20:10eeeno real IDE yet
20:10eeeif it doesn't work with eclipse, it ain't ready
20:10eeebut it's getting there
20:10eeefollow the steps on the wiki
20:10eeeand get that rlwrap going
20:10Chouserpowr-toc: If you don't try to AOT compile, I've found there's hardly anything at all to set up.
20:11eeei never got as far as vim-clojure . . .wish I had. I like vim
20:11powr-tocI'm not after an IDE... I think it's just that when I hack for fun I don't want to have to continually jump through the hoops of setting up each project, its startup scripts and dependencies
20:11dnolenmeh, things are really that much different with Python on Ruby, and personally I think setting up project structure is at least as easy as it is in Python.
20:11dnolenreally aren't that much different, I mean.
20:12eeedude, py-dev for eclipse vs. clojure-dev?
20:12eeeclojure is way harder
20:12powr-tocdnolen: but with ruby including a library is usually as simple as sudo gem install, and then you can just require it
20:12eeebut still way awesome
20:14powr-tocnow I'm not claiming that I want ruby gems... Perhaps just some simple tooling to help aggregate dependencies together onto a classpath
20:14eeeno, I have to say powr-toc is right. lisp and clojure have terrible entries
20:14dnolenpowr-toc: yes library management would be nice, I agree, still waiting for someone to do this ;)
20:14eeei couldn't get a lisp going to a satisfactory level for advanced AI on the weekend before the class so I dropped
20:14powr-tocdnolen: I don't even want anything that complicated
20:15hiredmanyou take the jars you want, put them in a directory, put all the jars in that directory in your classpath, done
20:16ChouserThe java ecosystem has some good options in library management -- someone just has to tie one or more of them into Clojure well.
20:16eeeyup . . . that part is easy. getting code completion, etc. isnt
20:17unlink1List out all the jars you ever want to have on your classpath, pass them to the nailgun server, and forget about it.
20:17eee(addressing hiredman)
20:17powr-tocunlink1: that's unsustainable and reeks of the old days of having a CLASSPATH env var :-\
20:18hiredmaneee: emacs and vim both have very satisfactory code completion
20:18unlink1I was being tongue-in-cheek, but in fact, that is how you have to use nailgun.
20:18powr-tocunlink1: well I guess that's why I don't use it =)
20:18eeei haven't gotten it working yet
20:18hiredmanpowr-toc: uh, what do you mean "reeks of the old days"
20:19unlink1powr-toc: Is there really an alternative?
20:19dnolenpowr-toc: yeah, I'd be happy if there was just a shell script that checked a server for available libraries and just downloaded them plus the jars. dump them into a .clojure directory, update a plaintext file of classpaths and be done with it. would make deploying my projects on Slicehost less repetitive.
20:19Chouserunlink1: surely you can use java.ext.dirs and just drop new .jars into the given directory?
20:19dnolensounds like a project for Clojure AppEngine ;)
20:19dysingerThere is starting to become some broken windows in clojure-contrib tests
20:19eeeis there a CLojure App Engine?
20:19hiredmanChouser: has java.ext.dirs always been reliable for you?
20:19dnolenyeah, Clojure runs on Google App Engine now.
20:20Chouserhiredman: with one exception, yes.
20:20eeeis there a link to that effect?
20:20hiredman...
20:20powr-tochiredman: well in the early days of Java people used to say you should set a CLASSPATH environment variable for your system... That's generally acknowledged as being a very bad habbit
20:20eeethere's a lot I just googled it
20:20dnoleneee: http://elhumidor.blogspot.com/2009/04/clojure-on-google-appengine.html
20:20dnolenis the best one.
20:21dysingercurrently a half dozen blow ups and failures running the clojure-contrib tests :/
20:21Chouserhiredman: yeah, I can't remember. There was one .jar that I had to add to my classpath manually, but usually it isn't necessary.
20:22hiredmandysinger: feel free to fix them
20:22eeecool
20:22dysingerthe person who broke them should feel even more free to fix them ;)
20:22hiredmanChouser: any idea why it is like that?
20:23powr-tocdnolen: unlink1 hiredman: I think I'm probably just moaning for the sake of it, but keeping ontop of this stuff is a problem... And I suspect it's why libraries like compojure and incanter ship with everything in the box
20:23Chouserhiredman: no. I should have noted the .jar at the time so that someone could track down the cause. But I didn't.
20:23Chouser<-- failed
20:24eeepowr-toc, it's important
20:24eeei agree
20:25eeecoworkers wanna start messing around but the environment isn't as inviting as python, and it needs to be a goal
20:25eeei think bundling clojure with a tiny vm might be a good idea, so it installs like python
20:25hiredmandysinger: if people who care about tests are unwilling to fix them, why should people who care less about tests?
20:26powr-tocso heres my process... 1) svn/git pull a project, 2) figure out what ant target I should run (if any) 3) run it 4) repeat for all dependencies 5) package dependencies into a project directory 6) finally think about coding
20:26eeehttp://jamvm.sourceforge.net/
20:26dysingerhiredman: not following you on that thought process
20:26hiredmanpowr-toc: the real problem there is lack of distributable jars
20:27eeejars aren't the same as "site-packages" in python
20:27dysingerIt doesn't appear that clojure-people are too worried about tests - clojure has zero tests and over the the last 6 weeks I have seen bit-rot set in on the clojure-contrib tests
20:27eeeor maybe they are ... is they a lib folder in jvm dir for global jars?
20:27powr-tochiredman: yes, you've hit the nail on the head! This problem seems a smaller one in java beacause I just download the jar file into a projet lib dir
20:28hiredmandysinger: you obviously care about the tests, I don't particularly, so if you complain about broken tests my solution is: if you care about broken windows, fix them
20:28hiredmaneee: yes
20:28dysingerhow can you not care about tests hiredman ?
20:28hiredmanit is very easy
20:29hiredmanI assure you
20:29dysingerif you don't write serious code I guess it would be
20:29eeeso i wanna some day recompile http://jamvm.sourceforge.net/ where it launches right into a repl
20:29eeethat'd be the shizznl
20:30eeethen you could just download clojure . . .instead of downloading java and then clojure
20:31eeemaybe it could even include waterfront, or whatever that IDE is (I never got it to compile)
20:31hiredmanif you really care so much, fix the tests, it is much more constructive then joining irc and bemoaning their brokeness
20:32dysingerhiredman I am looking at the tests - and I am also communicating that the tests are broke
20:32dysingerI'll do as I please
20:32dysingertelling me to fix the tests is constructive for you ?
20:33dysingerplz go back to your previous conversation
20:33dysingernot caring that unit tests are breaking and making a point to say you don't care about tests makes me not take you seriously
20:34hiredman*shrug*
20:38unlink1Clojure has no tests?
20:39gnuvince_unlink1: there are some in clojure-contrib
20:39unlink1but core has none?
20:39hiredmanthe core tests are in contrib
20:39dnolennope, we Clojurians are the living unit tests.
20:42unlink1What unit of Clojure are you responsible for testing?
20:42unlink1And what command do I execute to get you to test after I've made a change?
20:43eeeit's a matter of priorities
20:43eeei think that makes sense
20:44unlink1Where I'm from, tests make developing in the first place easier.
20:44eeefor me that's true. in the heap i'm writing, I'm trying to add more and more tests
20:44eeebut it's also true
20:44eeethat the community will find bugs
20:45eeewhen they try to do stuff that should make sense
20:45unlink1It's true that the community will find bugs in the source tree published by Rich Hickey.
20:46eeeand Rich should be slowly pulling things in from contrib . . . .which will be another pair of eyes
20:46unlink1But they won't find bugs in my local modification of clojure. I have to test that by hand.
20:46eeeand then the community will eventually find bugs there, too
20:47eeeoh yeah
20:47eeevery true
20:47unlink1Which discourages third-party contributes.
20:47unlink1*contributions
20:47eeebut
20:47eeevery very hard to write 100% covering tests
20:48eeeso . . . false sense of security?
20:48unlink1Nobody expects tests to give 100% coverage.
20:48unlink1They are understood to be a tool that aid the detection of regressions.
20:49unlink1If you don't have them at all, you have no such tool.
20:49eeei guess forking clojure isn't really in the plan
20:50eeealso
20:50eee.
20:50unlink1Or 3rd party contributions?
20:50eeethere seem to be a lot of those
20:50rhickey_what tests are failing?
20:50rhickey_ant -Dclojure.jar=/the/path/to/my/clojure.jar test
20:52eeeok so there are tests in the core after all that
20:52eee:0
20:56eeeis the simplest namespace just, like (ns dir.structure) ?
20:57eeeand in that, is "structure" the file you are in, or the dir you are in?
20:57eeeand is it basically like a package so that everything in a dir is in a namespace?
20:58eee(or for a beginner, I can use it that way?)
20:58dnoleneee: simplest namespace is just (ns foobar)
20:59eeewhich is a dir?
20:59dnolenjust the file
20:59eeeoh
20:59eeei want to put two files in a folder under "src"
20:59eeeone called "clj-algorithsm"
21:00eeeand one called "solve_15_puzzle.clj"
21:00dnolenfor two files you should probably add a folder to src
21:00eee(the first should have read, "clj_algotihms.clj")
21:00eeei did
21:00dnolensrc/foo/* -> foo.* if src is on your classpath.
21:00eeeoh I'm confused
21:01eeefolder is "clj_algorithms"
21:01eeefiles are "a_star.clj"
21:01eeeand "solve_15_puzzle.clj"
21:02eeeso my namespace is (ns clj_algorithms)?
21:02dnolenclj-algorithms.a-star and clj-algorithms.solve-15-puzzle seems like the proper ns to me.
21:02eeewell, clojure-dev doesn't seem to allow dashes in titles
21:03eeeonly underscores
21:03eeei mean in files
21:03eeeso the files and the ns doen't need to match up?
21:03dnolenyes, that's the same for everyone I believe.
21:03dnolenunderscores becomes dashes
21:03eeei see
21:04eeeand my 15 requires the a-star?
21:06dnolenyes if that's how you have it setup.
21:08eee(ns clj-algorithms.solve-15-puzzle (:require [clj-algorithms.a-star :as a-star]))
21:09dnolenlooks ok to me, hopefully you can test that line and get a nice happy nil value in return and not an error.
21:09eeei'll try
21:10eeeit wasn't happy
21:10dnolendarn
21:10eee(ns clj-algorithms.a-star :import persistent_heap PersistentHeap)
21:10dnolenand src/ is on your class path?
21:10eeethat is what I tried first
21:11eee java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Keyword (a_star.clj:3) 1:1 user=> #<Namespace clj-algorithms.a-star> 1:2 clj-algorithms.a-star=>
21:11hiredman(ns clj-algorithms.a-star (:import (persistent_heap PersistentHeap)))
21:11eeeoh
21:12eeethen there's a typo in the docs
21:12eeehttp://clojure.org/libs
21:12eeei looked at "example lib"
21:12hiredmanpersistent_heap should maybe be persistent-heap
21:13hiredmaneee: there is no typo
21:13hiredman(ns clj-algorithms.a-star (:import persistent_heap.PersistentHeap))
21:13eeein the example that in parens isn't ther
21:13hiredmanuh
21:14hiredmanI am looking at it, and they are
21:14eeeoh yeah
21:14eeesorry
21:14hiredman(ns com.my-company.clojure.examples.my-utils (:import java.util.Date) ...
21:14eeeinfernal parens
21:14eee:)
21:14eeethanks
21:16hiredmanyou missed rhickey_ asking which tests are broken
21:17eeerhickey_ ant -Dclojure.jar=/the/path/to/my/clojure.jar test
21:17eeeawesome.
21:17eeeis a-star in the contrib yet?
21:21eeethis language makes me hate going to work b.c. we don't use it there
21:22eeebut at this point, I'd still need you guys in a chat window :)
21:26eee,(!= '1 '2)
21:26clojurebotjava.lang.Exception: Unable to resolve symbol: != in this context
21:26eee,(not (= '1 '2))
21:26clojurebottrue
21:26eeereally?
21:30eeewhy isn't there a !=, clojurebot?
21:30eee:)
21:30hiredman,(not= 1 2)
21:30clojurebottrue
21:30eeeah
21:30eeenot to bad
21:30hiredman,((comp not =) 1 2)
21:30clojurebottrue
21:31dnolen(def != not=)
21:33eeeis this the best way to do this?
21:33eee(if (first goal-s)
21:33eeei used to just do (if goal-s
21:34eeeinfinite loop now
21:36hiredman(if (seq goal-s)
21:36eeeok
21:36eeei see in the docs now
21:37eeegood ol google
21:37eeesorry
21:37eeeseemed cool that you could go (if goal-s
21:38hiredmanyou might want to just switch calls to rest to next
21:38eeeok
21:38eeethat's the lazy way
21:38eeeright?
21:39hiredmanrest is fully lazy, which is why you have to call seq on what it returns
21:39eeeoh
21:39hiredmannext is not lazy for the first item (but it is for the rest)
21:40eeenow I can do (if goal-s
21:40eeeyou figured out i was using rest
21:47dysinger,(eval (eval '(list + 1 2 3)))
21:47clojurebotDENIED
21:47dysinger,(eval '(list + 1 2 3))
21:47clojurebotDENIED
21:51dysingerI wonder why (eval (eval '(list + 1 2 3))) works in 20090320 but not 1.0
21:54hiredmandysinger: works here
21:54hiredmanClojure 1.1.0-alpha-SNAPSHOT
21:55dysingerhmm I'll try 1.1
21:59hiredmanworks on 1.0 here too
22:00eee,(find '("a" "b") "b")
22:00clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.util.Map
22:01eee,(get '("a" "b") "b")
22:01clojurebotnil
22:01hiredman,(doc find)
22:01clojurebot"([map key]); Returns the map entry for key, or nil if key not present."
22:01hiredmanmakes sense yes?
22:01eeei want to know wat position
22:02hiredman,(.indexOf '(a b) 'b)
22:02clojurebot1
22:02eee,(.indexOf '("a" "b") "b")
22:02clojurebot1
22:02eeenah, that's gotta be in clj
22:02hiredmanit is clj
22:03eee,(index '("a" "b") "b")
22:03clojurebotjava.lang.Exception: Unable to resolve symbol: index in this context
22:03eee,(clojure.set.index '("a" "b") "b")
22:03clojurebotjava.lang.ClassNotFoundException: clojure.set.index
22:03hiredmanuse indexOf
22:03eee,(clojure.set.index (clojure.set ("a" "b")) "b")
22:03clojurebotjava.lang.ClassNotFoundException: clojure.set.index
22:04eeegrrrr
22:04hiredman,(.invoke (fn [] 1))
22:04clojurebot1
22:04eeewhat's that showing
22:05hiredmanthat function application is just a method call
22:05eeeit's kindof a deal breaker at work to drop back to java for stuff like that
22:05hiredmanoh please
22:05hiredman"drop back into java"
22:05eeethey hate java
22:05eeethat's their quote
22:05hiredmanthey are ignorant
22:05danleii have (defn position [coll item] (.indexOf coll item)) in my tools ...
22:05hiredmanmost likely redneck hick racists
22:06eeecheck it into core danlei
22:06eee(if that is possible)
22:06hiredmanthey should grow and overcome their ignorance
22:06dnolenand if you don't need the behavior of .indexOf as an fn you can always write a macro: (defmacro index-of [coll x] `(.indexOf ~coll ~x))
22:06hiredmanclojure is *HOSTED* on the jvm
22:06danleieee: well, usually the philosophy over here is, that if some functionality already exists in java, it is not wrapped. i just always type position automatically, so i defined it ...
22:07hiredmanthat was part its design
22:08eee(ducking) and if I need a hammer I can mold one out of iron ore?
22:08eeej/k
22:08danleidnolen: why should one use a macro here?
22:08hiredmanclojurebot: literal [3] clojure
22:08clojurebota very attractive hammer with a nice heft to it
22:10hiredmaneee: you want to wrap a perfectly good hammer in a layer of plastic and label it "gravity driven energy delivery device"
22:10eeeis .indexOf in C#?
22:10eeestarts with capotol I
22:10eeein C#
22:11eeeso host dependent
22:11dnolendaniel: personal pref really, one less fn call if you're not planning on using it as an fn.
22:11eeewhich is fine for, like gui stuff or something insane
22:11eeei bet it's in contrib somewhere
22:11danleidnolen: prem..., well ok. :)
22:11dnolendaniel: very :)
22:12dnolendaniel: mostly I attribute it to laziness.
22:12dysingerhiredman
22:12dysingerClojure 1.1.0-alpha-SNAPSHOT
22:12dysingeruser=> (= (eval (eval (quote (list + 1 2 3)))) 6)
22:12dysingerjava.lang.ExceptionInInitializerError (NO_SOURCE_FILE:0)
22:12dysingeruser=>
22:13dysingeris this not what you see ?
22:13dnolenno so much index-of but (defmacro parse-int [str] `(Integer/parseInt ~str))
22:14eeegoogle search ain't finding that nice marked up doc page for contribs yet
22:14eeecan't find the docs for contribs
22:14hiredmandysinger: nope
22:14hiredmanI see 6
22:14hiredmanon 1.0 and 1.1
22:14dysingerhere's 20090320
22:14dysingertim-dysingers-macbook-pro:~ tim$ clj
22:14dysingerClojure
22:14dysingeruser=> (= (eval (eval (quote (list + 1 2 3)))) 6)
22:14dysingertrue
22:14dysingeruser=>
22:14eeehttp://code.google.com/p/clojure-contrib/wiki/OverviewOfContrib
22:15hiredmandysinger: well that is not the test case you pasted earlier
22:15hiredmananyway
22:15dysinger1.1 are currenty 2 commits apart
22:15hiredmanI get 6
22:15dysinger1.1 and 1.0
22:15hiredmanon both
22:15dysingeryou shouldn't get 6 you should get true
22:15hiredmanI get six for the inner expression
22:16hiredmanso of course I get true for the outer expression
22:16dysingerhow could your 1.1 be different than mine ?
22:16hiredmanyou are doing it wrong?
22:16dysingerthat's cute
22:16hiredmancheck you classpath
22:16hiredmanyour
22:17hiredmanant clean then rebuild
22:17eeewould be cool if the contrib "includes?" returned the index instead of just true
22:17dysingerhiredman "check my classpath" lol
22:17hiredmanyeah, make sure you are using the right jar
22:18eeehow do you request a feature change to contrib?
22:18dysingerI am lightyears ahead of "the right jar"
22:18dysingerhiredman pastie your (System/getProperties) for me
22:19hiredmanI have done this on two machines, one with openjdk7 and one with diablo-jdk1.6
22:20dysingerso let me see your system properties from a machine where 1.1 evals that above
22:20hiredmanwhy?
22:21dysingerbecause it says a lot
22:22hiredmanuh
22:22hiredmanlisppaste8: url
22:22lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
22:22lisppaste8hiredman pasted "properties" at http://paste.lisp.org/display/79736
22:23lisppaste8hiredman annotated #79736 "second machine" at http://paste.lisp.org/display/79736#1
22:25danleieee: btw, looking at it again, if you want to use position (defn position [coll item] (.indexOf (seq coll) item)) might be better. (position "abc" \c)
22:25lisppaste8hiredman annotated #79736 "third" at http://paste.lisp.org/display/79736#2
22:26dysingercan anyone else besides hiredman verify that (= (eval (eval (quote (list + 1 2 3)))) 6) works on 1.0/1.1-SNAPSHOT ?
22:26danleidysinger: => true
22:26dysingerwtf
22:27eeeok thanks danlei
22:27clojurebottrue
22:27dnolenwhat are expecting to see dysinger?
22:27dnolenI see true as well.
22:28dysingerI get exception
22:28eeeas long as indexOf works for all seqs
22:28hiredman~works on my machine
22:28clojurebothttp://haacked.com/images/haacked_com/WindowsLiveWriter/IConfigMapPathIsInaccessibleDueToItsProt_1446B/works-on-my-machine-starburst.png
22:28dnolendysinger: where are you pulling your sources from? svn or github?
22:28dysingeruser=> (= (eval (eval (quote (list + 1 2 3)))) 6)
22:28dysingerjava.lang.ExceptionInInitializerError (NO_SOURCE_FILE:0)
22:28dysingeruser=>
22:28dysingersvn
22:28hiredmanhow are you starting clojure?
22:29dysingeremacs
22:29dysingerbut also tried java -jar clojure.jar XXX.YYY
22:29eeewhatever version I have, it works
22:29hiredmanwhere xxx.yyy is?
22:29dysingerok I believe you -
22:29eeereturned true
22:36eeei don't even know how to ask this
22:37eeedo you have to quote all the way down?
22:37eeeso like I want to send a list of lists to a function param
22:37eeedo you just quote the outside?
22:37hiredman"send"
22:37eeeor '('("a" "b") '("c" "d"))
22:37hiredmanjust the outside
22:38eeethe outside keeps anything from being evaled?
22:39eee'(a b) '(c d))
22:39eeeor expanded or whatever
22:39lisppaste8danlei pasted "position" at http://paste.lisp.org/display/79737
22:39eee,'(a b) '(c d))
22:39clojurebot(a b)
22:39eee,'(a b) (c d))
22:39clojurebot(a b)
22:39eee,'((a b) (c d))
22:39clojurebot((a b) (c d))
22:39eee,a
22:39clojurebotjava.lang.Exception: Unable to resolve symbol: a in this context
22:40eee,'((a b) ())
22:40clojurebot((a b) ())
22:41eee,(let [q '((a b) ())] (first q))
22:41clojurebot(a b)
22:41eee,(let [q '((a b) ())] (second q))
22:41clojurebot()
22:45danleihiredman: concerning that .indexOf returns a magic number (and yes, i consider this ugly), do you really think that something like "position" in core would be such a bad idea?
22:46hiredmanyes
22:46danleihm
22:46eeei found (includes?)
22:46eeeyou could just have that return the pos
22:46eeeinstead of true
22:46hiredmanit is errecting a barrier between clojure and the environment it was built to inhabit
22:47eeealso (includes?) is unnecessary by that argument . . .and so is a lot that is wrapped in core
22:47danleiwell, but its a useful abstraction. position is more general, and more lispy. but i do see your point, don't wanna argument here.
22:47hiredmaneee: correct
22:47eeebut, it's more resilient to not assume it will always be java
22:48eeeand
22:48eeeassuming jvm is not the same as assuming java
22:48eeei think it's low priority to wrap some things, I agree
22:48eeeand Rish points out that it's a pain to come up with docs when java already did it
22:49technomancydanlarkin: can you explain the difference between clojure-json and clojure.contrib.json?
22:49eeebut . .. we be talkin about pos here, not some crazy gui thing
22:49technomancyapart from the fact that yours uses keywords keys and contrib uses string keys...
22:49danleiin this case, it's (in my opinion) not just wrapping. dealing with magic numbers in lisp code is not idiomatic, in my opinion. but thats maybe just personal preference, so i'll just put it in my toolbox and shut up now. :)
22:49danlarkintechnomancy: the technical differences?
22:50eeeyeah, I'll somewhat shut up, too.
22:50hiredmaneee: clojure collections are all java Collections
22:50technomancydanlei: it's not just you; dealing with magic numbers is ridiculous
22:50eeebut I try to represent python folks considering clojure
22:50technomancydanlarkin: I mean did you write yours before there was one in contrib, or did you write yours because the contrib one was too slow, or what?
22:50eeewhich isn't necessarily me . . . so having a strong argument is best
22:52technomancydanlarkin: btw, re the http lib; I split out the "get/post/put" etc functions into its own namespace so the main thing in http/client.clj is just the request functions
22:52clojurebotfunctions are maps
22:52technomancyclojurebot: thanks for sharing.
22:52clojurebotfor is not used enough
22:53technomancyclojurebot: are you descended from Eliza?
22:53clojurebotHuh?
22:53hiredmaneee: clojure is built on java/the jvm it was purpose built for that, a similar language on other architectures will be that, a similar language, but not clojure
22:53technomancyclojurebot: did you say "huh" because of your childhood?
22:53clojurebotPardon?
22:53danlarkintechnomancy: I wrote it before there was one in contrib, also clojure-json uses constant memory for encoding and (I think) contrib.json can overflow the stack with big JSON files (or it used to at least?), and clojure-json can do indenting, and have custom encoder functions for types it doesn't know about, etc
22:54technomancydanlarkin: cool; sounds handy
22:54eeei guess i'm making an extension of the java argument, compile once, run anywhere
22:55danlarkinoh, not to mention that clojure-json correctly deals with all json I've thrown at it, while contrib.json has some bugs
22:55eeejvm is written for it's host so java byte code doesn't have to be
22:55technomancydanlarkin: I just get the feeling that contrib has a serious neglect issue.
22:55hiredmaneee: clojure compiles to jvm bytecode
22:55eeelikewise it'd be cool to have a language that didn't care what vm it ran on
22:55eeepipe dream for some things . .. but pos isn't a pipe dream
22:55eeeseems like a good goal
22:56eeeas fundamental as "next"
22:56eeeor "first"
22:56eeeor "nth"
22:56hiredmanit needs to be split
22:56eeei agree there
22:56eeeit needs to be split
22:56eeeif we are talking about contrib
22:56hiredmanpossible some kind of super package pulling most of contrib into one jar
22:57technomancytotally
22:57eeecore-staging
22:57technomancyyeah, some kind of "candidates for contrib" would be useful
22:57eeeor "core-candidates"
22:57technomancythen a "standard library" section
22:58technomancythen "deprecated" where we can move libraries whose tests don't pass.
22:58technomancy=)
22:58eee,(nth '(1 2 3) 2)
22:58clojurebot3
22:59eeeif nth is there, it's inverse should be
22:59eeepos
22:59eee:)
22:59danleijust ask rich about it, when he is around
22:59technomancyI think the reluctance to put stuff in core makes more sense once you realize core.clj is _one_ file
22:59replacadanlarkin: are you currently a contributor (i.e. have signed a CA)?
23:00danlarkinreplaca: yes
23:00technomancyand it's 4152 lines long
23:00replacadanlarkin: So we can just ptopose in the group that clojure-jsan replacee the current jsaon code
23:00PuzzlerQuick question: In the SLIME Repl, I can't get println to work when it is called from a newly-spun thread. Any suggestions?
23:01eeei wonder what the impact of such a large file is
23:01replacadanlarkin: would you be in favor of that?
23:01danlarkinsure! breaking change to those using the current contrib.json, but quite alright with me
23:01replacawell, there's a discussion, but we know that's broken
23:02replacathere doesn't seem to be much reason to have competing versions
23:02danleiPuzzler: there was (slime-redirect-inferior-output), but i don't think that works atm
23:02technomancydanlarkin: breaking just because of string keys and different function names, or is it more?
23:02technomancydanlarkin: but yeah, I'd submit it for inclusion. this is one instance of choice is not helpful.
23:02danlarkintechnomancy: and if they were relying on the broken behavior of current contrib.json
23:03replacaProbably we should write up a group posting about JSON
23:04replacaStuart wrote the existing one (are you here Stuart?) but I don't know if he's attached to it or not
23:08technomancydanlarkin: would love to get your feedback on the "resourcefully" branch if you could take a look.
23:08technomancyI think there's a place for a higher-level API around the client
23:09hiredmanhttp://mail.openjdk.java.net/pipermail/discuss/2009-April/001648.html "When the Sun goes down what happens to the OpenJDK"
23:11eeedo lists always make you insert at the beginning?
23:11eeei tried cons and conj
23:11hiredmanyes
23:11dnolenvectors will add at the end.
23:12eeewant my new stuff at the end
23:12hiredmanthat is a property of lists
23:12danleieee: cons, by definition, conj, because it's cheapest for lists
23:12eeeok ok
23:13eeebut how do I know I'm dealing with a vector from a function
23:13danleibtw, there is no *guarantee* that conj will always add at the end of a vector, is it?
23:13eeeseems hard
23:13hiredman,(doc conj)
23:13clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
23:14eeeuhg
23:14danleihiredman: so, what *does* guarantee adding at the end?
23:14eeeexactly
23:14dnolendaniel: it will always add the end, unless the vector gets coerced into something else
23:14hiredmandanlei: conj will always add at the end of vectors
23:14dnolenif for some reason it gets coerced you can always bring it back with (into [] ...)
23:15arohnerand you can tell what obj you have by doing (class obj), but I would be careful of making decisions based on that
23:15arohner,(class [])
23:15clojurebotclojure.lang.PersistentVector
23:15danleidnolen: thanks, i use vec btw
23:15hiredman~def vec
23:16danleiin practice, it's clear to me, that conj will add at the end of a vector. maybe it's just nitpicking ...
23:17eeeso now I DO have to quote the inner lists
23:18eee,(let [q ['(a b) '()]] (second q))
23:18clojurebot()
23:18eee,(let [q ['(a b) '()]] (first q))
23:18clojurebot(a b)
23:19hiredmaneee: you can quote the vector
23:19hiredman,'[(a b)]
23:19clojurebot[(a b)]
23:19eeein my code, that was barfing . . guess it wasn't that
23:20eee,(let [q '[(a b) ()]] (first q))
23:20clojurebot(a b)
23:21danlarkintechnomancy: it looks good, with-cookies would be very handy
23:21technomancydanlarkin: with-cookies could go into client.clj too
23:22technomancyyou like the idea of splitting the two namespaces?
23:23danlarkinoh, I'm slightly confused then I guess, what's the idea behind splitting the namespaces?
23:24technomancyjust that one's an API for lower-level stuff and resourcefully is more centered around interacting with REST services
23:24technomancysince you weren't too sure about adding get/put/post/delete etc to client
23:25eeethis transition function is gonna hurt my brain tonight. that's a whole nother chapter for me
23:25eeethanks for all the explanations and help
23:25danlarkinso resourcefully.clj would be for defining wrapper methods get/post...etc around client.clj's request function?
23:25technomancyright
23:28danlarkinI'm still not convinced of the need for a function that wraps another just providing one argument... although if that's what people want...
23:28technomancywe'll play with it; see how it feels