2009-09-03
| 00:14 | technomancy | will try in 1.1-snapshot; maybe it's been fixed |
| 00:36 | hiredman | clojurebot: example? |
| 00:37 | clojurebot | api examples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples |
| 00:37 | hiredman | clojurebot: example is Short, Self Contained, Correct (Compilable), Example http://sscce.org/ |
| 00:37 | clojurebot | Huh? |
| 00:37 | hiredman | clojurebot: jerk |
| 00:37 | clojurebot | Huh? |
| 00:38 | hiredman | damn it |
| 00:47 | technomancy | still broken with latest clojure master. |
| 00:47 | technomancy | looks like it only works with AOT'd functions |
| 00:48 | technomancy | will see if I can narrow it down to the a small repro case |
| 00:49 | hiredman | clojurebot: foo is is Short, Self Contained, Correct (Compilable), Example http://sscce.org/ |
| 00:49 | clojurebot | In Ordnung |
| 01:02 | technomancy | OK, narrowed it down to a 4-line repro case: http://p.hagelb.org/bughunt.clj.html |
| 01:08 | technomancy | ah... solved my problem by moving my functions zipmap into the backquoted part of the macro |
| 01:18 | technomancy | sweet; it works. |
| 01:18 | technomancy | some nice syntactic sugar for defining processing apps: http://github.com/technomancy/clj-processing/blob/4e762d4c4e84e4e5b36d28655be591f4f067a05e/src/rosado/processing/applet.clj |
| 01:19 | technomancy | ,processing |
| 01:19 | clojurebot | java.lang.Exception: Unable to resolve symbol: processing in this context |
| 01:19 | technomancy | ~processing |
| 01:19 | clojurebot | Excuse me? |
| 01:20 | hiredman | clojurebot: processing is http://github.com/technomancy/clj-processing/blob/4e762d4c4e84e4e5b36d28655be591f4f067a05e/src/rosado/processing/applet.clj |
| 01:20 | clojurebot | 'Sea, mhuise. |
| 01:22 | technomancy | there's a better URL; hang on |
| 01:22 | technomancy | clojurebot: processing is http://github.com/rosado/clj-processing/ |
| 01:22 | clojurebot | Ack. Ack. |
| 01:23 | technomancy | clojurebot: processing is a language/toolkit for visualizations. See the Clojure wrapper at http://github.com/rosado/clj-processing/ |
| 01:23 | clojurebot | Ik begrijp |
| 01:23 | technomancy | g'night folks |
| 03:54 | poet | having the same problem as here: http://paste.lisp.org/display/77765 any ideas for a solution? |
| 03:56 | jdz | what the hell is swank-clojure-config? |
| 03:57 | poet | says to do that here http://riddell.us/tutorial/slime_swank/slime_swank.html |
| 03:57 | poet | I tried setting the variable by itself and that didnt work either |
| 03:58 | hiredman | ~emacs |
| 03:58 | clojurebot | emacs is best configured for Clojure with instructions at http://technomancy.us/126 |
| 03:59 | poet | nice, Ill take a look |
| 03:59 | hiredman | I don't use emacs, but that seems to be the tutorial to follow |
| 04:09 | AWizzArd | Is there a mechanism in the jvm or Clojure for autodetecting file encodings? |
| 04:11 | jdz | no, but there is a library that attempts to do it |
| 04:12 | jdz | cpdetector.jar |
| 04:12 | AWizzArd | thx |
| 04:12 | jdz | not perfectly reliable, though |
| 04:12 | subhadeep | hi everyone |
| 04:13 | subhadeep | i'm trying out clojure box |
| 04:13 | subhadeep | but in emacs swing isnt working |
| 04:13 | subhadeep | slime hangs |
| 04:13 | jdz | osx, right? |
| 04:14 | subhadeep | windows |
| 04:14 | subhadeep | xp |
| 04:15 | AWizzArd | subhadeep: go into the inferior-lisp buffer |
| 04:15 | AWizzArd | there press a few times enter |
| 04:15 | AWizzArd | then swing will not hang anymore in emacs |
| 04:15 | subhadeep | uh oh |
| 04:16 | AWizzArd | the first time when you want to show a swing component you need to press a few times enter in the inferior repl :-) |
| 04:17 | subhadeep | umm |
| 04:17 | subhadeep | doesnt help |
| 04:17 | subhadeep | :( |
| 04:17 | subhadeep | (. javax.swing.JOptionPane (showMessageDialog nil "Hello World")) |
| 04:17 | subhadeep | i tried this |
| 04:17 | subhadeep | its stuck |
| 04:18 | AWizzArd | But when you start a Clojure repl from a shell, then it works. |
| 04:19 | subhadeep | yes |
| 04:19 | subhadeep | infact from emacs |
| 04:19 | subhadeep | if i open a windows shell |
| 04:19 | subhadeep | and try it out it works |
| 04:28 | eevar2 | encoding-detection is broken by design. just hardcode anything to utf-8 ;) |
| 04:29 | hiredman | :) |
| 04:34 | AWizzArd | eevar2: yeah, I would love to do that. Unfortunately others don't know about it |
| 04:35 | AWizzArd | clojurebot: paste |
| 04:35 | clojurebot | lisppaste8, url |
| 04:35 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 04:38 | lisppaste8 | AWizzArd pasted "Easier way to append to a file with specific encoding?" at http://paste.lisp.org/display/86490 |
| 04:38 | AWizzArd | using contribs duck-streams |
| 04:54 | liwp | subhadeep: that works fine for me once I switch to the *inferior-lisp* buffer and hit enter once |
| 04:55 | liwp | (javax.swing.JOptionPane/showMessageDialog nil "Hello World") is slightly better style IMO |
| 05:00 | subhadeep | ok liwp |
| 05:00 | subhadeep | lemme try |
| 05:03 | subhadeep | it works this time |
| 05:03 | subhadeep | thanks |
| 05:03 | subhadeep | hmm |
| 05:03 | subhadeep | but do i have to get to inferior-list buffer everytime i try swing? |
| 05:03 | Chousuke | shouldn't you run swing UI code in the swing thread? |
| 05:04 | subhadeep | uh oh |
| 05:05 | Chousuke | at least if you want to create or change UI elements from the repl thread |
| 05:05 | Chousuke | it's not very difficult, though. |
| 05:05 | subhadeep | invokelater |
| 05:05 | Chousuke | just (SwingUtilities/invokeLater #(your code here)) |
| 05:05 | Chousuke | or you can make a macro for that and do (swing your code here) :P |
| 05:08 | Chousuke | http://www.j2ee.me/products/jfc/tsc/articles/threads/threads1.html for more info |
| 05:11 | subhadeep | but without inferior-lisp buffer |
| 05:11 | subhadeep | i couldnt get the swing code running |
| 05:12 | subhadeep | though |
| 05:12 | subhadeep | learning emacs and clojure with clojure box :) |
| 05:12 | LauJensen | subhadeep: Youre only concern in regards to a seperate swing thread, is how you get messages? |
| 05:12 | subhadeep | no |
| 05:13 | subhadeep | in emacs |
| 05:13 | Chousuke | I had no problem running swing code from slime. |
| 05:13 | Chousuke | but I used my swing macros to run it. |
| 05:13 | subhadeep | i try (. javax.swing.JOptionPane (showMessageDialog nil "Hello World")) |
| 05:13 | subhadeep | and it gets stuck like that |
| 05:13 | LauJensen | Chousuke: You must have noticed that certain methods fail silently ? |
| 05:13 | subhadeep | until i try the inferior-lisp buffer |
| 05:13 | Chousuke | LauJensen: hm, not really. |
| 05:13 | LauJensen | oh... I get that hassle constantly |
| 05:14 | subhadeep | http://groups.google.com/group/clojure/browse_thread/thread/6c195c35ae9a7eb8 |
| 05:14 | subhadeep | has the issue documented |
| 05:14 | LauJensen | For instance an onAction event for a swing component, will fail 100% silently |
| 05:14 | subhadeep | but didnt get a convincing solution |
| 05:15 | Chousuke | LauJensen: I got exceptions in the *inferior-lisp* buffer |
| 05:15 | LauJensen | eh? |
| 05:15 | Chousuke | when some swing-action failed that is |
| 05:16 | LauJensen | I dont see how thats possible |
| 05:18 | Chousuke | well I don't know what it did, but the exception backtraces get printed *somewhere* |
| 05:18 | Chousuke | and I just tested. (javax.swing.SwingUtilities/invokeLater #(. javax.swing.JOptionPane (showMessageDialog nil "Hello World"))) works perfectly from the slime repl |
| 05:20 | subhadeep | it didnt work for me though |
| 05:20 | subhadeep | until as i said inferior-lisp came to the rescue |
| 05:20 | Chousuke | hm :/ |
| 05:20 | Chousuke | something's wrong with your java then. |
| 05:21 | subhadeep | umm i dont think so |
| 05:21 | subhadeep | its either winblows |
| 05:21 | subhadeep | or emacs config |
| 05:21 | Chousuke | might be. I'm on OS X. |
| 05:21 | liwp | It 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:21 | clojurebot | "if you never learnt Lisp, then you never learned to program" -- some rant on some blog somewhere |
| 05:21 | subhadeep | many other faced the same problem without any viable solution as ma google says |
| 05:21 | subhadeep | yes liwp |
| 05:22 | subhadeep | after inferior-lisp |
| 05:22 | subhadeep | swing works fine in slime |
| 05:22 | Chousuke | weird. |
| 05:22 | LauJensen | Chousuke: I'm on LInux and I have the same behaviour as subhadeep |
| 05:22 | liwp | I've seen the issue on OS X as well (at home). I'm at work on Windows at the moment. |
| 05:22 | subhadeep | thanks for the help liwp and AWizzArd |
| 05:22 | subhadeep | told ya :) |
| 05:23 | Chousuke | hm |
| 05:23 | Chousuke | well, it might be your emacs config then |
| 05:23 | LauJensen | Its flawless |
| 05:23 | Chousuke | mine is quite customised :P |
| 05:23 | subhadeep | :) |
| 05:24 | subhadeep | i will try out in solaris once i get back home |
| 05:24 | subhadeep | i started with clojure yesterday night when i was reading this debate on scala vs clojure |
| 05:24 | subhadeep | as to who will hold the jvm fort |
| 05:25 | subhadeep | thought of learning LISP for a long time so finally i gave it a try |
| 05:25 | subhadeep | :) |
| 05:25 | liwp | blah, I'm getting really tired of the whole scala vs. clojure thing. |
| 05:25 | Chousuke | I never got comfortable with common lisp |
| 05:25 | Chousuke | but Clojure is great. |
| 05:26 | subhadeep | yes JRuby too ;) |
| 05:26 | LauJensen | liwp: funny, it doesnt bother me one bit |
| 05:26 | liwp | Chousuke: 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:27 | liwp | LauJensen: 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:27 | Chousuke | I wonder why Clojure is being compared to scala so much |
| 05:27 | Chousuke | Where's Groovy? |
| 05:27 | liwp | Chousuke: exactly |
| 05:28 | LauJensen | liwp: Havent you noticed that language wars have been going on since masm and tasm? :) |
| 05:28 | liwp | LauJensen: sure :) |
| 05:28 | subhadeep | scala has some big follwoing among the web2.0 darlings like twitter |
| 05:28 | AWizzArd | How can I get a MapEntry from a map? |
| 05:28 | Chousuke | what kind of a map? |
| 05:29 | Chousuke | hmm |
| 05:29 | LauJensen | ,(map class {:foo 1 :bar 2}) |
| 05:29 | clojurebot | (clojure.lang.MapEntry clojure.lang.MapEntry) |
| 05:29 | AWizzArd | ,(map identity {:a 1, :b 2, :c 3}) |
| 05:29 | clojurebot | ([:a 1] [:b 2] [:c 3]) |
| 05:29 | Chousuke | oh, heh. |
| 05:29 | AWizzArd | these things that print like vectors, but those are MapEntry's |
| 05:29 | subhadeep | hmm |
| 05:29 | AWizzArd | ,(.getEntry {:a 1} 1) |
| 05:29 | clojurebot | java.lang.IllegalArgumentException: No matching method found: getEntry for class clojure.lang.PersistentArrayMap |
| 05:30 | hiredman | they are vectors |
| 05:30 | AWizzArd | ,(.getEntry {:a 1} :a) |
| 05:30 | clojurebot | java.lang.IllegalArgumentException: No matching method found: getEntry for class clojure.lang.PersistentArrayMap |
| 05:30 | AWizzArd | ,(map (comp identity) {:a 1, :b 2, :c 3}) |
| 05:30 | clojurebot | ([:a 1] [:b 2] [:c 3]) |
| 05:30 | AWizzArd | ,(map (comp class identity) {:a 1, :b 2, :c 3}) |
| 05:30 | clojurebot | (clojure.lang.MapEntry clojure.lang.MapEntry clojure.lang.MapEntry) |
| 05:30 | AWizzArd | no |
| 05:30 | AWizzArd | they are not vectors |
| 05:30 | hiredman | ,(ancestors clojure.lang.MapEntry) |
| 05:30 | clojurebot | #{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:30 | AWizzArd | just print like them |
| 05:30 | hiredman | ^- |
| 05:30 | hiredman | They Are Vectors |
| 05:30 | subhadeep | (+ 1 2 3) |
| 05:30 | clojurebot | *suffusion of yellow* |
| 05:30 | subhadeep | :) |
| 05:30 | hiredman | ~scala |
| 05:30 | clojurebot | Scala often gets in the way when trying to write neat code -- seen in #scala |
| 05:31 | AWizzArd | hiredman: ah okay, in the oop sense |
| 05:31 | AWizzArd | hiredman: how can I get such an entry when I have a key? |
| 05:31 | AWizzArd | there is a function for that, I just don't remember it :-) |
| 05:31 | Chousuke | I guess Clojure gets compared to scala because scala also advertises itself as a functional language. at least AFAIK |
| 05:31 | hiredman | ~def java.util.Map |
| 05:32 | eevar2 | and because they both run on the JVM |
| 05:32 | subhadeep | ~ruby |
| 05:32 | clojurebot | Chunky bacon! |
| 05:32 | subhadeep | hehe |
| 05:32 | hiredman | oh |
| 05:32 | AWizzArd | ah :) |
| 05:32 | hiredman | ~jdoc java.util.Map |
| 05:32 | Chousuke | I haven't studied Scala in depth because every snippet of scala code I have seen roused an irresistible urge to flee. |
| 05:32 | subhadeep | ~jruby |
| 05:32 | clojurebot | No entiendo |
| 05:33 | subhadeep | wokay |
| 05:33 | LauJensen | I 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:33 | subhadeep | wholly new syntax for me |
| 05:33 | subhadeep | coming from java/c++/ruby world |
| 05:33 | subhadeep | but its fun |
| 05:34 | Chousuke | there isn't much to learn anyway |
| 05:34 | subhadeep | umm |
| 05:34 | subhadeep | why ? |
| 05:34 | hiredman | ~literal [3] scala |
| 05:34 | clojurebot | <reply>{((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)} |
| 05:34 | Chousuke | If you mean clojure syntax, there's (), [], {}, and the reader macros (which are optional) |
| 05:34 | Chousuke | and some special forms. |
| 05:35 | subhadeep | yes :) |
| 05:35 | Chousuke | hiredman: I still can't figure out wth that is supposed to be. |
| 05:36 | subhadeep | parentheses everywhere |
| 05:36 | hiredman | it's cons as λ |
| 05:36 | subhadeep | ~scala |
| 05:36 | clojurebot | {((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)} |
| 05:36 | Chousuke | aha. |
| 05:36 | hiredman | it returns 1 |
| 05:36 | hiredman | (x: Any, y: Any) => x is like car |
| 05:37 | hiredman | (took me a while mucking around with scalabot) |
| 05:37 | Chousuke | right. |
| 05:38 | Chousuke | I can't remember the lisp definitions of cons either though. |
| 05:38 | Chousuke | and I can't read that well enough to see what it is. |
| 05:39 | hiredman | ,(((fn [a b] (fn [f] (f a b))) 1 2) (fn [a b] a)) |
| 05:39 | clojurebot | 1 |
| 05:40 | liwp | hiredman: 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:40 | hiredman | sure |
| 05:40 | liwp | yeah, that seems more familiar :) |
| 05:40 | Chousuke | ah, right. |
| 05:41 | liwp | to be fair to scala, the clojure version is a mess as well if you don't know clojure |
| 05:41 | Chousuke | there's less noise though. |
| 05:41 | liwp | agreed |
| 05:41 | liwp | less syntax => less noise ;) |
| 05:42 | Chousuke | that doesn't always hold though. |
| 05:42 | Chousuke | clojure has more syntax than common lisp, but I think it has less noise :) |
| 05:42 | sgtarr | what do you guys think about Scala? |
| 05:42 | Chousuke | mostly because of [] and {} |
| 05:43 | Chousuke | I also think the literal vector and map syntax also makes writing more expressive macros easier. |
| 05:43 | Chousuke | since you have two more syntax elements to work with. |
| 05:43 | Chousuke | or actually three since #{} is a literal set :P |
| 05:44 | Chousuke | but I haven't seen that in macros. |
| 05:45 | liwp | Chousuke: that is true, [] and {} do help. Also fewer parens in bindings and cond etc. help as well |
| 05:48 | liwp | sgtarr: 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:49 | liwp | So to me, at least for the time being, it's not very interesting |
| 05:49 | Chousuke | one 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:50 | liwp | Chousuke: do you have an example handy? |
| 05:52 | sgtarr | liwp: 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:52 | Chousuke | I 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:52 | Chousuke | if you had only lists available, it would be slightly more cumbersome to accomplish this. |
| 05:52 | Chousuke | though I suppose you could use quasiquote :) |
| 05:54 | LauJensen | What a fantastic idea to let ISPs decide the Whois format themselves. "COUNTRY:\tSE" "country: uk" "Country:\tUS" etc... :) |
| 05:55 | eevar2 | i'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:56 | hiredman | ~haskell |
| 05:56 | clojurebot | Yo 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:58 | Chousuke | that should say: you don't have to compute while you don't compute |
| 06:00 | LauJensen | so fix it |
| 06:00 | LauJensen | :) |
| 06:01 | Chousuke | nah, I'm lazy as well. |
| 06:08 | liwp | Chousuke: 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:11 | Chousuke | it's also possible to have the macro expect just seqs of course. |
| 06:12 | Chousuke | ,(letfn [[foo [x] x]] (letfn [(bar [x] x)] [(foo 2) (bar 3)]) |
| 06:12 | clojurebot | EOF while reading |
| 06:12 | Chousuke | ,(letfn [[foo [x] x]] (letfn [(bar [x] x)] [(foo 2) (bar 3)])) |
| 06:12 | clojurebot | [2 3] |
| 06:13 | Chousuke | hmm |
| 06:30 | djpowell | has 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:30 | LauJensen | ~rdfm |
| 06:30 | clojurebot | Titim gan éirí ort. |
| 06:30 | LauJensen | djpowell: Sorry, no idea |
| 06:52 | djpowell | rhickey: 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:20 | ambient | btw is there any natural language processing library for clojure in existance? |
| 07:20 | ambient | i guess it would have to work through java interop... |
| 07:22 | ambient | or 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:25 | triyo | I 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:26 | triyo | *getOpenStream = openStream |
| 07:28 | liwp | triyo: what happens if you do (parse (.openStream *url*))? |
| 07:28 | liwp | btw. the function is clojure.xml/parse not clojure/xml.parse |
| 07:29 | triyo | liwp: works fine...so is that a bug in the binding part of the clojure/xml.parse function or am I missing something? |
| 07:30 | liwp | based on the exception message is sounds like you're trying to call parse as a method on the InputStream |
| 07:30 | liwp | so (parse (.openStream *url*)) works but (parse (.openStream *url*) myparser) does not work? |
| 07:31 | triyo | thanks about ...xml/parse |
| 07:32 | liwp | triyo: 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:32 | liwp | did that help then? |
| 07:32 | liwp | or is it still broken? |
| 07:32 | triyo | and yes, parse (.openStream *url*)) works but (parse (.openStream *url*) myparser) does not |
| 07:33 | liwp | hmm |
| 07:33 | liwp | ,(doc clojure.xml/parse) |
| 07:33 | clojurebot | "([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:33 | liwp | so what's myparse then? |
| 07:33 | Fossi | why in hell is a regex a special datatype? |
| 07:34 | triyo | the way I see it, I call clojure.xml/parse with 2 parameters, 1st: InputStream and 2nd: the parsers to use |
| 07:35 | liwp | triyo: well based on the doc string the second arg is a fn that returns a parser |
| 07:35 | triyo | (parse "/path/to/local/file" myparser) works |
| 07:36 | liwp | so it would seem that myparser is fine |
| 07:36 | liwp | sorry, I don't have any more ideas - I'm going for lunch now |
| 07:36 | Fossi | ok, they are a reader macro. that's a little more sane |
| 07:37 | triyo | I have (:use clojure.xml) :) |
| 07:38 | triyo | then call parse function |
| 07:42 | triyo | clojure.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:04 | AWizzArd | ~seen kotarak |
| 08:04 | clojurebot | kotarak was last seen quiting IRC, 5534 minutes ago |
| 08:04 | AWizzArd | ,(/ 5534 60.0) |
| 08:04 | clojurebot | 92.23333333333333 |
| 08:04 | AWizzArd | ,(/ *1 24) |
| 08:04 | clojurebot | java.lang.IllegalStateException: Var clojure.core/*1 is unbound. |
| 08:05 | AWizzArd | ,(/ 92.2333333 24) |
| 08:05 | clojurebot | 3.8430555541666664 |
| 08:21 | bpattiso1 | BUILD FAILED |
| 08:21 | bpattiso1 | /home/bpattison/opt/fnparse/clojure-build.xml:86: Could not find clojure.lang.Compile. Make sure you have it in your classpath |
| 08:22 | bpattiso1 | ^^^ i'm getting the above from ant |
| 08:23 | bpattiso1 | any ideas? i've set the CLASSPATH to clojure .jar files but still get same error |
| 08:24 | Chouser | setting the CLASSPATH env var often has no effect since it's overridden by the command line |
| 08:25 | bpattiso1 | so there's an "ant" option to set the classpath -- unfortunately i'm not that familiar with ant |
| 08:29 | Chouser | me either. you might check the .xml file to see if in mentions a setting for the classpath. |
| 08:29 | Chouser | like I know the contrib .xml file has you set -Dclojure.jar=... on the ant command line. |
| 08:30 | bpattiso1 | i'll try that -- thanks |
| 08:53 | bpattiso1 | Chouser: a variation of the -D option worked! thanks |
| 08:58 | Chouser | bpattiso1: great. |
| 09:19 | lisppaste8 | raphinou pasted "looking for feedback on this code" at http://paste.lisp.org/display/86499 |
| 09:20 | raphinou | I just pasted working code, but as I'm new to lisp like languages, I'm looking for feedback on how to improve it |
| 09:20 | raphinou | if someone has too much time... ;-) |
| 09:24 | Chouser | looks fine to me, for whatever that's worth. |
| 09:25 | Chouser | the use of closures seems good |
| 09:25 | Chouser | you could clean up the formatting a little. *shrug* |
| 09:25 | Chousuke | raphinou: Great work not using . directly! What's with the extra spaces though? |
| 09:26 | raphinou | yes, I should take a better habit of formatting from the start.... |
| 09:27 | AWizzArd | Is there somewhere a good explanation of what ensure is doing? Good in the sense that it is targeted at idiots :) |
| 09:27 | Chouser | AWizzArd: what it does, or what it's for? |
| 09:27 | AWizzArd | second |
| 09:28 | AWizzArd | When should I use it? |
| 09:28 | Chouser | AWizzArd: you searched the google group? It's come up a couple times. |
| 09:28 | AWizzArd | I did that in the past, and at that time there were not too many entries. I can try it again now. |
| 09:28 | AWizzArd | I just had a dosync which won't work without ensure. |
| 09:29 | Chouser | you only need ensure when the behavior of your transaction depends on the value of a ref that you do not set. |
| 09:29 | Chouser | that you do not set within the transaction. |
| 09:30 | AWizzArd | When I read a value V in my transaction and depend on it, but without modifying V itself? |
| 09:30 | Chousuke | yeah. |
| 09:30 | Chouser | a ref V, yeah |
| 09:30 | AWizzArd | ok, then I will see where I had this case |
| 09:31 | AWizzArd | It must have been at least one path |
| 09:47 | AWizzArd | ,(+ nil) |
| 09:47 | clojurebot | nil |
| 09:49 | AWizzArd | hmm, why is it good that (+ nil) ==> nil? |
| 09:50 | Chouser | because (+ anything) is anything |
| 09:50 | Chouser | ,(+ nil 5) |
| 09:50 | clojurebot | java.lang.NullPointerException |
| 09:50 | AWizzArd | It is fine that: |
| 09:50 | AWizzArd | ,(+) |
| 09:50 | clojurebot | 0 |
| 09:50 | AWizzArd | but (+ nil) I find strange |
| 09:51 | AWizzArd | ,(+ "test") |
| 09:51 | clojurebot | java.lang.ClassCastException |
| 09:52 | Chouser | ok, a related question: why does it matter at all what (+ nil) does? |
| 09:52 | AWizzArd | Someone asked me today for a simple example that would produce a NPC. I wanted to show him, but... |
| 09:53 | Chouser | call any method on nil |
| 09:53 | AWizzArd | (.append nil) |
| 09:53 | AWizzArd | ,(.append nil) |
| 09:53 | clojurebot | java.lang.NullPointerException |
| 09:53 | AWizzArd | ,(.append nil "world) |
| 09:53 | clojurebot | EOF while reading string |
| 09:53 | AWizzArd | ,(count nil) |
| 09:53 | clojurebot | 0 |
| 09:53 | Chouser | ,(.i-just-made-this-up nil) |
| 09:53 | clojurebot | java.lang.NullPointerException |
| 09:54 | Chouser | or call nil itself |
| 09:54 | Chouser | ,((identity nil)) |
| 09:54 | AWizzArd | ,(nil) |
| 09:54 | clojurebot | java.lang.IllegalArgumentException: Can't call nil |
| 09:54 | clojurebot | java.lang.NullPointerException |
| 09:54 | AWizzArd | Now I also find it strange and incorrect that (count nil) ==> 0 |
| 09:55 | Chouser | well, if the Compiler can tell it's nil it won't even compile it. |
| 09:55 | AWizzArd | In CL it makes sense, because nil is the empty list. |
| 09:55 | Chouser | I don't understand why you would want things to generate more errors than necessary. |
| 09:56 | AWizzArd | error detection |
| 09:56 | AWizzArd | ,(count (get {:a []} :a) |
| 09:56 | clojurebot | EOF while reading |
| 09:56 | AWizzArd | ,(count (get {:a []} :a)) |
| 09:56 | clojurebot | 0 |
| 09:57 | AWizzArd | ,(count (get {:a []} :x)) |
| 09:57 | jdz | "nothing" has exactly zero elements in it, right? |
| 09:57 | clojurebot | 0 |
| 09:57 | AWizzArd | jdz: this is also true for 15 |
| 09:57 | AWizzArd | ,(count 15) |
| 09:57 | clojurebot | java.lang.UnsupportedOperationException: count not supported on this type: Integer |
| 09:57 | AWizzArd | A 15 contains no elements |
| 09:58 | Chouser | ,(map count (take 5 (iterate next [1 2 3 4]))) |
| 09:58 | clojurebot | (4 3 2 1 0) |
| 09:58 | jdz | yes, nil is "nothing", so it does not make sens to do any operations on it except testing whether something is nil... |
| 09:59 | AWizzArd | right |
| 09:59 | jdz | Chouser: why next? |
| 10:00 | jdz | nil is not a sequence |
| 10:00 | jdz | so it makes sense for count not to work on it |
| 10:00 | AWizzArd | I would agree with that right now. |
| 10:00 | Chouser | ,(conj nil 5) |
| 10:00 | clojurebot | (5) |
| 10:01 | jdz | ,(map count (take 5 (iterate rest [1 2 3 4]))) |
| 10:01 | clojurebot | (4 3 2 1 0) |
| 10:01 | Chouser | ,(cons :foo nil) |
| 10:01 | clojurebot | (:foo) |
| 10:01 | jdz | that conj call also is a stretch |
| 10:02 | jdz | cons, otoh, is perfectly normal |
| 10:02 | AWizzArd | ,(cons :foo (get {} :x)) |
| 10:02 | clojurebot | (:foo) |
| 10:02 | AWizzArd | ,(cons :foo (get {:x (list :xyz} :x)) |
| 10:02 | clojurebot | Unmatched delimiter: } |
| 10:02 | AWizzArd | ,(cons :foo (get {:x (list :xyz)} :x)) |
| 10:02 | clojurebot | (:foo :xyz) |
| 10:02 | Chouser | when 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:02 | AWizzArd | and more holes for type errors |
| 10:03 | Fossi | pff, who writes code with type errors anyway? ;) |
| 10:03 | AWizzArd | Humas ;) |
| 10:03 | AWizzArd | Humans |
| 10:04 | Raynes | Androids. |
| 10:04 | Chouser | If you had to explicitly handle nil in a bunch of cases, you'd have just as many holes as now. |
| 10:05 | Chouser | and you'd have to handle them in all cases instead of just the cases where the current default isn't what you want. |
| 10:05 | Chouser | current behavior |
| 10:05 | AWizzArd | why is |
| 10:05 | AWizzArd | ,(+ 5 nil) |
| 10:05 | clojurebot | java.lang.NullPointerException |
| 10:05 | AWizzArd | good then? |
| 10:05 | Chouser | AWizzArd: what would be the reasonable default there? |
| 10:06 | jdz | rule of thumb: nil is treated as an empty sequence if given to functions expecting sequences. |
| 10:06 | Fossi | IllegalArgument :) |
| 10:07 | Chouser | jdz: right. and returned by a subset of functions that return sequences |
| 10:12 | triyo | Chouser: 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:13 | triyo | *sescribed = describe |
| 10:16 | triyo | (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:19 | Chouser | hm... |
| 10:21 | Chouser | that really is an old post. I had been using Clojure for about 3 weeks at that point... |
| 10:23 | triyo | hehe, like me now, :) |
| 10:25 | AWizzArd | I 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:25 | triyo | I 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:26 | Chouser | triyo: note that tagsoup takes a org.xml.sax.InputSource |
| 10:26 | Chouser | that's what you're passing in? |
| 10:26 | Chouser | oh |
| 10:27 | Chouser | right. URL is returning you a java.io.InputStream. Different class |
| 10:28 | Chouser | triyo: note InputSource vs. InputStream |
| 10:29 | Chouser | fortunately InputSource has a ctor that takes an InputStream |
| 10:29 | triyo | I ran (show parser-instance) and confirmed that parse(InputStream) exists on org.ccil.cowan.tagsoup.Parser |
| 10:29 | Chouser | (parse (org.xml.sax.InputSource. (.openStream *url*)) startparse-tagsoup) |
| 10:31 | Chouser | triyo: I see InputSource and String overloads, nothing else. What version of tagsoup? |
| 10:31 | Chouser | I'm looking at 1.2 |
| 10:49 | inverselimit | newbie q: are there LAPACK bindings for clojure? |
| 10:55 | Chouser | inverselimit: never heard of it, but you might be able to use http://icl.cs.utk.edu/f2j/ |
| 11:20 | icylisper | any way to destructure-bind like (def [a b] (values a b)) , without using let ? |
| 11:21 | Chouser | I don't think so. |
| 11:21 | stuartsierra | No, you'd need a wacky macro to do that. |
| 11:22 | icylisper | Chouser: perhaps a macro destruct (destruct [a b] (values a b)) |
| 11:22 | icylisper | yeah |
| 11:22 | icylisper | something like cl's m-v-b |
| 11:23 | Chouser | sure, destructuring in general is used in places where one might use m-v-b in CL |
| 11:23 | Chouser | but def doesn't destructure. I suppose it could, though. |
| 11:24 | stuartsierra | def is complicated enough, I think |
| 11:24 | Chouser | def isn't even a macro :-) |
| 11:24 | icylisper | Chouser: true. it would be cool if it did :) |
| 11:45 | Fossi | it isn't really obvious that binding does not have the let* property of binding in the same order |
| 11:46 | stuartsierra | this has been brought up before |
| 11:46 | Fossi | caused some headscratching here for a while |
| 11:47 | Fossi | i get why, but i guess there could be a hint about it in the api docs |
| 11:47 | stuartsierra | yes |
| 11:48 | rhickey_ | patch welcome for doc |
| 11:49 | stuartsierra | http://www.assembla.com/spaces/clojure/tickets/152 |
| 11:49 | stuartsierra | i'll write a patch |
| 11:56 | stuartsierra | patch attached to #152 |
| 12:01 | lisppaste8 | drewr pasted "json-object-seq" at http://paste.lisp.org/display/86503 |
| 12:02 | drewr | stuartsierra: think there's a place for j-o-s in c.c.json.read? |
| 12:02 | drewr | maybe just json-seq? |
| 12:02 | drewr | I'm serializing a bunch of objects to files and need to read them in lazily |
| 12:03 | stuartsierra | I can see where that would be useful. |
| 12:03 | stuartsierra | How do you make sure the file gets closed? |
| 12:03 | drewr | ah, good question |
| 12:03 | rhickey_ | stuartsierra: fyi - I'm working on Clojure data structure serialization to/from RDF stores |
| 12:04 | drewr | stuartsierra: have to wrap in a with-open by hand I guess |
| 12:04 | stuartsierra | rhickey_: Awesome! Tell me more. |
| 12:05 | rhickey_ | 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:05 | lisppaste8 | drewr annotated #86503 "caller needs with-open" at http://paste.lisp.org/display/86503#1 |
| 12:06 | rhickey_ | everything gets flattened to triples, so you can query etc |
| 12:06 | rhickey_ | does automatic creation of bnodes for "owned" nested elements, or you can have external refs via URIs |
| 12:06 | rhickey_ | does multimap-style handling of sets as values |
| 12:07 | stuartsierra | rhickey_: Very, very interesting. |
| 12:07 | rhickey_ | can store keywords as values and use as properties |
| 12:07 | stuartsierra | What do you mean by multimap-style? |
| 12:07 | rhickey_ | handles all the atomic types as values |
| 12:08 | rhickey_ | {: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:08 | stuartsierra | That's good. |
| 12:09 | rhickey_ | there will be an rdfm/assoc* which does that set-aware association |
| 12:09 | stuartsierra | How do you map between Clojure keywords and RDF predicates? |
| 12:10 | rhickey_ | 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:10 | lisppaste8 | stuartsierra annotated #86503 "Simpler" at http://paste.lisp.org/display/86503#2 |
| 12:11 | rhickey_ | http://org.clojure/keywords/your-ns/your-key |
| 12:11 | drewr | stuartsierra: nice |
| 12:11 | rhickey_ | you can use strings as keys too, will be presumed a valid URI |
| 12:12 | stuartsierra | rhickey_: Ok. So I could (def dctitle "http://purl.org/dcterms/title") |
| 12:12 | rhickey_ | stuartsierra: yes, np, I looked at what you were doing putting URI strings into vars and look to support it |
| 12:12 | rhickey_ | you can mix and match |
| 12:13 | stuartsierra | Cool. Having a 1-to-1 mapping between Clojure data structures and RDF would make my day/month/year, I think. |
| 12:13 | rhickey_ | vectors become collections with rdf:_nnn properties |
| 12:13 | stuartsierra | ok |
| 12:13 | stuartsierra | Lists are rdf:List, I assume. |
| 12:13 | rhickey_ | metadata supported for maps |
| 12:14 | rhickey_ | I don't do lists or sets-as-collections yet |
| 12:14 | stuartsierra | ok |
| 12:14 | rhickey_ | restoring rdf:Lists is extremely piggy |
| 12:14 | stuartsierra | Sets as multiple properties makes more sense to me. |
| 12:15 | stuartsierra | Yes, I got annoyed trying to deal with rdf:List. I thought it would be easy. |
| 12:15 | rhickey_ | yes, as map members sets become multiple props, but as vector members not |
| 12:15 | stuartsierra | Ok, this makes sense. |
| 12:15 | clojurebot | this is not a bug |
| 12:16 | stuartsierra | What about literal datatypes? |
| 12:16 | rhickey_ | plus I will support (rdfm/assoc a-stored-vec i new-val) |
| 12:16 | rhickey_ | int/long/float/double/bigint/bigdec/boolean/calendar/string/keyword |
| 12:17 | rhickey_ | will add symbols |
| 12:17 | stuartsierra | How about things that don't map directly to Clojure/Java types, like "my string"@en? |
| 12:17 | rhickey_ | and (rdfm/conj a-stored-vec an-additional-val) |
| 12:18 | rhickey_ | stuartsierra: the objective of the library is definitely leveraging RDF stores to store Clojure data, not interop with RDF data |
| 12:18 | stuartsierra | Ok, fair enough. |
| 12:19 | rhickey_ | when reading back "my string"@en what would you expect to be returned? |
| 12:20 | stuartsierra | Best I could come up with is {:type :literal :value "my string" :language "en"} |
| 12:20 | rhickey_ | hmm |
| 12:21 | stuartsierra | This is the problem with every RDF library; some parts don't quite match any typical language constructs. |
| 12:21 | Chouser | #^{:language "en"} "my string" |
| 12:21 | Chouser | if only |
| 12:21 | rhickey_ | The library uses the Sesame API, which seems pretty widely supported - AllegroGraph, Virtuoso as well as Sesame. |
| 12:22 | stuartsierra | Sesame and Jena are probably the two big ones. |
| 12:22 | stuartsierra | The secondary layers like JRDF don't seem to add much. |
| 12:24 | rhickey_ | once the data is in you can use sparql etc to query it |
| 12:24 | stuartsierra | Are you using Sesame 1.x or 2.x? |
| 12:25 | rhickey_ | 2.x |
| 12:26 | stuartsierra | ok |
| 12:36 | winterstream | Hi 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:39 | Chouser | ,(into-array [-2.0 1.0]) |
| 12:39 | clojurebot | #<Double[] [Ljava.lang.Double;@1ade7f6> |
| 12:39 | Chouser | That's an array of Double not double |
| 12:39 | Chouser | ,(into-array Double/TYPE [-2.0 1.0]) |
| 12:39 | clojurebot | #<double[] [D@1cc903c> |
| 12:39 | Chouser | try that instead |
| 12:40 | winterstream | Ah |
| 12:40 | winterstream | Chouser: thanks! It works! |
| 12:43 | drewr | wow, that's confusing |
| 12:44 | stuartsierra | Boxed primitives are an unfortunate legacy feature of the JVME. |
| 12:44 | stuartsierra | *JVM |
| 12:44 | ole3 | how to convert an java array to a string? |
| 12:46 | stuartsierra | If it's an array of chars, (String. the-array) |
| 12:46 | stuartsierra | or bytes, (String. the-array "UTF-8") |
| 12:49 | ole3 | (make-array byte 2) |
| 12:50 | ole3 | oops |
| 12:50 | stuartsierra | ,(make-array Byte/TYPE 2) |
| 12:50 | clojurebot | #<byte[] [B@1ebaf3> |
| 12:50 | ole3 | :) thank you |
| 12:51 | ole3 | by the way, what's the difference between (new String ...) and (String. ....) |
| 12:59 | cschreiner | how can I test for a {} structure in my data? |
| 12:59 | drewr | ,(map? {:foo 1}) |
| 12:59 | clojurebot | true |
| 12:59 | cschreiner | ah |
| 12:59 | cschreiner | it is always so easy... |
| 13:00 | drewr | well, the easy things are :-) |
| 13:04 | stuartsierra | ole3: (String. ...) is syntactic sugar for (new String ...) |
| 13:04 | stuartsierra | Any EMACS fans know how to open a file in the *subdirectory* under point in a dired buffer? |
| 13:08 | drewr | C-x C-f then use completion? |
| 13:09 | drewr | it'll start in the current dired directory |
| 13:09 | stuartsierra | Right, 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:10 | drewr | if you've traversed to baz then find-file will be local to that dir |
| 13:11 | stuartsierra | Not if I've traversed to baz using dired-maybe-insert-subdir (bound to "i") |
| 13:11 | eyeris | Is 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:12 | drewr | stuartsierra: ah, that's different :-) |
| 13:13 | stuartsierra | My dired buffer looks like this: http://paste.lisp.org/+1UQZ |
| 13:14 | Chousuke | eyeris: update-in |
| 13:14 | eyeris | ty |
| 13:14 | Chousuke | it takes a seq of keys though :) |
| 13:15 | drewr | stuartsierra: you can't hit RET on the baz so that it's not a subdir at that point? |
| 13:15 | Chousuke | ,(update-in {:a 1 :b 2 :c {:a 3}} [:c :a] inc) |
| 13:15 | clojurebot | {:a 1, :b 2, :c {:a 4}} |
| 13:16 | stuartsierra | drewr: doesn't work if I hit RET on the subdir header line, works if I go up one parent and then hit RET |
| 13:16 | drewr | that's what I mean |
| 13:17 | drewr | i... i... i.... RET C-x C-f |
| 13:17 | drewr | at worst, ^ RET C-x C-f |
| 13:18 | stuartsierra | drewr: Yeah, just want it to be one key. Hmph. I guess I could write it. |
| 13:25 | lisppaste8 | stuartsierra pasted "dired-find-file-in-subdir" at http://paste.lisp.org/display/86509 |
| 14:00 | LauJensen | How do you define a 'triple' data structure? |
| 14:05 | Chouser | LauJensen: that's an RDF thing |
| 14:06 | Chouser | LauJensen: http://www.w3.org/TR/rdf-concepts/#section-triples |
| 14:06 | LauJensen | Thanks a lot |
| 14:07 | eyeris | How do I control which defs are exported from my namespace? |
| 14:07 | Chouser | eyeris: all vars are public unless marked private |
| 14:08 | Chouser | eyeris: you can use defn- or #^{:private true} to mark a var as private |
| 14:09 | eyeris | Okay |
| 14:09 | eyeris | Thanks |
| 14:25 | Chouser | ok, that's fun. (rseq ft) returns a thing just like ft except with cons/first/rest swapped for conj/peek/pop |
| 14:26 | Chouser | so 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:26 | Chouser | that is, both seq and rseq just return another finger-tree, not a cursor type of any kind. |
| 14:37 | eyeris | I swear I will never understand the rules for the ns macro |
| 14:37 | Chouser | :-( |
| 14:37 | eyeris | If I want to :use two namespaces, what is the syntax? |
| 14:37 | Chouser | (ns foo (:use [ns1 :only []] [ns2 :only []])) |
| 14:38 | eyeris | Okay, that works. |
| 15:14 | LauJensen | What is this obession that the chinese have for accessing /fastenv on my webserver ? |
| 15:15 | eyeris | LauJensen sounds like they're probing for a FastCGI vulnerability |
| 15:15 | LauJensen | oh ok - amazing perseverance |
| 15:15 | eyeris | Just a guess. |
| 15:15 | lisppaste8 | stuartsierra annotated #86509 "better dired-find-file-in-subdir" at http://paste.lisp.org/display/86509#1 |
| 15:21 | lisppaste8 | stuartsierra annotated #86509 "binding it to a key in dired" at http://paste.lisp.org/display/86509#2 |
| 15:23 | LauJensen | stuartsierra: ido aint doing for you ? |
| 15:23 | stuartsierra | LauJensen: what do you mean? What's ido? |
| 15:24 | LauJensen | ido-find-file, what I type back, and it auto completes to ~/home/coding/lisp/projects/clojureql/src/dk/bestinclass/backend.clj ? |
| 15:24 | LauJensen | s/what/where |
| 15:25 | LauJensen | I keeps a history of all your files, and whenever you type something, it finds the file |
| 15:25 | LauJensen | s/I/It |
| 15:26 | stuartsierra | ok, didn't know about that one. But no, I wanted something for opening a new file that doesn't exist yet. |
| 15:27 | LauJensen | ah ok |
| 16:42 | LauJensen | Is there any hope on the horizon for a quality UI toolkit for Java? |
| 16:50 | slyrus_ | LauJensen: hasn't there been hope for years now? |
| 16:51 | LauJensen | nope |
| 16:51 | LauJensen | I got my hopes up a little bit with the entrace of QtJambi - but then that died |
| 16:52 | stuartsierra | There's probably a good commercial toolkit out there. |
| 16:53 | slyrus_ | 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:53 | LauJensen | slyrus_: nope, sorry |
| 16:55 | hiredman | what is the problem with swing? |
| 16:56 | LauJensen | its ugly, its laggy, its unflexible |
| 16:57 | hiredman | laggy? |
| 16:58 | LauJensen | Its does not perform well |
| 16:58 | Chousuke | hm. |
| 16:58 | Chousuke | I'm not sure if that's swing's fault. |
| 16:58 | Chousuke | or just that people misuse it. :/ |
| 16:58 | LauJensen | Its swing |
| 16:59 | LauJensen | But Im not here to discuss swing, I was just probing for some new technological innovations |
| 17:01 | hiredman | the #java guys seem pretty happy with swing |
| 17:01 | LauJensen | They must not know better |
| 17:01 | hiredman | so what is better than swing, and why is it better? |
| 17:01 | Chousuke | LauJensen: with quick googling I can't find any resource that claims swing as particularly slow |
| 17:02 | LauJensen | hiredman: 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:02 | LauJensen | I'd say the only thing thats not better is GTK |
| 17:02 | stuartsierra | I 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:03 | stuartsierra | LauJensen: but both Aqua and MFC are single-platform products, Swing is trying to work everywhere. |
| 17:03 | hiredman | LauJensen: the visual studio comment makes it sound like a tools issue |
| 17:03 | LauJensen | stuartsierra: Doesnt change the user-perception |
| 17:04 | Chousuke | I think Swing may have an undeservedly bad reputation. :/ |
| 17:04 | Chousuke | just like Java has :P |
| 17:04 | stuartsierra | LauJensen: agreed, but that may explain why it's harder to do GUIs well in Swing than in Aqua or MFC. |
| 17:04 | LauJensen | hiredman: its a little bit of both |
| 17:04 | hiredman | I am inclined to agree with Chousuke |
| 17:05 | LauJensen | stuartsierra: Sure, but I'm cynical enough not to care, I just want somethings thats high quality :) |
| 17:05 | LauJensen | I'd go as far as to say that the UI side of things, is my only dark cloud over Clojure |
| 17:05 | LauJensen | Rich needs to put emphasis on the eye candy! :) |
| 17:05 | duncanm | if i have a list of maps, each one like {"x" 0 "y" 1}, how do i pluck out all the "x"s? |
| 17:06 | duncanm | ahh |
| 17:06 | duncanm | map! |
| 17:06 | stuartsierra | yep |
| 17:06 | LauJensen | (keys m) ? |
| 17:07 | stuartsierra | (map #(get % "x") list-of-maps) |
| 17:07 | duncanm | stuartsierra: that's exactly what i'm writing now |
| 17:07 | LauJensen | duncanm: this is the simplest way to go |
| 17:07 | LauJensen | ,(doto (java.util.ArrayList. (into [] (mapcat concat (map keys (list {"foo" 2 "bar" 3} {"min" 4 "max" 5}))))) java.util.Collections/shuffle) |
| 17:07 | clojurebot | #<ArrayList [bar, min, foo, max]> |
| 17:08 | LauJensen | nothing will beat that for pure elegance, but you'll get random results :) |
| 17:09 | LauJensen | its a sad day when even my 'code jokes' dont fly... |
| 17:10 | stuartsierra | wasn't sure what you were going for there |
| 17:11 | LauJensen | its not elegant, its not simple, it randomizes the result... just tought it was funny when (map keys ..) was enough |
| 17:11 | arbscht | rest 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:12 | LauJensen | haha |
| 17:13 | LauJensen | ClojureQL rocks - I just did a very awesome combination of compojure+clojureql+googlecharts to auto-generate some very nice stats for www.bestinclass.dk |
| 17:53 | Chousuke | hm. |
| 17:54 | Chousuke | just 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:54 | Chousuke | it has a small blue square that I can move around the screen with arrow keys. my drawing code was rather idiotic though... |
| 17:55 | Chousuke | (holding down an arrow key caused java to have over 100% CPU utilisation in top) |
| 17:56 | Chousuke | so I rewrote the code to be a bit smarter and now it uses ~7-10% :P |
| 17:56 | aack | \join #lisp |
| 17:56 | Chousuke | My dream is to write a small roguelike in Clojure at some point but first I really need to learn swing better :) |
| 17:58 | Chousuke | but 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:58 | Chousuke | it'd be neat to make a game by playing it :) |
| 17:58 | hiredman | Chousuke: you should make a clojure version of ruby-warrior http://github.com/ryanb/ruby-warrior/tree/master |
| 18:00 | tomoj | swing? :( |
| 18:00 | tomoj | it's really too bad java sucks at the console |
| 18:01 | tomoj | my dream is to write a messaging client, but it needs to run in screen |
| 18:01 | Chousuke | yeah, I couldn't find any terminal drawing stuff :/ |
| 18:02 | technomancy | Chousuke: you should try clj-processing |
| 18:02 | technomancy | it's a lot of fun |
| 18:02 | tomoj | I found jcurses but my tentative judgement is that it sucks |
| 18:02 | technomancy | ~processing |
| 18:02 | clojurebot | processing is a language/toolkit for visualizations. See the Clojure wrapper at http://github.com/rosado/clj-processing/ |
| 18:02 | hiredman | http://github.com/ryanb/ruby-warrior/tree/master |
| 18:02 | technomancy | incanter (the stats package) is migrating towards that |
| 18:02 | hiredman | er |
| 18:03 | hiredman | http://www.pitman.co.za/projects/charva/Screenshots.html "A Java Windowing Toolkit for Text Terminals" |
| 18:03 | tomoj | haven't tried that one yet |
| 18:04 | tomoj | my 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:04 | tomoj | maybe you can manipulate charva into being more minimal.. |
| 18:04 | spaceman_stu | is there a good way to implement type-specific versions of already defined fns? like count for an unsupported type |
| 18:05 | tomoj | spaceman_stu: I was just thinking about exactly that while walking home |
| 18:05 | tomoj | afaik, no |
| 18:05 | spaceman_stu | bummer |
| 18:06 | tomoj | I 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:06 | spaceman_stu | yeah, I was thinking about that |
| 18:06 | tomoj | but that doesn't seem like a good idea to me |
| 18:06 | technomancy | spaceman_stu: for things that are based on interfaces it's not hard to do |
| 18:06 | technomancy | but I don't think count is |
| 18:06 | technomancy | it's easy to proxy something like IMeta though |
| 18:07 | tomoj | oh, hmm, I hadn't thought about that |
| 18:07 | tomoj | I suppose you can also act like seqs, too? |
| 18:07 | tomoj | was trying to think of how to translate some python into clojure, and the python has objects that duck-type as lists |
| 18:07 | technomancy | actually, count does work on an interface |
| 18:07 | technomancy | just implement clojure.lang.Counted and write a count method |
| 18:08 | tomoj | I dunno if I'm happy using a java type, though :/ |
| 18:08 | Chousuke | ,(count (proxy [clojure.lang.Counted] [] (count [] 5))) |
| 18:08 | Chousuke | hmm |
| 18:08 | technomancy | docs say you have to guarantee constant-time counts; not sure how important that is |
| 18:11 | tomoj | is = linear in the size of the data structure? |
| 18:13 | stuartsierra | I think = checks hashes first, so it's constant if the structures are not equal, linear if they are. |
| 18:14 | stuartsierra | But (= (iterate inc 0) (iterate inc 0)) will not terminate. |
| 18:15 | technomancy | infinity is a constant. =) |
| 18:15 | tomoj | ah, but if you have a proxy like above, it'll use the default equals() from java and = will just compare the reference, right? |
| 18:16 | tomoj | but then, if you memoize a function call on that reference, you still prevent it from being garbage collected, I suppose. hrmmm |
| 19:10 | somnium | can clj-haml generate the xml? (would shave off 50-100 characters at least) |
| 19:12 | tomoj | hrmm |
| 19:12 | tomoj | trying to figure out how to write python's re.findall in clojure |
| 19:12 | tomoj | java.util.regex.Matcher wants you to call .find and then .group to get the next match |
| 19:14 | Chousuke | re-seq? |
| 19:14 | Chousuke | (doc re-seq) |
| 19:14 | clojurebot | "([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:15 | tomoj | oh |
| 19:15 | tomoj | damn |
| 19:15 | tomoj | missed that one, thanks :D |
| 19:17 | tomoj | the source is illuminating |
| 19:17 | tomoj | I was trying to do something like that but couldn't quite get it |
| 19:22 | tomoj | so anonymous functions can't call themselves if the recur needs to be not in tail position? |
| 19:22 | tomoj | I mean, without writing a Y combinator |
| 19:23 | Chouser | you can give a function an internal-only name |
| 19:23 | tomoj | right, yeah. but then I tried to switch it to anonymous, and couldn't because I need to recur but not in tail position |
| 19:23 | Chouser | ((fn zeros [] (lazy-seq (cons 0 (zeros))))) |
| 19:24 | Chouser | that name "zeros" isn't available externally, so in that sense it's "anonymous". |
| 19:24 | hiredman | ,((fn a [x] (if (zero? x) x (a (dec x)))) 1) |
| 19:24 | clojurebot | 0 |
| 19:24 | tomoj | I guess this is why the Y combinator exists |
| 19:24 | hiredman | … |
| 19:24 | Chouser | I guess I'm not quite sure what you're asking. 'recur' can only be used in tail position. |
| 19:25 | tomoj | right, 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:25 | hiredman | tomoj: Yes |
| 19:25 | tomoj | but that would be a silly thing to have just to avoid giving a name |
| 19:25 | hiredman | ,((fn a [x] (if (zero? x) x (a (dec x)))) 1) |
| 19:25 | clojurebot | 0 |
| 19:25 | tomoj | hiredman: yeah, I meant truly anonymous |
| 19:25 | tomoj | as in, unnamed |
| 19:25 | hiredman | it is anonymous |
| 19:26 | hiredman | a is just the equivilant of the 'this' pointer |
| 19:26 | Chousuke | even an anonymous person has something to refer to himself. :P |
| 19:27 | tomoj | well, sure, like 'this' or 'self' |
| 19:27 | tomoj | but we don't have that |
| 19:27 | hiredman | I think, in fact, at some point all functions just bound to thisfn |
| 19:27 | hiredman | tomoj: #$%!@#%$% |
| 19:27 | hiredman | we do |
| 19:27 | hiredman | (fn a []) |
| 19:27 | Chousuke | tomoj: sure we do. (fn self [] (self)) |
| 19:27 | Chousuke | tomoj: just like in python. :P |
| 19:27 | hiredman | if you put a symbol after a, inside the scope of the function, the function is bound to a |
| 19:27 | tomoj | right but if you change the name there, you have to go through and change the calls |
| 19:27 | tomoj | not that this is a real problem |
| 19:27 | Chousuke | tomoj: just like in python :) |
| 19:27 | hiredman | … |
| 19:28 | tomoj | "recur" is always the same nomatter the function name or whether you've even given it a name |
| 19:28 | Chouser | tomoj: just always use (fn thisfn [] ...) and you'll never have to rename your internal uses of thisfn. |
| 19:28 | tomoj | but yeah, this isn't actually a problem, I will just put a name there :) |
| 19:29 | tomoj | Chouser: true |
| 19:29 | Chouser | tomoj: you do know that 'recur' behaves differently from a self-call in the tail position? |
| 19:29 | hiredman | fn used to bind thisfn, before it got the ability to bind any name you choose |
| 19:29 | tomoj | Chouser: yeah |
| 19:29 | tomoj | Chouser: I was wondering if there was something that behaved like a self-call but didn't require giving a name |
| 19:29 | tomoj | not binding thisfn is really better, I suppose |
| 19:30 | tomoj | (now I realize what I was asking was whether thisfn existed) |
| 19:31 | Chouser | the problem with thisfn was when you had nests fns and wanted to call the outer one. |
| 19:32 | tomoj | I guess it's unlikely that you'd be using the name "thisfn" elsewhere |
| 19:32 | tomoj | but hygiene is good |
| 19:32 | tomoj | I could always write afn which binds thisfn |
| 19:45 | tomoj | ,(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:45 | clojurebot | 120 |
| 19:45 | tomoj | :D |
| 19:49 | tomoj | or better, |
| 19:49 | tomoj | ,(((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:49 | clojurebot | 120 |
| 19:52 | somnium | is that maintainable? |
| 19:53 | tomoj | well it could be more maintainable |
| 19:53 | tomoj | but clojurebot wants everything in one expr |
| 19:53 | tomoj | Y never needs to change, and if you separate it out it becomes much cleaner |
| 19:53 | tomoj | (but still useless) |
| 19:54 | technomancy | there's no function to translate between hyphen-case and camelCase, is there? |
| 19:54 | Chouser | hm, I think I wrote one... |
| 20:12 | Chouser | nm. I found what I was thinking of but it's broken or something. |
| 21:46 | prospero_ | is there a function that says whether something is IMeta? |
| 21:46 | prospero_ | meta? or metable or something |
| 21:48 | Chouser | I don't think so. just 'instance?' |
| 21:48 | Chouser | ,(instance? clojure.lang.IMeta []) |
| 21:48 | clojurebot | true |
| 21:48 | Chouser | ,(instance? clojure.lang.IMeta "") |
| 21:48 | clojurebot | false |
| 21:48 | prospero_ | ok, just wondering if there was a way less tied to the implementation |
| 21:50 | Chouser | nope, I think that's it. Interfaces aren't really implementation anyway -- they're interface. :-) |
| 21:51 | technomancy | is there a way to programmatically determine if Clojure is running interactively? |
| 21:51 | technomancy | I guess you could check for some of the bindings from the repl function |
| 21:52 | technomancy | it'd be great if environment developers could agree on a unified way of stating this. |
| 21:52 | technomancy | will suggest it on the mailing list. |
| 22:14 | Chouser | it could even include repl provider name and version number |
| 22:14 | Chouser | so that you could differentiate between :enclojure and :core if you really wanted to |
| 23:03 | tomoj | implementing IMeta means the value has metadata? |
| 23:05 | Chouser | right, it means you can call 'meta' on it. |
| 23:41 | duck1123 | This is probably a FAQ I'm missing somewhere, but how do I get my test script to return false on errors? |
| 23:56 | tomoj | huh |
| 23:57 | tomoj | clojure.test? |
| 23:59 | duck1123 | If I run a clojure script that executes clojure.test tests, how do I get the script return a -1 on failure |
| 23:59 | tomoj | oh, hmm |
| 23:59 | tomoj | well you can give a return code with System.exit |
| 23:59 | duck1123 | I build with maven |
| 23:59 | duck1123 | and I'm trying to get the plugin to fail on error |