2010-06-23
| 00:00 | dnolen_ | so yay, nay? no one using clj-apache-http ? |
| 00:12 | gstamp_ | is the macroexpand feature in swank-clojure not working for anyone else? When I try and expand a macro I just get the name of the macro back rather than the expansion |
| 00:17 | tomoj | gstamp_: where's point when you do it |
| 00:18 | gstamp_ | on the macro name itself |
| 00:19 | tomoj | put it on the opening paren |
| 00:20 | gstamp_ | great. thank you, that works |
| 00:20 | tomoj | I thought it used to clean it up a bit, but mine doesn't anymore |
| 00:32 | dnolen_ | tomoj: I patched it, you need to use swank-clojure from HeAD |
| 00:33 | tomoj | cool |
| 00:33 | tomoj | was that a regression or was it my imagination? |
| 00:33 | dnolen_ | tomoj: things broke because of clojure 1.2.0 work |
| 00:34 | tomoj | ah |
| 00:43 | tomoj | dnolen_: very nice, thanks :) |
| 00:43 | dnolen_ | tomoj: np |
| 00:43 | tomoj | for is such a monster |
| 00:43 | tomoj | 47 lines for (for [x (range 10)] x)... |
| 00:45 | dnolen_ | Clojure is like the most awesome Object Oriented language evar |
| 01:21 | defn | tomoj: did you look at the challenge problem |
| 01:24 | tomoj | yep |
| 01:24 | tomoj | haven't thought much about it, though |
| 01:30 | defn | help me solve it :) |
| 01:39 | tomoj | depth-first search can't be right, I guess |
| 01:46 | defn | actually i think that will work |
| 01:48 | tomoj | but it will be too slow, won't it? :( |
| 01:52 | defn | yeah :( |
| 01:52 | defn | I think using symmetry can help |
| 01:53 | defn | you could do depth first but discard bad paths early in the search |
| 01:54 | defn | detecting when a path splits the grid into two unconnected pieces could be helpful maybe??? |
| 03:02 | Licenser | hmm the agent pool thingy is really hurting clojures performance :( |
| 03:36 | Bahman | Hi all! |
| 03:37 | Bahman | I am new to Clojure and just learning it. |
| 03:38 | Bahman | I am Bahman from Iran. |
| 03:39 | Bahman | BTW, what's the difference between "remove" and "drop-while"? I can't find out how they differ. |
| 03:39 | Licenser | Greetings Bahman :) it is a good decision to learn Clojure, it's a wonderful language! |
| 03:40 | tomoj | ,(drop-while even? [2 4 6 1 3 7 8 10]) |
| 03:40 | tomoj | $(drop-while even? [2 4 6 1 3 7 8 10]) |
| 03:40 | sexpbot | => (1 3 7 8 10) |
| 03:40 | tomoj | $(remove even? [2 4 6 1 3 7 8 10]) |
| 03:40 | sexpbot | => (1 3 7) |
| 03:40 | Licenser | $(drop-while odd? [1 3 2 1 4]) |
| 03:40 | sexpbot | => (2 1 4) |
| 03:40 | Licenser | oh darn you tomoj ;P I was about to give the exact same esaple just with odd |
| 03:40 | tomoj | sorry :( |
| 03:41 | Bahman | Yes Licenser...I've always liked to learn Lisp but the problem was that as I'm a Java developer I'm used to read-to-use high-level components like Workflow engines which Lisp lacked. |
| 03:41 | Bahman | Fortunately Clojure doesn't have this problem. |
| 03:41 | Licenser | *nods* You'll also find the comunity qite friendly :) |
| 03:42 | Bahman | Licenser: Yes..it seems so :-) |
| 03:43 | Bahman | tomoj: 8 is even...why it's not dropped? |
| 03:43 | Licenser | Bahman: drop while drops the first elements as long as the condition is true |
| 03:43 | Licenser | remove removes all elements for that the condition is true |
| 03:44 | Licenser | so drop-while stops as soon as it finds a element that does not match the condition |
| 03:44 | Bahman | Licenser: I see the point. Thanks. |
| 03:44 | Licenser | :) |
| 03:44 | Licenser | welcome |
| 03:45 | Bahman | So, is it alright to ask here such silly questions if I'm stuck? :-D |
| 03:46 | Bahman | Or should I use the forums (if any)? |
| 03:46 | Licenser | Of cause it is, most of us started like that :P |
| 03:47 | Bahman | Good for me :-D |
| 04:13 | Kjellski | How would you do this idiomatically? I want to parse a file with "newline" separated textblocks. I want to group these blocks, which are themselves csv. I´ve already slurped the data in and parsed it with |
| 04:14 | Kjellski | clojure-csv. Now I´ve got the vector over vectors, wich I want to separate with the elements [""] in there.. |
| 04:14 | Kjellski | Any ideas? |
| 04:14 | Licenser | I'd make do (re-seq #"[^\n]" data) |
| 04:14 | Kjellski | On the file? |
| 04:14 | Licenser | ah okay you areldy have something |
| 04:15 | Kjellski | Okay, and after that use parse-csv? |
| 04:15 | Licenser | well won't clojure-csv not already do that for you? |
| 04:15 | Licenser | never used the cloure-csv lib |
| 04:15 | Kjellski | Yes, but it´s a vector over vectors, which I want to group elements from... |
| 04:16 | AWizzArd | ,(doc group-by) |
| 04:16 | Licenser | a vector of vectors, I guess it are vectors of fields in vectors of lines right? |
| 04:17 | AWizzArd | Okay, clojurebot is offline. But maybe clojure.contrib.seq/group-by |
| 04:17 | Kjellski | AWizzArd: Thanks, I´ll have a look at that... ;) |
| 04:17 | Licenser | $(doc group-by) |
| 04:17 | sexpbot | => ------------------------- clojure.core/group-by ([f coll]) Returns a map of the elements of coll keyed by the result of f on each element. The value at each key will be a vector of the correspon... http://gist.github.com/449631 |
| 04:17 | Kjellski | Licenser: thanks, I´ll have a try.... |
| 04:18 | Licenser | hmm I apearently suck at making clojure code fast .P |
| 04:19 | spariev | Licenser: you should write some ruby - it'll help you to stop worrying about clojure speed :) |
| 04:19 | Licenser | spariev: :P |
| 04:25 | Licenser | actually it's not slow it's an infinit loop |
| 04:34 | Licenser | hmm what was the function to divide two integers? |
| 04:34 | Licenser | rem was the reminder but I never can remember the name of the other one :( |
| 04:35 | spariev | $(doc quot) |
| 04:35 | sexpbot | => ------------------------- clojure.core/quot ([num div]) quot[ient] of dividing numerator by denominator. nil |
| 04:36 | Licenser | Thank you! |
| 05:06 | Licenser | Hmm I just tried to implement a few benchmarks in clojure and I noticed that it's beauty quicky gets burried under a heap of performance measures :( |
| 05:11 | eevar2 | Licenser: profiling overhead? |
| 05:11 | Licenser | eevar2: no what I mean is when you want to get close to java'ish speed you've to do tons of ugly things |
| 05:11 | Licenser | and it still isn't exactly fast :P |
| 05:12 | eevar2 | ah. missed "beauty" in that sentence |
| 05:12 | Licenser | clojure is great because solutions look clean and nice in it, are easy to read and understand |
| 05:12 | Licenser | if you want to get it fast this gets lost and you write java with parens in different places (at least that is what it feels like to me right now) |
| 05:13 | Fossi | well, most "benchmarks" are actually pretty screwed anyway |
| 05:13 | eevar2 | if you stick to the same algorithms, i.e. using loops instead of creating lists and so on, performance isn't all that different? |
| 05:13 | Fossi | well i guess that counts as "ugly things" |
| 05:13 | eevar2 | might not be quite as idiomatic, but |
| 05:14 | Licenser | eevar2: yes it does kind of |
| 05:14 | Licenser | because you can't really use any of the build in functions since they are slow |
| 05:14 | Licenser | well not slow slow but compared to pure javaish code they are slow |
| 05:15 | Licenser | my first atempt was quite nice looking short and well slow |
| 05:16 | Licenser | now it gets slowly more and more ugly as it gets faster and faster |
| 05:18 | tomoj | Licenser: you have a java version written? |
| 05:18 | Licenser | I know where one is but I haven't written it myself |
| 05:21 | tomoj | are you planning to blog this attempt? |
| 05:21 | Licenser | tomoj: yes as sonn as I'm happy with it but I'm not :P |
| 05:21 | tomoj | using prim? |
| 05:21 | tomoj | dunno how much that would help |
| 05:21 | Licenser | http://gist.github.com/449687 if you want to look |
| 05:21 | Licenser | tomoj: yes using prim |
| 05:22 | Licenser | I want to see how much worth the changes are |
| 05:22 | tomoj | the lisp code in that paper is horrifyingly ugly |
| 05:23 | AWizzArd | In what way? |
| 05:23 | Licenser | as in if you really benefit from it when writing fast code |
| 05:23 | Licenser | and while being nearly convinced that the tradeoff is worth it, I slwoy think again it isn't since you anway have to make it ugly if you want it fast |
| 05:24 | bobo_ | why is ugly code always faster then pretty code? in all languages, feels so wrong |
| 05:24 | Licenser | bobo_: I agree :I( |
| 05:24 | Licenser | but I think it isn't in assembly |
| 05:24 | Bahman | Licenser: Look at the C code: SMALL k2=(k+1)>>1 ...it's somewhat a cheating :-) You can only do such things in C or Assembly. |
| 05:25 | bobo_ | assambly is always ugly |
| 05:25 | eevar2 | Licenser: _are_ you profiling btw, or just fumbling around blind? ;) |
| 05:25 | Licenser | eevar2: I know what is slow, I managed to reduce the overhead to nearly 0 in my algorithm |
| 05:25 | Licenser | now the only thing that is slow is the permutations |
| 05:26 | Licenser | at least that is what I think |
| 05:26 | Licenser | but I'm not using a profiler as they always make me itchy |
| 05:26 | Licenser | I do profile by hand so (as in removing bits of code to see the impact) |
| 05:27 | Licenser | to make this fast I need to implement the permutations myself on a static mutating *cry* array |
| 05:27 | Licenser | as I did with the reversing part |
| 05:27 | hoeck | Licenser: and did you measure the differences of a relatively beautiful fannkuch benchmark in prim and normal clojure? |
| 05:27 | Licenser | hoeck: I admit no |
| 05:27 | Licenser | but I should do that |
| 05:28 | hoeck | because that would be really interesting to see |
| 05:29 | Licenser | true |
| 05:32 | hoeck | Licenser: do you have a nice looking but easily understandable and probably slow version of the fannkuch benchmark? |
| 05:32 | Licenser | hoeck: yes give me one second to make sure it is correct :P |
| 05:33 | hoeck | great :) |
| 05:35 | Licenser | it is still testing :P |
| 05:36 | Licenser | I got the source for scala from http://shootout.alioth.debian.org/u32/program.php?test=fannkuchredux&lang=scala&id=1 too |
| 05:36 | Licenser | for this clojure sadly is 10 times slower :( |
| 05:36 | Licenser | in the optimized version that is |
| 05:36 | Licenser | and 60 times lower in the nice one |
| 05:37 | Licenser | http://gist.github.com/449701 the nice code |
| 05:37 | Licenser | I find this pretty ideomatic at least |
| 05:37 | bartj | hi all |
| 05:38 | hoeck | Licenser: thanks |
| 05:38 | Licenser | welcome hoeck I might push the entire thing to github too |
| 05:38 | Licenser | perhaps others are better then me at making things fast <tm> |
| 06:08 | Licenser | hoeck: http://gist.github.com/449731 |
| 06:08 | Licenser | test results |
| 06:08 | bartj | I am not able to appreciate the value of partial |
| 06:08 | Licenser | it is only partially useful bartj |
| 06:15 | hoeck | Licenser: are you measuring the whole jvm execution time? |
| 06:15 | Licenser | hoeck: yes |
| 06:16 | hoeck | why? |
| 06:16 | Licenser | I know it is not exact |
| 06:16 | hoeck | no warmup etc etc? |
| 06:16 | Licenser | becase it should be the same for every compliation |
| 06:16 | Licenser | the multiplyer should not change |
| 06:16 | Licenser | just an index |
| 06:16 | Licenser | or rather a static value |
| 06:17 | Licenser | I will push my setup shortly |
| 06:18 | hoeck | but you are currently measuring jvm and clojure startup performance, not really the pfannkuchen |
| 06:21 | Licenser | hoeck: well for the small numbers yes, but usually I take bigger ones |
| 06:21 | Licenser | where you see something like a few secs difference |
| 06:21 | Licenser | or a magnitude of difference |
| 06:22 | spariev | Licenser: have you considered using Criterium http://hugoduncan.org/post/2010/benchmarking_clojure_code_with_criterium.xhtml for benchmarking ? |
| 06:22 | Licenser | *looks at that* |
| 06:22 | spariev | also, LauJensen has nice post on proper benchmarking AFAIK |
| 06:22 | Chousuke | including the jvm startup time and not doing any warmup will not make clojure look good at all :P |
| 06:23 | Licenser | spariev: since I want to not only benchmark clojure that isn't too helpful |
| 06:23 | Chousuke | it also won't be realistic |
| 06:23 | Licenser | actually if 1.1 takes twice as long as 1.2 (for example) that is a quite useful information unels 1.1 starts twice as slow as 1.2 |
| 06:26 | Chousuke | in those results you posted the actual execution time seems to be obscured by the startup. |
| 06:26 | Chousuke | It's difficult to tell how well it's actually performing |
| 06:26 | Licenser | Chousuke: yes I know that was just to show how it looks I'll post new ones that might be more interesting |
| 06:26 | Licenser | since they are longer runing |
| 06:26 | Licenser | but yes I know the benchmarks are falwed, as all benchmarks are, I know in what direction they are flawed so I hopefully won't go to draw bad conclusions from it |
| 06:27 | hoeck | Licenser: I'm using criterium too to do the fannkuch |
| 06:27 | hoeck | Licenser: which branch is the one you use |
| 06:27 | Licenser | I use 1.2 master and 1.2 equal |
| 06:28 | Licenser | I will github push the whoel setup in about 2 minutes (then this run should be through) |
| 06:28 | hoeck | Licenser: I mean, I'm looking for the one with magical loops and primitive ops as the default |
| 06:28 | Licenser | yes I push the exact .jars I use |
| 06:28 | Licenser | unless that is prohibited and rhicky will sue me for it :( |
| 06:28 | Chousuke | of course it's not prohibited :P |
| 06:28 | Licenser | :P |
| 06:29 | Chousuke | unless you've done modifications, of course |
| 06:29 | Licenser | http://gist.github.com/449748 |
| 06:29 | Licenser | here results now I push |
| 06:29 | Licenser | I compiled them |
| 06:32 | Chousuke | the difference with scala shouldn't be that big, considering you should be able to get jvm-native speeds from numerical calculations now. |
| 06:33 | Licenser | Chousuke: I agree but from the code I have it sadly is |
| 06:33 | Licenser | pushing right now but with all the jars in there it take a moment |
| 06:34 | Licenser | but the difference beteen master and equal is scarry for idomatic clojure code |
| 06:34 | Licenser | it seems the equal branch is slower right now |
| 06:34 | Licenser | at least for this kind of code |
| 06:35 | Licenser | 20s difference isn't startup time either |
| 06:35 | Licenser | I wonder what causes this |
| 06:41 | Chousuke | did you remember to use ^:static and type hint as necessary? |
| 06:41 | eevar2 | never ever profile your benchmarks |
| 06:42 | eevar2 | i hear you can go blind |
| 06:42 | defn | lol |
| 06:44 | bartj | is there a better way to remove empty strings in a sequence than: |
| 06:45 | bartj | , (remove #(= "" (.trim %)) [" " "abc" "" "x"]) |
| 06:45 | bartj | ,(remove #(= "" (.trim %)) [" " "abc" "" "x"]) |
| 06:48 | spariev | bartj: there is also blank? function in c.c.str-utils2/string , which you can use - (remove blank? [" " "abc" "" "x"]) |
| 06:49 | Licenser | eevar2: you know even I, and I know that might seem as a shock, can only do one thing at a time :P |
| 06:49 | Licenser | http://github.com/Licenser/clj-shootout have fun |
| 06:50 | Licenser | but Chousuke the point was to see how basic code works compared in main and equal |
| 06:50 | hoeck | Licenser: got a clojure build from may competing against equals, old code does (fannkuch 7) in 190ms, equals in 240 |
| 06:51 | bartj | spariev: cool, thanks |
| 06:51 | spariev | np |
| 06:51 | Licenser | hoeck: what? o.O |
| 06:51 | hoeck | Licenser: so we basically made the same observation, that equals is a bit slower on the idiomatic code |
| 06:52 | Licenser | wall 190 vs 240 isn't a bit sadly :( that is about 20% |
| 06:52 | hoeck | right :/ |
| 06:53 | Licenser | now the task is to find WHAT makes it slower eevar2 and now I'm going to profile |
| 06:53 | Chousuke | Licenser: that doesn't look like very fast code at all. |
| 06:54 | Licenser | Chousuke: I know it is ideomatic code, the nicest way I could come up to write this algorithm |
| 06:54 | Chousuke | and there's next to nothing that would get a benefit from the equals branch |
| 06:56 | Licenser | Chousuke: I know but oddly enough it is not too far away from what much clojure code deos: reorganizing lists and gathering data above them |
| 06:56 | Chousuke | Licenser: I think the main problem in the function version is that you're using concat a lot |
| 06:56 | Chousuke | that'll create one *really* lazy seq |
| 06:57 | Chousuke | My first guess would be that the overhead of laziness is killing performance :/ |
| 06:58 | Licenser | Chousuke: but it never gets realized fully |
| 06:58 | Chousuke | Licenser: that's the problem |
| 06:58 | Chousuke | Licenser: it creates a whole bunch of thunks :P |
| 06:58 | Licenser | only the first argument but I'll see once I toss on the horror profiler |
| 07:00 | Chousuke | you'll have one lazy seq, take one item from it, then make a lazy seq over the rest of it, repeating, until you have a lazy seq times a dozen :P |
| 07:01 | Licenser | actually 38 lazy seqs deep |
| 07:03 | Licenser | now I've to remember how I get this silly profiler to actually profile stuff :P |
| 07:04 | Licenser | there was some trick to put the the starting class but I don't remember o.O |
| 07:07 | Licenser | ah I fear I know what it was :( it was meh |
| 07:10 | Bootvis | what is the recommended way to store 2-dimensional data persistently? |
| 07:11 | Licenser | it seems reverse costs the most |
| 07:14 | Licenser | depends on your access method |
| 07:14 | Licenser | if it is 2 dimensional in sense of k/v then a hashmal if it is 2 dimensional in the sense of a matrix then a vector of vectors |
| 07:15 | Bootvis | thanks |
| 07:16 | Licenser | oddly enough both reverse and nthnext (both core functions) have gotten slower o.O |
| 07:32 | Licenser | this is very odd |
| 07:42 | Bahman | A question: I'm reading "Practical Closure" and I came across this sentence: "When writing idiomatic Clojure, one cannot use sequences too much." |
| 07:43 | Bahman | Is it correct? I think it should be "...once cannot avoid...". |
| 07:46 | Bahman | Just to clear things: I thought Clojure is about sequences but this sentence seems the have the opposite meaning. |
| 07:47 | cemerick | Bahman: It's an odd sentence in any case. |
| 07:47 | cemerick | Sequences are core to idiomatic clojure. |
| 07:47 | Licenser | seqs are usually your friends |
| 07:49 | spariev | bahman: maybe you should submit this error at the apress site - http://apress.com/book/errata/1312 , oddly (as compared to manning) there is no forum for this kind of stuff |
| 07:49 | Bahman | Good to know that...So it's just a typo. |
| 07:49 | Bahman | Thanks everyone. |
| 07:50 | Bahman | Will do spariev. |
| 07:53 | Licenser | it seels Chousuke is right lazy seq, for some reason is slower |
| 07:55 | Chousuke | I think the sentence makes perfect sense. |
| 07:55 | Chousuke | Saying you can't use sequences too much means no matter how much you use them, it's not excessive |
| 07:55 | ttmrichter | Wait a second: there's a SECOND book on Clojure out? Cool! |
| 07:56 | Chousuke | Bahman: ^^ |
| 07:56 | rfg | Bahman: I don't think it's a typo, just one of these sentences that doesn't sound right unless you are a native speaker. |
| 07:56 | cemerick | Chousuke: of course, you *can* use sequences too much, if they're not appropriate for a given problem. :-) |
| 07:56 | Licenser | actually it seems you can use them too much :P |
| 07:56 | Chousuke | cemerick: well, yeah. :P |
| 07:57 | Bahman | Oh! |
| 07:57 | cemerick | It's definitely an odd thing to say. |
| 07:57 | Chousuke | cemerick: but a little hyperbole never hurt anyone. much. |
| 07:57 | Bahman | You're just 30 seconds late rfg :-) |
| 07:58 | cemerick | Chousuke: and here I was going to reimpl stuff to use alist seqs instead of maps! :-P |
| 07:58 | rfg | That's because I'm typing on my phone :) |
| 07:58 | Licenser | so here is the odd thing: running the fannkuchen2 code with doall around the concat makes equal faster, doing it without the concat makes master faster |
| 07:58 | Chousuke | cemerick: but maps become alists when you call seq on them! |
| 07:58 | Bahman | So the sentence is analogous to "priceless"...whatever the "price" it is not enough...no matter how much seqs are used, it's not enough. Right? |
| 07:59 | Chousuke | Bahman: it's not *excessive* |
| 07:59 | Bahman | Chousuke: Got your point. |
| 08:00 | cemerick | Chousuke: right! Clearly, alists (and therefore seqs) are superior to maps! ;-) |
| 08:02 | AWizzArd | cemerick: alists as in CLs alists? |
| 08:03 | Licenser | aaaaaaaaaaaaaahhh lists? |
| 08:03 | cemerick | AWizzArd: yeah, don't worry about it, I'm being sarcastic/snarky. |
| 08:07 | cemerick | mmm, juicy NoSuchFieldError when AOT-compiling |
| 08:09 | rhickey | cemerick: I've got half a cup down, shoot |
| 08:09 | cemerick | rhickey: NoSuchFieldError during AOT: https://gist.github.com/d8ba04dd0613cb7e11ba |
| 08:11 | Bahman | Well, clojure.org seems to be banning access from Inside Iran :-( |
| 08:12 | rhickey | cemerick: have you got top-level calls? |
| 08:12 | Chousuke | Bahman: wouldn't it be the other way around :/ |
| 08:13 | cemerick | rhickey: No....but, in which direction are you after? |
| 08:13 | Bahman | I don't know...I doubt even those censor-men know about Clojure :-S |
| 08:13 | Chousuke | Bahman: ie. Iran would ban clojure.org (Though I have no idea why), not vice versa :P |
| 08:13 | cemerick | rhickey: The reference to the java class is in a fn; the static init in the class is there to support later RT.var lookups (both static and in method bodies). |
| 08:14 | rhickey | cemerick: which version of Clojure? |
| 08:15 | Bahman | Chousuke: Maybe...thinking how to find out... |
| 08:15 | ttmrichter | Bahman, I'll show you how to work around your censors if you want to talk in private. |
| 08:15 | Bahman | ttmrichter: Will appre |
| 08:15 | Bahman | I appreciate that :-) |
| 08:15 | ttmrichter | (For reference I'm in China and have censorship problems too. ;) |
| 08:16 | Chousuke | why would clojure.org get blocked? :P |
| 08:16 | cemerick | rhickey: latest snapshot AFAIK: 1.2.0-master-20100607.150309-85 |
| 08:16 | Chousuke | maybe because it's hosted on wikispaces? |
| 08:16 | ttmrichter | Chousuke: They may share an IP block with something the Iranian government doesn' tlike. |
| 08:18 | rhickey | great, going to ggroup starts infinite loop - google fail |
| 08:20 | cemerick | I heard that yesterday too -- which browsers are afflicted? FF does just fine. *shrug* |
| 08:20 | hoeck | strange, had the same problem a week ago, couldn't even login to gmail, deleting all my google related cookies helped though |
| 08:21 | rhickey | nuked cookies, works |
| 08:22 | rhickey | cemerick: target/classes is clear when you start this AOT? |
| 08:23 | cemerick | rhickey: yeah -- I've triple-checked that at this point |
| 08:23 | cemerick | I can bounce back and forth between success and failure reliably by commenting out the RT.load |
| 08:24 | rhickey | cemerick: have you got a circularity in your static inits? |
| 08:25 | cemerick | rhickey: not that I'm aware of, though wouldn't that cause an error of some kind? |
| 08:26 | cemerick | FWIW, this code is unchanged since the last time it was built ~Feb |
| 08:27 | Chousuke | git bisect? :) |
| 08:27 | rhickey | the error is really bogus, as every reference to a var callsite is made from within the same class |
| 08:27 | cemerick | Chousuke: If I must. I'm not thrilled about the prospect of bisecting ~5 months of clojure commits. |
| 08:28 | Associat0r | does Clojure allow unboxed user-defined value tyes (structs) on the CLR? |
| 08:29 | Chousuke | cemerick: well, it's a binary search so it won't take *that* long :) |
| 08:29 | cemerick | rhickey: My random initial thought was that the RT.load call isn't setting things up properly for the compiler -- so docviewer__init gets generated, but without certain vars that are only conditionally emitted? |
| 08:30 | cemerick | my understanding of the compiler is quite out of date, pre-reify |
| 08:32 | rhickey | cemerick: yes, you could not have the callsites flag set, but that would disable both the callsite field generation and the references to it, i.e. as if you didn't have callsites |
| 08:32 | cemerick | right |
| 08:33 | Associat0r | rhickey: does Clojure allow unboxed user-defined value tyes (structs) on the CLR? |
| 08:33 | cemerick | rhickey: so, binding *compile-path* = null before the RT.load in the java class (with a pop after) leads to a successful compile. |
| 08:34 | cemerick | rhickey: The RT.load generates classes missing the callsites, and then the "normal" load sees classfiles already, and just invokes the __init.load(), assuming callsites are already there? |
| 08:35 | rhickey | cemerick: you are getting two different versions of the classes |
| 08:44 | rhickey | cemerick: it used to be that during AOT the compiler loaded the classes from disk, now doesn't to support dynamic classes and interfaces |
| 08:44 | AWizzArd | When I AOTed a defrecord, will then (.getClassLoader MyRec) ==> #<AppClassLoader sun.misc.Launcher$AppClassLoader@1ba34f2> while a non-AOTed record will yield something such as #<DynamicClassLoader clojure.lang.DynamicClassLoader@13c7b52>? |
| 08:45 | cemerick | rhickey: then perhaps RT.load should suppress AOT using the same binding I just used? |
| 08:45 | AWizzArd | Could that be a way to build a reliable record? fn? |
| 08:46 | rhickey | cemerick: that's how explicitly loaded files get compiled |
| 08:47 | cemerick | so it is |
| 08:51 | cemerick | rhickey: RT.load has always been a bit hacky; perhaps a method specifically suited for runtime loading of namespaces from Java is warranted, which would then set things up so as to not trip up AOT. |
| 08:51 | cemerick | probably just an invocation of require, actually |
| 08:52 | rhickey | cemerick: who said you could call RT.load? |
| 08:52 | rhickey | you can invoke require |
| 08:52 | cemerick | rhickey: heh, no one! :-P |
| 08:53 | cemerick | But, tons of people do, because one often needs to load code from Java. A proper support route for that seems reasonable. |
| 08:53 | rhickey | cemerick: require |
| 08:53 | cemerick | supported* |
| 08:53 | rhickey | RT.var("clojure.core/require").invoke(...) |
| 08:54 | cemerick | rhickey: right as I said before -- but help out the poor java folk, and give them something with a signature like RT.require(String). |
| 08:54 | rhickey | cemerick: the general recipe is - get the var you would use to do the same job from Clojure and invoke it |
| 08:54 | AWizzArd | We need a better Java API (: |
| 08:55 | rhickey | cemerick: when does that stop? |
| 08:55 | cemerick | rhickey: at some point, but after zero. :-) |
| 08:55 | rhickey | cemerick: try the latest (disables direct binding, as it is doomed) |
| 08:56 | cemerick | rhickey: will do |
| 08:57 | cemerick | rhickey: Some supported host API is still needed though. At least enough to load namespaces and call fns in a java-idiomatic way. |
| 08:57 | AWizzArd | rhickey: Do you have plans to to provide a record? and/or deftype? function? |
| 08:58 | rhickey | AWizzArd: maybe |
| 08:58 | AWizzArd | Would be very helpful for my Serialization lib. |
| 08:59 | AWizzArd | Currently I check (parents MyRec) to estimate if something has good chances to be a record |
| 09:02 | chouser | if it's just a matter of a tool to view, create, and delete rules for you, perhaps it could be done outside gmail and then use http calls to make it happen inside |
| 09:04 | cemerick | contrib failures @ http://build.clojure.org/ just now |
| 09:05 | cemerick | not sure who turn the batlight on for these day |
| 09:05 | cemerick | days |
| 09:05 | cemerick | whoa, wonky hudson error |
| 09:09 | rhickey | cemerick: stuart halloway is on that |
| 09:20 | AWizzArd | Maybe if Clojure managed internally a Set of all defrecords/deftypes, then such a lookup could be done easily, without adding empty interfaces and such. |
| 09:22 | mattrepl | can anyone think of a reason why I'd be getting a Var unbound exception from within a deftest? The Var is defined in a "project.core" namespace and the test is defined in a "project.core-test" namespace which references "project.core" via a use expression in it's own namespace def "(ns project.core-test (:use [project.core] :reload-all).....)" |
| 09:23 | mattrepl | I'm using master branch, did the most recent pull yesterday. |
| 09:24 | rhickey | AWizzArd: a marker interface is far superior to a registry |
| 09:24 | AWizzArd | mattrepl: did you just do (def xyz) and then try to access it, without intializing it with a value? |
| 09:24 | AWizzArd | rhickey: ah okay, didn't know that |
| 09:24 | mattrepl | AWizzArd: in this case the Var is a function that was defined with defn |
| 09:25 | AWizzArd | Just thought that such a marker interface could be used by any class, even if those are not Records. |
| 09:26 | mattrepl | I get similar behavior from the "user" ns in SLIME, strangely it works only if I run slime-compile-defun before attempting to dereference the Var |
| 09:27 | mattrepl | I say "strangely" because I didn't have this problem before using a similar project setup |
| 09:29 | mattrepl | or rather, "the Var is bounded to a function that was defined with defn" |
| 09:30 | mattrepl | I have an idea of what would be broken, but I'm not sure why others wouldn't have already reported it... diving in... |
| 09:30 | mmarczyk | rhickey: about the ggroup infinite loop, deleting all googlegroups.com cookies fixed it for me |
| 09:31 | rhickey | mmarczyk: yes, me too |
| 09:31 | mmarczyk | rhickey: perhaps there were some groups.google.com cookies too... not sure |
| 09:31 | mmarczyk | ah, ok then :-) |
| 09:31 | rhickey | cemerick: any word on latest and your problem? |
| 09:32 | cemerick | rhickey: sorry, got caught by a call; another 15m anyway |
| 09:43 | mmarczyk | hm, I've got a (defprotocol ToSQL (to-sql [self])) in one namespace, then a (defrecord InfixOperator [op-name] ToSQL (to-sql [self] op-name)) in another; the latter generates a reflection warning -- "call to contains can't be resolved"; any idea why? |
| 09:43 | rsh | how do you remove a macro defined in a ns? |
| 09:44 | Chousuke | rsh: ns-unmap |
| 09:45 | rsh | thanks |
| 09:45 | mmarczyk | rsh: as you would with a function; nb. this won't have any effect on code using this macro and compiled when it was in place |
| 09:49 | mmarczyk | rhickey: in core_deftype.clj, line 215, shouldn't there be a type hint on v#? |
| 10:03 | alexyk | how do I make a stand-alone executable? uber-jar? |
| 10:03 | spariev | yes, lein uberjar will do |
| 10:22 | mattrepl | *sigh* misplaced parens around a series of defns. no compile error, but resulted in Var being interned but no function bounded |
| 10:24 | chouser | mattrepl: just yesterday systray had that very same error message with the very same cause |
| 10:26 | mattrepl | chouser: sounds like something worth fixing, maybe a compiler warning for nested defs? |
| 10:27 | chouser | just added it to my lint tool todo list |
| 10:32 | mattrepl | is it a conscious decision to put items like that in a lint tool instead of in the compiler? is there a plan to integrate a lint tool with the compiler? |
| 10:33 | chouser | I don't know. |
| 10:33 | chouser | Compiler errors are great, but warnings are a pain. We use a warning because we're not *sure* it's an error... |
| 10:34 | chouser | if we're not sure it's an error, that means someone might want to keep the warned code, which means they rightfully would want a way to turn it off |
| 10:35 | chouser | but you don't want a lib that turns it off to also turn it off in the lib-user's code, so how do you control the warning? at what granularity? |
| 10:36 | mattrepl | namespace? |
| 10:36 | chouser | if a flexible system is provided to let you turn on/off warnings per ns, file, function, etc. do we really want all that complexity bundled into the compiler? |
| 10:37 | chouser | perhaps if a lint tool can demonstrate sufficient value, simplicity, and flexibility, parts of it could be included in the compiler. or perhaps that would simply demonstrate it works fine standalone. |
| 10:37 | mattrepl | could be namespace metadata, the lint tool looks for it, and the compiler could optionally call lint |
| 10:37 | chouser | hm, that's an interesting idea |
| 10:39 | cemerick | rhickey: clean builds now, thank you :-) |
| 10:39 | cemerick | I suppose I'll go eliminate the RT.load usages in any case. |
| 10:41 | cemerick | I reserve the balance of my Java API griping time though. ;-) |
| 10:41 | chouser | heh, I like it. Senate rules. |
| 10:48 | AWizzArd | Is there a better way to produce all non-nil elements of a seq other than (take-while identity (iterate f coll)) or (take-while identity (repeatedly f))? |
| 10:48 | cemerick | chouser: same in the House. I'm cameralism-agnostic. |
| 10:48 | arohner | AWizzArd: (remove nil? seq) |
| 10:49 | AWizzArd | ,(last (take-while identity (iterate #(.getComponentType %) (class (make-array String 2 2 2 2))))) |
| 10:49 | AWizzArd | $(last (take-while identity (iterate #(.getComponentType %) (class (make-array String 2 2 2 2))))) |
| 10:49 | sexpbot | java.lang.NoClassDefFoundError: clojure/core$iterate$fn__3752 |
| 10:50 | AWizzArd | anyway, remove nil? is not the way, as this wouldn't produce the seq itself |
| 10:50 | chouser | I yield the remainder of my cameralism time to the gentleman from Massachusetts |
| 10:50 | cemerick | Man, one step towards a legislative process, and we're already getting less done! |
| 10:50 | AWizzArd | A version of iterate and/or repeatedly that stops when a specific result was found. |
| 10:51 | AWizzArd | (repeat-until nil? f) and (iterate-until nil? f coll) so to say |
| 10:52 | chouser | $(take-while identity (iterate #(and % (.getComponentType %)) (class (make-array String 2 2 2 2)))) |
| 10:52 | sexpbot | java.lang.NoClassDefFoundError: clojure/core$iterate$fn__3752 |
| 10:52 | chouser | the bots are all broken? |
| 10:52 | AWizzArd | seems so |
| 10:53 | AWizzArd | Not online or broken :p |
| 10:53 | AWizzArd | The above code I pasted works in my Clojure. |
| 10:55 | AWizzArd | Is there a Superclass for all Arrays? |
| 10:55 | chouser | Object |
| 10:55 | chouser | :-) |
| 10:55 | AWizzArd | Other than Obj... |
| 10:57 | AWizzArd | How can one detect if a given Object is an Array? |
| 10:58 | AWizzArd | (.isArray (make-array String 5)) |
| 10:58 | AWizzArd | k |
| 10:58 | chouser | really? |
| 10:59 | AWizzArd | yes |
| 10:59 | AWizzArd | http://java.sun.com/javase/6/docs/api/java/lang/Class.html#isArray() |
| 10:59 | chouser | I get java.lang.IllegalArgumentException: No matching field found: isArray for class [B |
| 10:59 | AWizzArd | yes, I forgot to wrap it into (class ..) |
| 10:59 | chouser | ah |
| 10:59 | AWizzArd | retyped it here |
| 11:01 | AWizzArd | (defn get-array-dims [a] (map count (take-while identity (iterate first (make-array Object 1 2 3 4 5))))) |
| 11:01 | AWizzArd | array? and get-array-dimensions could be helpful in Core. |
| 11:04 | rhickey | wtf? google group redirect infinite loop came right back |
| 11:39 | Kjellski | What would you do if you want to iterate through a vector and at some particular element you want to start collecting until some other particular element? |
| 11:40 | mattrepl | drop-while then take-while? |
| 11:42 | Kjellski | mattrepl: hmm, how would that look like? |
| 11:42 | Kjellski | ,(doc take-while) |
| 11:43 | mattrepl | (take-while #("not the end element") (drop-while #("not the start element"))) |
| 11:44 | Kjellski | mattrepl: thanks, I´ll try that... |
| 11:44 | mattrepl | tweak as necessary for inclusivity |
| 11:45 | hiredman | ping? |
| 11:46 | hiredman | ping? |
| 11:46 | clojurebot | PONG! |
| 11:47 | rmarianski | Kjellski: split-with might do what you want also |
| 11:48 | Kjellski | rmarianski: thanks, I´ll try that too... |
| 12:03 | Kjellski | rmarianski: Following problem, that gives me only the first occurence and rest. But I need it like this: blocks from 1 to 1 [1 2 2 1 3 3 1 4 4] -> ([1 2 2] [1 3 3] [1 4 4]) |
| 12:06 | rmarianski | Kjellski: afaik, you'll have to write something custom |
| 12:07 | dnolen | erg how can I produce a string that has double quotes without backquoting the double quote? |
| 12:07 | Chousuke | can you? |
| 12:07 | chouser | ,(char 34) |
| 12:07 | clojurebot | \" |
| 12:08 | Chousuke | that's probably not very convenient :P |
| 12:08 | chouser | no backquoting in the input! :-) |
| 12:09 | chouser | dnolen: there's no way to put double-quotes in a string literal without backquoting it. |
| 12:09 | dnolen | chouser: is there a simple way to replace them? |
| 12:10 | chouser | ,(.replace "I said 'Hello World!'" \' \") |
| 12:10 | clojurebot | "I said \"Hello World!\"" |
| 12:10 | chouser | you mean like that? |
| 12:14 | dnolen | chouser: thx, I thought the presence of \" in the string was an issue, but now I see that it's probably something else. |
| 12:17 | Kjellski | How can I "unuse" a namespace? |
| 12:20 | Fossi | Kjellski: afaik you can't |
| 12:21 | chouser | remove-ns |
| 12:21 | Raynes | There is remove-ns. |
| 12:21 | Raynes | o/ |
| 12:21 | Kjellski | ty |
| 12:21 | Raynes | ;) |
| 12:23 | Joreji | Anyone can tell me why (. (identity String) newInstance "fred") is no longer working? |
| 12:24 | Kjellski | Hmmm... removed like this: (remove-ns 'clojure.contrib.str-utils) but this won´t work because when I try (use 'clojure.contrib.str-utils2) e.g. chomp is already bound... =( |
| 12:27 | chouser | Joreji: the newInstance method of Class doesn't take any args. Doubt it ever has. |
| 12:28 | chouser | Joreji: if you want to use reflection to call a constructor with arguments, try clojure.lang.Reflector/invokeConstructor |
| 12:29 | Joreji | chouser: I got that from: http://en.wikibooks.org/wiki/Learning_Clojure |
| 12:29 | Joreji | All I want is to create an instance of a class which I store inside a symbol |
| 12:30 | chouser | ,(clojure.lang.Reflector/invokeConstructor String (to-array ["fred"])) |
| 12:30 | clojurebot | "fred" |
| 12:30 | Joreji | Ah, thanks! |
| 12:30 | chouser | it would be better to store a clojure function that does what you want, than just storing the symbol |
| 12:31 | chouser | ,(let [ctor #(String. %)] (ctor "fred")) |
| 12:31 | clojurebot | "fred" |
| 12:31 | chouser | simpler, more flexible, and much much faster |
| 12:33 | Joreji | chouser: Yeah, but I'd need to use a macro in order to get the #(String. %) fun work for other cases. This I'm trying to avoid. Fortunately I only use it sparsely, so it shouldn't be a problem. |
| 12:38 | chouser | ,((fn [p s] (->> [nil s] (iterate (fn [[_ [_ & xs]]] (split-with (complement p) xs))) (partition 2 1) (map (fn [[[_ [i]] [r]]] (cons i r))) (take-while first))) #{1} [1 2 2 1 3 3 1 4 4]) |
| 12:38 | clojurebot | ((1 2 2) (1 3 3) (1 4 4)) |
| 12:38 | chouser | Kjellski: that's for you |
| 12:38 | chouser | but I suppose there's a better way |
| 12:39 | chouser | oh. duh. |
| 12:40 | chouser | ,(map #(apply concat %) (partition 2 (partition-by #{1} [1 2 2 1 3 3 1 4 4]))) |
| 12:40 | clojurebot | ((1 2 2) (1 3 3) (1 4 4)) |
| 12:40 | chouser | sheesh |
| 12:42 | lpetit | Hello all, I've not been there for the past 24 hours. Are we close to the end of the prim et al. branch story ? |
| 12:43 | rhickey | lpetit: no |
| 12:44 | lpetit | ok ! |
| 12:45 | rhickey | lpetit: people have given up on bigint contagion too easily, I haven't, and am working on it |
| 12:47 | lpetit | rhickey: it's very exciting to assists / be part of the construction of such a great language ! |
| 12:48 | rhickey | lpetit: not very glamorous from here :) |
| 12:51 | hoeck | rhickey: so you are working on a compromise? |
| 12:53 | rhickey | hoeck: more like what I first proposed, i.e. bigint contagion, while addressing some issues of that, but keeping the best of the other work (loop/recur, literals as primitives, etc) |
| 12:53 | rhickey | bigint contagion would allow for polymorphic use of +, -, *, less need for auto-promoting prime versions |
| 12:55 | chouser | yay |
| 12:55 | hoeck | great |
| 12:55 | chouser | less need for prime versions seems like a huge win to me |
| 12:56 | Raynes | lpetit: Does counterclockwise work with Eclipse 3.5? I heard a guy saying it wasn't working earlier, so I'm curious. |
| 12:56 | rhickey | but a lot of work - a return to some sort of equiv based =, a new BigInt type, changes to key lookup in maps/sets |
| 12:57 | chouser | Are you punting on the new BigInt for now? Surely someone else could do that for you. |
| 12:57 | dnolen | wow, a better BigInt. no compromise. |
| 12:58 | rhickey | chouser: I'd love help on that, I could spec it easily. We need it because BigInteger and Long hashCodes differ for the same values, secondarily, for performance |
| 12:59 | chouser | I shouldn't volunteer for that, but I might anyway. |
| 12:59 | chouser | don't tell fogus I'm not working on the book. |
| 13:00 | fogus | don't tell chouser I'm not working on the book. |
| 13:00 | chouser | don't tell Manning we're not working on the book. :-/ |
| 13:01 | chouser | rhickey: the interface would look a lot like BigInteger? |
| 13:01 | rhickey | the net result would be that heterogeneous keys would be supported for maps and sets, when used with the Clojure API would use equiv, from Java, adds an .equals test |
| 13:02 | cemerick | rhickey: doesn't kawa have a good set of bigs? At least a good start, perhaps... |
| 13:02 | rhickey | chouser: not at all, quite minimal BigInt/fromBiginteger /fromLong .toBigInteger, j.u.Number API, accessors for long and BigInt parts, then just implement the needed support for clojure.lang.Numbers |
| 13:02 | cemerick | eh, it's probably not license-compatible |
| 13:03 | rhickey | cemerick: no need for that whole impl, just punt to BigInteger, all this is is a shell wrapping long-or-BigInteger, enforcing the semantic that BigInteger is null if fits in long |
| 13:03 | rhickey | It's quite a small thing |
| 13:04 | rhickey | remember, Long et al don't provide arithmetics, just holders, this is like that |
| 13:20 | chouser | rhickey: you'd want BigInt on the prim branch? |
| 13:25 | rhickey | chouser: on new branch, equiv, not there yet... |
| 13:26 | chouser | ok |
| 13:29 | rhickey | chouser: there now |
| 13:29 | rhickey | http://github.com/richhickey/clojure/tree/equiv |
| 13:33 | cemerick | Basically-working patch for #322 (making transitivity of AOT-compilation optional): http://github.com/cemerick/clojure/commit/6f14e0790c0d283a7e44056adf1bb3f36bb16e0e |
| 13:34 | cemerick | rhickey, chouser: thoughts welcome |
| 13:35 | cemerick | The only issue remaining is that the guard @ http://github.com/cemerick/clojure/commit/6f14e0790c0d283a7e44056adf1bb3f36bb16e0e#L1R5876 is necessary to avoid class gen by genclass and proxy, but putting it there makes protocol interface lookup fail at the moment. |
| 13:39 | hiredman | ,(docs resolve) |
| 13:39 | clojurebot | java.lang.Exception: Unable to resolve symbol: docs in this context |
| 13:39 | hiredman | ,(doc resolve) |
| 13:39 | clojurebot | "([sym]); same as (ns-resolve *ns* symbol)" |
| 13:46 | rhickey | chouser: you doing BigInt.java first? I need to twiddle with Numbers |
| 13:49 | bhenry | is there a built in exponents function? (something x y) -> x^y |
| 13:49 | chouser | rhickey: I was going to jump right into a .clj |
| 13:49 | chouser | deftype |
| 13:50 | rhickey | chouser: we'll have issue with that being available early enough |
| 13:50 | rhickey | bootstrap |
| 13:50 | chouser | :-( boo. yeah. |
| 13:50 | rhickey | chouser: if that sours it for you, let me know, the map part is easier than I thought |
| 13:51 | chouser | poor timing to work on a multistage clojure self-compiler I suppose |
| 13:51 | rhickey | yeah |
| 13:51 | chouser | I can still take a swing at it. |
| 13:53 | mattrepl | bhenry: (Math/pow x y) |
| 13:54 | bhenry | mattrepl: thanks. i was just using (defn ** [x y] (apply * (repeat y x))) |
| 13:55 | bhenry | ,(let [** #(apply * (repeat %2 %1))] (** 2 3)) |
| 13:55 | clojurebot | 8 |
| 13:57 | bhenry | ,(Math/pow 2 3) |
| 13:57 | clojurebot | 8.0 |
| 14:02 | chouser | rhickey: .toLong throws on overflow? returns primitive? |
| 14:06 | rhickey | chouser: follow http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Number.html |
| 14:08 | chouser | so longValue instead of toLong |
| 14:08 | rhickey | chouser: right |
| 14:15 | chouser | hm, could probably use two classes and one interface to leverage method dispatch instead of having if(bigint == null) everywhere |
| 14:22 | iwillig | hi, i am trying to build a standalone jar with lein and i keep on getting the perplexing error |
| 14:22 | iwillig | http://paste.pocoo.org/show/229013/ |
| 14:23 | iwillig | this is my main class |
| 14:23 | iwillig | http://paste.pocoo.org/show/229025/ |
| 14:23 | iwillig | anyone have a few tips for a nb |
| 14:24 | cemerick | iwillig: the error is actually in geo.io |
| 14:24 | qbg | Don't do def outside of the toplevel |
| 14:24 | cemerick | iwillig: and, what qbg said :-) |
| 14:24 | KirinDave | cemerick: Yo dude. I am back. |
| 14:25 | iwillig | cemerick: how where you able to tell the error was in io ? |
| 14:25 | qbg | Probably from "at geo.io$read_features__101.doInvoke(io.clj:49)" |
| 14:25 | qbg | being the most recent call in your code |
| 14:26 | iwillig | thanks gusy |
| 14:26 | iwillig | *guys |
| 14:28 | lpetit | Raynes: if you still here, then the answer is yes, 3.5 is its current primary target |
| 14:31 | cemerick | lpetit: it seemed to work with a 3.6 RC I tried last week *shrug* |
| 14:42 | lpetit | cemerick: thx for the info. I hoped it was. |
| 14:42 | lpetit | must quit, cu |
| 14:43 | cemerick | lpetit: np -- I only used it for an afternoon, though, so don't take that as gospel :-) |
| 15:04 | fliebel | Is there anything in Clojure or Java to make servers other than HTTP? especially SMTP and POP3. |
| 15:08 | bartj | , (/ 22 7) |
| 15:08 | clojurebot | 22/7 |
| 15:08 | bartj | , (/ 10 10) |
| 15:08 | clojurebot | 1 |
| 15:09 | bartj | er, why is (/ 10 10) not a Ratio type? |
| 15:10 | chouser | reduces |
| 15:10 | chouser | ,(/ 4 2) |
| 15:10 | clojurebot | 2 |
| 15:10 | chouser | ,(/ 2 4) |
| 15:10 | clojurebot | 1/2 |
| 15:11 | bartj | it seems, like division with remainders are retained as Ratio type, right? |
| 15:13 | chouser | division with integers that does not result in a whole number results in a Ratio, yes. |
| 15:16 | bartj | chouser: thanks |
| 15:29 | lpetit | tcrayford created a project on github about clojure refactorings. I expect to add this kind of feature sooner or later (rather sooner than later !) to counterclockwise, but I'm not sure about the current impl. He apparently choosed to use the reader. So he's loosing information : how the metadata was entered (was it ^:key1 ^:key2 or {:key1 true :key2 true} ?), the comments, etc. . When the... |
| 15:29 | lpetit | ...time permits to work on it for ccw, I guess I would first try to do as much as possible via static analysis with external source code parser, and maybe, in a second pass, try to 'plug' some info from a dynamic environment, if useful at all. Thoughts ? |
| 15:39 | bartj | , (contains? '("9" "8") "9") ; I was expecting a "true" |
| 15:39 | clojurebot | false |
| 15:40 | chouser | ,(contains? #{"9" "8"} "9") |
| 15:40 | clojurebot | true |
| 15:40 | fyuryu | bartj: contains? checks if a map contains a *key* |
| 15:41 | bartj | , (doc contains?) |
| 15:41 | clojurebot | "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'." |
| 15:41 | cemerick | lpetit: entirely as an observer, I've seen a lot of editor plugins have a lot of trouble when they did anything other than use the language's real parser/reader/compiler/etc |
| 15:41 | bartj | fyuryu: the doc says it is a collection? |
| 15:41 | somnium | is it possible to generate and populate namespaces programmatically? |
| 15:41 | bartj | I assumed any seq would do... |
| 15:42 | fyuryu | bartj: well, I should be more precise, but still, it looks for a key |
| 15:42 | cemerick | lpetit: the ^:key1 vs {:key1 true} thing is really more of a formatting preference than anything, and you can default that to use the former if the metadata map is all keyword keys and boolean true values. There's probably more complicated scenarios. |
| 15:43 | fyuryu | bartj: since vectors are also maps (of their keys) |
| 15:44 | lpetit | cemerick: ccw uses its own hand-made parsetree with great success AFAIK :-p |
| 15:44 | fyuryu | ,(contains? [0 1] 1) |
| 15:44 | clojurebot | true |
| 15:45 | cemerick | lpetit: well, hopefully it pans out well :-) |
| 15:46 | bhenry | fyuryu be cautious that the 1 it's finding is the key of that vector and not the value 1 |
| 15:46 | bhenry | ,(contains? [0 2] 1) |
| 15:46 | clojurebot | true |
| 15:46 | lpetit | cemerick: maybe, but what about the comments. And what about spaces / current indentation of the source code ? Why should a refactoring command ruin someone's carefully hand-made formatting ? I think those are pretty strong arguments against using the current parser as is. But still, I'm unsure about the "mix" story, as in mixing dynamic and static information to try go deeper in the... |
| 15:46 | lpetit | ...understanding of the semantics of the source code (e.g. where macros are used, that is almost ... everywhere !) ? |
| 15:47 | fyuryu | bhenry: yes, my example could be better. |
| 15:47 | bhenry | fyuryu my bad. i thought it was you having trouble, not answering the question. |
| 15:48 | fyuryu | ,(contains? [:a :b] 1) |
| 15:48 | clojurebot | true |
| 15:48 | lpetit | cemerick: but of course, if the current reader could be enhanced/instrumented to e.g. have a version which preserves everything in the source code |
| 15:48 | cemerick | lpetit: That's a fair point -- perhaps the next-gen reader should provide a more verbose output that includes everything tooling might need |
| 15:48 | cemerick | heh |
| 15:48 | lpetit | cemerick: but wait, no, there may still be the problem of the reader macros, no ? |
| 15:48 | lpetit | eh |
| 15:49 | lpetit | ,(read-string "hello") |
| 15:49 | clojurebot | hello |
| 15:49 | lpetit | ,(read-string "hello there") |
| 15:49 | clojurebot | hello |
| 15:49 | lpetit | ,(read-string "(hello there)") |
| 15:49 | clojurebot | (hello there) |
| 15:49 | lpetit | ,(read-string "(hello #_there)") |
| 15:49 | clojurebot | (hello) |
| 15:49 | lpetit | cemerick: see, #_there was swallowed too :-( |
| 15:50 | lpetit | (quite normal) |
| 15:50 | cemerick | lpetit: Sure -- the current impl isn't suitable then. IIUC, the reader's due for a pure-clojure replacement -- at that point, I'm sure the powers that be will be receptive to changes to help out on the tooling front. *shrug* |
| 15:50 | lpetit | cemerick: oh, and last but not least: the reader will only help with strict-strict correct syntax. I'm pretty sure the need may occur to be able to work on "sufficiently correct syntax" where possible |
| 15:51 | bartj | fyuryu: there is no "1" in [:a :b], yet returns true? |
| 15:51 | lpetit | cemerick: yeah. Though maybe our timeframes may not overlap :-( |
| 15:51 | cemerick | lpetit: any ideas how the scala plugins do it (which do use scalac et al)? |
| 15:51 | lpetit | cemerick: to be continued. thx for sharing thoughts |
| 15:51 | lpetit | cemerick: no idea |
| 15:52 | cemerick | heh, FWIW of course ;-) |
| 15:52 | raek | bartj: [:a :b] has the keys (in this case indices) 0 and 1 |
| 15:52 | bhenry | bartj it's finding the key 1 |
| 15:52 | bhenry | ,(let [v [:a :b]] (v 1)) |
| 15:52 | clojurebot | :b |
| 15:52 | lpetit | cemerick: of course :-p |
| 15:52 | lpetit | (just kidding) |
| 15:54 | bartj | , (contains? [:a :b] :c) |
| 15:54 | clojurebot | false |
| 15:55 | Licenser | greetings my lispy friends |
| 15:55 | bartj | ok, first time seeing vectors being used as maps! |
| 15:57 | chouser | ,(map (vec "acgt") [2 1 3 1 2 1]) |
| 15:57 | clojurebot | (\g \c \t \c \g \c) |
| 15:57 | chouser | ,(map (vec "acgt") [2 0 3 0 1 0]) |
| 15:57 | clojurebot | (\g \a \t \a \c \a) |
| 15:58 | bartj | bhenry: in your example, (contains? [:a :b] 1) -- we first get the key b and then check for the existence of b in [:a :b] - right? |
| 15:58 | fliebel | chouser: Huh, what are you doing? |
| 15:58 | chouser | fliebel: I'm using a vector as a fn |
| 15:58 | rhickey | chouser: got anything? |
| 15:58 | chouser | rhickey: yeah, but I don't know java very well |
| 15:59 | chouser | it's hurting me |
| 15:59 | fliebel | chouser: So you create a vector of char symbols which get retrieved with map? |
| 15:59 | chouser | rhickey: give me another 5 minutes and I might have a useful starting place for you. |
| 15:59 | rhickey | ouch |
| 15:59 | rhickey | chouser: ok, thanks |
| 15:59 | bhenry | bartj: you're confusing keywords with keys. and i should have said index instead of key. the 1 is an index in [:a :b] |
| 16:00 | bhenry | so contains? is looking for a key. in a vector, its keys are its indices. [:a :b :c] will return true in contains? for 0 1 2 |
| 16:01 | bartj | bhenry: thanks! |
| 16:01 | fliebel | Do Clojure or Java have a network library like Twisted? |
| 16:02 | dnolen | fliebel: Netty |
| 16:02 | dnolen | there's the beginning of wrapper for it called saturnine on github |
| 16:02 | fliebel | dnolen: thanks, I'll look it up. I need to do some SMTP adn POP3 server stuff. |
| 16:03 | bartj | bhenry: what about a list? |
| 16:03 | chouser | rhickey: I haven't touched Numbers.java, but I have a BigInt.java. You want it in email? |
| 16:03 | bartj | , (contains? '(9 8) 1) |
| 16:04 | clojurebot | false |
| 16:04 | bhenry | bartj a list will always return false in contains? |
| 16:04 | rhickey | chouser: could you please email to dev list? Thanks! |
| 16:06 | bartj | bhenry: it seems to be that lists also have indices because things like this: |
| 16:06 | bartj | (first '(1 2)) |
| 16:06 | bartj | , (first '( 1 2)) |
| 16:06 | clojurebot | 1 |
| 16:06 | bartj | *because of |
| 16:07 | bhenry | bartj, first doesn't find it by an index |
| 16:07 | bhenry | neither do things like get. |
| 16:07 | bhenry | you can |
| 16:07 | bhenry | 't do this |
| 16:08 | bhenry | ,(let [my-list '(1 2 3)] (my-list 1)) |
| 16:08 | clojurebot | java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn |
| 16:08 | bhenry | but you can do |
| 16:08 | bhenry | ,(let [my-vec [1 2 3]] (my-vec 1)) |
| 16:08 | clojurebot | 2 |
| 16:09 | bartj | and this is because vectors are allocated in contiguous memory locations and lists are not - right? |
| 16:10 | bhenry | that's over my head, but i just read the joy of clojure and they specifically cover contains? on lists and vectors and other things like sets. |
| 16:11 | bartj | er, anyone here can confirm the above, plz? |
| 16:11 | hiredman | bartj: that is not true |
| 16:11 | hiredman | vectors are not arrays |
| 16:11 | somnium | bartj its unrelated |
| 16:12 | rhickey | chouser: or just put in Files section of clojure-dev |
| 16:12 | bartj | hmm, then why does contains? work on vectors and not on lists? |
| 16:12 | hiredman | a list like '(1 2) is logically a head and a tail, there is no numbering |
| 16:13 | hiredman | ,(doc contains?) |
| 16:13 | clojurebot | "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'." |
| 16:14 | bartj | hiredman / bhenry: thank you for your patience, I get it... |
| 16:15 | chouser | rhickey: just sent. |
| 16:15 | rhickey | chouser: thanks! |
| 16:15 | chouser | I screwed up the overflow cases -- happy to fix it if you're rather not. |
| 16:16 | chouser | of course I likely screwed up other things too. Hope it saves you some time anyway. |
| 16:17 | rhickey | chouser: it will, thanks again |
| 16:24 | nathanmarz | does "reduce" use the stack as it goes through the seq? i'm getting a StackOverflowError while doing a reduce on a really long seq |
| 16:28 | bhenry | nathanmarz, is the code gistable (aka not proprietary) |
| 16:31 | nathanmarz | bhenry: http://gist.github.com/450501 |
| 16:31 | nathanmarz | it happens rarely |
| 16:31 | nathanmarz | it might be happening in that map actually |
| 16:36 | qbg | nathanmarz: The code might be making lazy thunks too deep with map |
| 16:37 | Chousuke | that's most likely what's happening. |
| 16:37 | qbg | Try using doall around the map |
| 16:38 | Chousuke | I'm not quite sure what you're trying to do there |
| 16:38 | Chousuke | what kind of input do you have and what kind of output do you need? |
| 16:38 | lpetit | chouser: no reimplementation of equals/hashcode in BigInt ? |
| 16:38 | chouser | oh |
| 16:38 | chouser | I didn't get that far, did I. :-P |
| 16:38 | chouser | I'm just so slow at Java |
| 16:38 | lpetit | wasn't it the whole point of doing the exercise ? :-p |
| 16:40 | rhickey | lpetit: done already |
| 16:40 | lpetit | rhickey: ok then, so no need to give more feedback on the email ? |
| 16:41 | rhickey | lpetit: nope, that was just a starting point |
| 16:41 | lpetit | rhickey: ok, so just using clojure-dev as your private chouser/rhickey sandbox :-p |
| 16:41 | rhickey | lpetit: public, that's the point |
| 16:42 | lpetit | rhickey: ok, copyright et al. |
| 16:48 | Nanakhiel | mmarczyk, are you there? |
| 16:48 | mmarczyk | Nanakhiel: ? |
| 16:48 | Nanakhiel | http://codepad.org/Ej8SrXi1 do you agree with the design goals? |
| 16:48 | Nanakhiel | As you can hopefully infer, it is designed towards easy and efficient compilation |
| 16:49 | mmarczyk | um, why'd you ask me? |
| 16:50 | Nanakhiel | mmarczyk, because you are the fifth greatest programmer. |
| 16:50 | mmarczyk | changed your nick, I see? |
| 16:50 | Nanakhiel | Also, you solved my issue with tail calls, and I have your leg in my stomach. |
| 16:50 | mmarczyk | anything to do with a recent screenshot? |
| 16:50 | Nanakhiel | Ahh |
| 16:50 | Nanakhiel | Nahh |
| 16:50 | Nanakhiel | I have multiple |
| 16:50 | Islaam | Including this treasure I got before all others |
| 16:50 | Lajla | I have about 30 registered I think |
| 16:51 | mmarczyk | well, sorry, no time now |
| 16:51 | Lajla | mmarczyk, you can't go anywhere, you have but one leg. |
| 16:52 | Lajla | Muahahahha |
| 18:18 | Licenser | optimizing clojure isn't actally funnny :( |
| 18:35 | dsop | is there a way at to start a compojure app using leinigen without building a jar? |
| 18:37 | lancepantz | dsop: you can do so from a repl, if that's what you're interested in |
| 18:37 | dsop | lancepantz: hm I was thinking more of a lein run target |
| 18:38 | lancepantz | yeah, just reopen you're namespace and call run-jetty in it |
| 18:38 | lancepantz | i guess you don't need to reopen it actually |
| 18:39 | lancepantz | *your :) |
| 18:43 | mmarczyk | dsop: there are at least two "lein run" plugins, one's available on Clojars -- leiningen-run "0.2" worked for me in a toy project -- and I remember reading about another one some time ago... |
| 18:44 | mmarczyk | dsop: here's another one: http://github.com/sids/lein-run/ |
| 18:48 | dsop | mmarczyk: thank you! |
| 19:00 | mmarczyk | np |
| 19:05 | kensanata | Yum, Practical Clojure arrived... |
| 19:11 | Licenser | benchmarks make me cry |
| 19:12 | Licenser | http://gist.github.com/450704 is ugly code! |
| 19:14 | Licenser | I give up for today good night people |
| 19:31 | alexyk | clj-json spends a long time rebuilding a map upon read. Is there a simple way to use jackson in stream mode, token by token, to rebuild a map very fast? |
| 19:31 | alexyk | I guess avoiding reflection, in case I know what my map looks like. |
| 19:34 | arete | alexyk: you can use ObjectMapper and pass a Map type to readValue(Type) |
| 19:34 | arete | but I don't know if it can handle clojure's Map types |
| 19:34 | alexyk | arete: what if I have nested maps? my idea is to read token by token |
| 19:35 | alexyk | and construct my nested type as I go |
| 19:35 | arete | alexyk: it'll make a map of maps |
| 19:35 | arete | jackson is fab =) |
| 19:35 | alexyk | arete: well I have 3 levels :) |
| 19:36 | arete | it has no depth limit |
| 19:37 | kiras | there doesn't seem to be a lot of information about using clojure for android programming yet. i found some links explaining how it can be done and this link http://groups.google.com/group/clojure/browse_thread/thread/213b7675a78755de/8195672b167d0ffd but is there a general consensus on whether it's a good idea at this point compared to just using java? |
| 19:41 | dsop | is there a good documentation of compojure 0.4, i searched but i didn't found any |
| 19:43 | nathanmarz | Chousuke qbg: you guys were right about that function, doall did the trick. thanks for the help |
| 19:43 | qbg | No problem |
| 19:43 | alexyk | how do you specify a main for leiningen's uberjar? |
| 19:43 | qbg | The :main option in project.clj |
| 19:44 | alexyk | meaning which clojure source to write? |
| 19:44 | mmarczyk | dsop: http://formpluslogic.blogspot.com/2010/04/migrating-from-compojure-032-to-040-and_01.html http://carpathia.blogspot.com/2010/05/yet-another-clojure-compojure-google.html http://compojureongae.posterous.com/ -- all "focused" articles, but you'll probably be able to gather some useful info from there |
| 19:44 | qbg | :main specifies the class to be used |
| 19:44 | qbg | I usually use a :gen-class'ed namespace |
| 19:45 | qbg | For a REPL, you would use :main clojure.main |
| 19:45 | alexyk | qbg: I have pure clojure, no gen-class... |
| 19:45 | alexyk | I just want one defn to be main |
| 19:46 | mmarczyk | alexyk: use :main with a namespace name |
| 19:46 | mmarczyk | alexyk: it'll call the function -main from there |
| 19:46 | alexyk | ok |
| 19:47 | qbg | I believe you still need to :gen-class that namespace |
| 19:49 | alexyk | lancepantz: is jiraph-0.1.3 on clojars fresh? |
| 19:52 | ninjudd | alexyk: it is, but i have some changes in my local repo that i'm planning to commit later this week |
| 19:52 | ninjudd | switching to protocols |
| 19:53 | ninjudd | and switching off ant |
| 19:53 | alexyk | ninjudd: coolio! finally a reason to learn them. Back to Clojure as OCaml now works and beats it 3x. |
| 19:53 | alexyk | speedwise |
| 19:53 | alexyk | but there's way |
| 19:53 | alexyk | to catch up since |
| 19:53 | alexyk | the current clojure is simple |
| 19:54 | alexyk | (sorry return is in the way :) |
| 19:55 | ninjudd | hmm, are you using the jiraph walk code? |
| 19:55 | alexyk | ninjudd: I only use the .tc |
| 19:56 | ninjudd | ah |
| 19:56 | ninjudd | are you doing graph traversals? or just bulk read and write benchmarks |
| 19:57 | mmarczyk | qbg: alexyk: apparently no :gen-class is needed for :main |
| 19:57 | alexyk | mmarczyk: cool, thx |
| 19:58 | qbg | Interesting... |
| 19:58 | mmarczyk | qbg: I tried (ns foo.core) (defn -main [& args] (println "Foo!")) plus a project.clj with just :main foo.core in defproject, ran lein uberjar (with clojure and contrib jars in lib/) and java -jar foo-0.0.1-standalone.jar prints Foo! |
| 19:59 | qbg | Perhaps leiningen does some magic |
| 19:59 | alexyk | ninjudd: did you guys figure out how to use clojure-protobuf with lein? |
| 19:59 | mmarczyk | I do note that leiningen.core is :gen-classed |
| 19:59 | mmarczyk | I wonder why |
| 19:59 | ninjudd | had some trouble getting it to work |
| 20:00 | alexyk | ninjudd: so do I have to manually do that beforehand? |
| 20:03 | technomancy | mmarczyk: the gen-class is to make the uberjar work |
| 20:03 | technomancy | since http://www.assembla.com/spaces/clojure/tickets/315-add-support-for-running--main-namespace-from-clojure-main-without-aot still hasn't been applied =\ |
| 20:05 | technomancy | wait... you got java -jar to work without gen-class? iiiiinteresting. |
| 20:05 | mmarczyk | technomancy: right |
| 20:06 | mmarczyk | technomancy: which is why I'm wondering if this issue might have been solved somehow without #315 noticing |
| 20:07 | mmarczyk | technomancy: btw, would you like a patch for this? http://github.com/technomancy/leiningen/issues/#issue/55 |
| 20:07 | technomancy | mmarczyk: yes! that'd be grande. |
| 20:07 | technomancy | and also grand. |
| 20:07 | mmarczyk | :-) |
| 20:08 | mmarczyk | :jar-name in defproject then? |
| 20:08 | technomancy | sure |
| 20:08 | mmarczyk | will be ready in a minute |
| 20:09 | lancepantz | mmarczyk: what about war and ubers? |
| 20:09 | mmarczyk | lancepantz: ah, good point about uber |
| 20:09 | lancepantz | i guess war would be in the plugin's logic |
| 20:09 | technomancy | mmarczyk: can't repro -main working without :gen-class here. perhaps you tried it with gen-class, removed the gen-class and tried again without cleaning? |
| 20:09 | mmarczyk | right |
| 20:09 | clojurebot | No, technomancy, you want gen-interface + proxy |
| 20:09 | mmarczyk | technomancy: hm... I thought I cleaned |
| 20:09 | mmarczyk | let me check again |
| 20:10 | mmarczyk | ah. well, apparently I hadn't -- sorry for the confusion |
| 20:11 | technomancy | got my hopes up. =) |
| 20:11 | technomancy | well, #315 solves it pretty nicely... just no idea how long it'll take to get applied. |
| 20:11 | mmarczyk | only for them to be shattered again immediately... sorry ;-) |
| 20:11 | mmarczyk | alexyk: :gen-class after all then... |
| 20:12 | mmarczyk | yeah, your comment on HN is relevant here... |
| 20:12 | alexyk | clojurebot talks back. I must have been drinking |
| 20:12 | technomancy | clojurebot has an attitude. |
| 20:13 | alexyk | it'll get Obama summon it to White House and fire it if it keeps at it |
| 20:15 | alexyk | "I have a deep respect and admiration for the clojurebot. It solved inane examples thrown at it by newbies for 2 years. It suffered hiredman's domestic abuse without crying. But Clojure is bigger than any bot." |
| 20:24 | mmarczyk | ah, turns out lein has the standard (uber)jar naming scheme hardcoded in a number of places... refactoring that now |
| 20:40 | mmarczyk | technomancy|away: would you mind having "lein jar foo" create "foo.jar" (rather than the current "lein jar foo.jar")? |
| 20:43 | bhenry | mmarczyk: why not both instead of "rather than" |
| 20:44 | mmarczyk | bhenry: how do you mean? take notice of a trailing ".jar" in the name and throw it away? |
| 20:44 | mmarczyk | bhenry: I mean, *not* throw it away, just not add another one |
| 20:46 | bhenry | something to catch it. i don't personally, but someone might have something made already to do this that they shouldn't have to change. it's not a big deal in this example, but i hate when things get broken from code changes. |
| 20:46 | mmarczyk | me too, so I suppose I won't break it after all :-) |
| 20:49 | mmarczyk | although actually in this case |
| 20:50 | mmarczyk | ...ah, never mind, I realised what I was going to say might be false actually :-P |
| 20:51 | bhenry | yeah. i wondered if people will read this later and be like "damn that bhenry, mmarczyk was going to make a change i've been hoping for since day one and he blew it." |
| 20:51 | mmarczyk | :-D |
| 20:52 | mmarczyk | it'll be an scratch-a-word-from-two-lines-then-add-to-one change, not to worry ;-) |
| 23:48 | slyrus | anyone (here) working on computational biology projects in clojure? |
| 23:51 | Bahman | Hi all! |