2008-11-13
| 00:30 | drewc | larrytheliquid: progv |
| 00:30 | drewc | larrytheliquid: ph .. wait .. no |
| 00:36 | drewc | and .. actually .. progv is nothing of the sort@ |
| 00:36 | drewc | s/@/! |
| 00:59 | arohner | how do I convert a clojure string to java.lang.CharSequence[]? |
| 00:59 | arohner | I tried (seq "my string") |
| 01:00 | hiredman | maybe into-array |
| 01:00 | hiredman | hmmm |
| 01:00 | hiredman | or not |
| 01:01 | hiredman | into-array will make a char array out of a seq of chars |
| 01:01 | arohner | yeah |
| 01:02 | hiredman | uh |
| 01:02 | hiredman | CharSequence is an interface |
| 01:02 | hiredman | which String implements |
| 01:03 | hiredman | so you should just be able to pass a clojure string in |
| 01:03 | hiredman | because clojure strings are java strings |
| 01:03 | arohner | I get "java.lang.ClassCastException: java.lang.String" |
| 01:04 | arohner | the signature on the function is 'java.lang.CharSequence...' |
| 01:04 | arohner | which I think means array, but (into-array "my string") should have returned an array of strings of length 1 |
| 01:05 | hiredman | (into-array (cast java.lang.CharSequence "my string")) |
| 01:06 | arohner | java.lang.ClassCastException: [Ljava.lang.Character; |
| 01:07 | arohner | I wish I understood exactly what the ellipsis means in javadocs |
| 01:07 | hiredman | well, I am stumped |
| 01:07 | arohner | it seems to mean array, but I haven't seen that explicitly |
| 01:07 | hiredman | uh |
| 01:07 | hiredman | [] means array |
| 01:08 | arohner | 'An argument type followed by an ellipsis (...) in a method's parameter list indicates that the method receives a variable number of arguments of that particular type. ' |
| 01:09 | hiredman | try the cast without the into-array |
| 01:10 | arohner | same. |
| 01:13 | arohner | got it |
| 01:13 | arohner | (into-array) takes a sequence |
| 01:14 | hiredman | ah |
| 01:14 | arohner | a string by itself is already a seq of chars, so (into-array "my string") returns char[] |
| 01:14 | arohner | to get an array of strings, (into-array ["my string"]) |
| 01:14 | arohner | and I think I already ran into this problem and figured it out once |
| 01:15 | arohner | maybe that's a sign I shouldn't be programming late. |
| 01:15 | arohner | well, thanks for the help. |
| 02:41 | Lau_of_DK | Good morning all |
| 02:44 | danlarkin | you and your gmt+1 |
| 02:50 | Chousuke | heh |
| 02:50 | Chousuke | morning |
| 03:02 | _Jordan_ | (functional programming noob question): Can anyone help me convert my current recursive solution to one that is able to use loop/recur? |
| 03:03 | danlarkin | _Jordan_: most likely you can just change the call to (my-function ...) to (recur ...) |
| 03:03 | danlarkin | if it's a tail-call |
| 03:04 | _Jordan_ | I tried, but apparently it's not tail-call, because it barfed... I still suck at knowing what I'm doing |
| 03:05 | _Jordan_ | but I would be delighted if you could show me how to make it tail-call :) |
| 03:05 | yangsx1 | _Jordan_: then paste your code on http://paste.lisp.org etc |
| 03:07 | _Jordan_ | http://paste.lisp.org/display/70288 |
| 03:09 | jdz | _Jordan_: look at the various Lisp implementations of factorial; there are both straight recursive and tail-recursive versions. |
| 03:12 | yangsx1 | _Jordan_: you need an accumulator to hold the result and return it when the stop condition is satisfied |
| 03:14 | hiredman | you could also turn it into a lazy-seq |
| 03:14 | hiredman | just to throw that out there |
| 03:18 | _Jordan_ | Got it! Thank you everyone! |
| 04:04 | Lau_of_DK | Is anyone here in possession of some type of comparison between Jetty and Apache. Im interesting in how scalable Jetty is |
| 04:31 | tWip | Lau_of_DK: do you mean apache httpd? or apache tomcat or something else |
| 04:32 | Lau_of_DK | httpd |
| 04:34 | tWip | that's a bit of apples vs oranges comparison as they don't have the same features |
| 04:35 | Lau_of_DK | Its not a matter of features per say, its basically a matter of wether or not Jetty can host as large systems as Apache without breaking |
| 04:35 | Lau_of_DK | I'd hate to begin on a project, only to have to abandon it in the first day of deployment |
| 04:35 | Lau_of_DK | @ tWip |
| 04:36 | tWip | well if you are coding in Clojure I don't think you can avoid having a servlet engine |
| 04:37 | Lau_of_DK | But thats the not really the issue :) |
| 04:38 | tWip | Only way to be sure is to do load benchmarking |
| 04:39 | tWip | but I would wager that the plain HTTP serving is not going to be the bottleneck in non trivial applications |
| 04:39 | tWip | and you can always use apache/yaws/something else for the static content |
| 04:42 | Lau_of_DK | You mean actually run 2 servers, 1 for servlets 1 for static ? |
| 04:43 | amagee | i'm trying to use a Timer in clojure, but it can't seem to find the 'schedule' method: if i try (. (new Timer) schedule), I get IllegalArgumentException: No matching field found: schedule (etc) |
| 04:43 | amagee | am i doing something really silly? |
| 04:43 | jdz | what about (. (new Timer) (schedule))? |
| 04:43 | tWip | Lau_of_DK: well I usually deploy by running apache on 80, then servlet engine in the non-privileged 8080 port |
| 04:44 | tWip | Lau_of_DK: apache does rewrite proxying to the servlet engine |
| 04:44 | jdz | amagee: or even (.schedule (new Timer)) |
| 04:44 | Lau_of_DK | tWip, thats sounds like the way to go. Have you got a get-me-started guide somewhere? |
| 04:44 | amagee | jdz: both of those give the same error |
| 04:44 | Lau_of_DK | amagee, make an agent and (Thread/sleep x) it for your intervals? |
| 04:45 | tWip | Lau_of_DK: no, not really... just the accumulated knowledge over the years which I haven't documented anywhere |
| 04:45 | jdz | amagee: i don't see any method in Timer class that has no arguments |
| 04:45 | jdz | amagee: i mean, the schedule metod |
| 04:46 | tWip | but I think the apache+mod_rewrite is a common for frontend for many app servers and tutorials should be available on the net |
| 04:46 | amagee | jdz: oh, i can get that error if the method name is right but the argument list is wrong? |
| 04:47 | jdz | amagee: well, i'm not very used to Java exceptions and when they are thrown, but this one apparently means that it was unable to find a schedule method with given argument list (empty) |
| 04:47 | jdz | amagee: hence, no matching member |
| 04:48 | amagee | ah yeah that makes sense |
| 04:48 | Lau_of_DK | amagee: (def a (agent 0)) (defn work [] (println "Running") (Thread/sleep 1000) (send-off a work) |
| 04:48 | Lau_of_DK | missing a few )) maybe :) |
| 04:49 | amagee | ah cool |
| 04:49 | amagee | thanks to both of you :) |
| 04:50 | amagee | Lau_of_DK: is that code supposed to loop indefinitely? |
| 04:50 | Lau_of_DK | it'll run forever :) |
| 04:51 | Lau_of_DK | (def keep-running (ref true)) (defn work [] (when @keep-running (do work)) |
| 04:51 | amagee | hmm when i run it from repl it just prints "Running" once then stops |
| 04:51 | Lau_of_DK | then (dosync (ref-set keep-running false)) to abort |
| 04:51 | Lau_of_DK | Thats probably because println doesnt flush by itself, so (println ..) (flush) might do the trick |
| 04:51 | jdz | Lau_of_DK: i'd consider your proposed solution ugly |
| 04:52 | Lau_of_DK | jdz, oh, how would you go about it ? |
| 04:53 | jdz | Lau_of_DK: i think there is nothing wrong using Timer.schedule. And what's more, your solution will drift off the correct intervals. |
| 04:53 | jdz | *off of |
| 04:53 | jdz | that might not be important, though |
| 04:54 | amagee | Timer.schedule knows to keep to the correct intervals? |
| 04:54 | jdz | amagee: what else does the 'period' parameter mean/ |
| 04:54 | jdz | ? |
| 04:55 | amagee | oh i just didn't know how clever it was |
| 04:55 | jdz | amagee: what kind of documentation are you reading? |
| 04:55 | amagee | i thought it'd be implemented like how Lau_of_DK did it |
| 04:55 | jdz | i just went to java.sun.com and read there |
| 04:56 | jdz | amagee: look at scheduleAtFixedRate method |
| 04:56 | Lau_of_DK | Well, amagee you can use my example for a reference on agents, but like jdz said, Timer/schedule might be more what you want |
| 04:56 | jdz | amagee: it's all stated right there, in the documentation. |
| 04:56 | amagee | ah cool yes that's very nice :) |
| 04:57 | amagee | i didn't know that |
| 04:57 | amagee | so i will use that |
| 04:57 | jdz | amagee: i did not, too, until you mentioned that class. but i bothered to read the documentation. |
| 04:57 | jdz | amagee: and i suggest you do the same |
| 04:57 | amagee | however i still haven't got your agent example working yet |
| 04:57 | amagee | (defn work[] (println "Running") (flush) (Thread/sleep 1000) (send-off a work)) |
| 04:58 | amagee | (work) |
| 04:58 | amagee | just prints "Running" once then goes back to prompt |
| 04:58 | amagee | (i'm just doing this out of interest now) |
| 05:09 | Lau_of_DK | (def a (agent 0)) |
| 05:09 | Lau_of_DK | (defn work |
| 05:09 | Lau_of_DK | [] |
| 05:09 | Lau_of_DK | (println "agent running") |
| 05:09 | Lau_of_DK | (Thread/sleep 1000)) |
| 05:09 | jdz | how about using lisppaste? |
| 05:09 | Lau_of_DK | in repl |
| 05:09 | Lau_of_DK | (send-off a work) |
| 05:11 | amagee | now i get no output |
| 05:12 | Lau_of_DK | just as test, not application for the real world, can you try this |
| 05:12 | Lau_of_DK | (import '(javax.swing JOptionPane)) |
| 05:13 | dnm | Is anyone else trying to use JUnit with Clojure, or am I it? |
| 05:14 | Lau_of_DK | and then instead of println use (JOptionpane/showMessageDialog "Test") |
| 05:14 | Lau_of_DK | my showMessageDialog doesnt follow documentation, so try showInputDialog "test" |
| 05:15 | Lau_of_DK | I retract that, use (JOptionPane/showMessageDialog nil "Test") |
| 05:16 | amagee | (defn work [] (JOptionPane/showMessageDialog nil "Test") (Thread/sleep 1000)) |
| 05:17 | amagee | and then, (send-off a work) .. ? |
| 05:17 | Lau_of_DK | after (def a (agent 0)) |
| 05:17 | Lau_of_DK | yea |
| 05:17 | amagee | does nothing |
| 05:19 | Lau_of_DK | hehe |
| 05:20 | Lau_of_DK | I might have forgot a little something |
| 05:21 | Lau_of_DK | Each loop should end with (send-off *agent* self) where self in this case is 'work' |
| 05:21 | Lau_of_DK | But mine isnt running either, and Im not sure why |
| 05:22 | amagee | hmm ok :) |
| 05:22 | amagee | well, still no luck with my other avenue either :( |
| 05:22 | amagee | trying (. (new Timer) scheduleAtFixedRate (proxy [TimerTask] [] (run [] (print "hello"))) 0 1000) |
| 05:22 | amagee | No matching method found: scheduleAtFixedRate for class java.util.Timer |
| 05:22 | amagee | but this time the arguments are right (i hope) |
| 05:23 | Lau_of_DK | hehe |
| 05:23 | Lau_of_DK | I think I got it |
| 05:24 | roblally | dnm - I've been looking at JUnit and Clojure a little. |
| 05:24 | Lau_of_DK | user> (def a (agent 0)) |
| 05:24 | Lau_of_DK | #=(var user/a) |
| 05:24 | Lau_of_DK | user> (def b (ref 0)) |
| 05:24 | Lau_of_DK | #=(var user/b) |
| 05:24 | Lau_of_DK | user> (defn work [a] (dosync (commute b inc)) (Thread/sleep 100) (send-off *agent* work)) |
| 05:24 | Lau_of_DK | #=(var user/work) |
| 05:24 | Lau_of_DK | user> (send-off a work) |
| 05:24 | Lau_of_DK | #<clojure.lang.Agent@8edb84> |
| 05:24 | Lau_of_DK | user> @b |
| 05:24 | Lau_of_DK | 33 |
| 05:24 | Lau_of_DK | work must of course take a paramter, which is the agent being dispatched |
| 05:25 | amagee | ok |
| 05:26 | amagee | cool |
| 05:27 | amagee | do you have any ideas about my Timer problem? |
| 05:27 | Lau_of_DK | I havent looked into it at all, but catch up with me tonight and I'll have time to dive into it if you want |
| 05:27 | amagee | mm well it is tonight over here :) |
| 05:27 | Lau_of_DK | oh :) |
| 05:28 | Lau_of_DK | Im thinking approx 8 hours from now, mayb 9� :)( |
| 05:28 | hoeck | amagee: try (long 0) and (long 1000) |
| 05:28 | Lau_of_DK | Can you post a link to the relevant Javadoc ? |
| 05:28 | amagee | hoeck: bingo, that did it :) |
| 05:29 | Lau_of_DK | hoeck, a man of a few well chosen words |
| 05:29 | amagee | hehe |
| 05:29 | amagee | thanks :) |
| 05:29 | hoeck | np :) |
| 08:11 | mehrheit | should integer? return false for Shorts and Bytes? |
| 08:13 | rhickey | mehrheit: probably not |
| 08:17 | rhickey | mehrheit: fixed (svn 1096) |
| 08:21 | mehrheit | well that's fast. |
| 08:33 | leafw | so AOT compiler support is in. Thanks Rick. |
| 08:36 | rhickey | leafw: you're welcome. just have to wait for contrib and other tools (slime/swank) to sync up |
| 08:38 | leafw | the webpage still has no docs on AOT specifically (empty search result) |
| 08:43 | cemerick | leafw: there's a lot in the language that isn't documented on the site |
| 08:44 | cemerick | I secretly think rhickey is betting that Stuart will take care of all of the documentation for him ;-) |
| 08:44 | rhickey | :) |
| 08:45 | Chousuke | that's not very secret thinking. |
| 08:46 | gnuvince | hahaha |
| 08:47 | gnuvince | Can you just imagine poor Stuart |
| 08:47 | gnuvince | "Damnit, stop changing the language so fast!" |
| 08:47 | cemerick | Chouser: damn, did I type that out loud?!? :-P |
| 08:47 | rhickey | generally the site catches up at release time, but I have gotten behind on some of the prose sections, like for a la carte hierarchy and the require/use system |
| 08:47 | cemerick | "Shoot, there's another chapter I'll have to rewrite" |
| 08:48 | cemerick | A friend of mine is a coauthor on a recently-released Django book, and they went through absolute fits keeping up with things there in the final days. I think that's just how it is if you're trying to be the early mover in the book biz. |
| 08:49 | rhickey | except for very recently, as part of a determined 'bunch some breaking changes together', there's not that much change of existing things, just new things, for instance the site doesn't get a lot of changes but isn't wrong, just doesn't include everything |
| 08:50 | gnuvince | cemerick: I can imagine. Adrian and Jacob released a book on Django for Apress during the 0.96-0.97pre days |
| 08:50 | gnuvince | So many things changed, I'm hoping they're onto a re-edit. |
| 08:50 | duck1123 | can you imagine how mad Stuart would be had this happened after the book went to print |
| 08:50 | gnuvince | Yeah |
| 08:51 | gnuvince | That would've been worse |
| 08:51 | gnuvince | A book that people can't just copy code from? |
| 08:51 | gnuvince | Ouch |
| 08:51 | duck1123 | pdfs are easy to fix, paper not so much |
| 08:51 | cemerick | rhickey: short of eliminating genclass, is there anything else coming down before "1.0"? |
| 08:52 | leafw | gnuvince: we should starting writing books like software (under version control), instead of software like books .... read a blog once about it--was neat idea |
| 08:52 | rhickey | cemerick: as far as breaking changes, no. They were: new regex format, uniform vector binding lists, move files for AOT, genclass into AOT |
| 08:53 | gnuvince | leafw: I don't disagree, but a lot of people enjoy reading paper. |
| 08:57 | leafw | someone has to invent the paper book that is updatable. |
| 09:00 | leafw | I have an iLiad, and it's pretty neat -- can write on top of PDFs. But it's a bit too slow to operate. |
| 09:33 | Craig | I just updated to the latest SVN, and slime breaks for me. It appears to be a problem with add-classpath: calling it seems not to affect the classpath. I'm inferring this because (.getProperty System "java.class.path") doesn't change after I call add-classpath. |
| 09:33 | drewr | Craig: Back up a few revs. |
| 09:34 | Craig | Is this a known problem in HEAD? |
| 09:34 | rhickey | Craig: the system classpath is never changed by add-classpath |
| 09:34 | Craig | Ah. |
| 09:35 | rhickey | add-classpath is really just for repl emergencies, want to try a new lib without restarting etc. Once you know you need a lib, out it in your real classpath |
| 09:35 | Craig | Well, the error I get is pretty consistent with classpath not being updated. (require 'swank) fails with a java.io.FileNotFoundException: Could not locate swank.class or swank.clj on classpath: (NO_SOURCE_FILE:0) |
| 09:35 | rhickey | put it |
| 09:36 | Craig | (Not arguing that it doesn't work as you say - just trying to figure it out.) |
| 09:36 | rhickey | If swank hasn't been updated, then its files are in nested directories and need to be moved |
| 09:36 | Craig | Ah, right. |
| 09:38 | Chouser | rhickey: FYI, gen-interface doesn't work exactly the same compiled as it does dyn-loaded. It appears to have something to do with Class/forName, but I haven't pinned it down exactly yet. |
| 09:38 | Chouser | I'll let you know when I've got a simple test that reproduces. |
| 09:39 | rhickey | Chouser: ok |
| 09:47 | Craig | OK, the classpath is sorted, but now (require 'swank) is blowing up with "No such namespace: clojure". This is coming from swank.clj, this line: (clojure/ns swank ...) |
| 09:50 | rhickey | Craig: there's no such namespace clojure - now clojure.core |
| 09:51 | Craig | Heh, you *would* send that two seconds after I read that in the SVN log. :) |
| 09:51 | Craig | Thanks! |
| 09:51 | rhickey | but I think you don't need the qualifier at all for ns |
| 09:52 | Craig | Yeah, my fix was to remove it - I'm on to the next error now. |
| 09:54 | Craig | So, last dumb question (for a few more minutes, at any rate): now all .clj files have to be on classpath to get loaded? Directory is no longer inferred from namespace? |
| 09:55 | rhickey | Those are two separate questions - directory is inferred from namespace, but the relationship is: my.fancy.lib ==> my/fancy/lib.clj, somewhere in classpath |
| 09:55 | Craig | Or, looking at the source, perhaps just the last element of the namespace implies a file now, rather than a directory. |
| 09:55 | Craig | Got it. |
| 09:55 | rhickey | you can still load .cljs not in classpath with load-file, by why? |
| 09:56 | Craig | Thanks - I can see now how swank-clojure needs to be fixed. Appreciate the education. |
| 09:56 | rhickey | np |
| 10:22 | shoover | anyone try AOT on IKVM.NET yet? looks like it's reading the .class files, but no difference in startup time |
| 10:23 | rhickey | shoover: startup time there could be dominated by translation to IL |
| 10:23 | rhickey | but with class files you could precompile with ikvmc, no? |
| 10:24 | shoover | must be. I was hoping that previously it was a combination of ASM bytecode generation + IL translation, and this would be a magic win |
| 10:24 | shoover | I know ikvmc precompiles jars. I'll check on .class files |
| 10:47 | cemerick | rhickey: it would be handy if keyword and symbol could take and return keywords and names as well as strings. I've found myself doing a lot of (if (string? foo) (keyword foo) foo) lately. |
| 10:47 | cemerick | s/names/symbols |
| 10:49 | rhickey | cemerick: keyword, when passed as symbol, would do what? |
| 10:49 | rhickey | passed a symbol |
| 10:50 | cemerick | rhickey: I should have added a "respectfully" in there. Anyway: (keyword :foo) => :foo, (keyword "foo") => :foo, (symbol 'foo) => 'foo, (symbol "foo") => 'foo |
| 10:50 | cemerick | keyword shouldn't take symbols, symbol shouldn't take keywords |
| 10:50 | rhickey | or do you just mean (keyword :akeyword) == identity |
| 10:51 | cemerick | yes, exactly |
| 10:51 | rhickey | ok |
| 10:51 | cemerick | whew, I guess I took the long way 'round the barn there. :-) |
| 10:51 | rhickey | I've needed that too |
| 10:51 | cemerick | rhickey: FYI, I bring it up because I want Java calls into fns to be able to pass strings, but let all of the backend clojure code work in keywords, etc. |
| 10:56 | rhickey | cemerick: that's up - rev 1097 |
| 10:56 | cemerick | rhickey: thanks |
| 10:59 | rhickey | Some people have asked how to donate to Clojure, so I've turned donations on in SF: https://sourceforge.net/project/project_donations.php?group_id=137961 - thanks to all for your support! |
| 11:00 | Craig | So what exactly is your day job? Not that it matters: I plan to contribute anyway. |
| 11:00 | rhickey | Craig: I do consulting and Clojure |
| 11:01 | rhickey | work for myself |
| 11:01 | Craig | Nerdvana. :) I'm halfway there myself. |
| 11:22 | cemerick | rhickey: I'm calling into clojure fns quite a bit, and needing to wrap a lot of calls to avoid declaring a checked Exception on those caller methods. What's the motivation for adding the checked exception on .invoke() signatures? |
| 11:23 | drewr | SLIME support updated to work with r1097. |
| 11:23 | drewr | http://github.com/drewr/swank-clojure/tree/master |
| 11:39 | triddell | drewr: Is there a master repository for swank-clojure? When I wrote the tutorial at http://riddell.us/clojure I pulled from http://github/jochu/swank-clojure.git |
| 11:40 | triddell | but I now want to update to support the newest revision of clojure |
| 11:40 | drewr | triddell: That's the author's repository. I made the changes in my own "forked" repo. |
| 11:40 | drewr | You could add mine as a remote if you wanted to, then pull the changes from there. |
| 11:40 | drewr | Or, you could wait for jochu to merge my or his own changes. |
| 11:41 | triddell | drewr: ok, thanks... did you require any .emacs changes to get your new version to work? |
| 11:42 | drewr | No. |
| 11:43 | triddell | ok, cool |
| 11:43 | rhickey | cemerick: fns end up calling varied things. without the Exception decl I would have to wrap all checked exceptions |
| 11:44 | rhickey | I hate checked exceptions |
| 11:45 | cemerick | rhickey: Sure -- but that only applies if you're implementing IFn in Java, which I assume is an edge case compared to calling into clojure fns from Java. |
| 11:45 | drewr | rhickey: That was one of the things that drove me from Java screaming. |
| 11:45 | Chousuke | drewr: slime seems to work. thanks for the fix. |
| 11:46 | rhickey | cemerick: Clojure fns call Java all the time, e.g. user fns calling java.io etc |
| 11:47 | drewr | Chousuke: You're welcome! |
| 11:47 | rhickey | have already gotten complaints the few places I am wrapping, because consumers can't catch typed exceptions |
| 11:49 | cemerick | I think I'm only whining because I'm writing in Java this morning. :-) |
| 11:49 | rhickey | It is truly painful - number one complaint I have about Java |
| 11:49 | rhickey | a terrible misfeature |
| 11:50 | drewr | If they wanted to, would it be possible to fix that in the JVM? |
| 11:50 | Chouser | are not all exceptions checked? |
| 11:51 | rhickey | It's just a compiler thing, they could turn into warnings tomorrow |
| 11:51 | cemerick | rhickey: the pain would be mitigated when calling into clojure if Var had a series of parallel .invoke methods that wrapped any thrown exceptions in an IllegalStateException, or whatever |
| 11:51 | cemerick | .invokeQuietly or something ;-) |
| 11:51 | rhickey | Chouser: no, certain branches of the exception hierarchy are not checked |
| 11:52 | rhickey | cemerick: interesting |
| 11:52 | rhickey | I'm reluctant to add more methods not knowing the impact of vtable size, if any, on perf |
| 11:53 | cemerick | I can't imagine that that's an issue anymore, especially on 1.6+ |
| 11:53 | rhickey | cemerick: you could make a static invoker/call method that did that |
| 11:55 | cemerick | You mean a class with series of .invoke(IFn/Var, arg1, arg2 ..., argN) methods? |
| 11:56 | rhickey | cemerick: right |
| 11:56 | cemerick | yeah, maybe. We'll see what my mood is like the next time I need to write a Java wrapper for some clojure fns. |
| 11:56 | cemerick | :-) |
| 11:56 | rhickey | Fns.call(f,a1,a2) |
| 12:23 | unfo | bradbev: when you have time, could you please come on over to #emacs for a vimpulse-related question? |
| 12:23 | bradbev | unfo: sure |
| 12:27 | shoover | rhickey: good call on ikvmc class compilation. I had to hack RT.load, but running everything through ikvmc took startup down to 3 seconds from 6 on my machine |
| 12:28 | shoover | still can't touch the jvm's .7 secs though |
| 12:33 | kotarak | shoover: hi, is the hg mirror still updated? |
| 12:38 | larrytheliquid | any help with test syntax recommendations would be appreciated: http://paste.lisp.org/display/70313 |
| 13:08 | AWizzArd | Moin |
| 13:44 | rhickey | AOT changes spelled out: http://groups.google.com/group/clojure/msg/58e3f8e5dfb876c9 |
| 13:48 | blackdog | thanks rhickey awesome stuff |
| 13:48 | rhickey | you're welcome |
| 13:51 | Chouser | rhickey: do you expect to fold gen-interface into AOT as well? |
| 13:52 | rhickey | Chouser: could do, although I'd really like to keep any such interface-generating file free of other stuff. |
| 13:53 | Chouser | ok, just curious. I still haven't had a need to use gen-interface. |
| 14:04 | sohail | hey, AOT is official |
| 14:04 | sohail | nicely done rhickey |
| 14:04 | rhickey | well, AOT is officially ready-to-try |
| 14:04 | shoover | kotarak: I lost my web host so the hg mirror is not automatically updated anymore. I will have it sync at least daily soon |
| 14:06 | gnuvince | http://www.reddit.com/r/programming/comments/7d6vs/rich_hickey_adds_aot_compilation_to_clojure/ |
| 14:15 | AWizzArd | aot makes Clojure now much more attractive for commercial development, great |
| 14:17 | sohail | just catching up on the list... howcome tests are a contrib |
| 14:17 | sohail | interesting way to do it |
| 14:17 | Chouser | because that way we can write tests while Rich writes AOT |
| 14:18 | sohail | Chouser, the other day I was looking for tests to see how something worked and I couldn't find them! |
| 14:20 | sohail | so long as they are written, that's actually a pretty damn good way to do it |
| 14:20 | Chouser | well, there aren't very many yet. Send Rich your CA and you can help out! |
| 14:21 | sohail | not a bad idea, I'd feel like less of a leech |
| 14:27 | AWizzArd | In the sources I find several times (when (seq obj) ..), or (if (seq obj) ..). First I thought this was wrong even though it would work, and that really seq? was meant. But could it not make sense to have a function for saying (and (coll? obj) (not (empty? obj))) ? |
| 14:28 | gnuvince | AWizzArd: seq applied to an empty sequence returns nil. |
| 14:28 | drewr | rhickey: What's the consequence of namespaces only having one segment now? |
| 14:28 | drewr | It seems to still work. |
| 14:29 | AWizzArd | gnuvince: exactly... and (and (coll? x) (not (empty? x))) also returns nil if x is an empty collection |
| 14:29 | rhickey | drewr: don't do that, it will leave you with a class in no package |
| 14:29 | tomhickey | H4ns & rhickey: clojure.org now has a print stylesheet, let me know if you need any changes |
| 14:29 | rhickey | tomhickey: thanks! |
| 14:29 | AWizzArd | tomhickey: very cool, thanks |
| 14:29 | tomhickey | np |
| 14:30 | drewr | rhickey: Ah, I see. |
| 14:30 | rhickey | drewr: that's why I had to move clojure ns down into clojure.core |
| 14:31 | drewr | Yeah, I realized that. I was just wondering why some stuff I had still worked without a package. |
| 14:31 | wwmorgan | AWizzard; it may be instructive to look up the definition of empty? |
| 14:31 | rhickey | wwmorgan: :) |
| 14:32 | rhickey | AWizzArd: (seq x) is idiomatic Clojure |
| 14:32 | AWizzArd | okay good, when it is defined this way it makes sense |
| 14:32 | rhickey | also just (when x ...) when you know x is a seq |
| 14:33 | AWizzArd | yes, that also feels natural/good for me to do |
| 14:33 | H4ns | tomhickey: hammer! |
| 14:34 | AWizzArd | rhickey: what about doing (when x ..) for using the implicit return value nil? I also do that in CL, even though some people prefer (if (null x) nil (else ..)) |
| 14:37 | rhickey | AWizzArd: yes, please, when's implicit nil is a fine thing. |
| 14:42 | AWizzArd | Can dissociating elements from a map be done in near constant time? |
| 14:43 | rhickey | AWizzArd: from a hash map, yes, same as assoc |
| 15:16 | tomhickey | clojure.org now has code highlighting (via js). please let me know if you see any issues |
| 15:18 | AWizzArd | *click* |
| 15:18 | AWizzArd | yeah, looks very nice |
| 15:19 | AWizzArd | It's good and important that Clojure has this nice Web 2.0 look. |
| 15:19 | rhickey | tomhickey: looks great - thanks again! |
| 15:24 | rhickey | I wonder what it would take to get Clojure highlighting on paste.lisp.org? |
| 15:25 | drewr | I'm sure chandler wouldn't be opposed to it. |
| 15:25 | drewr | What's doing the parsing? |
| 15:26 | rhickey | maybe js regex, tomhickey ? |
| 15:27 | tomhickey | yes, clojure.org is doing it with regex using Dan Webb's codehighlighter script, http://svn.danwebb.net/external/CodeHighlighter/ |
| 15:31 | tomhickey | paste.lisp.org seems to markup the code on the server side |
| 15:35 | drewr | That's what I was thinking. I tried to download the source, but common-lisp.net is broken right now. |
| 15:36 | drewr | Er, the FTP part of it is. |
| 15:37 | H4ns | drewr: did you open a ticket for that? can you? please include information on where you found the ftp path that has become inaccessible. |
| 15:38 | drewr | H4ns: I didn't know I could open a ticket. |
| 15:39 | H4ns | drewr: just send a quick email to rt@common-lisp.net - that will help us tremendously! thanks! |
| 15:43 | drewr | H4ns: Done. |
| 15:44 | H4ns | drewr: *bow* |
| 15:46 | drewr | It was nothing, really. |
| 15:49 | Chousuke | hm, found an error on the site. on the "other libraries" page there's a piece of code like this: (pvec (par f :filter-index <; :map-index vector)) |
| 15:50 | Chousuke | commenting out half of the expression probably is not intended :) |
| 15:52 | tomhickey | Chousuke: thanks, i'll look into that |
| 15:53 | Chousuke | syntax highlighting really helps in spotting errors like that |
| 15:56 | tomhickey | Chousuke: fixed. thanks for the report |
| 15:56 | Chousuke | you're welcome |
| 16:21 | sohail | tomhickey related to richhickey? |
| 16:21 | drewr | sohail: Brothers. |
| 16:22 | sohail | nice |
| 16:24 | gnuvince | Who's the older one? |
| 16:24 | duck1123 | I was wondering that myself |
| 16:29 | tomhickey | rich is the older one |
| 16:30 | sohail | must be nice to have a brother with the same interests |
| 16:30 | tomhickey | so i've got like 14 years before i make my own language! ;) |
| 16:31 | sohail | clojure: the 14 year language |
| 16:32 | AWizzArd | I guess Clojure will be one of the last Lisps before computers will understand human language and will do the programming for us |
| 16:32 | H4ns | "right" |
| 16:32 | Hun | there's always another lisp. |
| 16:32 | duck1123 | isn't that what they said about the first lisp? |
| 16:33 | Hun | i think you can prove that by induction if you tried really hard |
| 16:33 | Chousuke | lisp is funny |
| 16:34 | Chousuke | you can have thousands of dialects, but at its core, it's still "just" lisp |
| 16:34 | Hun | the syntax doesn't resemble the original one a bit... just the data structures. i still think it's hard to define what `makes' a lisp |
| 16:35 | Chousuke | You could write an XML-based lisp. it just wouldn't be very lispy. |
| 16:35 | AWizzArd | Hun: I think Paul Graham gave a nice summary: http://www.paulgraham.com/diff.html |
| 16:36 | Hun | i know that one. i just don't know how much i agree with it :) |
| 16:36 | cemerick | Chousuke: http://www.agentsheets.com/lisp/XMLisp/ |
| 16:36 | Chousuke | cemerick: yeah, I should've known it has already been done |
| 16:36 | sohail | Chouser, I think jelly is the xml based lisp |
| 16:36 | sohail | it has proper macros I think |
| 16:37 | Hun | i don't think you really need functions to do a lisp. you can bootstrap those with just eval and cons. but you can bootstrap anything with 0 and 1 also... so i'm not sure there ;) |
| 16:38 | AWizzArd | I interpreted Graham in this regard more like: he wants to give us something like (lambda ()) or (fn []), as a 1st class datatype that you can pass around |
| 16:38 | AWizzArd | and create on-the-fly |
| 16:39 | Hun | with which semantics? most lambdas i know are lexical |
| 16:39 | Hun | the ones in emacs work completely different, though i think i'd still call it a lisp |
| 17:02 | cemerick | is there an incantation to override :private and access such a marked var? |
| 17:03 | kotarak | (ns-resolve 'foo.bar 'private-var), although private there for a reason |
| 17:04 | gnuvince_ | Wow |
| 17:04 | gnuvince_ | Clojure builds in 11 seconds |
| 17:04 | gnuvince_ | that's impressive |
| 17:18 | sohail | gnuvince, it is amortized over the runtime of your program ;-) |
| 17:19 | gnuvince_ | heh |
| 17:19 | gnuvince_ | I compiled GHC from scratch once. That took *way* longer than 11 seconds ;) |
| 17:24 | sohail | like I said, amortized |
| 17:24 | sohail | :-) |
| 18:04 | hiredman | is there a clojure http client that does ssl and doasn't use gen-and-load-class? |
| 18:05 | cemerick | there's lots of java http clients, FWIW |
| 18:05 | hiredman | yeah, well |
| 18:06 | cemerick | getting http right is not an easy thing. Is there a clojure impl floating around at all? |
| 18:06 | hiredman | after spending some time with the jakarta httpclient and trying to futz with java.net.URLConnection I am ready to try and put my laptop through a brick wall |
| 18:06 | hiredman | there is one in the clojure files stuff that I know of |
| 18:08 | hiredman | but it uses gen-and-load class for some ssl "stuff" |
| 18:10 | cemerick | wwmorgan: what's the http library you ended up liking? |
| 18:11 | wwmorgan | jakarta httpclient |
| 18:11 | wwmorgan | didn't have any problems with SSL IIRC |
| 18:11 | cemerick | yeah, that's what I thought. hiredman, I'd say stick it out with jakarta. (reliable) http clients are weekender projects. |
| 18:12 | hiredman | I guess I will |
| 18:12 | cemerick | s/are/aren't :-P |
| 18:19 | H4ns | hiredman: there is a clojure wrapper around some common http client in http://groups.google.com/group/clojure/files |
| 18:19 | H4ns | hiredman: (http-client/url-do "http://planet.lisp.org/" "GET" []) |
| 18:20 | H4ns | hiredman: it is not particularily pretty, but worked for me right out of the box. |
| 18:24 | hiredman | H4ns: that part did work for me out of the box, but https does not, and however the author got https working he used some gen-and-load-class stuff, which I would rather avoid |
| 18:25 | H4ns | hiredman: ah, ok, understood. |
| 18:26 | H4ns | hiredman: did you look at xlightweb already? that is what i use, but i did not try https with it |
| 18:27 | hiredman | I have not |
| 18:27 | H4ns | http://vaxbusters.org/http-client.clj is what i currently use in my planet lisp poller |
| 18:29 | hiredman | I think almost anything would be less painful then trying to figure out how many arrays jakarta nests the two different kinds of header objects |
| 18:32 | hiredman | I'll take a close look at xlightweb, thanks |
| 18:33 | hiredman | wow |
| 18:35 | H4ns | hiredman: works? |
| 18:44 | hiredman | H4ns: still kicking the tire, but looks good |
| 18:46 | H4ns | ok. good luck! |
| 18:51 | Drakeson | Have you seen this error on emacs+slime+OSX: java.lang.Exception: No such namespace: clojure (NO_SOURCE_FILE:1) |
| 18:52 | Chousuke | you either need a fixed slime or an older revision of clojure |
| 18:55 | Chousuke | Drakeson: There were some breaking changes in the newer versions. A fixed clojure-swank is here: http://github.com/drewr/swank-clojure/tree/master (not the "official" clojure-swank; I don't know if it has these changes yet) |
| 18:55 | Drakeson | Chousuke: thanks. I was suspecting my settings. |
| 18:56 | drewr | Chousuke: jochu has merged my changes, so you guys can pull from the official repo. |
| 18:56 | Chousuke | ah, excellent. |
| 19:00 | Drakeson | great, thanks :) |
| 20:03 | jtoy | can you mix and match languages on the jvm like clojure and jruby together? |
| 20:04 | arohner | is there any way to make System.err show up in the slime buffer rather than only in *inferior-lisp*? |
| 20:04 | arohner | jtoy: I haven't used jruby, but if their calling conventions are as nice as clojure's ( :-) ), it should be easy |
| 20:05 | jtoy | but i mean in general, can you mix jvm languages? like there is also groovy and scala,etc |
| 20:05 | arohner | you should be able to. it's all just .class files |
| 20:06 | arohner | that being said, I haven't tried it |
| 20:08 | rhickey | jtoy: you should be able to call from language to language through the interfaces they present to Java, as each can call Java |
| 20:08 | rhickey | there has been some work on a multi-language MOP |
| 20:09 | jtoy | rhickey: nice, didn't know you hung out here, is it worth to get the pragmattic book? I dont program java at all, but I plan to start playing with clojure |
| 20:10 | rhickey | jtoy: yes, the pragmatic book looks good so far |
| 20:40 | gnuvince_ | Does a multi-method's dispatching function need to have the same arity as the defmethods will have? |
| 20:41 | rhickey | gnuvince: it gets pased all args, but you can just & rest away the ones you don't care about |
| 20:42 | gnuvince_ | rhickey: okay |
| 20:42 | gnuvince_ | thank you. |
| 20:43 | rhickey | sure |
| 21:12 | Chouser | can whole classes be garbage collected? |
| 21:13 | rhickey | Chouser: that depends, it is something they are working on, but basically they are kept alive by their classloaders |
| 21:13 | Chouser | hm. |
| 21:14 | Chouser | (Class/forName (.getName (class (fn [] 99)))) |
| 21:14 | rhickey | that's one reason why langs use their own tear-off loaders for dynamic class creation |
| 21:14 | Chouser | That works, but if I store the name in a var and do forName later, it fails. |
| 21:16 | rhickey | Chouser: what are you trying to do? |
| 21:16 | Chouser | heh. good question! |
| 21:16 | rhickey | the concrete class of an anonymous fn is, well, anonymous |
| 21:17 | Chouser | I'm trying to track down my gen-interface problem. I'd like to find some way besides gen-interface to dynamically load a class. |
| 21:18 | rhickey | chances are entire expression above is compiled under a tear-off loader, class can only be found by name under that loader |
| 21:18 | Chouser | it's anonymous but my snippet above does return a class. |
| 21:18 | Chouser | ah. ok. |
| 21:18 | rhickey | as I said, tear-of loaders are used so classes like this can be reclaimed |
| 21:18 | Chouser | ok |
| 21:39 | Chouser | I just can't seem to reproduce this error twice in a row. |
| 21:41 | rhickey | Chouser: what happens? |
| 21:47 | Chouser | hm, paste's not working |
| 21:48 | Chouser | http://n01se.net/paste/Q2i -- gen-interface compile issue |
| 21:49 | Chouser | I've gotten this to happen a couple times, but even if I delete all generated .class files, I can't get it to happen the same way twice. |
| 22:53 | arohner` | does clojure have zip? |
| 22:53 | Chouser | it has a lib called zip, but I doubt that's what you want |
| 22:53 | rhickey | http://www.sauria.com/blog/2008/11/13/olio-a-web-20-benchmark/ |
| 22:54 | arohner` | i.e. (zip '(1 2 3) '(4 5 6)) => ((1 4) (2 5) (3 6)) |
| 22:54 | Chouser | (map list '(1 2 3) '(4 5 6)) |
| 22:56 | arohner` | interesting. |
| 22:56 | arohner` | thanks |
| 23:03 | bradbev | Hmm, refs & lazy mapping have interesting effects |
| 23:04 | Chouser | oh? |
| 23:04 | bradbev | Hmm, lisppaste is broken |
| 23:04 | Chouser | yeah |
| 23:05 | arohner` | Chouser: another solution to my earlier question: interleave |
| 23:05 | bradbev | but basically map over a list of refs doing deref, then change the ref value & then look at the lazy seq |
| 23:05 | arohner` | sort of |
| 23:05 | bradbev | (def refs (into [] (map #(ref %) (range 10)))) |
| 23:05 | bradbev | (println (map deref refs)) |
| 23:05 | bradbev | (def dref (map deref refs)) |
| 23:05 | bradbev | (doseq r refs |
| 23:05 | bradbev | (dosync |
| 23:05 | bradbev | (ref-set r (* 2 @r)))) |
| 23:05 | bradbev | (println dref) |
| 23:06 | bradbev | the lazy seq shows the changed refs - but that is a little confusing really |
| 23:07 | bradbev | It makes sense when you consider how lazy map works, but it is not really what you'd expect in general if it weren't lazy |
| 23:09 | Chouser | ah, I see. yep. |
| 23:10 | bradbev | so if you ever map over a seq containing refs, you need to make it a concrete instance, or get burned |
| 23:16 | Chouser | right. Probably better to keep them in a vector. |
| 23:18 | bradbev | yep. But it is a wee bit of a gotcha. |
| 23:19 | Chouser | have to be careful with any kind of side-effect mixed with lazy seqs |
| 23:21 | bradbev | indeed. lazy only works with immutable data. On the upside, this is the first real gotcha I've found with Clojure |
| 23:22 | Chouser | Another good one is laze seqs over a resource that goes away. |
| 23:23 | bradbev | eek, that would be very bad. |
| 23:23 | bradbev | I'm not entirely sure that I'm sold on lazy seqs |
| 23:23 | bradbev | or at least map returning a lazy seq |
| 23:24 | Chouser | oh, I'm completely sold. But they are what they are -- you can't pretend they're not lazy. |
| 23:24 | Chouser | ...and I think there's a solution in the works for the resource issue. |
| 23:24 | bradbev | I'm still coming to grips with it I think |
| 23:25 | bradbev | but I'm learning that you can't treat lazy seqs as a transparent abstraction |
| 23:27 | Chouser | well, you can't treat them as non-lazy |
| 23:27 | Chouser | if someone hands you a seq, you can treat it as a seq without knowing what it really is underneath |
| 23:30 | bradbev | yes. I guess though I need to know which functions return lazy seqs (or which seqs are mutable), and ensure I instance those seqs during the transaction I'm in |
| 23:32 | Chouser | I guess I've never done much witha seq of mutables. Does sound a bit squirrley. |
| 23:33 | bradbev | I haven't either really, but in the process of learning about lazy seqs it occurred to me this could happen |
| 23:45 | jphr | hey folks, just starting to learn clojure, wondering if there is an equivalent from CL's atom predicate? |
| 23:47 | Chouser | jphr: not quite. There's coll? which you could negate |
| 23:47 | jphr | that would probably work |