2009-12-19
| 00:19 | jasapp | does anyone remember how to use the different regular expression flags? |
| 00:20 | somnium` | like #"(?i)FoObAr+" ? |
| 00:20 | jasapp | yup, that's what I was looking for |
| 00:20 | jasapp | thanks |
| 00:21 | jasapp | is that in the docs anywhere? I couldn't find it |
| 00:21 | _ato | http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html |
| 00:21 | _ato | probably the Clojure documentation should link to that |
| 00:21 | somnium` | a perl/javascript syntax would be nice |
| 00:22 | somnium` | maybe with cinc |
| 00:24 | chouser | is it that different? |
| 00:24 | somnium` | no |
| 00:25 | somnium` | mostly just move the flags to the end it appears |
| 00:26 | devlinsf | chouser: ping |
| 00:26 | chouser | devlinsf: hi! |
| 00:26 | devlinsf | Just saw your feedback |
| 00:27 | devlinsf | I modified withMeta because the original code use it |
| 00:27 | devlinsf | Wanted to do something "Similar" |
| 00:28 | devlinsf | Do you know why the use of EMPTY is there? |
| 00:28 | devlinsf | (That was causing the bug, btw) |
| 00:29 | devlinsf | Hmm... I wonder if withMeta loses the comparator |
| 00:29 | chouser | that's how the other collections do it |
| 00:30 | chouser | devlinsf: it used to, I think, but was fixed by using the two-arg constructors. :-) |
| 00:31 | devlinsf | Right |
| 00:31 | devlinsf | So, should I just break convention here? |
| 00:31 | devlinsf | (A quick REPL test shows we're okay) |
| 00:32 | chouser | I can't tell you what rhickey is more likely to accept, but that's what I'd do. |
| 00:33 | devlinsf | Okay. I'm adding a comment to explain the deviation in the source. |
| 00:34 | devlinsf | Should I include some tests too? |
| 00:34 | chouser | well, it's different from what used to be there and from the other collections, but it's a pattern used elsewhere in that file. |
| 00:35 | chouser | if you want, sure. tests are great. if you do, please put them in the same patch file, though they can be a separate commit if you want. |
| 00:36 | devlinsf | Hmm... sounds good |
| 00:37 | devlinsf | I'm curious. What's the process of these patches getting into core? Does Rich review all of them? |
| 00:37 | chouser | yep, each and every one. |
| 00:37 | devlinsf | Okay. |
| 00:39 | chouser | I think if people comment that the patch is good, he may be able to approve it more easily, I'm not sure. |
| 00:40 | devlinsf | Well, I appreciate the review |
| 00:40 | chouser | once he approves, he or I can push it to github. |
| 00:40 | chouser | sure, happy to have the help. thanks! |
| 00:41 | chouser | I have no sense if he'll want this in 1.1 or not, but I'd like it to be. |
| 00:43 | devlinsf | Me too |
| 00:43 | devlinsf | It's a bug fix, so that's gotta make the case easier, right? |
| 00:43 | chouser | I'd think so. |
| 00:44 | chouser | ok, bedtime. thanks again for working on this. |
| 00:45 | devlinsf | np |
| 00:46 | devlinsf | I'll have patch #2 ready tonight |
| 02:27 | scottj_ | Does technomancy's swank-clojure try to use tramp to find the source of a function and bail on Windows or is it something else in my setup? |
| 02:27 | scottj_ | (M-.) |
| 03:41 | LauJensen | Morning gents |
| 04:24 | triyo | The bean function returns a map that represents the bean. The map contains the :class key with the Class value. When running (json-str (bean my-bean)) it complains about the Class value bound to :class as json write process doesn't know how to convert it I guess. |
| 04:24 | triyo | one solution I can think of is to dissoc the :class, is this the best option? |
| 04:25 | triyo | also, how do I do this when the bean in question could have number of nested levels of beans with their own :class keys |
| 04:32 | triyo | ok, the json lib source says the following: "You can extend this library to handle new types by adding methods to |
| 04:32 | triyo | print-json." |
| 05:38 | Bjering | What am I doing wrong here? |
| 05:38 | Bjering | (build-dataflow[(cell :source a) (cell b (* 2 ?a))]) |
| 05:52 | vegai | what's the error? Are you supposed to have a space before [? |
| 05:55 | Bjering | #<Object java.lang.Object@d70b42>) (NO_SOURCE_FILE:0)> |
| 05:56 | Bjering | ah |
| 05:57 | Bjering | found it, a missing arg when defining cell a |
| 05:57 | vegai | ah, right |
| 05:57 | Bjering | This worked (build-dataflow [(cell :source a 0) (cell b (* 2 ?a))]) |
| 06:18 | hamza | hey guys, i would like to call a function with side effects n times is there a repeat like call for this? i don't care about the return value. |
| 06:19 | _ato | ,(doc dotimes) |
| 06:19 | clojurebot | "([bindings & body]); bindings => name n Repeatedly executes body (presumably for side-effects) with name bound to integers from 0 through n-1." |
| 06:20 | _ato | ,(dotimes [i 3] (println "hi")) |
| 06:20 | clojurebot | hi hi hi |
| 06:21 | hamza | _ato: thanks a lot. |
| 07:18 | Ankou | hi, the documentation of clojure.walk talks of some examples but where are those examples? |
| 07:22 | Ankou | because I can't figure out what clojure.walk is doing? |
| 07:37 | hoeck | Ankou: there are some examples of walk at the bottom of its source |
| 07:42 | hoeck | Ankou: for example, there: http://github.com/richhickey/clojure/blob/master/src/clj/clojure/walk.clj#L52 |
| 08:46 | interferon | i compiled a clojure file to java bytecode. when i run it from the command line with "java" it runs everything in -main, but then doesn't terminate |
| 08:46 | interferon | could it be because of still-running threads? |
| 08:48 | the-kenny | hm.. good question |
| 08:53 | interferon | actually, it did terminate after maybe a minute |
| 08:54 | notallama | man. glsl is really picky. (or my implementation is). in a for loop, "++i" works, but "i = i + 1" does not. |
| 08:54 | interferon | but there's nothing in -main except a print statement, and that has already passed |
| 08:57 | notallama | also, would anyone here be interested in a clojure wrapper for lwjgl? i'm working on one, and i'll probably put it on github soon. (i'm going a different direction than penumbra. less gpgpu, more game engine) |
| 08:57 | the-kenny | notallama: Sounds cool |
| 08:58 | the-kenny | I would at least try it |
| 08:59 | notallama | i just got a geometry shader running in it. :) i'll probably put it up and make a post later today or tomorrow. |
| 09:01 | interferon | any way to pass in a default value for a param? |
| 09:01 | interferon | do i have to do (def foo ([x] (foo x 0)) ([x y] ...)) ? |
| 09:04 | jasapp | take a look at defnk in clojure.contrib.def |
| 09:05 | interferon | ,defnk |
| 09:05 | clojurebot | java.lang.Exception: Unable to resolve symbol: defnk in this context |
| 09:07 | jasapp | ,(require 'clojure.contrib.def) |
| 09:07 | clojurebot | nil |
| 09:07 | jasapp | ,defnk |
| 09:07 | clojurebot | java.lang.Exception: Unable to resolve symbol: defnk in this context |
| 09:08 | jasapp | heh |
| 09:08 | jasapp | ,clojure.contrib.def/defnk |
| 09:08 | the-kenny | ,clojure.contrib.def/defnk |
| 09:08 | clojurebot | java.lang.Exception: Can't take value of a macro: #'clojure.contrib.def/defnk |
| 09:08 | clojurebot | java.lang.Exception: Can't take value of a macro: #'clojure.contrib.def/defnk |
| 09:08 | jasapp | it's early, I'm slow this morning :) |
| 09:08 | lpetit | ,(doc defnk) |
| 09:08 | clojurebot | "clojure.contrib.def/defnk;[[fn-name & fn-tail]]; Define a function accepting keyword arguments. Symbols up to the first keyword in the parameter list are taken as positional arguments. Then an alternating sequence of keywords and defaults values is expected. The values of the keyword arguments are available in the function body by virtue of the symbol corresponding to the keyword (cf. :keys destructuring). defnk accepts |
| 09:08 | lpetit | ~source defnk |
| 09:09 | lpetit | not so early in France :-p |
| 09:11 | jasapp | true |
| 09:12 | lpetit | there has been also a discussion recently (one to two month from today) on the ml concerning a generalization of defnk via something called like (if I remember correctly) let-kw ... |
| 09:14 | jasapp | that'd be interesting |
| 09:14 | lpetit | there it is: http://groups.google.com/group/clojure/browse_thread/thread/d6b5fa21073541c1/551f6527b31900ca?lnk=gst&q=defnk#551f6527b31900ca |
| 09:14 | jasapp | I have to admit, I do miss cl's default arguments |
| 09:16 | lpetit | ~lisppaste |
| 09:16 | clojurebot | lisppaste8: url |
| 09:16 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 09:16 | lisppaste8 | lpetit pasted "last version of let-kw placed on the ml" at http://paste.lisp.org/display/92353 |
| 09:17 | lpetit | must leave, bye guys |
| 09:17 | jasapp | thanks for that link |
| 09:17 | jasapp | bye |
| 09:28 | patrkris | The documentation for clojure and clojure-contrib found on clojure.org/api is for clojure 1.1? Is there anywhere documentation can be found for just 1.0? I'm just asking out of curiosity. |
| 10:04 | devlinsf | ,(transient (sorted-map 1 2 3 4)) |
| 10:04 | clojurebot | java.lang.ClassCastException: clojure.lang.PersistentTreeMap cannot be cast to clojure.lang.IEditableCollection |
| 11:13 | LauJensen | Mostly for the young: I blogged about 4 simple Rosetta problems as well as the Rosetta project: http://www.bestinclass.dk/index.php/2009/12/rosetta-serving-dish-4/ |
| 11:32 | jasapp | LauJensen: cool |
| 11:58 | a_strange_guy | clojurebot: paste? |
| 11:58 | clojurebot | lisppaste8, url |
| 11:58 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 11:59 | lisppaste8 | devlinsf pasted "test" at http://paste.lisp.org/display/92355 |
| 12:05 | lisppaste8 | a_strange_guy pasted "cond-let?" at http://paste.lisp.org/display/92356 |
| 12:05 | a_strange_guy | hi everyone |
| 12:05 | a_strange_guy | does anyone use cond-let from contrib? |
| 12:06 | devlinsf | Hmmm... what ns is it in? |
| 12:06 | a_strange_guy | in c.c.cond |
| 12:07 | a_strange_guy | i thought that it works like if-let |
| 12:07 | a_strange_guy | was trying to replace my nested if-lets with it |
| 12:08 | devlinsf | Never use it much |
| 12:08 | a_strange_guy | but it doesn't work as expected, and the docs dont make any sense to me |
| 12:09 | devlinsf | Yeah, the docs are opaque |
| 12:10 | ksm | How do I force a stop in the repl? |
| 12:11 | devlinsf | ksm: C-c C-c |
| 12:11 | devlinsf | At least, that works in SLIME |
| 12:11 | the-kenny | devlinsf: In Emacs, of course |
| 12:11 | ksm | I'm using the vimclojure |
| 12:12 | devlinsf | ksm: Enclojure has a "reset REPL" option |
| 12:12 | devlinsf | Sorry, can't help : |
| 12:12 | devlinsf | :( |
| 12:14 | a_strange_guy | does emacs+slime provide a better repl than enclojure? |
| 12:15 | the-kenny | a_strange_guy: Emacs + Slime is the nonplusultra for lisp programming. |
| 12:16 | a_strange_guy | gotta try emacs for once ^^ |
| 12:16 | devlinsf | I love SLIME. The one thing I like about Enclojure better is that it does a better job of handling classpath/build stuff. I wish emacs had support for easy classpath stuff |
| 12:17 | the-kenny | devlinsf: It has: M-x swank-clojure-project |
| 12:17 | a_strange_guy | how well does slime handle completions? |
| 12:17 | devlinsf | Oh? |
| 12:17 | a_strange_guy | clojure aswell as java completions |
| 12:17 | the-kenny | devlinsf: If you have a "default" setup (lib/ src/ and classes/) you can invoke swank-clojure-project on the dir and emacs will start a repl |
| 12:17 | devlinsf | the-kenny: Could you post a link to docs for that |
| 12:18 | the-kenny | devlinsf: It's perfect if you use leiningen |
| 12:18 | the-kenny | Stand By |
| 12:18 | the-kenny | devlinsf: http://github.com/technomancy/swank-clojure "Project Layout" |
| 12:18 | the-kenny | (In the Readme) |
| 12:19 | devlinsf | Okay |
| 12:19 | the-kenny | a_strange_guy: Clojure completions are either based on "simple" expansion of buffer contents or based on reflection of the clojure api. |
| 12:20 | a_strange_guy | so it looks up the current vars? |
| 12:20 | the-kenny | a_strange_guy: Yes, it detects all the contents of the current namespace. |
| 12:20 | the-kenny | a_strange_guy: It also supports fuzzy completion: "skeys" expands to "select-keys" |
| 12:21 | a_strange_guy | does that also work for java Classes and calls? |
| 12:21 | a_strange_guy | i'm trying to make java scriptable |
| 12:21 | the-kenny | hm.. I'm not sure |
| 12:22 | the-kenny | a_strange_guy: Looks like it works for imported classes, but not for their methods |
| 12:23 | the-kenny | a_strange_guy: Shouldn't be very hard to implement.. maybe I'll give it a try someday |
| 12:24 | a_strange_guy | the-kenny: do you have any good links for setting up emacs+slime on linux |
| 12:24 | proppy | Hi, how do I install package from clojars ? |
| 12:27 | proppy | ah got it I should create a skeleton project first |
| 12:27 | the-kenny | a_strange_guy: Yeah, the readme. It covers anything clojure-specific. A tutorial for emacs is included in emacs |
| 12:27 | the-kenny | C-h t or so |
| 12:30 | the-kenny | (C-h t means: Hold ctrl, press h, release ctrl and press t |
| 12:30 | the-kenny | +) |
| 12:34 | alexyk | chouser: any better idea how built-in sort-by beats a Schwarzian transform? |
| 12:51 | chouser | alexyk: nope. It's a HotSpot Christmas Miracle! |
| 12:52 | chouser | afaict, there's no way as it's written for the java routine that actually does the sorting to know avoid calling the keyfn twice for every comparison |
| 12:53 | chouser | and the way I wrote it, which should do a very fast transform once before and once after a simpler sort doesn't go any faster. |
| 12:53 | alexyk | chouser: we'll take such miracles any day, and twice for xmas! :) |
| 12:53 | chouser | I haven't profiled mine. Perhaps I'm doing something dumb that's slowing it down. |
| 12:58 | jweiss | if i want to truly treat code as data - let's say i want to generate new fns using an existing fn as a template (but i can't change the original fn). i know there's the "source" fn to use in a macro to get the code of the original fn, but it doesn't work in a repl. is there another way? |
| 12:59 | devlinsf | jweiss: What exactly are you trying to do? |
| 13:00 | Chousuke | the source function is not a reliable way to get the function source |
| 13:00 | jweiss | devlinsf: I want to use existing fns as a template, keeping the original fn as-is (as readable as it was before), and create new "patched" fns from it |
| 13:00 | Chousuke | it's just a quick and dirty repl tool :) |
| 13:00 | devlinsf | Ah |
| 13:00 | jweiss | Chousuke: is there another way? |
| 13:00 | Chousuke | no. |
| 13:01 | Chousuke | the source of a function is not stored anywhere after the function is defined. |
| 13:01 | Chousuke | unless you use a custom macro I guess. |
| 13:01 | devlinsf | Is the "Patch" easy to encapsulate in a fn? |
| 13:01 | jweiss | yeah, i realize i could make all my fns macros, but that sounds like a bad idea to me |
| 13:02 | Chousuke | no I mean, a custom macro for defining the fns |
| 13:02 | the-kenny | jweiss: You could create a new macro based on defn: defn-source or so. |
| 13:02 | Chousuke | instead of defn. |
| 13:02 | devlinsf | Try writing it as a higher order function |
| 13:02 | jweiss | oh i see |
| 13:02 | Chousuke | but yeah, I think a higher-order function would be the most idiomatic approach :/ |
| 13:02 | jweiss | i'm not sure what that means |
| 13:02 | jweiss | write what as a higher order fn |
| 13:03 | devlinsf | jweiss: can you post your fn & a "patched" version? |
| 13:03 | jweiss | ok |
| 13:03 | devlinsf | Like, on the group or lisppaste? |
| 13:04 | jweiss | (defn myproc [] (print "a") (print "b")) -> (defn myproc2 [] (println "hello") (print "b")) |
| 13:04 | devlinsf | Ah |
| 13:04 | jweiss | i just want to replace one of the forms. i'm ok with marking the form somehow |
| 13:04 | devlinsf | Does your fn have side affects? |
| 13:04 | jweiss | devlinsf: yes |
| 13:04 | devlinsf | Ah. I vote for a macro |
| 13:05 | jweiss | devlinsf: how would i do that |
| 13:05 | Shantanu | hi all |
| 13:05 | jweiss | the macro won't have access to the original forms of the fn |
| 13:05 | devlinsf | Well... wait a sec |
| 13:05 | Shantanu | can anybody tell me a Maven2 repo for Clojure 1.1 RC ? |
| 13:06 | devlinsf | ,(let [myproc-2 (fn [f] (f "a") (f "b))] (myproc-2 print)) |
| 13:06 | clojurebot | EOF while reading string |
| 13:07 | devlinsf | ,(let [myproc-2 (fn [f] (f "a") (f "b"))] (myproc-2 print)) |
| 13:07 | clojurebot | ab |
| 13:07 | devlinsf | ,(let [myproc-2 (fn [f] (f "a") (f "b"))] (myproc-2 println)) |
| 13:07 | clojurebot | a b |
| 13:07 | devlinsf | Notice that myproc-2 takes a fn as an argumet |
| 13:07 | devlinsf | argument |
| 13:08 | devlinsf | That's called a higher-order fn |
| 13:08 | jweiss | devlinsf: yeah, but that's too simplistic, my real examples won't be using the same arguments either |
| 13:08 | devlinsf | Well, can you post the real deal? |
| 13:09 | jweiss | devlinsf: i'll have to think of an example that clojurebot can evaluate |
| 13:09 | devlinsf | Nah, just use lisppaste |
| 13:09 | jweiss | but basically i want to be able to replace (print "b") with ANY form |
| 13:09 | devlinsf | http://paste.lisp.org/new/clojure |
| 13:10 | devlinsf | Any form? Hmmm... maybe you want to use clojure.template? |
| 13:10 | jweiss | i want a way to tell clojure "this new fn is just like the old one, but replace this form with this one" |
| 13:10 | devlinsf | That's custom macro teritory |
| 13:10 | devlinsf | As in (defmacro defmycustom...) |
| 13:12 | jweiss | hm templates seems to be somethnig i could make use of |
| 13:12 | Shantanu | (Repeat question) Can anybody tell me a Maven2 repo for Clojure 1.1 RC ? |
| 13:15 | devlinsf | Shantanu: Here's Rich's post |
| 13:15 | devlinsf | http://groups.google.com/group/clojure/browse_thread/thread/24b9745199afbd89# |
| 13:15 | devlinsf | Shantanu: No mention of maven, though :( |
| 13:16 | Shantanu | devlinsf: Thanks, i guess i would use a local copy for a while until 1.1 arrives in th Maven repo |
| 13:17 | devlinsf | Shantanu: Yeah, sorry. Mention this on the group. I know Rich is interrested in having Maven work |
| 13:17 | Shantanu | devlinsf: I was expecting clojars.org to have it at least, but no luck there :-( |
| 13:18 | Shantanu | devlinsf: I will |
| 13:19 | devlinsf | jweiss: If clojure.template solves you problem, could you post your experience to the list? |
| 13:20 | jweiss | devlinsf: well, it won't solve the problem by itself, that's for sure. biggest hurdle right now is keeping the source of the original fn somewhere as data. which Chousuke pointed out i might do with a customized defn-like macro |
| 13:20 | the-kenny | 4Isn't the one from build.clojure.org usable in maven? |
| 13:21 | jweiss | but it would be nice if the language did this for me |
| 13:21 | jweiss | i guess it's pretty rare that someone would want that |
| 13:22 | devlinsf | jweiss: Do you really need to keep the source? Could you provide a list of symbols & custom forms, and def everything at once? |
| 13:22 | jweiss | devlinsf: i probably could, i'm just worried the resulting code would be pretty unreadable. |
| 13:23 | devlinsf | That's where the template comes in... hmmmm... |
| 13:24 | the-kenny | Maybe a (binding) is possible to |
| 13:24 | the-kenny | Something like a macro which does bindings according to some table where the changed symbols are kept |
| 13:25 | abedra | is there an easy way to make the return of a function into a regex pattern? |
| 13:26 | abedra | e.g i have a function "delimiter" that decides what a string delimiter is |
| 13:26 | the-kenny | abedra: (re-pattern your-string) |
| 13:26 | abedra | and i want to take the return of that and just call re-split (delimiter foo) |
| 13:27 | abedra | thanks |
| 13:27 | abedra | i think that will do it |
| 13:32 | devlinsf | jweiss: You totally want clojure.template :) |
| 13:34 | devlinsf | jweiss: Check this out http://gist.github.com/260186 |
| 15:06 | devlinsf | chouser: ping |
| 15:07 | chouser | devlinsf: hi |
| 15:07 | devlinsf | chouser: Just saw your comment |
| 15:08 | devlinsf | chouser: I used the exact same filename. Was that bad form? |
| 15:08 | chouser | hm... I thought I checked for that. |
| 15:08 | devlinsf | chouser: lemme check too |
| 15:09 | devlinsf | chouser: Yeah, the file is attached to the ticket. |
| 15:09 | devlinsf | chouser: It has the changes in it. |
| 15:10 | chouser | ohhh, I see. |
| 15:11 | chouser | you've got the previous patch in there too, adding the 2-arg withMeta, and then removing it again. |
| 15:12 | devlinsf | Yeah |
| 15:12 | devlinsf | Is that a problem |
| 15:12 | devlinsf | ? |
| 15:15 | devlinsf | chouser: I did everything in the same branch. Still learning git |
| 15:15 | chouser | well, it's probably less good. |
| 15:16 | chouser | same branch is a matter of personal preference. The generated patch is fine either way. |
| 15:17 | devlinsf | okay. I'll keep that in mind next time |
| 15:17 | chouser | I should say, rhickey hasn't provided firm direction on most of this, so all I can give is my own opinion. |
| 15:17 | chouser | I'd genereally try to keep the diff itself as small as possible -- less for people to review. |
| 15:18 | chouser | so deleting unreleated commented-code, for example, I'd generally avoid. |
| 15:19 | devlinsf | Right, I can see that |
| 15:19 | chouser | and including code in one commit that's deleted in the next, all in one patch, can also be confusing. |
| 15:20 | chouser | Your fix, in the end, is just replacing two lines and adding some tests. It'd be nice if that's all that shows up in the diff. |
| 15:21 | devlinsf | Right. |
| 15:21 | devlinsf | Resubmit or leave it? |
| 15:21 | chouser | I can do it if you don't want to. |
| 15:22 | devlinsf | Only if it's quick. Don't want to eat up too much of your time on this issue |
| 15:23 | chouser | sure, I'll do it. |
| 15:23 | Chousuke | squashing commits is pretty easy with git. |
| 15:24 | devlinsf | Cool |
| 15:26 | chouser | oh, shoot, I should have included your tests. |
| 15:27 | devlinsf | chouser: What about the java comments I added above empty? |
| 15:27 | devlinsf | Do they make the next guy's job easier? |
| 15:31 | chouser | good question |
| 15:31 | devlinsf | I don't follow Rich's style here (because that was causing the bug) |
| 15:33 | chouser | what do you mean? |
| 15:33 | devlinsf | Well, Rich uses a static field EMPTY to generate empty each time |
| 15:34 | chouser | oh, right. but avoiding the use of EMPTY is used elsewhere in that same file for the same reason. |
| 15:34 | devlinsf | He calls EMPTY.withMeta(meta()) |
| 15:35 | devlinsf | Not always. Look at create(items) |
| 15:36 | devlinsf | Anyway, this departs from the way things are done in the rest of Clojure |
| 15:36 | devlinsf | Hence, the /** java commets*/ Are probably a good idea. Javadoc will pick those up, too. |
| 15:37 | devlinsf | That's what I was thinking when I put them in. |
| 15:39 | hiredman | withMeta :( |
| 15:43 | chouser | devlinsf: Sometimes it's appropriate for comments to describe an alternate way something could be implemented and explain why it isn't, but I think those cases are pretty rare. |
| 15:43 | chouser | hiredman: what's wrong with withMeta? |
| 15:44 | devlinsf | chouser: Okay, cool. I guess the tests will prevent regression, so this should be fine. |
| 15:44 | hiredman | it replaces the map with another map, which leads to multiple functions that muck with metadata stepping on each other's feet |
| 15:45 | devlinsf | metdata is persistent |
| 15:45 | devlinsf | hiredman: I had your reaction initially |
| 15:46 | hiredman | for example, zippers store stuff in metadata |
| 15:46 | hiredman | (-> some-zipper some-function-which-naively-uses-withmeta zip/node) ;*BOOM* |
| 15:47 | hiredman | better to use vary-meta or similar where possible |
| 15:48 | devlinsf | hiredman: can you reproduce the bug? |
| 15:48 | hiredman | ,(use 'clojure.zip) |
| 15:48 | clojurebot | java.lang.IllegalStateException: next already refers to: #'clojure.core/next in namespace: sandbox |
| 15:48 | hiredman | ,(require '[clojure.zip :as zip]) |
| 15:48 | clojurebot | nil |
| 15:49 | hiredman | ,(-> '(1 2 3) zip/seq-zip) |
| 15:49 | clojurebot | [(1 2 3) nil] |
| 15:49 | hiredman | ,(-> '(1 2 3) zip/seq-zip (with-meta {}) zip/node) |
| 15:49 | clojurebot | (1 2 3) |
| 15:49 | hiredman | gah |
| 15:49 | hiredman | ,(-> '(1 2 3) zip/seq-zip meta) |
| 15:49 | clojurebot | {:zip/branch? #<core$seq_QMARK___4482 clojure.core$seq_QMARK___4482@1b53c44>, :zip/children #<core$identity__4959 clojure.core$identity__4959@1cf287e>, :zip/make-node #<zip$seq_zip__8135$fn__8137 clojure.zip$seq_zip__8135$fn__8137@7173bf>} |
| 15:50 | hiredman | ,(-> '(1 2 3) zip/seq-zip zip/down meta) |
| 15:50 | clojurebot | {:zip/branch? #<core$seq_QMARK___4482 clojure.core$seq_QMARK___4482@1b53c44>, :zip/children #<core$identity__4959 clojure.core$identity__4959@1cf287e>, :zip/make-node #<zip$seq_zip__8135$fn__8137 clojure.zip$seq_zip__8135$fn__8137@1808c77>} |
| 15:51 | hiredman | gah |
| 15:51 | hiredman | ok, zippers don't work exactly like I thought |
| 15:51 | hiredman | but the metadata thing is still an issue |
| 15:52 | chouser | vary-meta is build on withMeta() |
| 15:52 | slashus2 | Is there a good tutorial on using zippers? The only ones I see are in Haskell. |
| 15:52 | hiredman | chouser: sure |
| 15:53 | hiredman | I'm not saying withmeta is horrible, I am saying using it without regard for what metadata might already exist is bad |
| 15:53 | chouser | yes, true. |
| 15:54 | chouser | brb |
| 16:18 | the-kenny | If I use swap on an atom, is the supplied function f retried when another thread has changed the value? |
| 16:18 | the-kenny | *value of the atom |
| 16:22 | Chousuke | the operation is atomic, so yes. |
| 17:17 | rads | anyone know why when I do `lein swank` I get "Could not find clojure.main. Make sure you have it in your classpath"? |
| 17:18 | the-kenny | rads: Try running lein deps first |
| 17:22 | rads | the-kenny |
| 17:22 | rads | er, that worked, thanks |
| 17:22 | the-kenny | You're welcome |
| 17:26 | rads | when I do M-x slime-connect it seems to connect fine, but no REPL pops up |
| 17:50 | the-kenny | Interesting blog post about tail call optimization in the jvm: http://weblogs.java.net/blog/forax/archive/2009/12/18/tailcall-anyone |
| 17:52 | hiredman | I can't figure out how to emit the wide bytecode withe the asm lib bundled with cojure |
| 17:52 | alexyk | liebke: ping |
| 17:53 | liebke | alexyk: hey |
| 17:53 | alexyk | couple questions: if I want to contribute, e.g. the clustered scatter-plot, where should I add it in a fork? |
| 17:53 | alexyk | or, rather, preprocessing of xy's to compressed xy's |
| 17:54 | liebke | ah, good question |
| 17:55 | liebke | what about transformations |
| 17:55 | alexyk | ok |
| 17:55 | alexyk | at top level? |
| 17:55 | liebke | yeah |
| 17:56 | alexyk | so, src/main/clojure/incanter/transformations.clj? |
| 17:56 | liebke | yep |
| 17:57 | alexyk | ok. Another problem: when I chart from remote server via X, (use '[incanter ...]) inits the local X on my MacBook. From that moment on, if MBP goes to sleep, that kills remote X server and the clojure repl, with gigs of painfully loaded data. |
| 17:58 | liebke | hmmm |
| 17:58 | alexyk | So I'm stuffing it all back into Mongo, thank G-d for that. But is there a way to unload incanter after plotting, or disconnect from X, or something? |
| 17:59 | liebke | good question, but I don't have an answer |
| 17:59 | the-kenny | hm.. I will give mongodb a try |
| 17:59 | liebke | if you figure out a fix, let me know |
| 18:00 | alexyk | I tunnel X via ssh -X or ssh -Y. In general, I think it's a common setup for data mining on big boxes remotely, so would be good to find a way to be able to suspend clients without killing servers. |
| 18:00 | the-kenny | Fast: Best mongodb-lib for clojure |
| 18:00 | alexyk | the-kenny: congomongo |
| 18:00 | liebke | yeah, I use ssh -X myself |
| 18:01 | alexyk | liebke: did you experience this server quitting? |
| 18:01 | liebke | I haven't run into the problem yet, but it doesn't mean I won't |
| 18:03 | hiredman | the issue is really with the X protocol, your best bet is just not to let your laptop go to sleep |
| 18:04 | Anniepoo | question for all - I'm needing to do a fuzzy word match. Anybody here with any experience with such? |
| 18:04 | hiredman | you might try using some kind of vnc instead of tunneling x11 |
| 18:04 | hiredman | x2vnc or something |
| 18:05 | liebke | hiredman: hmm, interesting idea. I guess it's good to know about this problem with x11 |
| 18:07 | thearthur | whats the functions to return true if any member of a collection matches a predicate? |
| 18:07 | hiredman | putting the laptop to sleep will kill the X connection, and the x archtecture makes it not, uh, "restartable" |
| 18:07 | hiredman | some |
| 18:09 | thearthur | hiredman, thanks, had my brain stuck on any? |
| 18:10 | gravity | There are programs that will act as the equivalent of "screen" for X11. I don't know if they'll work for OSX though, but it's worth a look |
| 18:10 | hiredman | really? I guess I shouldn't be surprised |
| 18:10 | liebke | gravity: thanks, I'll have to look for one |
| 18:11 | gravity | http://www.insanelymac.com/forum/index.php?showtopic=80076 lists mac-specific options (xmove) |
| 18:12 | alexyk | hiredman: interesting |
| 18:12 | liebke | gravity: cool thanks |
| 18:12 | gravity | np |
| 18:27 | the-kenny | mh.. congomongo looks so... big and ugly compared to clojure-couchdb |
| 18:34 | jasapp | the-kenny: how so? |
| 18:35 | qed | http://blog.labnotes.org/2009/12/19/all-your-maven-are-belong-to-us/ |
| 18:35 | qed | interesting stuff |
| 18:35 | jasapp | I've been using congomongo, but haven't used couchdb at all |
| 18:36 | the-kenny | jasapp: I think it's because the interface to couchdb is much simpler (just http). |
| 18:37 | jasapp | ahh |
| 18:38 | somnium | writing BSON encoders for tcp/ip is definitely a PITA |
| 18:39 | the-kenny | Oh sorry somnium, I didn't want to decry your work. |
| 18:39 | somnium | the-kenny: *shrug* Ive been wrapping the java driver |
| 18:40 | jasapp | did you have any ideas on doing the map reduce stuff, or the sorting? |
| 18:40 | jasapp | somnium, for congomongo? |
| 18:40 | jasapp | I've got some time over the next few weeks, and I wouldn't mind hacking on it some. |
| 18:40 | somnium | jasapp: yes, the biggest obstacle is the java driver |
| 18:41 | jasapp | I guess I haven't looked at the java part too closely |
| 18:41 | jasapp | what's limiting? |
| 18:41 | somnium | jasapp: the encoding, its in Bytes or one of the subclasses |
| 18:42 | somnium | ah, for map-reduce etc, its mostly there in the java driver |
| 18:43 | jasapp | is there anyway to write map reduce functions in clojure, instead of js? |
| 18:43 | jasapp | short of using the clojure to js translator |
| 18:44 | somnium | jasapp: have to gen js somehow |
| 18:44 | the-kenny | there are two clojure -> js libs I'm aware of |
| 18:45 | somnium | Im working on one with basic support for TCO and clojureish semantics |
| 18:45 | jasapp | cool |
| 18:46 | somnium | maybe just alter the prototype for array and object to support seq could work |
| 18:47 | somnium | but clojure encoders would mean sorted-maps, hash-sets, whatever could be stored in mongo with great performance |
| 18:48 | jasapp | if there is anything I can help with, please let me know |
| 18:48 | somnium | jasapp: if working on a tcp/ip BSON client sounds like a fun project... (hint hint) |
| 18:48 | jasapp | hmm, I might be interested in tackling that |
| 18:49 | jasapp | so you avoid using the java drivers completely? |
| 18:50 | somnium | yeah, the main issue is performance |
| 18:51 | somnium | but right now some work is being repeated, so deftype based clojure encoders should be equivalent if not faster |
| 18:52 | jasapp | I'll take a look at bson and see if it's something I can handle |
| 18:53 | somnium | its bit twiddling the byte buffers where Im mostly clueless |
| 18:53 | jasapp | someone mentioned on here the other day that clojure was particularly slow when it cames to bits |
| 18:54 | jasapp | I think that's maybe fixed in 1.1 though |
| 18:55 | somnium | hopefully byte arrays are pretty fast |
| 18:56 | somnium | the driver uses os-streams through java.nio |
| 19:03 | _ato | jasapp: bit-twiddling and arithmatic in Clojure should be no slower than Java as long as you are careful about it and use appropriate casts to avoid boxing. |
| 19:04 | jasapp | _ato: thanks for the info |
| 19:04 | jasapp | I wish I could remember who said that, and what exactly they said |
| 19:04 | jasapp | does clojurebot keep a log? |
| 19:05 | the-kenny | jasapp: Yes |
| 19:05 | somnium | maybe the bit-shift operators? |
| 19:05 | the-kenny | clojurebot: logs |
| 19:05 | clojurebot | logs is http://clojure-log.n01se.net/ |
| 19:05 | _ato | it could be because the bit-shift operators are java function ca |
| 19:05 | _ato | lls |
| 19:05 | _ato | but I would have thought hotspot would inline them anyway |
| 19:08 | somnium | hmm, bit-and calls out to clojure.lang.Numbers, do they get boxed on the way? |
| 19:08 | _ato | ~def bit-shift-right |
| 19:08 | _ato | hmm |
| 19:08 | _ato | you're right |
| 19:08 | _ato | that's worrying |
| 19:08 | _ato | since they're wrapped in Clojure functions without inlines that's going to be forcing boxing |
| 19:09 | somnium | jasapp: the encoders just need to bash on ByteBuffers, no actual bit-twiddling needed |
| 19:10 | jasapp | alright |
| 19:10 | _ato | bit-not, bit-or etc have inlines, just looks like set, test and shifts are missing them |
| 19:11 | somnium | ive only ever used bit-twiddling on euler problems :/ |
| 19:11 | hbock | has anyone attempted to run clojure on an embedded JVM, e.g., Squawk? |
| 19:12 | the-kenny | hbock: I've not.. but I would like to see it running on the lejos-jvm :) |
| 19:12 | hiredman | a lot of that stuff doesn't use "modern" jvms |
| 19:13 | hiredman | e.g. 1.5 or later |
| 19:13 | hbock | the-kenny: interesting. |
| 19:13 | _ato | hbock: it works in jamvm, it's kind of slow though |
| 19:13 | hiredman | squawk is j2me which is 1.4 |
| 19:13 | hiredman | so no dice |
| 19:13 | hbock | :( |
| 19:13 | hbock | damn. |
| 19:13 | hbock | FIRST robotics is using the Squawk JVM |
| 19:14 | hbock | we were hoping to get clojure running on our bot. |
| 19:15 | hiredman | hbock: I could be wrong, there might be some kind of j2me that is 1.5+ |
| 19:15 | hiredman | (not as far as I can tell though) |
| 19:16 | hiredman | ~maxine |
| 19:16 | clojurebot | Titim gan éirí ort. |
| 19:16 | hiredman | clojurebot: maxine is http://research.sun.com/projects/maxine/ |
| 19:16 | clojurebot | Roger. |
| 19:19 | notallama | so, would it count as writing a jvm in java if you wrote it in clojure? |
| 19:21 | hiredman | I'm not sure if maxine does a bytecode transform or a transform over source (to get the native bits) |
| 19:22 | hiredman | maybe asm could be reworked to emit some special bytecodes |
| 19:22 | hbock | hmm. newbie question: does paredit work without modification with clojure? |
| 19:22 | somnium | does hotspot completely rewrite the output from javac? |
| 19:23 | hiredman | somnium: eh? |
| 19:24 | somnium | I watched a talk a while back, and the gist I got was that hotspot undoes all of javac's optimizations and completely reoptimizes at runtime |
| 19:25 | hbock | ahh. looks like there's a clojure-paredit.el |
| 19:26 | hiredman | somnium: hotspot generally is about generating native code from bytecode |
| 19:27 | somnium | hiredman: it was yegge bashing on java/c++ I think, so some of it might have been hyperbole I guess |
| 19:27 | hiredman | it might not be |
| 19:28 | hiredman | but hotspot watches for hotspots and kicks in, so you have to do x executions before it kicks in |
| 19:29 | hiredman | x is generally on the order of 1000, I hear |
| 19:29 | chouser | somnium: I'm under the same impression, that hotspot decompiles what javac produces and then does its own optimizations. |
| 19:29 | somnium | http://www.youtube.com/watch?v=tz-Bb-D6teE |
| 19:29 | hiredman | so for the first 1000 you have only what javac gave you |
| 19:30 | somnium | it does make Foo foo = ((Foo)Foomaker.MakeFoo()) seem particularly silly |
| 19:32 | hiredman | that is purely a compiler issue |
| 19:33 | hiredman | while the bytecode is typed and you do casts and such, the compiler could be smarter and do inference, etc |
| 19:35 | lopex | javac doesnt do any optimizations |
| 19:35 | lopex | except for very obvious ones, like constant propagation for static finals |
| 19:48 | interferon | do lazy sequences do any kind of caching? if i evaluate the first 10 elements of a lazy sequence and then later ask for the first 20, will the first 10 be computed again? |
| 19:48 | somnium | interferon: if its the same lazy-seq it will be cached |
| 19:49 | somnium | ,(doc lazy-seq) |
| 19:49 | clojurebot | "([& body]); Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequent seq calls." |
| 19:49 | interferon | great. thanks. |
| 19:58 | alexyk | how do you refer to the whole pattern, e.g. fn [[k v]] -- how do you get [k v] back too? |
| 19:59 | somnium | ,(let [[k v :as all] [1 2]] (list k v all)) |
| 19:59 | clojurebot | (1 2 [1 2]) |
| 20:00 | alexyk | ah |
| 20:43 | xochipil1i | fffffffffffffffffffffffff |
| 20:43 | xochipil1i | wtf |
| 21:06 | alexyk | somnium: can mongo do merges? |
| 21:14 | somnium | alexyk: like (merge {:a :b} {:c :d}) ? |
| 21:14 | alexyk | yeah, inside mongo |
| 21:14 | alexyk | before returning |
| 21:15 | alexyk | I have two big collections, same keys |
| 21:15 | alexyk | :user |
| 21:15 | somnium | alexyk: I dont know :/ |
| 21:16 | somnium | try #mongodb? |
| 21:16 | alexyk | somnium: I have a sense it might... will ask mongo ppl |
| 21:16 | alexyk | yeah |
| 21:17 | somnium | my actual use of mongo so far has just been as a read-only fact-table |
| 21:19 | somnium | /join #mongodb |
| 21:19 | somnium | \join mongodb |
| 21:19 | somnium | sry |
| 21:21 | alexyk | ,(count (second (first [[:a [1 2 3]] [:b [4 5]]]))) ; how do I use comp to get rid of some ()s? |
| 21:21 | clojurebot | 3 |
| 21:22 | chouser | ,(->> [[:a [1 2 3]] [:b [4 5]]] first second count) |
| 21:22 | clojurebot | 3 |
| 21:23 | chouser | ,((comp count second first) [[:a [1 2 3]] [:b [4 5]]]) |
| 21:23 | clojurebot | 3 |
| 21:23 | alexyk | chouser: cool. But is comp applicable here too? |
| 21:23 | alexyk | ah yes |
| 21:24 | chouser | :-) |
| 21:24 | hiredman | :) |
| 21:24 | somnium | ♥ ->> |
| 21:43 | devlinsf | quick git question |
| 21:43 | devlinsf | how do I "forget" all the changes since my last commit |
| 21:45 | dnolen | devlinsf: git reset --hard HEAD^ |
| 21:46 | dnolen | remove --hard if you don't want to blow away the index |
| 21:46 | tolstoy | git --reset --har..... ah, yeah. |
| 21:47 | devlinsf | Works, thanks! |