#clojure logs

2009-09-03

00:14technomancywill try in 1.1-snapshot; maybe it's been fixed
00:36hiredmanclojurebot: example?
00:37clojurebotapi examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
00:37hiredmanclojurebot: example is Short, Self Contained, Correct (Compilable), Example http://sscce.org/
00:37clojurebotHuh?
00:37hiredmanclojurebot: jerk
00:37clojurebotHuh?
00:38hiredmandamn it
00:47technomancystill broken with latest clojure master.
00:47technomancylooks like it only works with AOT'd functions
00:48technomancywill see if I can narrow it down to the a small repro case
00:49hiredmanclojurebot: foo is is Short, Self Contained, Correct (Compilable), Example http://sscce.org/
00:49clojurebotIn Ordnung
01:02technomancyOK, narrowed it down to a 4-line repro case: http://p.hagelb.org/bughunt.clj.html
01:08technomancyah... solved my problem by moving my functions zipmap into the backquoted part of the macro
01:18technomancysweet; it works.
01:18technomancysome nice syntactic sugar for defining processing apps: http://github.com/technomancy/clj-processing/blob/4e762d4c4e84e4e5b36d28655be591f4f067a05e/src/rosado/processing/applet.clj
01:19technomancy,processing
01:19clojurebotjava.lang.Exception: Unable to resolve symbol: processing in this context
01:19technomancy~processing
01:19clojurebotExcuse me?
01:20hiredmanclojurebot: processing is http://github.com/technomancy/clj-processing/blob/4e762d4c4e84e4e5b36d28655be591f4f067a05e/src/rosado/processing/applet.clj
01:20clojurebot'Sea, mhuise.
01:22technomancythere's a better URL; hang on
01:22technomancyclojurebot: processing is http://github.com/rosado/clj-processing/
01:22clojurebotAck. Ack.
01:23technomancyclojurebot: processing is a language/toolkit for visualizations. See the Clojure wrapper at http://github.com/rosado/clj-processing/
01:23clojurebotIk begrijp
01:23technomancyg'night folks
03:54poethaving the same problem as here: http://paste.lisp.org/display/77765 any ideas for a solution?
03:56jdzwhat the hell is swank-clojure-config?
03:57poetsays to do that here http://riddell.us/tutorial/slime_swank/slime_swank.html
03:57poetI tried setting the variable by itself and that didnt work either
03:58hiredman~emacs
03:58clojurebotemacs is best configured for Clojure with instructions at http://technomancy.us/126
03:59poetnice, Ill take a look
03:59hiredmanI don't use emacs, but that seems to be the tutorial to follow
04:09AWizzArdIs there a mechanism in the jvm or Clojure for autodetecting file encodings?
04:11jdzno, but there is a library that attempts to do it
04:12jdzcpdetector.jar
04:12AWizzArdthx
04:12jdznot perfectly reliable, though
04:12subhadeephi everyone
04:13subhadeepi'm trying out clojure box
04:13subhadeepbut in emacs swing isnt working
04:13subhadeepslime hangs
04:13jdzosx, right?
04:14subhadeepwindows
04:14subhadeepxp
04:15AWizzArdsubhadeep: go into the inferior-lisp buffer
04:15AWizzArdthere press a few times enter
04:15AWizzArdthen swing will not hang anymore in emacs
04:15subhadeepuh oh
04:16AWizzArdthe first time when you want to show a swing component you need to press a few times enter in the inferior repl :-)
04:17subhadeepumm
04:17subhadeepdoesnt help
04:17subhadeep:(
04:17subhadeep(. javax.swing.JOptionPane (showMessageDialog nil "Hello World"))
04:17subhadeepi tried this
04:17subhadeepits stuck
04:18AWizzArdBut when you start a Clojure repl from a shell, then it works.
04:19subhadeepyes
04:19subhadeepinfact from emacs
04:19subhadeepif i open a windows shell
04:19subhadeepand try it out it works
04:28eevar2encoding-detection is broken by design. just hardcode anything to utf-8 ;)
04:29hiredman:)
04:34AWizzArdeevar2: yeah, I would love to do that. Unfortunately others don't know about it
04:35AWizzArdclojurebot: paste
04:35clojurebotlisppaste8, url
04:35lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
04:38lisppaste8AWizzArd pasted "Easier way to append to a file with specific encoding?" at http://paste.lisp.org/display/86490
04:38AWizzArdusing contribs duck-streams
04:54liwpsubhadeep: that works fine for me once I switch to the *inferior-lisp* buffer and hit enter once
04:55liwp(javax.swing.JOptionPane/showMessageDialog nil "Hello World") is slightly better style IMO
05:00subhadeepok liwp
05:00subhadeeplemme try
05:03subhadeepit works this time
05:03subhadeepthanks
05:03subhadeephmm
05:03subhadeepbut do i have to get to inferior-list buffer everytime i try swing?
05:03Chousukeshouldn't you run swing UI code in the swing thread?
05:04subhadeepuh oh
05:05Chousukeat least if you want to create or change UI elements from the repl thread
05:05Chousukeit's not very difficult, though.
05:05subhadeepinvokelater
05:05Chousukejust (SwingUtilities/invokeLater #(your code here))
05:05Chousukeor you can make a macro for that and do (swing your code here) :P
05:08Chousukehttp://www.j2ee.me/products/jfc/tsc/articles/threads/threads1.html for more info
05:11subhadeepbut without inferior-lisp buffer
05:11subhadeepi couldnt get the swing code running
05:12subhadeepthough
05:12subhadeeplearning emacs and clojure with clojure box :)
05:12LauJensensubhadeep: Youre only concern in regards to a seperate swing thread, is how you get messages?
05:12subhadeepno
05:13subhadeepin emacs
05:13ChousukeI had no problem running swing code from slime.
05:13Chousukebut I used my swing macros to run it.
05:13subhadeepi try (. javax.swing.JOptionPane (showMessageDialog nil "Hello World"))
05:13subhadeepand it gets stuck like that
05:13LauJensenChousuke: You must have noticed that certain methods fail silently ?
05:13subhadeepuntil i try the inferior-lisp buffer
05:13ChousukeLauJensen: hm, not really.
05:13LauJensenoh... I get that hassle constantly
05:14subhadeephttp://groups.google.com/group/clojure/browse_thread/thread/6c195c35ae9a7eb8
05:14subhadeephas the issue documented
05:14LauJensenFor instance an onAction event for a swing component, will fail 100% silently
05:14subhadeepbut didnt get a convincing solution
05:15ChousukeLauJensen: I got exceptions in the *inferior-lisp* buffer
05:15LauJenseneh?
05:15Chousukewhen some swing-action failed that is
05:16LauJensenI dont see how thats possible
05:18Chousukewell I don't know what it did, but the exception backtraces get printed *somewhere*
05:18Chousukeand I just tested. (javax.swing.SwingUtilities/invokeLater #(. javax.swing.JOptionPane (showMessageDialog nil "Hello World"))) works perfectly from the slime repl
05:20subhadeepit didnt work for me though
05:20subhadeepuntil as i said inferior-lisp came to the rescue
05:20Chousukehm :/
05:20Chousukesomething's wrong with your java then.
05:21subhadeepumm i dont think so
05:21subhadeepits either winblows
05:21subhadeepor emacs config
05:21Chousukemight be. I'm on OS X.
05:21liwpIt seems to me that you have to hit enter once in the *inferior-lisp* buffer and after that subsequent Swing calls work fine. That is, after hitting enter in the lisp buffer I can now bring up the dialog as many times as I want without any problems. So if you have a really long running Emacs process and slime session it's not a big deal.
05:21clojurebot"if you never learnt Lisp, then you never learned to program" -- some rant on some blog somewhere
05:21subhadeepmany other faced the same problem without any viable solution as ma google says
05:21subhadeepyes liwp
05:22subhadeepafter inferior-lisp
05:22subhadeepswing works fine in slime
05:22Chousukeweird.
05:22LauJensenChousuke: I'm on LInux and I have the same behaviour as subhadeep
05:22liwpI've seen the issue on OS X as well (at home). I'm at work on Windows at the moment.
05:22subhadeepthanks for the help liwp and AWizzArd
05:22subhadeeptold ya :)
05:23Chousukehm
05:23Chousukewell, it might be your emacs config then
05:23LauJensenIts flawless
05:23Chousukemine is quite customised :P
05:23subhadeep:)
05:24subhadeepi will try out in solaris once i get back home
05:24subhadeepi started with clojure yesterday night when i was reading this debate on scala vs clojure
05:24subhadeepas to who will hold the jvm fort
05:25subhadeepthought of learning LISP for a long time so finally i gave it a try
05:25subhadeep:)
05:25liwpblah, I'm getting really tired of the whole scala vs. clojure thing.
05:25ChousukeI never got comfortable with common lisp
05:25Chousukebut Clojure is great.
05:26subhadeepyes JRuby too ;)
05:26LauJensenliwp: funny, it doesnt bother me one bit
05:26liwpChousuke: yeah me neither. I read through Practical CL but I didn't do anything else with CL after that. I also did some scheme, but that didn't stick either.
05:27liwpLauJensen: I just don't get it why there's suddenly this big need to compare the two. The only thing they have in common is that they run on the JVM
05:27ChousukeI wonder why Clojure is being compared to scala so much
05:27ChousukeWhere's Groovy?
05:27liwpChousuke: exactly
05:28LauJensenliwp: Havent you noticed that language wars have been going on since masm and tasm? :)
05:28liwpLauJensen: sure :)
05:28subhadeepscala has some big follwoing among the web2.0 darlings like twitter
05:28AWizzArdHow can I get a MapEntry from a map?
05:28Chousukewhat kind of a map?
05:29Chousukehmm
05:29LauJensen,(map class {:foo 1 :bar 2})
05:29clojurebot(clojure.lang.MapEntry clojure.lang.MapEntry)
05:29AWizzArd,(map identity {:a 1, :b 2, :c 3})
05:29clojurebot([:a 1] [:b 2] [:c 3])
05:29Chousukeoh, heh.
05:29AWizzArdthese things that print like vectors, but those are MapEntry's
05:29subhadeephmm
05:29AWizzArd,(.getEntry {:a 1} 1)
05:29clojurebotjava.lang.IllegalArgumentException: No matching method found: getEntry for class clojure.lang.PersistentArrayMap
05:30hiredmanthey are vectors
05:30AWizzArd,(.getEntry {:a 1} :a)
05:30clojurebotjava.lang.IllegalArgumentException: No matching method found: getEntry for class clojure.lang.PersistentArrayMap
05:30AWizzArd,(map (comp identity) {:a 1, :b 2, :c 3})
05:30clojurebot([:a 1] [:b 2] [:c 3])
05:30AWizzArd,(map (comp class identity) {:a 1, :b 2, :c 3})
05:30clojurebot(clojure.lang.MapEntry clojure.lang.MapEntry clojure.lang.MapEntry)
05:30AWizzArdno
05:30AWizzArdthey are not vectors
05:30hiredman,(ancestors clojure.lang.MapEntry)
05:30clojurebot#{java.lang.Iterable java.util.concurrent.Callable clojure.lang.IFn clojure.lang.IPersistentVector java.util.Collection java.util.Map$Entry java.lang.Runnable clojure.lang.Seqable clojure.lang.AMapEntry clojure.lang.Streamable java.util.RandomAccess java.util.List clojure.lang.Indexed clojure.lang.IMeta java.lang.Object clojure.lang.Counted clojure.lang.Associative clojure.lang.APersistentVector clojure.lang.IObj clojure.
05:30AWizzArdjust print like them
05:30hiredman^-
05:30hiredmanThey Are Vectors
05:30subhadeep(+ 1 2 3)
05:30clojurebot*suffusion of yellow*
05:30subhadeep:)
05:30hiredman~scala
05:30clojurebotScala often gets in the way when trying to write neat code -- seen in #scala
05:31AWizzArdhiredman: ah okay, in the oop sense
05:31AWizzArdhiredman: how can I get such an entry when I have a key?
05:31AWizzArdthere is a function for that, I just don't remember it :-)
05:31ChousukeI guess Clojure gets compared to scala because scala also advertises itself as a functional language. at least AFAIK
05:31hiredman~def java.util.Map
05:32eevar2and because they both run on the JVM
05:32subhadeep~ruby
05:32clojurebotChunky bacon!
05:32subhadeephehe
05:32hiredmanoh
05:32AWizzArdah :)
05:32hiredman~jdoc java.util.Map
05:32ChousukeI haven't studied Scala in depth because every snippet of scala code I have seen roused an irresistible urge to flee.
05:32subhadeep~jruby
05:32clojurebotNo entiendo
05:33subhadeepwokay
05:33LauJensenI saw a thread recently which had the topic of "how to convert language x people to clojure" - I dont understand this mentality. I will not convert and I will not make an attempt at discussion, simply because Clojure is superior and I dont want to share the power.
05:33subhadeepwholly new syntax for me
05:33subhadeepcoming from java/c++/ruby world
05:33subhadeepbut its fun
05:34Chousukethere isn't much to learn anyway
05:34subhadeepumm
05:34subhadeepwhy ?
05:34hiredman~literal [3] scala
05:34clojurebot<reply>{((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)}
05:34ChousukeIf you mean clojure syntax, there's (), [], {}, and the reader macros (which are optional)
05:34Chousukeand some special forms.
05:35subhadeepyes :)
05:35Chousukehiredman: I still can't figure out wth that is supposed to be.
05:36subhadeepparentheses everywhere
05:36hiredmanit's cons as λ
05:36subhadeep~scala
05:36clojurebot{((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)}
05:36Chousukeaha.
05:36hiredmanit returns 1
05:36hiredman(x: Any, y: Any) => x is like car
05:37hiredman(took me a while mucking around with scalabot)
05:37Chousukeright.
05:38ChousukeI can't remember the lisp definitions of cons either though.
05:38Chousukeand I can't read that well enough to see what it is.
05:39hiredman,(((fn [a b] (fn [f] (f a b))) 1 2) (fn [a b] a))
05:39clojurebot1
05:40liwphiredman: so there's a lambda which takes x and y as args and returns another lambda. The second lambda takes f as an arg and applies f to x and y. And finally we pass in (1, 2) to the first lambda and then the ((x, y) => x) lambda to the second lambda. Something like that?
05:40hiredmansure
05:40liwpyeah, that seems more familiar :)
05:40Chousukeah, right.
05:41liwpto be fair to scala, the clojure version is a mess as well if you don't know clojure
05:41Chousukethere's less noise though.
05:41liwpagreed
05:41liwpless syntax => less noise ;)
05:42Chousukethat doesn't always hold though.
05:42Chousukeclojure has more syntax than common lisp, but I think it has less noise :)
05:42sgtarrwhat do you guys think about Scala?
05:42Chousukemostly because of [] and {}
05:43ChousukeI also think the literal vector and map syntax also makes writing more expressive macros easier.
05:43Chousukesince you have two more syntax elements to work with.
05:43Chousukeor actually three since #{} is a literal set :P
05:44Chousukebut I haven't seen that in macros.
05:45liwpChousuke: that is true, [] and {} do help. Also fewer parens in bindings and cond etc. help as well
05:48liwpsgtarr: I've looked at a little scala code in the past, mostly Lift and actors examples. Nothing wrong with it an it's a big step up from Java. I just think that Haskell and OCaml (even F#) are more interesting as strongly typed functional languages. Also, my understanding is that people are writing more OOP like code than FP like code in it, but I might be wrong.
05:49liwpSo to me, at least for the time being, it's not very interesting
05:49Chousukeone thing that [] allows nicely is user code inside macros. you can have your macro syntax centered around vectors, and evaluate lists normally as user code. I think one of the html libraries does just this.
05:50liwpChousuke: do you have an example handy?
05:52sgtarrliwp: seems like it is useful as a stepping stone for people not willing to dive into FP in every scenario, but rather work on it
05:52ChousukeI guess something like [:html [:body (generate-list "foo" "bar" "zonk")]] where generate-lists produces [:ul [:li "foo"] [:li "bar"] [:li "zonk"]] would be possible
05:52Chousukeif you had only lists available, it would be slightly more cumbersome to accomplish this.
05:52Chousukethough I suppose you could use quasiquote :)
05:54LauJensenWhat a fantastic idea to let ISPs decide the Whois format themselves. "COUNTRY:\tSE" "country: uk" "Country:\tUS" etc... :)
05:55eevar2i'm also shooting for haskell as my non-lisp FP language. moere new & interesting concepts than scala, and as it's just for playing around anyway..
05:56hiredman~haskell
05:56clojurebotYo dawg, I heard you like Haskell, so I put a lazy thunk inside a lazy thunk so you don't have to compute while you compute.
05:58Chousukethat should say: you don't have to compute while you don't compute
06:00LauJensenso fix it
06:00LauJensen:)
06:01Chousukenah, I'm lazy as well.
06:08liwpChousuke: oh, that's what you meant with macro syntax. I thought you might mean that it would be easier to implement (rather than call) the macro if the call used vectors for somethings and lists for others. It sounded like a real pain to me if you would have to check the types of args in the macro definition. It all makes sense now
06:11Chousukeit's also possible to have the macro expect just seqs of course.
06:12Chousuke,(letfn [[foo [x] x]] (letfn [(bar [x] x)] [(foo 2) (bar 3)])
06:12clojurebotEOF while reading
06:12Chousuke,(letfn [[foo [x] x]] (letfn [(bar [x] x)] [(foo 2) (bar 3)]))
06:12clojurebot[2 3]
06:13Chousukehmm
06:30djpowellhas rich mentioned anything about what his rdfm project is for? Is it for working with rdf, or is it designed as a way to serialize clojure datastores to a persistent store?
06:30LauJensen~rdfm
06:30clojurebotTitim gan éirí ort.
06:30LauJensendjpowell: Sorry, no idea
06:52djpowellrhickey: what is the purpose of the rdfm project you've been working on? To work with RDF? To be a general purpose way to store clojure datastructures?
07:20ambientbtw is there any natural language processing library for clojure in existance?
07:20ambienti guess it would have to work through java interop...
07:22ambientor perhaps i should make a dent in my budget and finally buy peter norvig's book, iirc it has some stuff about that stuff
07:25triyoI am trying to call clojure/xml.parse with InputStream and my own Parser, like so (parse (.openStream *url*) myparser) but it throws IllegalArgumentException saying parse method not found. If I pass a string as path to file instead of InputStream it works 100%. my *url* is a java.net.URL and it has of course the getOpenStream which returns InputStream.
07:26triyo*getOpenStream = openStream
07:28liwptriyo: what happens if you do (parse (.openStream *url*))?
07:28liwpbtw. the function is clojure.xml/parse not clojure/xml.parse
07:29triyoliwp: works fine...so is that a bug in the binding part of the clojure/xml.parse function or am I missing something?
07:30liwpbased on the exception message is sounds like you're trying to call parse as a method on the InputStream
07:30liwpso (parse (.openStream *url*)) works but (parse (.openStream *url*) myparser) does not work?
07:31triyothanks about ...xml/parse
07:32liwptriyo: I just meant that the function is parse and it's in the clojure.xml namespace, so if you're calling (clojure/xml.parse ...) you're doing it wrong
07:32liwpdid that help then?
07:32liwpor is it still broken?
07:32triyoand yes, parse (.openStream *url*)) works but (parse (.openStream *url*) myparser) does not
07:33liwphmm
07:33liwp,(doc clojure.xml/parse)
07:33clojurebot"([s] [s startparse]); Parses and loads the source s, which can be a File, InputStream or String naming a URI. Returns a tree of the xml/element struct-map, which has the keys :tag, :attrs, and :content. and accessor fns tag, attrs, and content. Other parsers can be supplied by passing startparse, a fn taking a source and a ContentHandler and returning a parser"
07:33liwpso what's myparse then?
07:33Fossiwhy in hell is a regex a special datatype?
07:34triyothe way I see it, I call clojure.xml/parse with 2 parameters, 1st: InputStream and 2nd: the parsers to use
07:35liwptriyo: well based on the doc string the second arg is a fn that returns a parser
07:35triyo(parse "/path/to/local/file" myparser) works
07:36liwpso it would seem that myparser is fine
07:36liwpsorry, I don't have any more ideas - I'm going for lunch now
07:36Fossiok, they are a reader macro. that's a little more sane
07:37triyoI have (:use clojure.xml) :)
07:38triyothen call parse function
07:42triyoclojure.xml/parse says arg list options are as follows: ([s] [s startparse]) ... I am using the second of the two and the doc string says that 's' can be a string, File or InputStream
08:04AWizzArd~seen kotarak
08:04clojurebotkotarak was last seen quiting IRC, 5534 minutes ago
08:04AWizzArd,(/ 5534 60.0)
08:04clojurebot92.23333333333333
08:04AWizzArd,(/ *1 24)
08:04clojurebotjava.lang.IllegalStateException: Var clojure.core/*1 is unbound.
08:05AWizzArd,(/ 92.2333333 24)
08:05clojurebot3.8430555541666664
08:21bpattiso1BUILD FAILED
08:21bpattiso1/home/bpattison/opt/fnparse/clojure-build.xml:86: Could not find clojure.lang.Compile. Make sure you have it in your classpath
08:22bpattiso1^^^ i'm getting the above from ant
08:23bpattiso1any ideas? i've set the CLASSPATH to clojure .jar files but still get same error
08:24Chousersetting the CLASSPATH env var often has no effect since it's overridden by the command line
08:25bpattiso1so there's an "ant" option to set the classpath -- unfortunately i'm not that familiar with ant
08:29Chouserme either. you might check the .xml file to see if in mentions a setting for the classpath.
08:29Chouserlike I know the contrib .xml file has you set -Dclojure.jar=... on the ant command line.
08:30bpattiso1i'll try that -- thanks
08:53bpattiso1Chouser: a variation of the -D option worked! thanks
08:58Chouserbpattiso1: great.
09:19lisppaste8raphinou pasted "looking for feedback on this code" at http://paste.lisp.org/display/86499
09:20raphinouI just pasted working code, but as I'm new to lisp like languages, I'm looking for feedback on how to improve it
09:20raphinouif someone has too much time... ;-)
09:24Chouserlooks fine to me, for whatever that's worth.
09:25Chouserthe use of closures seems good
09:25Chouseryou could clean up the formatting a little. *shrug*
09:25Chousukeraphinou: Great work not using . directly! What's with the extra spaces though?
09:26raphinouyes, I should take a better habit of formatting from the start....
09:27AWizzArdIs there somewhere a good explanation of what ensure is doing? Good in the sense that it is targeted at idiots :)
09:27ChouserAWizzArd: what it does, or what it's for?
09:27AWizzArdsecond
09:28AWizzArdWhen should I use it?
09:28ChouserAWizzArd: you searched the google group? It's come up a couple times.
09:28AWizzArdI did that in the past, and at that time there were not too many entries. I can try it again now.
09:28AWizzArdI just had a dosync which won't work without ensure.
09:29Chouseryou only need ensure when the behavior of your transaction depends on the value of a ref that you do not set.
09:29Chouserthat you do not set within the transaction.
09:30AWizzArdWhen I read a value V in my transaction and depend on it, but without modifying V itself?
09:30Chousukeyeah.
09:30Chousera ref V, yeah
09:30AWizzArdok, then I will see where I had this case
09:31AWizzArdIt must have been at least one path
09:47AWizzArd,(+ nil)
09:47clojurebotnil
09:49AWizzArdhmm, why is it good that (+ nil) ==> nil?
09:50Chouserbecause (+ anything) is anything
09:50Chouser,(+ nil 5)
09:50clojurebotjava.lang.NullPointerException
09:50AWizzArdIt is fine that:
09:50AWizzArd,(+)
09:50clojurebot0
09:50AWizzArdbut (+ nil) I find strange
09:51AWizzArd,(+ "test")
09:51clojurebotjava.lang.ClassCastException
09:52Chouserok, a related question: why does it matter at all what (+ nil) does?
09:52AWizzArdSomeone asked me today for a simple example that would produce a NPC. I wanted to show him, but...
09:53Chousercall any method on nil
09:53AWizzArd(.append nil)
09:53AWizzArd,(.append nil)
09:53clojurebotjava.lang.NullPointerException
09:53AWizzArd,(.append nil "world)
09:53clojurebotEOF while reading string
09:53AWizzArd,(count nil)
09:53clojurebot0
09:53Chouser,(.i-just-made-this-up nil)
09:53clojurebotjava.lang.NullPointerException
09:54Chouseror call nil itself
09:54Chouser,((identity nil))
09:54AWizzArd,(nil)
09:54clojurebotjava.lang.IllegalArgumentException: Can't call nil
09:54clojurebotjava.lang.NullPointerException
09:54AWizzArdNow I also find it strange and incorrect that (count nil) ==> 0
09:55Chouserwell, if the Compiler can tell it's nil it won't even compile it.
09:55AWizzArdIn CL it makes sense, because nil is the empty list.
09:55ChouserI don't understand why you would want things to generate more errors than necessary.
09:56AWizzArderror detection
09:56AWizzArd,(count (get {:a []} :a)
09:56clojurebotEOF while reading
09:56AWizzArd,(count (get {:a []} :a))
09:56clojurebot0
09:57AWizzArd,(count (get {:a []} :x))
09:57jdz"nothing" has exactly zero elements in it, right?
09:57clojurebot0
09:57AWizzArdjdz: this is also true for 15
09:57AWizzArd,(count 15)
09:57clojurebotjava.lang.UnsupportedOperationException: count not supported on this type: Integer
09:57AWizzArdA 15 contains no elements
09:58Chouser,(map count (take 5 (iterate next [1 2 3 4])))
09:58clojurebot(4 3 2 1 0)
09:58jdzyes, nil is "nothing", so it does not make sens to do any operations on it except testing whether something is nil...
09:59AWizzArdright
09:59jdzChouser: why next?
10:00jdznil is not a sequence
10:00jdzso it makes sense for count not to work on it
10:00AWizzArdI would agree with that right now.
10:00Chouser,(conj nil 5)
10:00clojurebot(5)
10:01jdz,(map count (take 5 (iterate rest [1 2 3 4])))
10:01clojurebot(4 3 2 1 0)
10:01Chouser,(cons :foo nil)
10:01clojurebot(:foo)
10:01jdzthat conj call also is a stretch
10:02jdzcons, otoh, is perfectly normal
10:02AWizzArd,(cons :foo (get {} :x))
10:02clojurebot(:foo)
10:02AWizzArd,(cons :foo (get {:x (list :xyz} :x))
10:02clojurebotUnmatched delimiter: }
10:02AWizzArd,(cons :foo (get {:x (list :xyz)} :x))
10:02clojurebot(:foo :xyz)
10:02Chouserwhen things have reasonable default behavior instead of erroring out, there are fewer special cases that have to be handled with extra pieces of explicit code
10:02AWizzArdand more holes for type errors
10:03Fossipff, who writes code with type errors anyway? ;)
10:03AWizzArdHumas ;)
10:03AWizzArdHumans
10:04RaynesAndroids.
10:04ChouserIf you had to explicitly handle nil in a bunch of cases, you'd have just as many holes as now.
10:05Chouserand you'd have to handle them in all cases instead of just the cases where the current default isn't what you want.
10:05Chousercurrent behavior
10:05AWizzArdwhy is
10:05AWizzArd,(+ 5 nil)
10:05clojurebotjava.lang.NullPointerException
10:05AWizzArdgood then?
10:05ChouserAWizzArd: what would be the reasonable default there?
10:06jdzrule of thumb: nil is treated as an empty sequence if given to functions expecting sequences.
10:06FossiIllegalArgument :)
10:07Chouserjdz: right. and returned by a subset of functions that return sequences
10:12triyoChouser: I came across this old post http://markmail.org:80/message/2e7i72y4cg36wqdx and I got it to work as you sescribed it (xml.clj was updated with your change I can see) ... I am struggling to get the parse to work with that tagsoup parser when using s as InputStream instead of string. I get a IllegalArgumentException on tagsoup's parse method.
10:13triyo*sescribed = describe
10:16triyo(parse "/path/to/my/file" startparse-tagsoup) works 100% but (parse (.openStream *url*) startparse-tagsoup) fails with IllegalArgumentException on parse method. I see TagSoup has overloaded version of parse method that allows InputStream so I can't seem to see whats causing the problem.
10:19Chouserhm...
10:21Chouserthat really is an old post. I had been using Clojure for about 3 weeks at that point...
10:23triyohehe, like me now, :)
10:25AWizzArdI have many threads generate data and want to write it into a file. Is there already something like a Queued writer that will take a string to write and an index which tells in what order to write, and which will write as soon the queued write jobs allow that (because of their order)?
10:25triyoI am just so puzzled with this as I see org.ccil.cowan.tagsoup.Parser has a parse(InputStream) method and I know java.net.URL's openStream method returns a InputStream and thats what I pass as s param of startparse-tagsoup function
10:26Chousertriyo: note that tagsoup takes a org.xml.sax.InputSource
10:26Chouserthat's what you're passing in?
10:26Chouseroh
10:27Chouserright. URL is returning you a java.io.InputStream. Different class
10:28Chousertriyo: note InputSource vs. InputStream
10:29Chouserfortunately InputSource has a ctor that takes an InputStream
10:29triyoI ran (show parser-instance) and confirmed that parse(InputStream) exists on org.ccil.cowan.tagsoup.Parser
10:29Chouser(parse (org.xml.sax.InputSource. (.openStream *url*)) startparse-tagsoup)
10:31Chousertriyo: I see InputSource and String overloads, nothing else. What version of tagsoup?
10:31ChouserI'm looking at 1.2
10:49inverselimitnewbie q: are there LAPACK bindings for clojure?
10:55Chouserinverselimit: never heard of it, but you might be able to use http://icl.cs.utk.edu/f2j/
11:20icylisperany way to destructure-bind like (def [a b] (values a b)) , without using let ?
11:21ChouserI don't think so.
11:21stuartsierraNo, you'd need a wacky macro to do that.
11:22icylisperChouser: perhaps a macro destruct (destruct [a b] (values a b))
11:22icylisperyeah
11:22icylispersomething like cl's m-v-b
11:23Chousersure, destructuring in general is used in places where one might use m-v-b in CL
11:23Chouserbut def doesn't destructure. I suppose it could, though.
11:24stuartsierradef is complicated enough, I think
11:24Chouserdef isn't even a macro :-)
11:24icylisperChouser: true. it would be cool if it did :)
11:45Fossiit isn't really obvious that binding does not have the let* property of binding in the same order
11:46stuartsierrathis has been brought up before
11:46Fossicaused some headscratching here for a while
11:47Fossii get why, but i guess there could be a hint about it in the api docs
11:47stuartsierrayes
11:48rhickey_patch welcome for doc
11:49stuartsierrahttp://www.assembla.com/spaces/clojure/tickets/152
11:49stuartsierrai'll write a patch
11:56stuartsierrapatch attached to #152
12:01lisppaste8drewr pasted "json-object-seq" at http://paste.lisp.org/display/86503
12:02drewrstuartsierra: think there's a place for j-o-s in c.c.json.read?
12:02drewrmaybe just json-seq?
12:02drewrI'm serializing a bunch of objects to files and need to read them in lazily
12:03stuartsierraI can see where that would be useful.
12:03stuartsierraHow do you make sure the file gets closed?
12:03drewrah, good question
12:03rhickey_stuartsierra: fyi - I'm working on Clojure data structure serialization to/from RDF stores
12:04drewrstuartsierra: have to wrap in a with-open by hand I guess
12:04stuartsierrarhickey_: Awesome! Tell me more.
12:05rhickey_Basically you can save #^{:foo :foo} {:a 1 :b 2 :c #{3 4 5} :d [6 7 {:g 8}]}, in a single shot, and read it back also with a single call
12:05lisppaste8drewr annotated #86503 "caller needs with-open" at http://paste.lisp.org/display/86503#1
12:06rhickey_everything gets flattened to triples, so you can query etc
12:06rhickey_does automatic creation of bnodes for "owned" nested elements, or you can have external refs via URIs
12:06rhickey_does multimap-style handling of sets as values
12:07stuartsierrarhickey_: Very, very interesting.
12:07rhickey_can store keywords as values and use as properties
12:07stuartsierraWhat do you mean by multimap-style?
12:07rhickey_handles all the atomic types as values
12:08rhickey_{:a #{1 2 3}} for some uri xxx will yield triples xxx :a 1, xxx :a 2, xxx :a 3, rather than an RDF collection as the value
12:08stuartsierraThat's good.
12:09rhickey_there will be an rdfm/assoc* which does that set-aware association
12:09stuartsierraHow do you map between Clojure keywords and RDF predicates?
12:10rhickey_basically you can spit a relatively arbitrary structure into the triple store, but later use rdfm/assoc/assoc*/dissoc/dissoc* inside RDF transaction and get both the new value and the necessary triples stored
12:10lisppaste8stuartsierra annotated #86503 "Simpler" at http://paste.lisp.org/display/86503#2
12:11rhickey_http://org.clojure/keywords/your-ns/your-key
12:11drewrstuartsierra: nice
12:11rhickey_you can use strings as keys too, will be presumed a valid URI
12:12stuartsierrarhickey_: Ok. So I could (def dctitle "http://purl.org/dcterms/title&quot;)
12:12rhickey_stuartsierra: yes, np, I looked at what you were doing putting URI strings into vars and look to support it
12:12rhickey_you can mix and match
12:13stuartsierraCool. Having a 1-to-1 mapping between Clojure data structures and RDF would make my day/month/year, I think.
12:13rhickey_vectors become collections with rdf:_nnn properties
12:13stuartsierraok
12:13stuartsierraLists are rdf:List, I assume.
12:13rhickey_metadata supported for maps
12:14rhickey_I don't do lists or sets-as-collections yet
12:14stuartsierraok
12:14rhickey_restoring rdf:Lists is extremely piggy
12:14stuartsierraSets as multiple properties makes more sense to me.
12:15stuartsierraYes, I got annoyed trying to deal with rdf:List. I thought it would be easy.
12:15rhickey_yes, as map members sets become multiple props, but as vector members not
12:15stuartsierraOk, this makes sense.
12:15clojurebotthis is not a bug
12:16stuartsierraWhat about literal datatypes?
12:16rhickey_plus I will support (rdfm/assoc a-stored-vec i new-val)
12:16rhickey_int/long/float/double/bigint/bigdec/boolean/calendar/string/keyword
12:17rhickey_will add symbols
12:17stuartsierraHow about things that don't map directly to Clojure/Java types, like "my string"@en?
12:17rhickey_and (rdfm/conj a-stored-vec an-additional-val)
12:18rhickey_stuartsierra: the objective of the library is definitely leveraging RDF stores to store Clojure data, not interop with RDF data
12:18stuartsierraOk, fair enough.
12:19rhickey_when reading back "my string"@en what would you expect to be returned?
12:20stuartsierraBest I could come up with is {:type :literal :value "my string" :language "en"}
12:20rhickey_hmm
12:21stuartsierraThis is the problem with every RDF library; some parts don't quite match any typical language constructs.
12:21Chouser#^{:language "en"} "my string"
12:21Chouserif only
12:21rhickey_The library uses the Sesame API, which seems pretty widely supported - AllegroGraph, Virtuoso as well as Sesame.
12:22stuartsierraSesame and Jena are probably the two big ones.
12:22stuartsierraThe secondary layers like JRDF don't seem to add much.
12:24rhickey_once the data is in you can use sparql etc to query it
12:24stuartsierraAre you using Sesame 1.x or 2.x?
12:25rhickey_2.x
12:26stuartsierraok
12:36winterstreamHi everyone. I'm trying to instantiate a Java object whose constructor parameters are (double[], double). In Clojure's REPL, if I try (LinearObjectiveFunction. (into-array [-2.0 1.0]) -5.0), Clojure complains that no suitable constructor exists. What am I missing? The class I want to instantiate is described at http://commons.apache.org/math/api-2.0/org/apache/commons/math/optimization/linear/LinearObjectiveFunction.html
12:39Chouser,(into-array [-2.0 1.0])
12:39clojurebot#<Double[] [Ljava.lang.Double;@1ade7f6>
12:39ChouserThat's an array of Double not double
12:39Chouser,(into-array Double/TYPE [-2.0 1.0])
12:39clojurebot#<double[] [D@1cc903c>
12:39Chousertry that instead
12:40winterstreamAh
12:40winterstreamChouser: thanks! It works!
12:43drewrwow, that's confusing
12:44stuartsierraBoxed primitives are an unfortunate legacy feature of the JVME.
12:44stuartsierra*JVM
12:44ole3how to convert an java array to a string?
12:46stuartsierraIf it's an array of chars, (String. the-array)
12:46stuartsierraor bytes, (String. the-array "UTF-8")
12:49ole3(make-array byte 2)
12:50ole3oops
12:50stuartsierra,(make-array Byte/TYPE 2)
12:50clojurebot#<byte[] [B@1ebaf3>
12:50ole3:) thank you
12:51ole3by the way, what's the difference between (new String ...) and (String. ....)
12:59cschreinerhow can I test for a {} structure in my data?
12:59drewr,(map? {:foo 1})
12:59clojurebottrue
12:59cschreinerah
12:59cschreinerit is always so easy...
13:00drewrwell, the easy things are :-)
13:04stuartsierraole3: (String. ...) is syntactic sugar for (new String ...)
13:04stuartsierraAny EMACS fans know how to open a file in the *subdirectory* under point in a dired buffer?
13:08drewrC-x C-f then use completion?
13:09drewrit'll start in the current dired directory
13:09stuartsierraRight, that's what I'm trying to avoid. Like if I'm in a dired buffer on "/home/stuart/project" but I've expanded the subdirs to "/home/stuart/project/src/main/java/foo/bar/baz" and I want to open a file there.
13:10drewrif you've traversed to baz then find-file will be local to that dir
13:11stuartsierraNot if I've traversed to baz using dired-maybe-insert-subdir (bound to "i")
13:11eyerisIs there a form of assoc that simple takes a map, key, and function, with a body similar to this? (assoc m :k (f (:k m)))
13:12drewrstuartsierra: ah, that's different :-)
13:13stuartsierraMy dired buffer looks like this: http://paste.lisp.org/+1UQZ
13:14Chousukeeyeris: update-in
13:14eyeristy
13:14Chousukeit takes a seq of keys though :)
13:15drewrstuartsierra: you can't hit RET on the baz so that it's not a subdir at that point?
13:15Chousuke,(update-in {:a 1 :b 2 :c {:a 3}} [:c :a] inc)
13:15clojurebot{:a 1, :b 2, :c {:a 4}}
13:16stuartsierradrewr: doesn't work if I hit RET on the subdir header line, works if I go up one parent and then hit RET
13:16drewrthat's what I mean
13:17drewri... i... i.... RET C-x C-f
13:17drewrat worst, ^ RET C-x C-f
13:18stuartsierradrewr: Yeah, just want it to be one key. Hmph. I guess I could write it.
13:25lisppaste8stuartsierra pasted "dired-find-file-in-subdir" at http://paste.lisp.org/display/86509
14:00LauJensenHow do you define a 'triple' data structure?
14:05ChouserLauJensen: that's an RDF thing
14:06ChouserLauJensen: http://www.w3.org/TR/rdf-concepts/#section-triples
14:06LauJensenThanks a lot
14:07eyerisHow do I control which defs are exported from my namespace?
14:07Chousereyeris: all vars are public unless marked private
14:08Chousereyeris: you can use defn- or #^{:private true} to mark a var as private
14:09eyerisOkay
14:09eyerisThanks
14:25Chouserok, that's fun. (rseq ft) returns a thing just like ft except with cons/first/rest swapped for conj/peek/pop
14:26Chouserso you can build/consume from the other end, then call rseq again to switch back to a normal-direction finger-tree, all without losing any abilities.
14:26Chouserthat is, both seq and rseq just return another finger-tree, not a cursor type of any kind.
14:37eyerisI swear I will never understand the rules for the ns macro
14:37Chouser:-(
14:37eyerisIf I want to :use two namespaces, what is the syntax?
14:37Chouser(ns foo (:use [ns1 :only []] [ns2 :only []]))
14:38eyerisOkay, that works.
15:14LauJensenWhat is this obession that the chinese have for accessing /fastenv on my webserver ?
15:15eyerisLauJensen sounds like they're probing for a FastCGI vulnerability
15:15LauJensenoh ok - amazing perseverance
15:15eyerisJust a guess.
15:15lisppaste8stuartsierra annotated #86509 "better dired-find-file-in-subdir" at http://paste.lisp.org/display/86509#1
15:21lisppaste8stuartsierra annotated #86509 "binding it to a key in dired" at http://paste.lisp.org/display/86509#2
15:23LauJensenstuartsierra: ido aint doing for you ?
15:23stuartsierraLauJensen: what do you mean? What's ido?
15:24LauJensenido-find-file, what I type back, and it auto completes to ~/home/coding/lisp/projects/clojureql/src/dk/bestinclass/backend.clj ?
15:24LauJensens/what/where
15:25LauJensenI keeps a history of all your files, and whenever you type something, it finds the file
15:25LauJensens/I/It
15:26stuartsierraok, didn't know about that one. But no, I wanted something for opening a new file that doesn't exist yet.
15:27LauJensenah ok
16:42LauJensenIs there any hope on the horizon for a quality UI toolkit for Java?
16:50slyrus_LauJensen: hasn't there been hope for years now?
16:51LauJensennope
16:51LauJensenI got my hopes up a little bit with the entrace of QtJambi - but then that died
16:52stuartsierraThere's probably a good commercial toolkit out there.
16:53slyrus_LauJensen: I didn't say a quality UI toolkit, I said _hope_ for one. that's been around for as long as I can remember.
16:53LauJensenslyrus_: nope, sorry
16:55hiredmanwhat is the problem with swing?
16:56LauJensenits ugly, its laggy, its unflexible
16:57hiredmanlaggy?
16:58LauJensenIts does not perform well
16:58Chousukehm.
16:58ChousukeI'm not sure if that's swing's fault.
16:58Chousukeor just that people misuse it. :/
16:58LauJensenIts swing
16:59LauJensenBut Im not here to discuss swing, I was just probing for some new technological innovations
17:01hiredmanthe #java guys seem pretty happy with swing
17:01LauJensenThey must not know better
17:01hiredmanso what is better than swing, and why is it better?
17:01ChousukeLauJensen: with quick googling I can't find any resource that claims swing as particularly slow
17:02LauJensenhiredman: Aqua for instance, performs better, looks nicer, is more easily extended. Same goes for Windows MFC, which is just pure joy to work with in Visual Studio
17:02LauJensenI'd say the only thing thats not better is GTK
17:02stuartsierraI have noticed Swing apps with a lot of drawing errors, but I don't know if that's Swing's fault or the app's fault.
17:03stuartsierraLauJensen: but both Aqua and MFC are single-platform products, Swing is trying to work everywhere.
17:03hiredmanLauJensen: the visual studio comment makes it sound like a tools issue
17:03LauJensenstuartsierra: Doesnt change the user-perception
17:04ChousukeI think Swing may have an undeservedly bad reputation. :/
17:04Chousukejust like Java has :P
17:04stuartsierraLauJensen: agreed, but that may explain why it's harder to do GUIs well in Swing than in Aqua or MFC.
17:04LauJensenhiredman: its a little bit of both
17:04hiredmanI am inclined to agree with Chousuke
17:05LauJensenstuartsierra: Sure, but I'm cynical enough not to care, I just want somethings thats high quality :)
17:05LauJensenI'd go as far as to say that the UI side of things, is my only dark cloud over Clojure
17:05LauJensenRich needs to put emphasis on the eye candy! :)
17:05duncanmif i have a list of maps, each one like {"x" 0 "y" 1}, how do i pluck out all the "x"s?
17:06duncanmahh
17:06duncanmmap!
17:06stuartsierrayep
17:06LauJensen(keys m) ?
17:07stuartsierra(map #(get % "x") list-of-maps)
17:07duncanmstuartsierra: that's exactly what i'm writing now
17:07LauJensenduncanm: this is the simplest way to go
17:07LauJensen,(doto (java.util.ArrayList. (into [] (mapcat concat (map keys (list {"foo" 2 "bar" 3} {"min" 4 "max" 5}))))) java.util.Collections/shuffle)
17:07clojurebot#<ArrayList [bar, min, foo, max]>
17:08LauJensennothing will beat that for pure elegance, but you'll get random results :)
17:09LauJensenits a sad day when even my 'code jokes' dont fly...
17:10stuartsierrawasn't sure what you were going for there
17:11LauJensenits not elegant, its not simple, it randomizes the result... just tought it was funny when (map keys ..) was enough
17:11arbschtrest assured, my face was deeply embedded in my palm when I read that. there was an instant, though, in which I panicked about my choice of ClojureQL...
17:12LauJensenhaha
17:13LauJensenClojureQL rocks - I just did a very awesome combination of compojure+clojureql+googlecharts to auto-generate some very nice stats for www.bestinclass.dk
17:53Chousukehm.
17:54Chousukejust now this swing talk made me take a look at my swing experiments file I wrote some time ago to learn how it works.
17:54Chousukeit has a small blue square that I can move around the screen with arrow keys. my drawing code was rather idiotic though...
17:55Chousuke(holding down an arrow key caused java to have over 100% CPU utilisation in top)
17:56Chousukeso I rewrote the code to be a bit smarter and now it uses ~7-10% :P
17:56aack\join #lisp
17:56ChousukeMy dream is to write a small roguelike in Clojure at some point but first I really need to learn swing better :)
17:58Chousukebut if I ever get to the point that I have an avatar walking around the dungeons, I'm going to embed a clojure repl in the game for spellcasting :P
17:58Chousukeit'd be neat to make a game by playing it :)
17:58hiredmanChousuke: you should make a clojure version of ruby-warrior http://github.com/ryanb/ruby-warrior/tree/master
18:00tomojswing? :(
18:00tomojit's really too bad java sucks at the console
18:01tomojmy dream is to write a messaging client, but it needs to run in screen
18:01Chousukeyeah, I couldn't find any terminal drawing stuff :/
18:02technomancyChousuke: you should try clj-processing
18:02technomancyit's a lot of fun
18:02tomojI found jcurses but my tentative judgement is that it sucks
18:02technomancy~processing
18:02clojurebotprocessing is a language/toolkit for visualizations. See the Clojure wrapper at http://github.com/rosado/clj-processing/
18:02hiredmanhttp://github.com/ryanb/ruby-warrior/tree/master
18:02technomancyincanter (the stats package) is migrating towards that
18:02hiredmaner
18:03hiredmanhttp://www.pitman.co.za/projects/charva/Screenshots.html "A Java Windowing Toolkit for Text Terminals"
18:03tomojhaven't tried that one yet
18:04tomojmy problem is that I'm not really interested in making it look like a shitty old console gui with windows and tabs. I just want like irssi
18:04tomojmaybe you can manipulate charva into being more minimal..
18:04spaceman_stuis there a good way to implement type-specific versions of already defined fns? like count for an unsupported type
18:05tomojspaceman_stu: I was just thinking about exactly that while walking home
18:05tomojafaik, no
18:05spaceman_stubummer
18:06tomojI suppose you might be able to replace count with a multimethod and have it delegate to the old count for things it doesn't know about
18:06spaceman_stuyeah, I was thinking about that
18:06tomojbut that doesn't seem like a good idea to me
18:06technomancyspaceman_stu: for things that are based on interfaces it's not hard to do
18:06technomancybut I don't think count is
18:06technomancyit's easy to proxy something like IMeta though
18:07tomojoh, hmm, I hadn't thought about that
18:07tomojI suppose you can also act like seqs, too?
18:07tomojwas trying to think of how to translate some python into clojure, and the python has objects that duck-type as lists
18:07technomancyactually, count does work on an interface
18:07technomancyjust implement clojure.lang.Counted and write a count method
18:08tomojI dunno if I'm happy using a java type, though :/
18:08Chousuke,(count (proxy [clojure.lang.Counted] [] (count [] 5)))
18:08Chousukehmm
18:08technomancydocs say you have to guarantee constant-time counts; not sure how important that is
18:11tomojis = linear in the size of the data structure?
18:13stuartsierraI think = checks hashes first, so it's constant if the structures are not equal, linear if they are.
18:14stuartsierraBut (= (iterate inc 0) (iterate inc 0)) will not terminate.
18:15technomancyinfinity is a constant. =)
18:15tomojah, but if you have a proxy like above, it'll use the default equals() from java and = will just compare the reference, right?
18:16tomojbut then, if you memoize a function call on that reference, you still prevent it from being garbage collected, I suppose. hrmmm
19:10somniumcan clj-haml generate the xml? (would shave off 50-100 characters at least)
19:12tomojhrmm
19:12tomojtrying to figure out how to write python's re.findall in clojure
19:12tomojjava.util.regex.Matcher wants you to call .find and then .group to get the next match
19:14Chousukere-seq?
19:14Chousuke(doc re-seq)
19:14clojurebot"([re s]); Returns a lazy sequence of successive matches of pattern in string, using java.util.regex.Matcher.find(), each such match processed with re-groups."
19:15tomojoh
19:15tomojdamn
19:15tomojmissed that one, thanks :D
19:17tomojthe source is illuminating
19:17tomojI was trying to do something like that but couldn't quite get it
19:22tomojso anonymous functions can't call themselves if the recur needs to be not in tail position?
19:22tomojI mean, without writing a Y combinator
19:23Chouseryou can give a function an internal-only name
19:23tomojright, yeah. but then I tried to switch it to anonymous, and couldn't because I need to recur but not in tail position
19:23Chouser((fn zeros [] (lazy-seq (cons 0 (zeros)))))
19:24Chouserthat name "zeros" isn't available externally, so in that sense it's "anonymous".
19:24hiredman,((fn a [x] (if (zero? x) x (a (dec x)))) 1)
19:24clojurebot0
19:24tomojI guess this is why the Y combinator exists
19:24hiredman
19:24ChouserI guess I'm not quite sure what you're asking. 'recur' can only be used in tail position.
19:25tomojright, I guess I was asking if there was an alternative to recur that just called the current function without needing to be in tail position
19:25hiredmantomoj: Yes
19:25tomojbut that would be a silly thing to have just to avoid giving a name
19:25hiredman,((fn a [x] (if (zero? x) x (a (dec x)))) 1)
19:25clojurebot0
19:25tomojhiredman: yeah, I meant truly anonymous
19:25tomojas in, unnamed
19:25hiredmanit is anonymous
19:26hiredmana is just the equivilant of the 'this' pointer
19:26Chousukeeven an anonymous person has something to refer to himself. :P
19:27tomojwell, sure, like 'this' or 'self'
19:27tomojbut we don't have that
19:27hiredmanI think, in fact, at some point all functions just bound to thisfn
19:27hiredmantomoj: #$%!@#%$%
19:27hiredmanwe do
19:27hiredman(fn a [])
19:27Chousuketomoj: sure we do. (fn self [] (self))
19:27Chousuketomoj: just like in python. :P
19:27hiredmanif you put a symbol after a, inside the scope of the function, the function is bound to a
19:27tomojright but if you change the name there, you have to go through and change the calls
19:27tomojnot that this is a real problem
19:27Chousuketomoj: just like in python :)
19:27hiredman
19:28tomoj"recur" is always the same nomatter the function name or whether you've even given it a name
19:28Chousertomoj: just always use (fn thisfn [] ...) and you'll never have to rename your internal uses of thisfn.
19:28tomojbut yeah, this isn't actually a problem, I will just put a name there :)
19:29tomojChouser: true
19:29Chousertomoj: you do know that 'recur' behaves differently from a self-call in the tail position?
19:29hiredmanfn used to bind thisfn, before it got the ability to bind any name you choose
19:29tomojChouser: yeah
19:29tomojChouser: I was wondering if there was something that behaved like a self-call but didn't require giving a name
19:29tomojnot binding thisfn is really better, I suppose
19:30tomoj(now I realize what I was asking was whether thisfn existed)
19:31Chouserthe problem with thisfn was when you had nests fns and wanted to call the outer one.
19:32tomojI guess it's unlikely that you'd be using the name "thisfn" elsewhere
19:32tomojbut hygiene is good
19:32tomojI could always write afn which binds thisfn
19:45tomoj,(letfn [(Y [f] ((fn [x] (f (fn [y] ((x x) y)))) (fn [x] (f (fn [y] ((x x) y)))))) (F [f] (fn [x] (if (zero? x) 1 (* x (f (dec x))))))] ((Y F) 5))
19:45clojurebot120
19:45tomoj:D
19:49tomojor better,
19:49tomoj,(((fn [f] ((fn [x] (f (fn [y] ((x x) y)))) (fn [x] (f (fn [y] ((x x) y)))))) (fn [f] (fn [x] (if (zero? x) 1 (* x (f (dec x))))))) 5)
19:49clojurebot120
19:52somniumis that maintainable?
19:53tomojwell it could be more maintainable
19:53tomojbut clojurebot wants everything in one expr
19:53tomojY never needs to change, and if you separate it out it becomes much cleaner
19:53tomoj(but still useless)
19:54technomancythere's no function to translate between hyphen-case and camelCase, is there?
19:54Chouserhm, I think I wrote one...
20:12Chousernm. I found what I was thinking of but it's broken or something.
21:46prospero_is there a function that says whether something is IMeta?
21:46prospero_meta? or metable or something
21:48ChouserI don't think so. just 'instance?'
21:48Chouser,(instance? clojure.lang.IMeta [])
21:48clojurebottrue
21:48Chouser,(instance? clojure.lang.IMeta "")
21:48clojurebotfalse
21:48prospero_ok, just wondering if there was a way less tied to the implementation
21:50Chousernope, I think that's it. Interfaces aren't really implementation anyway -- they're interface. :-)
21:51technomancyis there a way to programmatically determine if Clojure is running interactively?
21:51technomancyI guess you could check for some of the bindings from the repl function
21:52technomancyit'd be great if environment developers could agree on a unified way of stating this.
21:52technomancywill suggest it on the mailing list.
22:14Chouserit could even include repl provider name and version number
22:14Chouserso that you could differentiate between :enclojure and :core if you really wanted to
23:03tomojimplementing IMeta means the value has metadata?
23:05Chouserright, it means you can call 'meta' on it.
23:41duck1123This is probably a FAQ I'm missing somewhere, but how do I get my test script to return false on errors?
23:56tomojhuh
23:57tomojclojure.test?
23:59duck1123If I run a clojure script that executes clojure.test tests, how do I get the script return a -1 on failure
23:59tomojoh, hmm
23:59tomojwell you can give a return code with System.exit
23:59duck1123I build with maven
23:59duck1123and I'm trying to get the plugin to fail on error