#clojure logs

2009-12-20

00:05scottjIs there a function that inverts a tree? Not sure if that's the right name, but I want to convert (a (b 1)) to (b (a) 1)
00:28alexykhow do we do optional parameters?
00:29scottj&
00:29_ato(defn foo [x & [y z]] ...) y and z are optional (they'll be nil if not specified)
00:30_atoor (defn foo [x & options] ...) if you want any number of optional arguments (options will be a list of them)
01:09tolstoySo, I'm going to assume you can just 'export CLASSPATH="my-tons-o-jars" emacs' and be able to use Slime with code that depends on those jars. Right? ;)
01:10efarrarsounds reasonable tolstoy
01:10efarrarthat's what i've experienced in the vim equivalent of slime
01:10tolstoyThere doesn't happen to be a way to, say, (load "random-jar-file") right from the repl, is there?
01:11efarraryes, but it doesn't always work for everything
01:11tolstoyI keep thinking about the ASDF stuff people have hacked up with Common Lisp.
01:11tolstoyAh, okay.
01:11tolstoyI'm using Aquamacs, and it has a cool "server" mode, so I can start emacs from the command line pretty easily.
01:12scottjtolstoy: you can run M-x swank-clojure-project, tell it the dir of your project, and it will look in lib dirs and put all the jars on the classpath and start slime
01:12scottj,swank-clojure-project
01:12clojurebotjava.lang.Exception: Unable to resolve symbol: swank-clojure-project in this context
01:12tolstoyHm. I think I better take notes.
01:33tolstoyWhen you do a git fetch on, say, the 1.0.x branch. How do you diff what you just fetched? git diff HEAD 1.0.x? Something like that?
01:41tolstoyWhich branch of clojure-contrib matches up with clojure 1.1-rc1?
01:53ambienthmm, i have a problem with clojure-project in emacs/swank-clojure where it doesn't find clojure.main, even when it's in my classpath. seems emacs overwrites that.
01:54ambientwhen I try and do M-x clojure-project on the project root
02:01tolstoyHm. Swank doesn't seem to have used my CLASSPATH from when I started emacs.
02:02tolstoyAt least if you go by (System/getProperty "java.class.path").
02:04arbschttolstoy: you probably want to set swank-clojure-classpath
02:05tolstoyWhere do I set that?
02:05arbschtin emacs
02:05tolstoyOy.
02:06tolstoyHm. That command doesn't exist. Or do you mean set something in .emacs?
02:09tolstoyambient: When I run swank-clojure-project, I got some sort of hang on "polling" and nothing happens except a prompt for slime-abort-connection.
02:09arbschttolstoy: try swank-clojure-extra-classpaths
02:10tolstoyarbscht: Are you talking M-x swank.... ? Cause there's nothing but the project thing.
02:11arbschttolstoy: it's a variable in emacs -- do C-h v swank-clojure-extra-classpaths for info
02:12tolstoySo, you mean you have to edit your .emacs file whenever you switch projects and so on? Yikes.
02:13arbschttolstoy: you could update its value at runtime too. depends what you want to do
02:14ambienttolstoy: yes, that's my problem too
02:15tolstoyHere I thought I was going to write some code, and now I have to figure out how to set a variable in emacs lisp. I never seem to get that sort of thing right.
02:15tolstoyBitch bitch moan. I know it'll pay off in the end.
02:18ssideriswriting code > setting up coding environment
02:18ssiderismuch much more preferable
02:20tolstoyDo I just put a string in there?
02:22arbschttolstoy: a list of strings
02:22tolstoySo, I do the C-h v swank-clojure-classpath, and I see a (swank-clojure-classpath) in the flip-down. Do I just replace that with a stirng? Do I type in (setq swank-clojure-classpath '("patha", "pathb"))? I see no docs anywhere.
02:23tolstoy(setq swank-clojure-extra-classpaths (list "/class/path/1" .... ))
02:24ambienthttp://www.thibault.org/adder/ clojure on python, :P
02:29taliosclojure on python is just wrong :P
02:29taliosclojure on jython is where its at :)
02:30ambientjust another layer of abstraction...
02:30taliosMuch like my polyglot maven/clojure work.
02:30_atonice
02:30_atothat's something I
02:30_atove much thought about
02:30_atoa compiler to python/ruby/perl bytecode
02:30_atofor scripting etc
02:30taliosabstractions on abstractions, abstracting the abstraction with yet more abstractions
02:32ambientit's cool how clojure is much more portable, lisp designed to sit on oop platform
02:42tolstoyAh, man. I thought I'd just start-up swank-clojure as part of my app and then hook to it with emacs, but you can't even build it without maven, it seems. I so don't want to download Maven.
02:42tolstoyMaybe netbeans is the way to go for interactive dev.
02:44_atotolstoy: http://clojars.org/repo/swank-clojure/swank-clojure/1.1.0-SNAPSHOT/swank-clojure-1.1.0-20091121.091400-2.jar
02:44_atoand it's built with leiningen not maven
02:45tolstoyAh. I saw pom.xml and had to fight off the nitemares from a few years ago.... well, it wasn't that bad, I guess.
02:47_atoyeah, I understand. I've worked with it a while and I still find Maven frightening.
02:48tolstoyYeah, it's like, "Cool! A neat little project!" Then, three hours of macports + downloading massive repos later, I get my simple little lib to play with.
02:49_atoyep... and no matter how many pom files I write, I still have to look up the syntax for even the most basic things. Same for the mvn command-line
02:50tolstoyI know people hate including jar files in your source tree, but, sheesh. It's sooooo much simpler. ;)
02:52tolstoyOkay. I've been complaining. Really, I worked all this out with CL a few years ago, and loved it. It's the damn CLASSPATH thing that gets me after a while.
02:52tolstoyBUT, I just started swank in a shell repl, and connected via emacs, and I LOVE IT!
02:52_ato:)
02:53tolstoyI can make a nice little shell script to get me started without having to mess with .emacs. Joy! ;)
02:55talios_ato - I'm working on maven polyglot support for clojure. no XML in site.
02:57_atotalios: yeah, I've been following. It's definitely an improvement, but XML is just the tip of the iceberg when it comes to Maven's horror. I integrated Maven into Clojars (for the repository deployment), using the Maven API directly and boy was that complex. The amount of hoops that Plexus (the auto-injector frameworky thing) makes you jump through to do anything is insane
02:58tolstoyHow do you cleanly shutdown a swank server?
02:59_atotolstoy: (System/exit 0) maybe?
02:59_atoI just Ctrl-C it normally :-P
02:59tolstoyHeh. swank.swank doesn't export a stop-server. ;)
02:59_atothere's a M-x slime-quit-lisp or something
02:59talios_ato: thankfully plexus is on the way out with maven 3 - guice baby guice :)
02:59_atowhich I think just sends System/exit
03:00johnmn3g'day
03:00tolstoyM-x slime-repl-sayoonara does it, too.
03:01_atotalios: ah. I haven't looked at Guice, just Spring and now Plexus. So far I've got a rather negative opinion of dependency injection frameworks in general, but maybe it's just the ones (or the uses of them) I've been exposed to
03:02johnmn3I'm trying to build a simple swing repl. I'd like to somehow bind *out* and *err* to a JTextArea and *in* to a JTextField, but neither have a .getInputStream or something similar. How would you guys accomplish this?
03:06_atoyou'd probably want to capture input/output for java code called from Clojure as well, so I'd probably use (System/setIn) with a PipedInputStream
03:06_atoand similar for output
03:07_atoyou can override *in* for Clojure code just by doing (binding [*in* something] ...)
03:07_atoalso see:
03:07johnmn3I was thinking of using a buffer and having another thread constantly flushing any content to the JTextArea, but I'd like to find a simpler solution... one where simply pressing enter (like at the regular repl) puts the code into to *in*, gets evaled, and automatically goes from *out* to the JTextArea
03:07_ato,(doc with-out-str)
03:07clojurebot"([& body]); Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls."
03:08johnmn3ah
03:09johnmn3So I need to somehow wrap the JTextArea in a StringWriter and then bind that to *out*
03:11johnmn3_ato: the part where you said, "for the java code called from clojure," that would be covered by rebinding *in* and *out* right?
03:11_atoI don't think so
03:11_ato,(doc *in*)
03:11clojurebot"; A java.io.Reader object representing standard input for read operations. Defaults to System/in, wrapped in a LineNumberingPushbackReader"
03:11_atocause java code would be using System/in and System/out directly
03:12_ato,System/out
03:12clojurebot#<PrintStream java.io.PrintStream@161daed>
03:12_ato,(.println System/out "hello")
03:12clojurebotnil
03:12johnmn3by java code, you mind like (.toUpperCase "hi")?
03:12_atooh that's fine.. it's just if the java code has a print in it
03:13_atoif you don't care about threads/asynchronous output then just something like this might do the trick: (->> (.getText input-text-area) (read-str) (eval) (with-out-str) (.append output-text-area))
03:13_atoor whatever the appropriate swing calls are (I haven't used swing in years)
03:14johnmn3sounds about right... but what is with-out-str doing right here?
03:14_atoit's rebinding *out* for you
03:14_atoand turning the results into a string
03:15_ato,(with-out-str (println "hello world"))
03:15clojurebot"hello world\n"
03:15johnmn3ok, so we get a string and eval it.. then we take that string and make it the destination of the results, coming from *out*, then append it?
03:17johnmn3, (let [a "hi"] (with-out-str (println (let [a "123"]) a))))
03:17clojurebot"nil hi\n"
03:17_atoyeah, so we get a string, read it into clojure data structures with (read-string), then eval it like: (with-out-str (eval form)) so with-out-str returns a string of our output which we then add to the output text area
03:18_ato(reverse (with-out-str (println "hello")))
03:18_ato,(reverse (with-out-str (println "hello")))
03:18clojurebot(\newline \o \l \l \e \h)
03:18johnmn3whereas
03:18johnmn3,(reverse (println "hello"))
03:18clojurebot()
03:18clojurebothello
03:18_atoright
03:19taliosmm, for some reason the repl isn't printing stacktraces, is that an option I can turn on
03:19talios?
03:19_atotalios: hmm.. it should normally popup a new slime buffer thing with the stack trace
03:20taliosbah - who uses slime ;p
03:20_atooh you mean the repl directly?
03:20_atothat's weird then
03:20taliosapparantly its a new feature to limit useless stacktraces ;:)
03:20_atocould try: (.printStackTrace *e)
03:20taliosjust did
03:21_atohmm dunno then. I don't use a direct repl very often
03:21taliosnah thats ok - as long as I know that its clojure supressing them by default, I'm ok with that
03:22taliossadly the trace didn't actually help thou
03:22johnmn3,(with-out-str (println (with*err*?)))
03:22clojurebotjava.lang.Exception: Unable to resolve symbol: with*err*? in this context
03:22johnmn3,(println (with*err*?))
03:22clojurebotjava.lang.Exception: Unable to resolve symbol: with*err*? in this context
03:22taliosannoyingly - my macro throws a ClassCastException, but if I run its steps manually - its fine
03:22_atojohnmn3: yeah, you'll have to catch exceptions and do whatever you want to do with their stack trace
03:23johnmn3I'd like to do what the repl does, and just append them into the JTextArea
03:24johnmn3(doc with-err-string)
03:24clojurebotexcusez-moi
03:24johnmn3,(doc with-err-string)
03:24clojurebotI don't understand.
03:24_ato~def with-out-str
03:32johnmn3works good
03:39talios'lo headius
03:39headiusoh hai
03:41johnmn3does anyone know of an buffer kind of object I can get to automatically call (.append myJTextArea ), which I can use to .getOutputStream, for the purposes of binding *err* and *out* to?
03:42johnmn3with the new protocols, I wonder if I could extend some existing java queue or stream to do that.
03:46vegaiare there any mechanisms for making a high availibility solution a la Erlang? With supervisors t al
03:47tolstoyvegai: I don't think so. Not built in.
03:47taliosjohnmn3: you could do that now with (proxy) and create out own OutputStream that appends to a JTextArea
03:49johnmn3hmm.. How do I explore the interface of OutputStream? does (show OutputStream) show me the methods I need to over-ride?
03:50johnmn3show shows it has three .write signatures
03:50johnmn3[12] write : void (byte[])
03:50johnmn3[13] write : void (byte[],int,int)
03:50johnmn3[14] write : void (int)
03:51johnmn3PrintWriter has a write : void (String)
03:52johnmn3can any class be extended like that?
03:53talios(proxy) just implements an Interface, it's not extending anything
03:54johnmn3I mean, are OutputStream or PrintWriter interfaces? Aren't they concrete classes (or whatever)? Do I need to find their interface counterparts?
03:58taliosMmm your right, they're classes. For some reason I was thinking they were interfaces.
03:58taliosIn that case I don't think (proxy) will help.
03:58johnmn3is there a command to message clojurebot with code, and he'll post it to lisppaste?
04:00johnmn3yea, something like a IPrinterWriter
04:03_atojohnmn3:
04:03_atohttp://java.sun.com/j2se/1.5.0/docs/api/java/io/PrintWriter.html
04:04_atowrapping a PipedOutputStream in a PrintWriter would be an alternative to using proxy
04:05_atohttp://java.sun.com/j2se/1.5.0/docs/api/java/io/PipedOutputStream.html
04:10taliosbah, that w00t was premature
04:12johnmn3ah'kkhaa
04:12johnmn3PrintWriter out = new PrintWriter(new TextAreaWriter(myTextArea));
04:14johnmn3ah, he's actually defining TextAreaWriter in the example.. I'll see if I can use proxy to create a TextAreaWriter
04:46johnmn3I'm trying to subclass Writer but I'm getting a ctor exception on String, with the relevant code as:
04:46johnmn3(write [cbuf off len]
04:46johnmn3 (.append text-area (String. cbuf off len)))
04:47johnmn3Do I need to type hint here or something?
05:16LauJensenjohnmn3: Best way to answer that question is (set! *warn-on-reflection* true) and compile the code
05:16johnmn3LauJensen: ok, will try that.
06:21LauJensenBlogged about the Arc challenge: http://www.bestinclass.dk/index.php/2009/12/beating-the-arc-challenge-in-clojure/
07:03ambientLauJensen: just by rapid reading, that really doesn't look like a solution to a challenge, but a trivial problem :)
07:05_atoLauJensen: it says in the "challenge" description: the value entered in the input field must not be passed in the url
07:05LauJensenreally?
07:06_atoyep.. in the blockquoted bit
07:06LauJensenaah
07:06LauJensenThanks :)
07:15_atothat "challenge" just seems to be saying hey arc ships with a continuation/closure based web framework in the standard library. Which I guess is okay, but not really very interesting if you've seen one before
07:18LauJensenTrue
07:18LauJensenBut I think Compojure is suffiently elegant to want to show it to people
07:18LauJensenAnd now I get to show of the session middle-ware as well :)
07:19_atohehe :)
07:23_atoeek
07:23_atoI'm looking at the Haskell version: http://gist.github.com/260052
07:24_atoI guess I must already be forgetting most of the Haskell of learnt
07:24LauJensenIts pretty complex
07:24LauJensenGo is kinda nice
07:24LauJensenRuby looked nice, until I saw the custom library the guy made in order to make it nice :)
07:27_atothe Go version cheats to look nice, it uses mutable global state, so it'll break if two people access it simultaneously ;-)
07:27_atothough I dunno maybe Go has a nice sessions library
07:29_atothe ruby one is strange, dunno why he's using html strings for that, I thought sinatra had helpers for that
07:29_atooh right
07:29_atohe says it doesn't hmm.. maybe I'm just think of rails / haml
07:31LauJensen_ato: link to your Wide Finder blog post plz?
07:32_atoLauJensen: you mean this link? http://meshy.org/2009/12/13/widefinder-2-with-clojure.html
07:35LauJensenthats the one
07:36LauJensenI linked that to your name, article now updated with session middleware instead of URL trick
07:43_atoactually, yeah you're right. With the sessions, that is quite a nice demo of all the basic bits of Compojure
07:43_atocertainly beats a usual hello world example
07:47LauJensenGlad you like it
07:51LauJensen_ato: I wonder if I should adopt your disclaimer from the top of your WideFinder article "This code can be reproduced in Java, which can be reproduced in C++, which can be reproduced in C, which can be reproduced in ASM, which can be reproduced in a Hex-Editor: Source code here" :)
07:54_atohehe, the turing-completeness disclaimer. :-)
07:56_atoYeah, I mainly added that cause I knew I'd get a swarm of comments saying... but you can do the same thing in language X. Which is beside the point.
07:57arbschtI believe the official designation was "Clojurian", not "Clojurist"
07:57LauJensenarbscht: correct
07:57LauJensen_ato: Did you succeed?
07:58_atoLauJensen: succeed at preventing the swarm of comments? seems so. :-)
07:58LauJensenI've tried to avoid certain types on comments in every post I've done - the only thing which works for sure is moderation :) When you speaking of a n-level language, I'd say anything you can do in N, you can also do in N-1. But nothing everything makes sense doing in N-1, so the important this is: Can you do it in N ? ... cryptic - but makes sense?
07:58LuytWhy is there need for vectors in Clojure? Can't lists do what vectors do?
07:59LauJensenLuyt: They cant have the same performance characteristics
07:59_atoLuyt: vectors allow fast indexed lookup. lists are slower for indexed lookup as they have to be traversed
07:59LuytI see.
07:59LauJensenAh thats a shame alex, too slow :)
07:59hiredmanLuyt: you are asked if linked lists can offer constant time indexed access?
07:59hiredmanasking
08:00LuytI am reading the book and just wondered why there were both vectors and lists, but now that's clear to me.
08:00LuytI thought maybe the one was immutable and the other not, like you have in Python (tuples vs. lists)
08:01_atoyeah, they're both immutable in Clojure
08:02arbschtthere are also useful differences in semantics and syntax
08:02arbscht,(conj [1 2 3] 4)
08:02clojurebot[1 2 3 4]
08:02arbscht,(conj '(1 2 3) 4)
08:02clojurebot(4 1 2 3)
08:02Luyt,(into [1 2 3] 4)
08:02clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
08:03Luyt,(into [1 2 3] [4])
08:03clojurebot[1 2 3 4]
08:03Luyt,(into '(1 2 3) '(4))
08:03clojurebot(4 1 2 3)
08:03_atolists have the advantage that you can stick them on the front of other seqs, like lazy sequences or vectors, and adding them to the front of such objcets is really fast
08:04_atowhere with a vector you'd have to convert the whole seq to a vector
08:04hiredmangenerally you don't into a list
08:04hiredmanyou just call seq
08:05LuytThat was my next question: why is there an 'into' if you already have 'conj' ?
08:05hiredman(which is not the same, but close enough for most cases)
08:05_ato,(into [1 2 3] [4 5 6])
08:05clojurebot[1 2 3 4 5 6]
08:05LauJensen,(reduce conj '() [1 2 3 4])
08:05clojurebot(4 3 2 1)
08:05_atointo is for conjing multiple things at once
08:05hiredmanwhy have multiple instructions when a processor only needs one?
08:08hiredmanI imagine rhickey found himself writing (reduce conj x y) so he packaged it up into (har) clojure.core
08:09LauJensenhehe
08:10_atoyeah, since it's such a common thing to do, it's worth naming even just for readability. "into" gives you a much better idea of the intent than "reduce conj" which requires more thinking about
08:11_atoand of course later on it turned out to be handy since, into can add transients
08:12LuytAh, I see, (conj [1 2] [3 4]) vs. (reduce conj [1 2] [3 4]) and (into [1 2] [3 4])
08:14hiredman,(conj [1 2] [3 4])
08:14clojurebot[1 2 [3 4]]
08:14hiredmanvery different
08:14LuytYes, (reduce conj [1 2] [3 4]) and (into [1 2] [3 4]) both return [1 2 3 4]
08:16LuytWell, with that mystery solved I get another cup of coffee ;-)
08:16LauJensenBtw, for the rest of your bloggers who have had some difficulty getting good source highlighting for your Clojure-code. I made a little macro that works with htmlize, so to get code on my blog I mark the region and hit M-x blog, and its in my clipboard ready to be pasted in html :)
08:20_atoLauJensen: cool. htmlize is very handy. I'm currently using markdown with pygments for the highlighting, which looks like this: http://meshy.org/~ato/tmp/2009-12-13-widefinder-2-with-clojure.markdown.txt
08:21LauJensenNothing is highlighted?
08:21LauJensenI think CGrand is also using some modified version of Pygments
08:22_atoI mean that's the source code
08:22_atothe highlighted output is in my blog post http://meshy.org/2009/12/13/widefinder-2-with-clojure.html
08:22LauJensenaah, gotcha
08:22LauJensen_ato: How did you set it up ?
08:23_atoLauJensen: using Jekyll: http://wiki.github.com/mojombo/jekyll
08:24LauJensenOk - Maybe Htmlize is good enough after all :)
08:24_atooh yeah, htmlize is fine, I use that quite a lot too. I just hate hand-writing long HTML pages
08:25LauJensenYea, which htmlize saves me from - the only problem is if I need to edit, I usually just re-paste the whole thing
08:26_atoyeah, that's what I was finding too.
08:29LauJensenThis was one of my first posts and I've received several emails (as late as earlier this week) asking me about the setup, how did I get it to look like that, which OS etc, http://www.bestinclass.dk/index.php/2009/09/layout-emacs-etc/
08:31LauJensen_ato: Sounds like you wrote this http://arclanguage.org/item?id=1521
08:34_atohehe, nope. I like the BASIC version though. It really shows how complicated a "basic" app is these days compared to what it used to be. So much stuff (HTML, sessions, urls) you have to worry about that you didn't used to
08:34_atoon the other hand it's much easier to get images and different font sizes and such up in a webapp than it would be in basic. ;-)
08:37LauJensenSo generally, would you say that you have a tendency to over-think things? :)
08:41_atototally. simplicity is hard, and it just seems to keep getting harder the more technologies that are invented.
08:49chouserHi, I'd like to discuss something that just hasn't received enough attention in quite a while.
08:49chouserparenthesis!
08:50_ato:O
08:50liebkehaha, I've got this great idea for reducing the number of parentheses in Clojure!!! ;-)
08:50_atothe taboo word!
08:50the-kennyliebke: No! We need more of them.
08:51liebke:)
08:51chouserobviously parenthesis are ignorable and "disappear" over time
08:51chouserobviously parenthesis are the core and essence of a lisp
08:53liebkeI do think people's perceived problem with parentheses is actually caused by deep nesting of function calls. I think more liberal use of 'let' is a solution to their problem, not reducing the number of parens
08:54rhickeyThere are several problems with parens, they need to be separated in order to talk about them
08:54rhickeyfirst and foremost if the familiarity issue
08:55rhickeyis the
08:55rhickeycode as data is different from code using syntax
08:55rhickeyso, first reactions are "I can't read that"
08:56rhickeyan incorrect extension is "that is unreadable"
08:56rhickeyjust like someone who knows only Japanese might find English unreadable, but would be wrong to declare it generally so
08:56Chousukedepends on who's writing it :)
08:57LauJensen(.replaceAll rhickey "\n" ",")
08:58LauJensenI can't believe I'm not getting more love on HackerNewz, between me and Go I'm the only one who solved the problem
09:03aldebrnLauJensen, I just read your post on 1d automata and J, I wish more people withstood their impulse to badmouth something they find on the internet that they don't understand and don't like :P
09:03_atommm. Probably the functional thing is probably the larger stumbling block for people with an solely-imperative background. Trying to read Clojure without understanding functional programming is a pretty hard task. You're likely to come off thinking it's just gibberish and then not realising that's why it structurally looks so different blame the parens
09:05_atoI remember when I first encountered functional programming (Haskell) it took some time to wrap my head around. It felt like Haskell was totally unreadable at first.
09:06LauJensenaldebrn: Who badmouthed?
09:07aldebrnLauJensen, I meant, your comment ' I was planning to let him know, that only the writer of such hideous looking code could read it, but then I tripped over his blog...' You rock, I wish more people stopped to learn more about things like you did instead of just commenting negatively and forgetting :)
09:08LauJensenaaah, thanks - yea I'm glad I did, J is a good helper and truely a REPL language
09:09aldebrnI'm paranoid about my own ignorance but it took me a while to learn that others were less so, and I should assign internet comments very little weight. So many people have prejudices against Lisps, or anything-not-C#, etc..
09:10aldebrnJ looks really cool, and it maps into Clojure well
09:10LauJensenTrue.
09:11LauJensenAnd yea, I hope to hook J into Clojure, calling the j.dll directly from a j macro, but I haven't got the prototype running yet
09:11LauJensenOne thing you noticed quickly about J, is that its blazingly fast
09:12LauJensens/you/I
09:15aldebrnj.dll faster than Clojure? Would it be worthwhile to have a Clojure-to-J compiler for speed?
09:17chouserI do think most lisps have a weakness around parens in that they can mean so many different things when used in code.
09:17chouserthis is not a new statement from me. :-)
09:18rhickeychouser: exactly - it ends up that 'everything is a list' is not in fact the simplest
09:18rhickeydue to this overloading
09:18rhickeythat incidental complexity thing again
09:19chouserhumans find visual hints to be very useful. {} meaning code blocks or hashes (usually formatted quite differently) is nice, to differentiate from (foo) as grouping and foo() as calling
09:20rhickeychouser: right, but taken farther that's the argument for syntax
09:20chouserfoo(bar, baz) { bing(); bang(); } conveys some vauge but useful meaning even without knowing the meaning of the words.
09:20chouserrhickey: yes
09:20chouser(foo ((bar) (baz)) ((bing) (bang))) conveys almost no meaning at all.
09:21chouser(foo [bar baz] (bing) (bang)) is an interesting middle ground.
09:21rhickeyso, why not syntax?
09:22LauJensenaldebrn: No, that would be a bad way to go. But for some things, mathematical expressions etc, a J interface would be nice, because at those things its much faster than Clojure I think
09:22hiredmanchouser: it conveys no meaning because you are using nonsense words
09:23chouserhomoiconicity buys simpler macros, simpler compiler, simpler debates about new feature syntax.
09:23patrkrisis it correct to say that the STM in Clojure is dynamic?
09:24chouserhiredman: this is how code looks to people unfamilier with the vocabulary.
09:24hiredmanchouser: algo syntax is just as uncomprehendable to people why haven't written code before
09:25hiredmanlisp has syntax, it is expressed in words (symbols) rather than brackets and what not
09:27ChousukeI think vectors an maps give clojure enough syntax elements so that you can avoid overloading parentheses.
09:27rhickeychouser: those are downstream benefits. More syntax means more syntax rules, and thus more to understand., so more complexity up front. This might be amortized over a lifetime of use of a single language and thus might be a net gain. Once you learn more languages, there is less amortization and the per-language up front costs seem higher.
09:27Chousukewithout having to have a "full" syntax like most languages.
09:28hiredman(defn f [x] x) vs. defn f (x) x end
09:28hiredmanwhat's the difference? where is the syntax?
09:29chouserI don't think Clojure syntax would be harder to understand for first-time programmers than other languages. But relatively few people in that position are entering these discussions.
09:29Chousukewell, in the lisp case, the syntax is the macro mini language. ie. how it interprets the code elements
09:29rhickeyhiredman: there is a huge difference. the structure, parens, always delimit, whereas you have to know end/; etc delimit
09:29Chousukebut the generic "structural" syntax is uniform
09:30rhickeyand what matches with end
09:30hiredmanrhickey: so not only does lisp have syntax but is has a more regular syntax
09:30chouserOn the other hand, C, C++, Java, JavaScript, lua, etc. have similar enough syntax that once you've learned one or two, the work necessary to understand a lisp is higher than to understand another from the "C-like" category.
09:31rhickeyhiredman: it has syntax for a very few data structures, at that point, you brain can organize code. AScribing it meaning goes to the words, but that's true in langs with syntax too. In langs with syntax, elaborate rules must be used to discern the structure before other things come into play. We've just internalized many of those elaborate rules
09:32hiredmanactually I just finished watching some presentation of norvigs where he gives his reason for more or less jumping to python from lisp
09:32hiredmanstudents reading the ai book couldn't seem to figure out how to map from the pseudo code in the book to lisp, but the pseudo code was almost an exact map to python
09:33rhickeya key question is, how much different a language can one learn if they are unwilling to have different syntax? Lisps want code-as-data for macros, Haskell wants juxtaposition as application (as big a leap from C-derivees) for its functional style
09:33rhickeydoes setting up an arbitrary limit on difference-from-what-I-know determine a hard limit for what you can know?
09:34chouserbbl
09:35hiredmanI wonder what could be achieved if all the effort into lisp without parens went into, you know, doing something cool with lisp
09:35rhickeyhiredman: but what about Norvig's point?
09:35rhickeyseems somewhat valid
09:35hiredmanrhickey: "you can't fight reality"
09:36hiredmanthe talk was actually about scientific computing with python and this just an antidote in the intro
09:36fliebelHow can I dynamically add a jar to the classpath? add-classpath is deprecated, which most of the time means there is a better way.
09:36Chousukewell, the pseudocode was probably significantly more pythonlike in structure, so it was easier to associate with python.
09:37hiredmannot having read the book (and not knowing common lisp) I cannot comment
09:38Chousukebut in doing so, the studetds may have relied too much on the "physical" structure of the code, rather than the logical structure.
09:38hiredmanfliebel: I'd appreciate it if you could give http://gist.github.com/255766 a try
09:39hiredmanif you run it as a clojure script it will create a cl.jar file and print out usage instructions
09:41fliebelhiredman: huh? I don't want to create a jar, I want a Java library accessible at the repl.
09:43hiredmanfliebel: the clojure file generates a classloader that is then used to replace the system classloader
09:43hiredmanthe replacement classloader has a an "add" method
09:44fliebelah...
09:46hiredmangah, typo, should be getSystemClassLoader
09:49liebkehiredman: I'd like to give your class loader a try. Can you give a usage example of adding a class/jar within a running repl? I'm not quite getting it from the usage message at the end of the gist.
09:51hiredman(.add (ClassLoader/getSystemClassLoader) (URL. "file:///some.jar"))
09:51hiredman(.add (ClassLoader/getSystemClassLoader) MyMagicalClassLoader)
09:54liebkehiredman: okay, so the URL points to a jar, I see. I really don't understand Java ClassLoaders, so the second example isn't clear, but the first one makes sense now. Thanks.
09:55hiredmanthe second example means you can make your own classloader that does magical things (bytecode on the fly?) and add that to be searched for classes
09:55aldebrnhiredman, rhickey, I'm a refugee from Python (too inflexible for very complicated things). My view is, if people think Python is more useful and easier than Lisp, fine, but I think they're wrong and I'm putting my money where my mouth is by working in and on Clojure
09:56hiredman:P
09:56hiredman~python
09:56clojurebotpython is ugly
09:56liebkehiredman: cool, I'll leave the development of magical class loaders to you though :-)
09:57aldebrnI think someone here was commenting earlier that they thought Ruby was elegant until they saw the backend code that allowed for that elegance. I don't know ruby but I think that's a good description for Python too, all the nice elegant things in the language are unmalleable
09:58hiredmanliebke: I don't know much about classloaders myself, this is just sort of a rough cut of a solution for adding classes during developement
09:59liebkehiredman: yeah, I think it can be very useful
10:08fliebelIs there a place to get a nice overview of the workings of all those different include, use, require, etc...
10:09fliebelI try to do something simple like including a clj file from the repl living in the working directory.
10:10arj_I'm having trouble bending 'some' to find a struct with a specific field in my sequence, any hints?
10:11hiredman,(some :foo [{:bar 1} {:foo 1}])
10:11clojurebot1
10:11hiredman,((comp first filter) :foo [{:bar 1} {:foo 1}])
10:11clojurebot{:foo 1}
10:12arj_aha nice
10:13arj_so that last one will all stop after finding the element?
10:13Chousukeyeah.
10:14arj_cool :-)
10:14arj_thanks
10:14fliebelI'm on the repl running in a directory where a few clj files are laying around, how can I use these?
10:15fliebelimport and friend only seem to work with cp and java stuff
10:16_atofliebel: maybe (load "somefile.clj")
10:16_atobut best would be to just add "." to the classpath
10:17fliebellike this? -classpath /opt/local/share/java/clojure/lib/*:.
10:17_atoyup
10:18hiredmanfliebel: there is always load-file
10:18fliebelhiredman: I think that is easier than fiddling with cp…
10:19fliebelis there a :load thing for the ns macro?
10:19hiredmannope
10:20hiredmanI highly recomend you get your classpath worked out and use the ns macro's :use and :require over relying on load-file
10:22fliebelhiredman: but after adding . to the cp I still can't get it to work… I got to get a clear image how Clojure works together with java.
10:23hiredmanwell, while "just add . to your classpath" is good advice, it doesn't take in to account the possibility that you don't have your namespaces/directory tree laid out well
10:24hiredmannamespaces?
10:24clojurebotnamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
10:25lisppaste8johnmn3 pasted "JTextArea *out* *err*" at http://paste.lisp.org/display/92391
10:25fliebelhiredman: that'll be the problem. I'm trying to run a file with a strange ns in the current dir, so I think that's why It's not working
10:25johnmn3can someone check that out? I can't figure out what the correct way to set the proxy up for Writer is.
10:26johnmn3I've found lots of guides online for socket-repls, but not swing repls
10:26hiredmanjohnmn3: you are missing implementations for write that take less then three args
10:26hiredmanand that is not how you hint a character array
10:27hiredmanand that is not how you hint ints
10:29johnmn3ah.. but the javadoc on writer states that you only override the three parameter write, I think. But I tried writing aritys from 1 to 4 parameters.. though I never had all 4 write methods written in the proxy.
10:30hiredmanjohnmn3: proxy overides by name, so if you provide an implementation for .write, it needs to handle all possible aritys for methods named write
10:31hiredmanI would just toss out the hints
10:31johnmn3so do I do a method for each? (write [buf] ... (write [buf myint] ... etc. ?
10:31johnmn3yea, I probably don't need them.
10:32hiredmanor you can (write ([buf] ...) ([buf int] ...) ...)
10:33johnmn3ah, rite
10:33hiredmanif I recall the single arg .write can take a buffer or an int
10:33johnmn3damn, there's 5 write methods :/
10:33hiredmanso you will need to check that
10:34johnmn3int, string, or char[]
10:34fliebelMost of the time noobs like me actally do something wrong when they find a bug, but this seems quite strange to me: (line-seq (BufferedReader (FileReader. "/some/file")))
10:34fliebeljava.lang.Exception: Expecting var, but BufferedReader is mapped to class java.io.BufferedReader
10:34johnmn3missing the dot?
10:34hiredmanhttp://gist.github.com/107140
10:35johnmn3BufferedReader_._
10:36fliebeljohnmn3: hmm, you're right *ashamed*
10:36johnmn3fliebel: I just did that a few minutes ago
10:37johnmn3hiredman: so you've had that hanging around.. this is what I've been working on all day.
10:37hiredmanjohnmn3: no guarantee that it works or whatever, I haven't touched it in a while, and if I recall it was finicky
10:38johnmn3ok
10:40hiredmanwow, yeah, I recall tearing my hair out over treating jta's as a reader and a writer
10:41johnmn3I like that add-ctrl-enter-listener. I was going to add that too.
10:41johnmn3so you used an OutputStream instead of a PrintWriter
10:42hiredmanyeah, I went as low as possible, because there were fewer operations to support
10:43hiredmanand then it gets wrapped in an OutputStreamWriter and then a PrintWriter
10:45johnmn3I'm probably just going to use your code as a base.
10:45hiredmanby all means
10:48johnmn3npe.. I'll hack on it and try to find it.
10:52hiredmanhuh
10:52hiredmanyeah, it runs, but I could some kind of npe
10:53hiredmanoh, right, you have to select what you want to run, then hit C-<RET>
10:53johnmn3ah, you have to highlight the code to ctrl-enter. with nothing highlited...
10:53johnmn3right
10:55johnmn3I was thinking of doing some kind of tokenizer, to eval whatever expression is within the matching parens to the left of the caret.
10:55johnmn3like (+ (+ 1 2) 3)| <ctrl+enter> evals to 6
10:56cemerickI didn't check my clojure list inbox for a couple days, and then return to find a bunch of pissing-into-the-wind about eliminating parens.
10:56hiredmanright, not wanting to do that, I went for the easy fix
10:58benjiI'm a newby and don't understand why the highlighted line in http://pastebin.com/d24a97957 doesn't seem to have any effect.
10:59johnmn3what are the right terms I want to be using to find examples of doing that? clojure tokenizer ?
10:59the-kennybenji: map is *lazy*
10:59the-kennybenji: Wrap the map-thing in a (doall (map ...))
11:00hiredmanjohnmn3: I doubt you will find examples
11:00benji!!
11:00benjigotcha
11:00hiredmanbut I think you just need to count parens
11:00hiredman(basically)
11:00the-kennybenji: map applies the function when needed. If you do (take 3 (map ...)), it only creates the first 3 elements
11:01hiredmanthe-kenny: take is *lazy*
11:01benjithanks the-kenny; got it working
11:01the-kennyhiredman: Oh.. bad example ;)
11:01hiredman:P
11:03tolstoyIs there a way to get the (println ...) output of another thread to show up in the emacs / slime buffer?
11:03the-kennytolstoy: It shows up in the *inferior lisp* buffer
11:04tolstoythe-kenny: Yeah, I'm seeing that. Is that pretty much all we got?
11:04the-kennyhm.. I'm not sure if it's possible
11:07akingtolstoy: (add-hook 'slime-connected-hook 'slime-redirect-inferior-output)
11:08tolstoyaking: Cool, thanks!
11:10tolstoyExamining hiredman's hack to get setName working on PircBot....
11:36hiredmantolstoy: it's in contrib now, towards the end of java-utils
11:53the-kennyLooks like the docstring for c.c.math is broken - It ends with: "[...] the floor of the square root and the ".
11:55the-kennyhttp://richhickey.github.com/clojure-contrib/math-api.html
13:31johnmn3which do you think would be preferable for a text editor that can evaluate code when the caret is next to the expression... in front of the expression or behind the expression?
13:32johnmn3I was thinking behind, because you could write the expression, then immediately evaluate it, without having to move the caret back to the front of the expression.
13:32johnmn3or is there a better idiom all together.
13:32johnmn3?
13:33the-kennyjohnmn3: I think all three are possible in emacs.
13:33JonSmithi think emacs does 'evaluate last expression'
13:35johnmn3well, if we had (+ 2 3 )<caret>(- 2 3) and we hit the evaluate keys, which would get evaled?
13:36johnmn3I suppose shift+ctrl+enter could be the opposite of ctrl+enter
13:39johnmn3if evaluating to the right of the caret in the following expr: (let [a 3] <caret>(+ 1 a)) would emacs error with a being undefined?
13:40cark emacs evals top-level or after caret on same line or toplevel before caret on same line
13:41carkat least that's how i picture it
13:41carkso you're stuck at doing it all =D
13:42johnmn3also, if using paredit, if getting the caret to the right of the closing parens is a pain, people will rather eval from the opening parens
13:44scottjIs there something in contrib that will invert a tree (is there a better name for this?), like turn (a (b _ 1) 2) to (b (a _ 2) 1) ?
13:45johnmn3not sure what you mean by "or toplevel before the caret on the same line".. do you mean, wherever a caret is on a given line, it will scope from the outermost expression on that line and all subexpressions on the following lines that belong to that outer scope (which started on the line the caret was on)?
13:46johnmn3scottj: does the _ have to stay in the inner expr?
13:47scottjjohnmn3: yeah, but I'd be interested if there's a solution when it doesn't.
13:49carkjohnmn3 : you should install emacs with clojure-mode and make some tests
13:49carkit does the right thing
13:50johnmn3scottj: I don't know of something that automatically inverts a tree like that in contrib.. but you might be able to do it easily. depends on how you want to deal with unbalanced trees, I think.
13:51johnmn3cark: yea, I should.
13:52scottjjohnmn3: for the example I gave (3 elements in each list), can you give me a hint on how you'd solve it?
13:57johnmn3I'd split the list down the center. For cases where the list had an odd number of elements, I'd put the extra element on the right side I guess. I think it'd be more interesting with a list like this: (a (b (c d e) f g) (h I) (j k (l ( n (o p)))))
13:59johnmn3maybe tagging each element with a "nest-level" and then rebuild a list from left to right but flipping the nest-level for each element.
14:00johnmn3it looks like (o p) are the deepest level, at 5. So an inverted list might look more like (((((a) b) c d e (f ... etc.
14:02scottjcool, thanks for the ideas. One place this can be used is if you want to generate a bunch of unit conversion functions, but only define the relationship one way. For fahrenheit to celsius you'd write (/ (* (- % 32) 5) 9) then you could easily generate the inverse. I'm hoping to use this to define a few unit relationships and then generate a bunch of unit conversion functions that combine them.
14:03johnmn3hmm
14:04scottj(of course you also have to invert the operations)
14:04johnmn3that'd be cool.. I don't think my last example would be what you want then.
14:18lisppaste8johnmn3 pasted "get-expr" at http://paste.lisp.org/display/92397
14:19johnmn3theres my get-expr function... grabs expression from it's matching paren, starting from the paren on the right.
14:19johnmn3kinda ugly.. feel free to pretty it up.
14:21johnmn3also, it's not yet smart enough to detect ")(" or \( \)
14:25johnmn3It's a little naive.. will be hard to add that smartness to it without some kind of smarter parsing mechanism.. I thought I remember someone already wrote some kind of parsing library for clojure.
14:29johnmn3perhaps using a cond instead will allow for more flexibility and extension.
14:37radsif I'm adding something to a vector and I don't care about the order, does it matter if I use cons or conj?
14:38devlinsfrads: I think conj is more idiomatic
14:38JonSmithi thought cons returns a seq
14:39JonSmithyup
14:39JonSmith,(cons 1 [2 3 4 5])
14:39devlinsf,(class (cons :a [:b]))
14:39JonSmithhmm
14:39JonSmithno clojurebot :-(
14:39devlinsf,(class (conj [:b] :a))
14:39devlinsfAh!!!!
14:40devlinsfWell, I just ran mine at a REPL
14:40JonSmithapi says so, if you trust it
14:40devlinsfa cons returns a clojure.lang.Cons object
14:40devlinsfconj returned a clojure.lang.PersistentVector
14:41devlinsfIf you are expecting a vector back, you must use conj
15:37tolstoyFolks, how to you matchup clojure-contrib with any given branch of clojure? For instance, which clojure-contrib goes with clojure 1.1?
15:38devlinsftolstoy: We're working on freezing a branch w/ 1.1
15:38devlinsftolstoy: for now, use master
15:38tolstoyOkay.
15:39tolstoyGood enough for me. ;)
16:10johnmn3does anyone know how clojure's repl implements it's ability to not eval until a closing parens is matched to the opening one?
16:11johnmn3I'm reading the source for main/repl and I"m not seeing it.
16:16chouserjohnmn3: do you mean how pressing <enter> early still doesn't cause it to eval?
16:16johnmn3right
16:17johnmn3I'd think it counts parens, but it knows not to count escaped parens from strings or characters
16:17chouserthe 'read' function reads from a stream until it has read a whole form or eof
16:17chouserat the repl, the input stream blocks until you type something and press <enter>, so while it's blocked, so is 'read'
16:18chouser'eval' isn't called until after 'read' returns.
16:19johnmn3I want to implement the ability into a gui repl, where you can eval a form with a ctrl+enter..
16:20johnmn3so I'll need to feed-read a character stream from the caret of the JTextArea into read, and it'll know when to eval?
16:21johnmn3It'll just keep reading until EOF and spit out for extra characters like: java.lang.Exception: Unmatched delimiter: )
16:23johnmn3making get-expr to get a desired form, while accounting for all the escaped parens is proving difficult :)
16:25chouseryeah, I wouldn't try to parse it yourself. that's what 'read' is for.
16:27chouserWhat I did was feed 'read' a StringReader. If it threw an "EOF while reading" exception, I knew the input was incomplete. :-)
16:27AWizzArdHi guys, what‘s new? :)
16:27johnmn3but read can't tell me when a given function ends in the middle of a lot of functions in a JTextArea, can it?
16:28johnmn3AWizzArd: not much
16:28devlinsfjohnmn3: Use read-string
16:28devlinsfcombine and actionlistener on a JTextField & read-string
16:29johnmn3devlinsf: what do you mean?
16:30devlinsfWell, JTextArea fires a ActionEvent when you press enter
16:30devlinsfSo, I'd make my action listener list this
16:30devlinsf(read-string (. getText my-j-text-area))
16:31johnmn3yea, but I don't want to eval the whole document.. just the form next to the caret
16:31devlinsfOH
16:31devlinsf:(
16:32devlinsfI thought you were trying to use a command line input
16:33johnmn3I've got a function that counts parens (if open-paren (inc parens)) (if close-paren (dec parens), more or less, which works...
16:34AWizzArddoes the Master branch on github now include everything from the NEW branch?
16:34devlinsfAWizzArd: for core?
16:34johnmn3but I need to account for all the cases in which parens are loose or escaped, where the reader doesn't normally count them.
16:34AWizzArddevlinsf: yes
16:34devlinsfAWizzArd: No. In fact, this is the point of releasing 1.1
16:35johnmn3and I don't even know what all the cases are.
16:35devlinsfAWizzArd: most of new is going to wait for 1.2
16:35AWizzArdI used NEW in the past weeks, since the first checkins of deftype, but now see this 1.1.x and Master and New and don't know which is for me.
16:35devlinsfAWizzArd: new has the deftype stuff. 1.1 explicitly does not
16:36AWizzArdSo, is New still mostly a superset of 1.1.x and Master?
16:36devlinsfjohnmn3: You could split the body by lines, and add them one at a time
16:36devlinsfAWizzArd: Yeah, new is a superset
16:37AWizzArdk, thx
16:37johnmn3devlinsf: what do you mean?
16:38devlinsfjohnmn3: Assume the body of your document is split by #"[\r\n]"
16:38johnmn3separate toplevel functions by whitespace?
16:39devlinsfjohnmn3: Start taking lines one at a time
16:39devlinsfjohnmn3: Yeah
16:39devlinsfIt's ugly, but it might work
16:39johnmn3yea.. the programmer must adhere to that convention.
16:40johnmn3well, are there cases I'd need to account for other than ")" "(" /) and /( that' I'd need to drop from my counting?
16:41devlinsfWell, depends
16:41devlinsfThat might cover 99.9% of stuff
16:41johnmn3if there are few enough cases, I'll just hack out a gnarly cond until it works.
16:41devlinsfAre you willing to frustrate your user at .1%?
16:42johnmn3do defmacros allow for a an unbalance paren?
16:42devlinsfSometimes .1% wrong is acceptable
16:42johnmn3no, I wouldn't want it to be broken for even a small percent.
16:42devlinsfOkay. Spend some extra time test then
16:43devlinsfSounds like you've got a good direction to go now
16:43johnmn3yea.
16:44johnmn3are there any quoting things, ~ @ # ` ' or any others that clojure makes floating (un-paired) parens accepted?
16:45devlinsfNot that I'm aware of
16:46johnmn3testing the get-expr fn against all the fns in core would probably do the trick, eh?
16:46devlinsfThe reader treats ~ and company as a character
16:46devlinsfLook at clojure.lang.LispReader.java for more info
16:47johnmn3ok
17:03AWizzArdWhy is long producing an overflow without an exception, while incing a long might throw one?
17:03AWizzArd,(long 9223372036854775808)
17:04AWizzArd,(inc (long 9223372036854775807))
17:05qed,(unchecked-inc (long 9223372036854775807))
17:10AWizzArdalso interesting behaviour: starting from 64x the same digit, it produces funny outputs, for example -1 for (long 9999999999999999999999999999999999999999999999999999999999999999). But I can add some 9's and it will always stay -1.
17:10AWizzArdWhen I add in some different digits then the output will change
17:11LicenserAWizzArd: I'd guess it is because it's an cast which thinks 'the user will know what they do when forcing this to be a long)
17:14AWizzArdI just would not expect from testing (long 62*digit '5') that (long 64*digit '5') or (long 69*digit '5') will always produce 4099276460824344803.
17:17hiredmanping?
17:17johnmn3pong
17:18johnmn3hey, thanks for the help yall. later
17:19hiredmanAWizzArd: 9999999999999999999999999999999999999999999999999999999999999999 is a bigint with out the cast to long
17:19hiredmanso you get a different combination of ops from c.l.Numbers
17:19hiredmangrrr
17:21AWizzArdhiredman: ah, interesting, thanks for the info.
17:22hiredmanhuh
17:22hiredmanpeople don't waste anytime, clojurebot isn't even back in channel yet and it is already getting privmsg'ed stuff
17:23hiredmanping?
17:23hiredmanclojurebot: hello?
17:23clojurebotBUENOS DING DONG DIDDLY DIOS, fRaUline hiredman
17:23hiredmanclojurebot: ping
17:23clojurebotPONG!
17:25hiredman, (type 9999999999999999999999999999999999999999999999999999999999999999)
17:25clojurebotjava.lang.ExceptionInInitializerError
17:25hiredman:(
17:25hiredman,(type 9999999999999999999999999999999999999999999999999999999999999999)
17:25clojurebotjava.lang.ExceptionInInitializerError
17:25hiredmanhuh, worked at my repl
17:26qedworks here too
17:26hiredmanworks at clojurebot's repl
17:26hiredman,(type 9999999999999999999999999999999999999999999999999999)
17:26clojurebotjava.lang.ExceptionInInitializerError
17:26hiredman,(type 9999999999999999999999999999999999)
17:26clojurebotjava.lang.ExceptionInInitializerError
17:26hiredman,(type 9)
17:26clojurebotjava.lang.Integer
17:26qed,(type (bigint 9999999999999999999999999999999999999999999999999999999999999999))
17:26clojurebotjava.lang.ExceptionInInitializerError
17:26hiredmaninteresting
17:26hiredman~clojurebot
17:26clojurebotclojurebot has a lot of features
18:15AWizzArdIs there a hook for implementing my own printing behaviour (in the repl) for my deftypes?
18:18liebkeAWizzArd: you should be able to use print-method for that
18:19AWizzArdok, this is what i thought, but i was not sure if there is already another way for doing this
18:20liebkeI haven't heard of a new way, but here's an example of the print-method for Matrices in Incanter, https://gist.github.com/96a1b26706acd55ea0e2
18:51AWizzArdI remember I read something about a keyword-let or with-keywords thing. Is it already decided if this will go into Clojure?
19:01devlinsfHey, anybody here run OS X.6 ?
19:02the-kennydevlinsf: Me
19:02the-kenny10.6.2
19:02devlinsfthe-kenny: The bundled JVM works?
19:02the-kennydevlinsf: Yes
19:03the-kennyBut I think you can change the default jvm in some settings program, wait
19:03the-kennyJava SE 6 64 Bt is my default jvm.
19:04devlinsfOkay. I run 10.5 now, I'm probably gonna make the upgrade over the Holidays
19:05devlinsfthe-kenny: Thanks for answering my questions
19:05boyd /Applications/Utilities/Java Preferences but on snow leopard I think you only get Java SE 6
19:05the-kennyThe update is trivial. I had not a single problem
19:05the-kennyboyd: Yes, SE6 is the only available option, but there's one with 32 and one with 64 bit
19:06boydAgreed
19:06devlinsfgood to know
19:07the-kennycompilation of programs is a bit tricky because the gcc wants to create code for ppc, i386 and x86_64 by default.
19:41Luytdevlinsf: What I did: I just replaced the harddisk in my macmini and installed snowleopard on it. If it wouldn't work well, I could always swap my old HD in.
19:41Luytdevlinsf: I think installation on an external HD works as well, to try things out.
19:42devlinsfLuyt: I've got a macbook pro, so I can't do that :(
19:42LuytWell, an external HD then.
19:42devlinsfOh, external??
19:42devlinsfHmmm...
19:42LuytYes, you can perform an install of snowleopard on an external HD, and even boot from it too ;-)
19:45LuytBut I just decided to put an Intel X25 SSD into my macmini, put Snowleopard on it, then transfered over my important files from the old harddisk (which I hooked up with a SATA to USB kit)
19:52the-kennyYeah, I've done it a step more: I cloned my internal hd onto an external and upgraded sl on the external to check everything out
19:52the-kennyas everything was fine, I upgraded my internal hd after that :)
20:12tolstoyBefore I go and write something, is there a function that tells me if any member in a given list A is somewhere in list B?
20:12_ato,(some #{4} [1 2 3 3 4 5 6 6])
20:12clojurebot4
20:13_ato,(some #{42} [1 2 3 3 4 5 6 6])
20:13clojurebotnil
20:13tolstoy,(some '(a b) '(1 2 3 4 a c))
20:13clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
20:13_ato,(some #{'a 'b} '(1 2 3 4 a c))
20:13clojurebota
20:14_ato,(doc some)
20:14clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return true if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
20:14tolstoyIs there somewhere that groups related core functions rather than just presents them in a big list?
20:15_atohttp://clojure.org/sequences
20:15tolstoyAh, right!
20:15_atoalso: http://clojure.org/cheatsheet
20:15tolstoyI need to start book marking those subject pages. Thanks.
21:09ztellmanis there any way to pull javadoc strings off of a method at runtime?
21:10chouserI don't think there's any javadoc stored in the runtime
21:10chouserbut clojure.contrib.repl-utils has a 'javadoc' fn that will launch a browser pointing at whatever class you mane.
21:11ztellmanhmm, I was hoping it was saved with the reflection information
21:11ztellmanoh well
21:20interferonflatten seems to completely flatten a list, is there a way to simply flatten the highest level?
21:23chouser,(apply concat [[1 2 3] [4 5] [6 7 [8 9]]])
21:23clojurebot(1 2 3 4 5 6 7 [8 9])
21:24interferonmakes sense
21:24interferonthanks
21:31tolstoyerror: java.lang.IllegalStateException: repeat already refers to: #'clojure.core/repeat in namespace
21:31tolstoyHm. str-utils2 not playing nice with core?
21:34_atotolstoy: you're supposed to import str-utils2 with an alias. eg (:require [clojure.contrib.str-utils2 :as str])
21:34_atoand then to str/join or whatever
21:34tolstoyYeah, I did that, but it's not working. Maybe I've slimed on repl too many.
21:36KirinDaveDoes anyone know whats the mystic invocation to get leiningen to pull down the 1.1.0-RC1?
21:36tolstoySomething wrong with (ns (:use [clojure.contrib.str-utils2 :str str]))?
21:36tolstoyOops. I meant :as.
21:43tolstoyNope. Aliasing str-utils2 doesn't seem to work.
21:53chousertolstoy: add :only [] to your :use clause.
21:53dublindanI'm trying to redirect where the repl gets its input from, im trying to do something like this: (binding [*in* my-in] (clojure.main/repl))
21:53dublindanbut i cant seem to figure out how to implement my-in
21:53tolstoychouser: Thanks. I've relented and gone that route. Works! ;)
21:54dublindanI just want to be able to return a string, but proxying clojure.lang.LineNumberingPushbackReader makes me have to create Readers and such, which seems like a lot of work to simply return a string
21:56chouserdublindan: you want repl to read from a string?
21:56hiredman,(read-string "foo")
21:56clojurebotfoo
21:56hiredman?
21:57dublindanchouser: I want the repl to read its input from an external source, so i was trying to implement readLine and such to return the string read from elsewhere
21:58chouserdublindan: socket? file? string?
21:58hiredmanhttp://gist.github.com/107140
21:58dublindanchouser: a java.util.concurrent.LinkedBlockingQueue
21:59hiredmanread doesn't need neading a LNPBR
21:59dublindanhiredman: thanks, that looks like it might do what I want
22:01alexyksome cross-language fun: tried to see what a workflow would look like in Haskell. Now Haskell has no built-in maps. There's a module for it, and calls look like: M.insert x y m. So here scripting languages with built-in hashes really make it look better.
22:02KirinDaveMan, I love the way constantly reads.
22:02KirinDaveSeriously good name for a function.
22:03alexyk,(doc constantly)
22:03clojurebot"([x]); Returns a function that takes any number of arguments and returns x."
22:03KirinDaveIn hiredman's code:" :need-prompt (constantly false)"
22:03KirinDavegood stuff
22:04alexyk,(constantly [1 2 {:a 1}])
22:04clojurebot#<core$constantly__4953$fn__4955 clojure.core$constantly__4953$fn__4955@1c7510d>
22:04alexyk,(constantly 3 [1 2 {:a 1}])
22:04clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$constantly
22:04alexykah
22:04KirinDave(constantly true) and (constantly false) are popular.
22:05alexyk,(let [fc (constantly [1 2 {:a 1}])] (constantly 5))
22:05clojurebot#<core$constantly__4953$fn__4955 clojure.core$constantly__4953$fn__4955@13638d4>
22:05alexyk,(let [fc (constantly [1 2 {:a 1}])] (fc 5))
22:05clojurebot[1 2 {:a 1}]
22:05alexykthere
22:06alexykfrom the stupid dog tricks dept. :)
22:06alexykis (iterate inc 0) the shortest way to create infinite integer stream?
22:06alexykHaskell has [1..] or something.
22:10dublindanhiredman: thanks, that worked perfectly!
22:17AWizzArdIs there a foo for which (foo :my.namespace/kw) ==> ::kw ?
22:24JonSmithalexyk: a lot of the haskell material really helps to read to understand clojure stuff
22:25tomojAWizzArd: isn't ::kw just a shortcut for :my.namespace/kw ?
22:26alexykJonSmith: funny thing, I used OCaml for a while and looked at Haskell several times, but the lack of built-in maps makes them look paler for data mining. Hashtbl.insert or Map.insert ... is not flowing. But FP is pretty much the same.
22:26AWizzArdtomoj: there is a reader macro which transforms ::kw into :my.namespace/kw. I look for a function which goes the other way around.
22:26alexykstrangely sexps look nicer now. You don't have to ponder parenthesizing.
22:26alexykyou just do it.
22:27alexyk(just (do it))
22:27JonSmithyup
22:27JonSmithi've never gotten the argument against sexps
22:28JonSmithalthough
22:28JonSmith(if (you (do (it (alot)))))
22:28tomojAWizzArd: I guess..
22:28tomoj,(keyword (str ":" (name :my.namespace/foo)))
22:28clojurebot::foo
22:28tomoj?
22:29alexykthere should be a magic Closing Bracket. (you (do (it (a (lot} ; } closes all
22:30JonSmithi forget what that is called
22:30JonSmithone of the lisps had that
22:30alexykthe opening parens are usually clear. The closing chunk is an orgy of closing.
22:30JonSmithhyperparen or something
22:30alexykbtw a friend of mine can't understand why clojure needed to pollute lispiness with ugly []s
22:30JonSmithalthough, its not like you are going through trying to figure out how they match up :-)
22:30alexykhe's like, [wtf?]
22:30alexykJonSmith: I do! I blink them all
22:31AWizzArdtomoj: yes, this works. I just thought there may be something else already in it.
22:32alexykare []s for vectors, and thence fun params? why couldn't we do without them?
22:32JonSmithi think of clojure as a datastruture programming language rather than list processesing
22:32alexykwhy are they needed in let, for, doseq?
22:32alexykJonSmith: exactly
22:33alexykI dig []s for vectors, but why is fun params, doseq, let, not clear
22:33JonSmithi think its just for differentiation of binding forms
22:33alexykah
22:34JonSmithlike in CL you have (let ((var 1) (var 2)) (+ 1 2))
22:34AWizzArdGives your eyes more substance to perceive.
22:34JonSmithand that lets you differentiate the different variables with an extra set of parens
22:34JonSmithclojure just uses different brackets
22:34alexykAWizzArd: or more irregularity to stumble on
22:35AWizzArdif you think so, then don't use an editor with paren highlightning
22:35alexykAWizzArd: my editor is rlwrap
22:36AWizzArdyou can have small irregularity by writing programs via 0 and 1 :-)
22:36JonSmithit is a bit of a pain for certain macros (there is an extra step for binding forms), but otherwise I'm kind of neutral on it
22:37AWizzArdI did CL 6 years before I discovered Clojure. I prefer the Clojure style, using []s.
22:38AWizzArdalexyk: you can write your own let which will behave like CLs if you wish.
22:38tomojalexyk: why insist on rlwrap?
22:38AWizzArdn8
22:39alexykwell I enjoy Clojure, that's just what my friend asks :)
22:39alexyktomoj: simple for remote server
22:39tomojah
22:39tomojactually..
22:39tomojhow?
22:39tomojsounds more complicated to me
22:40alexyktomoj: works for now, my lein has rlwrap java ... in it. technomancy added it for me. :)
22:41tomojoh, but you're not editing files on the remote server?
22:41alexykrlwrap stores history locally, is searcheable, beats jline hands down.
22:41alexyktomoj: my TextMate has a command to send a selection to the term where the repl is.
22:42tomojyeah, but I think I've heard you here more than once complaining about the different ways that clojure is hard to write :)
22:42tolstoyalexyk: Oh, cool. Do you just start up a swank server and TextMate sends to it?
22:42alexykbut most often I do one-ling-liners in repl and paste them back locally if they're worth it. I don't use swank at all.
22:42tolstoyAh.
22:42alexykTextMate sends either the current line, or selection if present, to the tab of iTerm called "Clojure".
22:42tomojmeanwhile I have paredit in my repl, so.. not very sympathetic :P
22:43alexyktomoj: that's the part of clojure-mode for emacs?
22:43tomojno paredit is separate
22:43alexykis there a single .el I can drop into .emacs and be uber-clojure-emacs-geek?
22:44tomojI don't think so
22:44alexykor a couple... is there a fixed agreed upon clojure-mode?
22:44JonSmiththat's a good idea though
22:44JonSmiththere is clojure-mode and paredit
22:44JonSmithslime is nice too
22:44tomojand swank-clojure
22:44JonSmithyeah
22:44alexykis slime orthogonal to swank-clojure?
22:44JonSmithyou know, i don't think i even use slime with clojure
22:45liebkeI wrote about setting up emacs, slime, swank, and paredit today: http://incanter-blog.org/2009/12/20/getting-started/
22:45tomojI think package.el can install them all
22:45JonSmithyup
22:45tomojliebke: cool
22:46alexykliebke: you da man again!
22:47liebke:)
22:47tomojI think there are some tweaks to paredit needed
22:47alexykliebke: you bowed before the magesty of maven, too! :)
22:48liebkeah, I've resigned myself to it for Incanter, but I wouldn't recommend it to smaller projects. I just need Leiningen to work correctly on the Mac again
22:49alexykliebke: I think mvn is a safe bet, especially for cross-platform stuff with Java and (performant) Scala.
22:50alexykbut nothing prevents pom.xml and project.clj from coexisting
22:50liebketrue. and when talios has got polyglot support for clojure-based config files, I think it will be fine.
22:55alexykliebke: I'm surprised how well sexps work for data-mining. You can have a long one-liner which does a clearly defined job, and is well-bounded. OCaml or Haskell would have multi-liners, harder for repls and copy-pasting.
22:56alexykand built-in maps are the killer
22:56liebkeI agree, sexps are great on a repl, much better than any other syntax I'm familiar with
22:57alexykI'm pondering things like joins of maps on keys for graphing. That's a generalization of my typical EDAs. Combine one x with various y's.
22:57alexykWhen data is in Mongo, that joining can be done selectively quering the database.
22:58liebkevery cool, i'm hoping you'll write about your set up some time
23:00alexykliebke: yep, after the submission deadline for a paper is done with...
23:00liebkegreat