2010-04-11
| 00:51 | Drakeson | After deftype'ing foo, how can I create an instance with named arguments? (deftype foo [a b]) (foo {:a 1 :b 2}) fails. |
| 00:52 | hiredman | (defn foo-named [& {:keys [a b]}] (foo a b)) |
| 00:55 | Drakeson | hiredman: thanks. I was hoping for a deftypek or something like that |
| 00:58 | carkh | ,(let [a (fn [& {:keys [a b]}] [a b])] (a {:a 1 :b 2}) |
| 00:58 | clojurebot | EOF while reading |
| 00:58 | carkh | ,(let [a (fn [& {:keys [a b]}] [a b])] (a {:a 1 :b 2})) |
| 00:58 | clojurebot | [nil nil] |
| 00:58 | carkh | ok the & was an error, right ? |
| 00:58 | carkh | i hoped for a new syntaw for named parameters |
| 00:59 | hiredman | right |
| 00:59 | hiredman | if you are passing a map |
| 00:59 | hiredman | ,(let [a (fn [& {:keys [a b]}] [a b])] (a :a 1 :b 2)) |
| 00:59 | hiredman | ,(let [a (fn [& {:keys [a b]}] [a b])] (a :a 1 :b 2)) |
| 00:59 | clojurebot | [nil nil] |
| 00:59 | hiredman | bah |
| 00:59 | hiredman | clojurebot isn't running a new enough clojure |
| 00:59 | carkh | ok so that's a new syntax ? cool ! |
| 01:00 | carkh | beause defnk has the problem that it's not showing a very informative parameter list in slime |
| 01:00 | hiredman | clojurebot: git 277f0235c1387ddd6247a72857597814a3e10bc3 |
| 01:00 | clojurebot | add &form and &env implicit args to macros |
| 01:00 | hiredman | bah |
| 01:00 | hiredman | :D |
| 01:01 | hiredman | clojurebot: git 5772be9fc5ac9ddf92b727908c20b9aab971224a |
| 01:01 | clojurebot | gitorious mirror is http://gitorious.org/clojure/clojure |
| 01:01 | Drakeson | it is a commit of march 23 |
| 01:01 | hiredman | clojurebot: github 5772be9fc5ac9ddf92b727908c20b9aab971224a |
| 01:01 | clojurebot | http://github.com/richhickey/clojure/tree/master |
| 01:01 | hiredman | clojurebot: you suck |
| 01:01 | clojurebot | excusez-moi |
| 01:01 | hiredman | anyway, a patch of mine made it in |
| 01:01 | hiredman | sweet |
| 01:02 | carkh | yay for you =) |
| 01:03 | carkh | i can't wait for 1.2 |
| 01:03 | hiredman | http://github.com/richhickey/clojure/commit/5772be9fc5ac9ddf92b727908c20b9aab971224a |
| 01:59 | defn | how does one "turn on" the new {} = everything syntax? |
| 02:00 | defn | {reduce + {1 2 3 4}}, etc. |
| 02:00 | chouser | ?? |
| 02:01 | defn | I saw an example where there are no []s or ()s, just {}s |
| 02:01 | chouser | never heard of it |
| 02:01 | defn | huh, really? |
| 02:02 | hiredman | no such thing |
| 02:02 | defn | ill see if i can find the post that mentioned it |
| 02:02 | chouser | you're sure it was clojure and not some kind of scheme? |
| 02:02 | defn | i wonder if it was on april 1st |
| 02:02 | defn | :) |
| 02:03 | TakeV | defn: That was April Fools, yeah. :P |
| 02:04 | defn | bahahaha i feel so silly |
| 02:04 | defn | who wrote that? |
| 02:04 | defn | i need to kill them... |
| 02:06 | defn | ah yes, sean devlin |
| 02:06 | defn | that monster... |
| 02:08 | TakeV | That was along with something like "Everything returns void now, so it's really easy to make all your function full of side effects. This is awesome." |
| 02:09 | defn | hahaha yes now that im watching it again i get the joke -- i was just listening along working on something else and looked over when he mentioned the "new" syntax |
| 02:52 | scottj | in joy of clojure they have (in C like languages), "a == b && b == c && a == c". Why do you need the last one? What would be a case where the first two tests being true wouldn't have the third be true? |
| 03:01 | gregh | perhaps the case where == is an overloaded operator that does not have the transitive property |
| 03:01 | gregh | == is transitive for usual data types like integers and strings |
| 03:01 | gregh | a non-transitive == operator would be highly unusual, actually :) |
| 03:26 | Raynes | ,(macroexpand '(doseq [x [1 2 3]] (println x)) |
| 03:26 | clojurebot | EOF while reading |
| 03:27 | Raynes | ,(macroexpand '(doseq [x [1 2 3]] (println x))) |
| 03:27 | clojurebot | (loop* [seq_9167 (clojure.core/seq [1 2 3]) chunk_9168 nil count_9169 (clojure.core/int 0) i_9170 (clojure.core/int 0)] (if (clojure.core/< i_9170 count_9169) (clojure.core/let [x (.nth chunk_9168 i_9170)] (do (println x)) (recur seq_9167 chunk_9168 count_9169 (clojure.core/unchecked-inc i_9170))) (clojure.core/when-let [seq_9167 (clojure.core/seq seq_9167)] (if (clojure.core/chunked-seq? seq_9167) (clojure.core/let [c__52 |
| 03:27 | Raynes | Oh boy. |
| 03:30 | chouser | you think that's bad, you should look at 'for' |
| 03:30 | Raynes | Licenser: ping. |
| 03:31 | Raynes | chouser: For some reason, clj-sandbox isn't whitelisting that. That means that one of of the functions it uses isn't whitelisted, but it looks like everything but println is whitelisted, and println is whitelisted locally in sexpbot so I think it should be working. |
| 03:32 | Raynes | This sucks. |
| 03:33 | Raynes | $(for [x [1 2 3]] (+ x 3)) |
| 03:33 | sexpbot | DENIED! |
| 03:33 | Raynes | Same problem there, looks like. |
| 03:35 | Raynes | Macros are tricky little buggers. |
| 03:38 | Raynes | chunk-buffer and chunk-append weren't whitelisted, so maybe I can get for to work. :O |
| 03:43 | Raynes | Or not. |
| 03:54 | Raynes | Oh no. |
| 03:55 | Raynes | Well, we're screwed. doseq and for both use the '.' special form. It's what's causing the problem here. |
| 03:56 | Raynes | Maybe this will be incentive to fix the . problem. |
| 04:01 | Crowbar7 | time to invent a new key on the keyboard |
| 04:10 | Licenser | Raynes: pong |
| 04:10 | Raynes | Licenser: We has us a problem. :p |
| 04:11 | Raynes | Looks like several useful macros can't be whitelisted unless '.' is whitelisted. :o |
| 04:11 | Licenser | Raynes: there are no prolems there are only challanges :P |
| 04:11 | Raynes | Indeed. |
| 04:11 | Raynes | condp uses throw as well. |
| 04:12 | Licenser | hrm |
| 04:12 | Licenser | heh |
| 04:12 | Raynes | It's not telling me why condp isn't working. |
| 04:12 | Raynes | Just (). |
| 04:12 | Raynes | But, it's obvious throw is probably part of that reason. |
| 04:12 | Raynes | doseq and for both do (.nth ..) |
| 04:13 | Raynes | Which is killing us. |
| 04:13 | Licenser | ,(condp = 1 1 "a" 2 "b") |
| 04:13 | clojurebot | "a" |
| 04:13 | Raynes | ,(throw (Exception. "Hai")) |
| 04:13 | clojurebot | java.lang.Exception: Hai |
| 04:13 | Licenser | hrm seems I've to make this . replacement soon :( |
| 04:13 | Raynes | The sooner the better. ;) |
| 04:15 | Raynes | Well, I guess throw isn't the only problem in condp. Still didn't whitelist it. |
| 04:15 | Raynes | Maybe it's because it mentions a Java class? |
| 04:17 | Raynes | Licenser: I just pushed with some new chunk functions that I missed. |
| 04:17 | Licenser | neat |
| 04:17 | Licenser | I've an 'simple' idea for . but I'll have to give that a look later got to go sadly |
| 04:18 | Raynes | Kay. Have fun. :) |
| 04:18 | Licenser | thanks see you later |
| 04:24 | defn | hello all |
| 04:30 | defn | ls |
| 06:02 | imran_sr | Hi. I was wondering if there is an equivalent of pmap for filter? I see some references online to a clojure.parallel namespace, but I don't see that anywhere in clojure.core or clojure-contrib |
| 06:07 | Raynes | chouser: Which one of you wrote the self-licking lollipop bit in Joy? |
| 06:11 | imran_sr | Raynes: (intejecting, clojure newbie here), is there an equivalent to pmap for filter? I can't find the clojure.parallel namespace which is mentioned in Volkman's tutorial |
| 06:11 | Raynes | imran_sr: I'm not sure. :( |
| 06:12 | imran_sr | ok |
| 06:13 | patrkris | imran_sr: http://clojure.org/other_libraries - perhaps this is what you're looking for |
| 06:13 | patrkris | at the top |
| 06:13 | patrkris | but the library is deprecated |
| 06:13 | imran_sr | patrkris: thanks, I'll check that out |
| 06:19 | patrkris | imran_sr: perhaps you can do something with the partition function, pmap and filter - but maybe that'll add too much overhead |
| 06:21 | imran_sr | patrkris: you mean roll my own pfilter? |
| 06:21 | patrkris | imran_sr: yeah, sort of |
| 06:22 | imran_sr | patrkris: (strip-out-nulls (pmap my-filter-func? sequence)) |
| 06:22 | imran_sr | kind of like that? |
| 06:23 | patrkris | yeah, or you could use partition to divide your sequence into pieces, and each piece can be handed to your filter function, which will then filter out some elements |
| 06:23 | Chousuke | That's only useful if the filter function is really slow |
| 06:24 | patrkris | Chousuke: because the partitioning will be too slow in most cases? |
| 06:24 | dcnstrct | hi. The "lein deps" command has never worked for me with any project. I'm having difficult time I must be missing something obvious.. could anyone take a look and give me a pointer ? thanks; http://gist.github.com/362636 |
| 06:24 | Chousuke | and the overhead of threading |
| 06:24 | patrkris | ah |
| 06:24 | Chousuke | and it's not like it can divide the sequence in pieces. it still needs to go over it linearly |
| 06:25 | patrkris | Chousuke: yeah, that's what I meant by it being too slow |
| 06:25 | Chousuke | so the operations on individual items much take enough time for parallelisation to make sense at all |
| 06:25 | imran_sr | btw, does using pmap have any consequences for laziness (in other words, does it somehow make it un-lazy)? |
| 06:25 | Chousuke | yes |
| 06:25 | Chousuke | it stays ahead by a few items I think |
| 06:26 | Chousuke | but it's not completely strict |
| 06:26 | imran_sr | Chousuke: but only by a few? |
| 06:26 | patrkris | Chousuke: do you happen to know whether partition works more efficiently if it detects a vector being partitioned? |
| 06:26 | Chousuke | patrkris: no. |
| 06:26 | Chousuke | as in, no, it doesn't. :) |
| 06:26 | patrkris | ok |
| 06:27 | Chousuke | There is an experimental parallel library for reducing/mapping over vectors efficiently |
| 06:27 | Chousuke | in the par branch of the git repo. |
| 06:28 | Chousuke | it works by mapping/reducing in parallel over the chunks that a vector is made of |
| 06:28 | bsteuber | dcnstruct: could you also post you project.clj? |
| 06:28 | Chousuke | But it depends on a JDK7 feature (which is available as a jar for JDK6). I guess that's why it's not merged to master yet. |
| 06:29 | patrkris | Chousuke: so what would be the ideal way to parallelize on large sequences in clojure as of now? |
| 06:30 | Chousuke | patrkris: pmap |
| 06:30 | imran_sr | Gentlemen, I have a (overly verbose, fairly dumb and brute force) solution for project euler 5, which I wanted to use a base to try out simple parallelization. Mind if I post a pastebin of it? I'm not sure how I would roll my own pfilter that would work for that |
| 06:30 | Chousuke | patrkris: sequences are inherently non-parallelisable |
| 06:30 | patrkris | Chousuke: i see what you mean |
| 06:30 | Chousuke | patrkris: they are, after all, sequences. :) |
| 06:31 | dcnstrct | http://gist.github.com/362640 <--- project.clj thanks for taking a look. the proejc tI'm trying to build is here: http://github.com/ugglan/cljaws |
| 06:31 | patrkris | Chousuke: you are right, of course |
| 06:31 | Chousuke | Hm |
| 06:31 | Chousuke | Looks like some tickets in contrib assembla should be closed ;P |
| 06:32 | imran_sr | http://clojure.pastebin.com/cJLEu3et |
| 06:34 | patrkris | Chousuke: is there any way of efficiently partitioning a vector? Maybe there is something fundamental I don't understand :) |
| 06:34 | Chousuke | patrkris: that's what the par library does |
| 06:35 | Chousuke | patrkris: internally, vectors are trees so they are very amenable to parallel processing |
| 06:35 | patrkris | Chousuke: ah ok |
| 06:35 | Chousuke | patrkris: but that fact is not exposed via a public API |
| 06:35 | Chousuke | yet. |
| 06:36 | patrkris | Chousuke: but I guess one could use arrays as an alternative? |
| 06:36 | bsteuber | dcnstruct: lein deps for cljaws works on my machine |
| 06:37 | bsteuber | dcnstrct, I mean |
| 06:37 | Chousuke | patrkris: well, arrays are sequential too, but since they're indexed I suppose they can be partitioned easily |
| 06:37 | bsteuber | so it seems like something might be wrong with your lein / maven install |
| 06:38 | bsteuber | do you happen to use windoze? |
| 06:38 | dcnstrct | ubuntu 9.10 |
| 06:38 | dcnstrct | I installed lein with the install script |
| 06:38 | dcnstrct | about 3 weeks ago |
| 06:38 | dcnstrct | I can try removing it and doing that again I suppose |
| 06:39 | dcnstrct | is that what you're using ? the stable lein |
| 06:39 | bsteuber | yes, same ubuntu, same lein |
| 06:39 | bsteuber | weird |
| 06:40 | dcnstrct | well thnx for the confirmation that it's a weird problem and I didn't miss anything really obvious.. that's good enough for now :) |
| 06:41 | bsteuber | :) |
| 06:49 | Chousuke | hm |
| 06:50 | Chousuke | assembla could use some "needs approval from Rich" toggle for tickets |
| 06:51 | Chousuke | There seem to be quite many tickets that float in a limbo because they have neither been accepted nor rejected :/ |
| 08:41 | mikem | ~def to-byte-array |
| 08:41 | clojurebot | excusez-moi |
| 08:59 | defn | at clojure.core$seq__3538.invoke(core.clj:107) at clojure.core$map__4077$fn__4078.invoke(core.clj:1877) |
| 08:59 | defn | how do you read that? |
| 08:59 | defn | where is invoke called? |
| 09:00 | defn | is there a good resource to trace the roots of invoke? |
| 09:02 | Chousuke | it's the step function of a map |
| 09:02 | Chousuke | -a |
| 09:03 | Chousuke | clojure.core/seq calls an anonymous function defined within clojure.core/map and that throws an exception |
| 09:06 | Chousuke | invoke is the java method that actually contains the code of a clojure function, so you can just ignore it and think "function call" |
| 09:08 | defn | Chousuke: by step function are you referring to something like (map #(+ % 4 2) [1 2 3 4]) |
| 09:08 | defn | Chousuke: where #(+ % 4 2) is the step function? |
| 09:08 | Chousuke | ~def map |
| 09:09 | Chousuke | eh, that's out of sync again |
| 09:10 | defn | Chousuke: im reading it -- a little thrown by the lazy-seq and chunked stuff still |
| 09:10 | Chousuke | lazy-seq might create a function too. |
| 09:10 | defn | could you clarify step function? is that a piece of the lazy seq? |
| 09:10 | defn | Chousuke: ah |
| 09:11 | Chousuke | I mean just the function that gives the "rest" of the sequence |
| 09:11 | defn | Chousuke: but does not necessarily evaluate it? |
| 09:12 | Chousuke | well, of course not. except for its first element. |
| 09:12 | Chousuke | but the rest is only generated when the first element is needed so that's okay |
| 09:12 | defn | Chousuke: okay, i see, thanks |
| 09:12 | Chousuke | anyway, most likely something is wrong with the function you're passing to map |
| 10:46 | Licenser | defn: as a advice, if you encounter things like that name your anonymous functions |
| 10:46 | Licenser | use (fn function-name [] ...) instead of #(...) |
| 11:03 | Raynes | I'm strongly against naming anonymous functions. Goes against everything they believe in. ;) |
| 11:03 | Raynes | Licenser: What's your "simple idea" for '.'? :o |
| 11:07 | Ankou | hi, is there something like memfn for static methods? |
| 11:08 | Raynes | Ankou: You don't want to use memfn. |
| 11:08 | Raynes | Use an anonymous function instead. |
| 11:08 | Raynes | In both cases. |
| 11:24 | Ankou | why not memfn? |
| 11:33 | chouser | memfn predates the #() syntax -- since it's less general, it probably will be deprecated |
| 11:35 | Licenser | Raynes: beasically to alias a function to . in the namespace |
| 11:36 | Raynes | Licenser: Indeed. That would be dead simple. |
| 11:36 | Licenser | yea but I'm not sure if it works/how good it works :P |
| 11:36 | Raynes | Well, it's an idea. Ideas make me happy. :> |
| 11:38 | Licenser | ^^ |
| 11:40 | Licenser | hrm |
| 11:40 | Licenser | but not working |
| 11:41 | Raynes | :( |
| 11:41 | Licenser | forms take priority over functions |
| 11:42 | Licenser | so it actually is back to walking the entire form and replacing all . wiht dot or whatever |
| 11:42 | Licenser | and keep . itself blacklisted |
| 11:42 | Licenser | narf this will be horrible |
| 11:42 | Licenser | I'm not sure if this is going to work |
| 11:42 | Licenser | hmm I see a flaw here |
| 11:43 | Licenser | is there a macro that runs stuff while being evaluated? |
| 11:45 | Licenser | so defmacro is a way out |
| 11:45 | Licenser | ,(defmacro x) |
| 11:45 | clojurebot | DENIED |
| 11:45 | Licenser | okay nice |
| 11:51 | Licenser | hrm |
| 11:53 | Raynes | Is there some sort of tool to count the number of lines of every file in a directory and it's sub directories recursively? |
| 11:53 | Raynes | :o |
| 11:54 | Licenser | Raynes: (for i in `find .`; do cat $i; end) | wc -l |
| 11:54 | Licenser | or something along the line |
| 11:55 | StartsWithK | wc -l `find .` |
| 11:55 | ducki2p | find . -type f -exec wc -l {} \; | awk '{total += $1} END{print total}' |
| 11:55 | Licenser | (for i in `find src`; do cat $i; done;) | wc -l |
| 11:55 | StartsWithK | wc -l `find . | grep .clj` for clj only |
| 11:56 | Raynes | :o |
| 11:56 | Raynes | Thanks, everybody. :p |
| 11:56 | Licenser | heh there are so many ways |
| 11:56 | ducki2p | plenty of choice; pick one :) |
| 11:56 | Licenser | also you could write a clojure program to do that for you |
| 11:56 | Raynes | My bashfoo is weak. |
| 11:56 | Licenser | I love for :P |
| 11:56 | ducki2p | there is also a special tool for this class of problems |
| 11:56 | ducki2p | 'google' :) |
| 11:57 | StartsWithK | Raynes, http://paste.pocoo.org/show/200415/ |
| 11:57 | StartsWithK | to count clojure files, no empty lines and no comments |
| 11:57 | Raynes | Sexpbot is 938 lines. O.O |
| 11:57 | Raynes | StartsWithK: Cool. Thanks. |
| 11:57 | StartsWithK | .. so support for (comment ..) |
| 11:58 | StartsWithK | so=no |
| 11:59 | Raynes | 884 lines. :D |
| 11:59 | Licenser | heh |
| 11:59 | Raynes | That makes it the largest project I've ever written in any language. |
| 11:59 | Licenser | I am urprised that find . -name *.clj does not go into sub directories o.O |
| 12:00 | Licenser | Raynes: heh |
| 12:00 | ducki2p | Licenser: put quotes around *.clj, so your shell doesnt expand that |
| 12:00 | Licenser | ah darn it I feel stuid now thanks ducki2p |
| 12:01 | Raynes | Of course, you have to subtract around 40-50 lines for the bf interpreter, which I didn't have the heart and courage to write myself. |
| 12:01 | Raynes | And around 20 for Rich's Norvig's spelling corrector. :> |
| 12:01 | Licenser | Raynes: it also counts newlines which are not LOC :P |
| 12:02 | ducki2p | another useful tool for this is sloccount; not sure if it natively recognizes Clojure |
| 12:02 | Raynes | ducki2p: It doesn't. |
| 12:02 | Licenser | clj-cat `find . -name "*.clj"` | grep -v "^$" | grep -v "^;" | wc -l |
| 12:02 | Licenser | try this |
| 12:02 | ducki2p | darn |
| 12:02 | Licenser | coderay does that too, but also not for clojure |
| 12:03 | Licenser | I think that is a pretty good aproximation |
| 12:03 | Raynes | 861 |
| 12:03 | Licenser | clj-sandbox gets about 400 there |
| 12:03 | Licenser | Also I'm not sure that many LOC are a good thing :P |
| 12:03 | asimjalis | Hi |
| 12:04 | Licenser | hi asimjalis |
| 12:04 | Licenser | I personally would be glad of the sandbox code had less, well we could technically substract save-fn's since it is more a database then code |
| 12:04 | Licenser | nearly 90 LOC in there |
| 12:06 | AsimJalis | I was checking to see if I could post to the channel. Now that I can I have nothing else to say. At least for now. |
| 12:06 | Licenser | heh |
| 12:13 | AsimJalis | Are there any examples of generating Java or some other language using Clojure? |
| 12:13 | AsimJalis | I mean human-readable code rather than .class files. |
| 12:13 | AsimJalis | Or just code -- it doesn't have to be human-readable. But still actual code. |
| 12:15 | Licenser | AsimJalis: there is something that generates JS from clojure |
| 12:15 | Licenser | and it is pretty readable too |
| 12:15 | AsimJalis | Also I am not looking for a Clojure translator. I just want to define my own mini language inside Clojure and then have a translator that translates a sexp composed of this mini-language into the target language. |
| 12:15 | AsimJalis | Licenser: What is it called? |
| 12:15 | Licenser | I don't remember :( |
| 12:16 | AsimJalis | Well, at least now it's no longer an unknown unknown. So thanks for that :-) |
| 12:16 | Licenser | scryptica and scrypticus |
| 12:17 | Licenser | AsimJalis: now it's even a known to you :P |
| 12:17 | Licenser | scryptica is the up to date one it seems |
| 12:18 | Licenser | well I'm dead tired :( night people |
| 12:18 | Licenser | (doc macroexpand) |
| 12:18 | clojurebot | "([form]); Repeatedly calls macroexpand-1 on form until it no longer represents a macro form, then returns it. Note neither macroexpand-1 nor macroexpand expand macros in subforms." |
| 12:19 | AsimJalis | Neat. Thanks! |
| 12:33 | AsimJalis | Yeah, Scryptica looks more complete. |
| 12:39 | Raynes | AsimJalis: COBOL is for Cwitters!!!! :p |
| 12:53 | Drakeson | where are things like swank:pprint-eval defined? in slime or in swank-clojure? |
| 12:57 | chouser | I've got to shuffle network boxes around. Nobody say anything important... :-) |
| 13:53 | asimjalis | The recursive solution seems more flexible -- if I want to bite off different amounts each time. |
| 13:54 | kiras | When I have a line that starts with only one ; emacs indents it to column 40. This happens in elisp-mode and clojure-mode. I was told in #emacs that this is the convention in elisp and that those comments are typically used after other text and to use ;; otherwise. Is this the convention in clojure as well? In Programming Clojure, there are examples where ; is used and it's not indented in this way and at http://clojure.org/reader, it ju |
| 13:54 | kiras | Single-line comment, causes the reader to ignore everything from the semicolon to the end-of-line. with nothing about indentation. |
| 13:55 | kjellski | Hi there =) |
| 13:56 | kjellski | Someone familiar with the labrepl arround? |
| 13:58 | asimjalis | What is labrepl? |
| 13:58 | kjellski | There was an example with a "data/words" file. I wanted to get the frequencies of characters in all the words and I´m struggling with the summing part... |
| 13:58 | zakwilson | If I have maps of keywords to ints and I want to speed up (merge-with + foo bar), can I do that with type hints? Unchecked math? |
| 13:58 | kjellski | labrepl is a project from stuart halloway... it´s ment to explain clojure... |
| 13:58 | asimjalis | I asked the same question when it was mentioned on HN -- the README does not say what it is, just how to get it. |
| 13:59 | kjellski | Basically it´s a local website with some stuff to play with for leaning and exploring clojure... |
| 13:59 | asimjalis | Ok. |
| 14:00 | kiras | In vim, the comments are indented as in Programming Clojure... |
| 14:01 | asimjalis | kjellski: Ok. Thanks. Your summary should be snuck in somewhere at http://github.com/relevance/labrepl |
| 14:02 | kjellski | Excuse me, what does snuck mean? |
| 14:02 | chouser | sneak |
| 14:02 | chouser | sneaked |
| 14:03 | asimjalis | Oh, sorry. It should be inserted somewhere at http://github.com/relevance/labrepl |
| 14:03 | kjellski | Okay... I´ll try to find a good solution first ;) |
| 14:03 | dcnstrct | ,(gen-and-load-class 'my.CoolException :extends Exception) |
| 14:03 | clojurebot | java.lang.Exception: Unable to resolve symbol: gen-and-load-class in this context |
| 14:03 | dcnstrct | hrmmm |
| 14:04 | chouser | gen-and-load-class is ancient -- been gone for ages |
| 14:05 | dcnstrct | ahhh damn ancient wikibook confused me http://en.wikibooks.org/wiki/Clojure_Programming/Concepts#User_Defined_Exceptions |
| 14:05 | dcnstrct | what should I google then ? |
| 14:05 | asimjalis | is proxy the current way to do this? |
| 14:05 | chouser | proxy is okay except you can't really rely on the classname that it generates |
| 14:06 | chouser | gen-class is your best option, but it requires AOT compilation. |
| 14:06 | hoeck | kiras: when in doubt, consider looking at core.clj :) |
| 14:06 | kiras | hoeck: ah... i should have thought of that. ty |
| 14:07 | chouser | are you sure you need your own named exception class? I'd recommend looking at clojure.contrib.condition |
| 14:08 | hoeck | kiras: in core, I found both ; and ;; for whole-line comments |
| 14:08 | kiras | so it's being indented incorrectly in emacs? |
| 14:09 | The-Kenny | kiras: ;; is the correct comment for a whole-line comment in my and emacs' opinion |
| 14:09 | The-Kenny | As far as I remember, ; gets indented wrong by emacs |
| 14:09 | The-Kenny | (right-aligned) |
| 14:09 | dcnstrct | hrmmm now that I think about it there's no reason why I need singly-typed errors. thnx |
| 14:10 | kiras | The-Kenny: that's my experience too, but I'm wondering if emacs is right or wrong |
| 14:10 | The-Kenny | I think emacs is right. I read about this loose-convention somewhere on cliki.net |
| 14:10 | kiras | The-Kenny: since i've seen clojure ; comments formatted the other way too |
| 14:11 | kiras | The-Kenny: I was told it was correct for elisp, just would like to be sure that it's also correct for clojure |
| 14:12 | hoeck | kiras: I guess those are "standard" lisp comment conventions |
| 14:12 | The-Kenny | hoeck: I think so too. Saw it on cliki.net somewhere |
| 14:12 | asimjalis | I was reading the comments about jobs at the clojure site in a recent conversation here http://clojure-log.n01se.net/date/2009-12-14.html . . . |
| 14:12 | hoeck | kiras: eg, see http://norvig.com/luv-slides.ps p. 41 |
| 14:12 | kiras | as hoeck pointed out, in core.clj ; is not indented to column 40 |
| 14:12 | The-Kenny | It's also described here: http://www.labri.fr/perso/strandh/Teaching/Langages-Enchasses/Common/Strandh-Tutorial/indentation.html |
| 14:12 | kiras | for example: |
| 14:12 | kiras | ;during bootstrap we don't have destructuring let, loop or fn, will redefine later |
| 14:12 | kiras | (def |
| 14:12 | kiras | #^{:macro true} |
| 14:12 | kiras | let (fn* let [& decl] (cons 'let* decl))) |
| 14:13 | asimjalis | The clojure jobs I see here list it as something interesting to have with no expectation that it will be used at the job . . . |
| 14:13 | asimjalis | For example, "Interest/experience in interesting languages (Lisp, Scheme, Erlang, Scala, Smalltalk, Haskell, Forth, Clojure)" |
| 14:13 | asimjalis | This is from http://sfbay.craigslist.org/sfc/sof/1667187845.html |
| 14:14 | kiras | I was just wondering if the same conventions held in clojure... it seems kind of strange that it wouldn't be followed in core.clj of all places? |
| 14:14 | asimjalis | Are there companies using Clojure in production? |
| 14:14 | asimjalis | How does one find them? |
| 14:16 | dcnstrct | if you're good @ clojure and looking for a clojure job in the bay area check out this company |
| 14:16 | dcnstrct | http://www.runa.com/company/careers/ |
| 14:16 | dcnstrct | they're running clojure in production |
| 14:17 | dcnstrct | they're the guys who made this http://github.com/amitrathore/swarmiji |
| 14:18 | dcnstrct | supposidly everything there is in clojure except one rails app.. they use swarmiji in front of hbase to power all their stuff |
| 14:20 | dcnstrct | if you get the job paypal me 10% of your first 3 months salary for the recuritment fee |
| 14:20 | dcnstrct | ;) |
| 14:23 | hoeck | asimjalis: http://www.infoq.com/articles/deadline-clojure-appengine |
| 14:23 | asimjalis | Ok. |
| 14:23 | asimjalis | Heh. |
| 14:23 | asimjalis | How about 20% -- you're selling yourself short. |
| 14:24 | dcnstrct | deal |
| 14:27 | kjellski | asimjalis: This is my solution... could you have a look wethere there is a better way to do it? http://paste.lisp.org/display/97649 |
| 14:30 | Blackfoot | is there a way to break out of loops? sometime the like (doseq [foo bar-seq] (if foo (println ok) (break)) |
| 14:30 | Chousuke | throw an exception |
| 14:31 | dcnstrct | clojure.contrib.condition is your friend |
| 14:31 | Chousuke | of course, the better way is to filter your sequence so that it is not longer than you need it to be. |
| 14:31 | Chousuke | take-while is helpful |
| 14:35 | Blackfoot | ok, reading through those, thanks. It is not an exception in the logical sense, but it may work |
| 14:35 | lopex | (doseq [x '(1 2 3 4 5) :while (< x 3)] (println x)) |
| 14:38 | Blackfoot | lopex: perfect! thank you |
| 15:01 | Hali_303 | what do you use for debugging? nothing I've tried seems to be able to do single stepping or at least tracing |
| 15:03 | Hali_303 | eg. cc.trace/dotrace is pretty limited (can only instrument functions which are in the form given, but not those which are called within deeper levels) |
| 15:09 | opqdonut | yeah |
| 15:09 | opqdonut | so I use prns and staring at code |
| 15:13 | Chousuke | Java debuggers should work on Clojure. |
| 15:25 | zkim | If you're adventurous there's hugo duncan's break stuff: http://hugoduncan.org/post/2010/swank_clojure_gets_a_break_with_the_local_environment.xhtml havn't tried it myself though |
| 15:35 | dcnstrct | if a certain function requires Ahead Of Time compilation what does that mean exactly ? |
| 15:35 | dcnstrct | does it mean I can't start a normal clojure repl and use it ? |
| 15:36 | StartsWithK | dcnstrct, yes, you will need to compile the namespace where that function is declared |
| 15:36 | StartsWithK | and then add compiled version to classpath |
| 15:37 | dcnstrct | argg |
| 15:37 | dcnstrct | does anyone know of a way to work with user definied exceptions in clojure that does not require AOT compilation ? |
| 15:37 | asimjalis | What's the specific problem you are dealing with? |
| 15:37 | StartsWithK | but fns don't need aot, is there a gen-class in there? |
| 15:37 | dcnstrct | I have a function that needs to be able to throw a couple different kinds of exceptions as well as return a value |
| 15:38 | dcnstrct | I have a gen-class yeah |
| 15:38 | asimjalis | Could you just throw Runtime exceptions? Or subclasses of some well-known exceptions? |
| 15:39 | dcnstrct | well my original approach was to subclass java.lang.Exception: (gen-and-load-class 'user.UserException :extends Exception) |
| 15:39 | dcnstrct | but then I found out gen-and-load-class is gone |
| 15:39 | dcnstrct | I could throw Runtime exceptions |
| 15:40 | dcnstrct | thats a good idea |
| 15:40 | StartsWithK | define all your exceltions in one package, but as java files, and stick http://paste.pocoo.org/show/200563/ something like this in your build |
| 15:40 | StartsWithK | and your done |
| 15:41 | dcnstrct | oh right.. just use java to define the exceptions.. good idea too |
| 15:41 | dcnstrct | thnx people |
| 15:41 | asimjalis | Or you could use proxy and create subclasses of Exception or some special Java Exception that is already defined. |
| 15:45 | sattvik | dcnstrct: If you are using Clojure 1.1, proxy may be your best bet, although it is a bit limited. In one project I used both proxy and gen-class within the same namespace so that I could use proxy during development and gen-class for deployment. With Clojure 1.2, you get deftype which is fairly flexible given many of the advantages of proxy and gen-class all in one. |
| 15:47 | StartsWithK | but deftype can't extend Exception |
| 15:47 | StartsWithK | or it can now? |
| 15:49 | sattvik | StartsWithK: Hmm.. not sure. I can give it a try. |
| 15:50 | StartsWithK | sattvik, i think it can only extend interfaces from java side |
| 15:55 | sattvik | StartsWithK: I think you are right. |
| 16:11 | TakeV | Hmm, so with Penumbra, is there a trick to making it be an executable jar? Using the standalone, but it still doesn't work. |
| 16:13 | StartsWithK | TakeV, not sure about Penumbra, but JLine keeps its native libs inside the jar and unpacks them to temp dir before executing rest of its code |
| 16:13 | StartsWithK | other options is something like webstart (supports jogl) |
| 16:14 | TakeV | StartsWithK: It seems to not be able to find the main class. I didn't know that clojure had main classes. 0_o |
| 16:14 | Hali_303 | zkim: does that work with swank-clojure in ELPA? |
| 16:14 | StartsWithK | TakeV, everything on java must have entry point |
| 16:15 | StartsWithK | i guess, it is something you will define for your app and not something penumbra provides for you |
| 16:15 | TakeV | StartsWithK: How do I do that? |
| 16:16 | zkim | Hali_303: Not sure, I wouldn't think so unless the ELPA package is running off of swank-clojure's HEAD |
| 16:16 | zkim | It's on my list of things to look at though, I was really excited to see that post come across my reader |
| 16:17 | StartsWithK | TakeV, define one of your namespaces as (ns my.entrypoint (:gen-class :main true)) and create function named "-main" that takes no arguments in that namespace |
| 16:17 | Hali_303 | zkim: I see. so println is the best thing I can have now, right? |
| 16:17 | StartsWithK | then compile that namespace with clojure.compile |
| 16:17 | TakeV | Huh, thanks. |
| 16:17 | zkim | Hali_303: AFAIK, yes. JSwat or YourKit might help also |
| 16:18 | StartsWithK | other options are, you use clojure.main -e "(require 'my.entrypoint) (-main)" |
| 16:18 | Hali_303 | zkim: I tried JSwat without any luck a few months ago |
| 16:18 | StartsWithK | or custom java launcher |
| 16:19 | zkim | Hali_303: yeah, when I was starting out with clojure I was really aware of the lack of debugging tools, and as I've done more and more it hasn't been a big problem |
| 16:19 | asimjalis | Is there an easy way to deploy Clojure desktop apps? I created an app and I have it compiled into an uberjar, but my users might not have Java installed. |
| 16:19 | TakeV | Lein keeps throwing all kinds of errors now. Hmm... |
| 16:19 | zkim | Hali_303: although I'd qualify that with the fact that I havn't done anything really big with the language |
| 16:19 | dcnstrct | asimjalis, yes... use jaunch4j |
| 16:20 | dcnstrct | err launch4j |
| 16:20 | StartsWithK | TakeV, can you paste what it is? |
| 16:20 | StartsWithK | lisppaste8, help |
| 16:20 | zkim | Hali_303: off topic, but 303 as in Denver? |
| 16:20 | StartsWithK | http://paste.pocoo.org/ |
| 16:20 | TakeV | Exception in thread "main" Java returned: 1 (NO_SOURCE_FILE:0) |
| 16:21 | asimjalis | dcnstrct: Thanks! For a second I thought jaunch4j was the Clojure version of launch4j. I'm looking at it right now. |
| 16:21 | TakeV | The rest of the error is quite long. |
| 16:21 | StartsWithK | use the paste.pocoo.org |
| 16:22 | Hali_303 | zkim: no, it is just random string, so my name does not conflict with others |
| 16:22 | Hali_303 | :D |
| 16:22 | TakeV | http://paste.pocoo.org/show/200581/ |
| 16:22 | zkim | Hali_303: ah, got it :) |
| 16:23 | asimjalis | I am almost scared of asking questions because they all get answered -- do I really want to know in some cases? |
| 16:23 | zkim | Hali_303: but yeah, I mostly use println and c.c.pprint |
| 16:23 | Hali_303 | zkim: hm I've not yet used pprint, but looks nice, thanks |
| 16:23 | zkim | Hali_303: np |
| 16:25 | TakeV | StartsWithK: Would you like me to post my code and project.clj? |
| 16:26 | StartsWithK | TakeV, sure, maybe some can spot the error |
| 16:27 | TakeV | http://paste.pocoo.org/show/200583/ --- Project.clj is on the top, the source file is on the bottom. |
| 16:28 | StartsWithK | what did you use as argument for -e option |
| 16:29 | StartsWithK | it looks like eval throws the error |
| 16:29 | TakeV | -e option? |
| 16:29 | StartsWithK | uf, and, just to be safe, use two segment namespace names |
| 16:29 | StartsWithK | wings.foo |
| 16:30 | TakeV | Ah. |
| 16:31 | TakeV | Not sure what the -e option is. Trying to compile it with "lein compile", after running "lein deps" and "lein native-deps". |
| 16:31 | StartsWithK | one of the problems i see |
| 16:31 | StartsWithK | is app/start |
| 16:31 | StartsWithK | its outside any function |
| 16:31 | StartsWithK | place that inside your new -main |
| 16:31 | StartsWithK | as lein compiles the namespace, clojure will execute your code |
| 16:34 | TakeV | http://paste.pocoo.org/show/200586/ -- Result of running "java -jar wings-standalone.jar -Djava.library.path=native/linux/x86". |
| 16:37 | kzar | What's wrong with this? (for [[x y] (range 10)] [x y]) I'm trying to grab values out of the range in pairs |
| 16:37 | opqdonut | , (partition 2 (range 10)) |
| 16:37 | clojurebot | ((0 1) (2 3) (4 5) (6 7) (8 9)) |
| 16:38 | opqdonut | that tries to do a destructuring bind |
| 16:38 | StartsWithK | TakeV, when you type jar -tf wings-standalone.jar can you see "wings/core.class" file inside your jar? |
| 16:38 | opqdonut | , (let [thing [[1 2] [3 4] [5 6]]] (for [[x y] thing] y)) |
| 16:38 | clojurebot | (2 4 6) |
| 16:39 | opqdonut | that's how destructuring works |
| 16:40 | TakeV | StartsWithK: No. |
| 16:40 | StartsWithK | TakeV, hmm.. did you update :main in your project.clj to wings.core? |
| 16:41 | TakeV | Yes. Hmm... let me clean and recompile. |
| 16:42 | TakeV | Huh, still not appearing... |
| 16:42 | technomancy | dcnstrct: do you know about clojure.contrib.condition? |
| 16:43 | technomancy | it's much nicer than defining your own Exception subclasses |
| 16:43 | StartsWithK | TakeV, same error? and no .class file in jar? |
| 16:43 | TakeV | Yes, to both. |
| 16:43 | StartsWithK | is there some kind od buld/classes dir in your project |
| 16:43 | StartsWithK | can you see .class file in there |
| 16:43 | TakeV | Yes, there is a dir. But there are no files in there. 0_o |
| 16:45 | StartsWithK | TakeV, hmm |
| 16:45 | kzar | opqdonut: But what if the 'thing' isn't a vector of vectors, it's just a vector? (let [thing [1 2 3 4 5 6]] (for [[x y] thing] y)) |
| 16:45 | opqdonut | kzar: then you get an error :) |
| 16:45 | kzar | heh |
| 16:45 | opqdonut | , (let [thing [1 2]] (for [[x y] thing] y)) |
| 16:45 | clojurebot | java.lang.UnsupportedOperationException: nth not supported on this type: Integer |
| 16:46 | opqdonut | because 1 is not a sequence |
| 16:46 | StartsWithK | TakeV, what is compile step saying? |
| 16:46 | StartsWithK | do you see something like compiling wings.core |
| 16:46 | TakeV | The only thing it prints is "All :namespaces already compiled." |
| 16:47 | kzar | opqdonut: ah ok I see, but what if I want to take items from the front of a vector each time? |
| 16:47 | opqdonut | well one answer is partition |
| 16:47 | StartsWithK | TakeV, maybe you then need to add :namespaces [wings.core] to your project |
| 16:48 | kzar | opqdonut: Ah sweet I got it working thanks |
| 16:48 | StartsWithK | is there a lein user in the house? :) |
| 16:49 | StartsWithK | it looks compile will search for :namespaces and then skip to some kind of namespace guessing |
| 16:50 | StartsWithK | by matching file names |
| 16:50 | StartsWithK | is your file in src/wings/core.clj |
| 16:50 | TakeV | No. |
| 16:50 | Fossi | yes |
| 16:51 | StartsWithK | TakeV, place the file in src/wings/core.clj |
| 16:51 | StartsWithK | clean and recompile ad you did before |
| 16:52 | asimjalis | opqdonut: "for" expects thing to be a sequence of pairs. Try this instead: |
| 16:53 | asimjalis | ,(let [things [[1 2] [3 4]]] (for [[x y] things] y)) |
| 16:53 | clojurebot | (2 4) |
| 16:53 | TakeV | Still just printing "all :namespaces already compiled". Also added :namespaces [wings.core] to the project. |
| 16:53 | StartsWithK | so you have wings/project.clj wings/src/wings/core.clj |
| 16:53 | StartsWithK | in your project |
| 16:54 | TakeV | Ah, didn't rename it to core. One sec. |
| 16:55 | opqdonut | asimjalis: i was demonstrating that fact to kzar :) |
| 16:55 | LauJensen | Do we have some clojure wrapper for copying a file ? |
| 16:55 | clojurebot | clojurebot has a lot of features |
| 16:55 | asimjalis | ok |
| 16:55 | TakeV | Oh good, now it's throwing errors again. >_> |
| 16:55 | StartsWithK | TakeV, aha add :namespaces :all |
| 16:56 | StartsWithK | that will search for namespaces by filename matching in your src dir |
| 16:56 | technomancy | LauJensen: give two File objects to the copy method in duck-streams |
| 16:56 | technomancy | aka c.c.io |
| 16:57 | LauJensen | thanks phil |
| 16:57 | technomancy | good old duck-streams =) |
| 16:59 | TakeV | http://paste.pocoo.org/show/200598/ |
| 17:00 | StartsWithK | TakeV, add another ) at the end of your -main |
| 17:00 | TakeV | -_- |
| 17:01 | StartsWithK | :) |
| 17:01 | asimjalis | opqdonut: How could this be done using destructuring recursively in a loop for example instead of using partition? |
| 17:01 | opqdonut | sure |
| 17:01 | StartsWithK | TakeV, also, its ok to place app/start inside the -main |
| 17:01 | opqdonut | there should be a higher-level construct for this |
| 17:02 | opqdonut | something like haskell's tails or common lisp's loop :on or mapcdr |
| 17:03 | TakeV | Still getting the same error. This is starting to become irritating. :P |
| 17:04 | StartsWithK | same error about missing paren? |
| 17:04 | TakeV | The EOF thing. |
| 17:04 | StartsWithK | TakeV, you are missing one ) at the end of ns too |
| 17:04 | TakeV | Oh. >_> |
| 17:04 | StartsWithK | :) |
| 17:06 | TakeV | http://paste.pocoo.org/show/200599/ |
| 17:07 | StartsWithK | there is no jlwgl on classpat while you are compiling |
| 17:07 | StartsWithK | try :native-dependencies [[lwjgl "2.2.2"]] adding lwjgl dep to :dependencies too |
| 17:08 | TakeV | In project? |
| 17:08 | StartsWithK | yes |
| 17:08 | StartsWithK | add [lwjgl "2.2.2."] after penubra |
| 17:19 | hamza | ,(proxy [javax.swing.TransferHandler] [] (canImport [s] (println "s")) (canImport [c f] (println "c f"))) |
| 17:19 | clojurebot | java.lang.IllegalStateException: Var null/null is unbound. |
| 17:19 | hamza | is it possible to somehow define two canImport calls? |
| 17:20 | Crowb4r | Speaking of proxy, is there a good example of using proxy around? |
| 17:43 | chouser | hamza: use (proxy [...] [] (canImport ([s] ...) ([c f] ...))) |
| 17:43 | StartsWithK | TakeV, any progress? |
| 17:53 | hamza | chouser: thanks that worked.. |
| 17:53 | TakeV | StartsWithK: Not really. :\ |
| 17:54 | StartsWithK | whats the current error? |
| 17:55 | TakeV | StartsWithK: Same as last time. Got some lunch and just got back. :P |
| 17:55 | StartsWithK | hehe |
| 17:56 | StartsWithK | when you type jar -t wings-standalone.jar |
| 17:57 | StartsWithK | do you see opengl jars inside? |
| 17:58 | TakeV | I can't build the jar, as it will not compile. |
| 18:02 | StartsWithK | ok, are the opengl libs in your lib/ directory? |
| 18:03 | TakeV | Er, it started randomly being able to compile. |
| 18:03 | StartsWithK | that is a good sign :) |
| 18:05 | danlarkin | I'm drawing a blank, what's the best way to subsection an array |
| 18:05 | danlarkin | like subs does to strings |
| 18:05 | TakeV | Ok, yeah, the lwjgl and all required libs are in lib. |
| 18:05 | TakeV | danlarkin: Partition? |
| 18:05 | StartsWithK | ,(doc subvec) |
| 18:05 | clojurebot | "([v start] [v start end]); Returns a persistent vector of the items in vector from start (inclusive) to end (exclusive). If end is not supplied, defaults to (count vector). This operation is O(1) and very fast, as the resulting vector shares structure with the original and no trimming is done." |
| 18:06 | StartsWithK | oh, array, System/arraycopy |
| 18:06 | danlarkin | ja but an array, not a seq or a vec |
| 18:06 | danlarkin | oh there we go |
| 18:07 | danlarkin | thanks StartsWithK |
| 18:10 | carkh | |
| 18:12 | TakeV | Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path (core.clj:1) |
| 18:12 | TakeV | Er... |
| 18:12 | TakeV | Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path (core.clj:1) |
| 18:12 | TakeV | Exception in thread "main" java.lang.ExceptionInInitializerError |
| 18:12 | StartsWithK | is your lib path ok? |
| 18:12 | TakeV | I don't know. >_> |
| 18:12 | StartsWithK | what your lib path? |
| 18:13 | TakeV | wings/lib? |
| 18:14 | StartsWithK | can you paste "ls -R" from the root of your project |
| 18:15 | StartsWithK | also, can you try with absolute path |
| 18:16 | TakeV | http://paste.pocoo.org/show/200632/ |
| 18:18 | StartsWithK | TakeV, your java.library.path shoubl be native/<your-os-arch>/ |
| 18:20 | TakeV | StartsWithK: That is what I am passing to java -jar wings-standalone.jar |
| 18:20 | StartsWithK | java -Djava.library.path=native/linux/x86_64 wing-standalone.jar |
| 18:20 | StartsWithK | ? |
| 18:21 | StartsWithK | s* |
| 18:21 | StartsWithK | with the -D prefix and = |
| 18:21 | TakeV | Yeah, only x86. 32-bit for the fail. >_> |
| 18:22 | TakeV | Ah, but not in that order. |
| 18:22 | TakeV | Ok, that works! |
| 18:22 | StartsWithK | :) |
| 18:23 | TakeV | Thank you so very much. :) |
| 18:23 | StartsWithK | np |
| 18:32 | StartsWithK | what is the name of text indexing project for clojure? |
| 18:32 | StartsWithK | i remeber there was one |
| 18:32 | technomancy | lucene works fine |
| 18:33 | StartsWithK | caponia :) |
| 18:35 | StartsWithK | lucene is ~1mb, thats not so bad |
| 18:36 | TakeV | Clojure is garbage collected, right? What exactly gets collected, since there are no real variables. |
| 18:37 | carkh | there are values anyways, and all the java stuff, and persostent data structures |
| 18:38 | hiredman | TakeV: gc doesn't have anything to do with variables |
| 18:38 | hiredman | variables aren't gc, things that are referenced by variables are gc'ed |
| 18:39 | hiredman | if I create a big map of stuff, but don't keep a reference to it, the map is garbage since I can never use it |
| 18:41 | asimjalis | You can prod the garbage collector with (System/gc) if you think it's not being aggressive enough. |
| 18:41 | rlb | TakeV: ...or if you create a big sequence, reduce it, etc. The gc will collect anything that's no longer reachable, and computations allocate things with limited lifespans all the time. |
| 18:41 | asimjalis | ,(System/gc) |
| 18:41 | clojurebot | nil |
| 18:41 | hiredman | asimjalis: :( |
| 18:41 | hiredman | never do that |
| 18:41 | asimjalis | Why? |
| 18:41 | clojurebot | why not? |
| 18:42 | asimjalis | hiredman: Why not? |
| 18:44 | hiredman | it negates the purpose of having a gc |
| 18:44 | hiredman | better to tune heap params |
| 18:45 | hiredman | http://java-monitor.com/forum/showthread.php?t=188 |
| 18:45 | hamza | AFAIK you can't force java gc to run it will only hint it. |
| 18:45 | hiredman | etc |
| 18:54 | TakeV | rlb: That makes sense. |
| 18:56 | asimjalis | I've found it useful in testing from the REPL to get some idea about the memory footprint of processes. |
| 19:05 | asimjalis | I am writing a Clojure library that lets me write Java as sexps and to use defmacro. Any good starting points? |
| 19:06 | asimjalis | Here is some code in Common Lisp I am using as a starting point: http://www.keyongtech.com/4689544-how-to-do-java-in#14 |
| 19:06 | hiredman | why bother? |
| 19:07 | hiredman | I would either just write clojure, or write clojure to generate jvm bytecode via one of the bytecode engineering libraries |
| 19:07 | asimjalis | I need to deliver Java for work. |
| 19:07 | hiredman | :( |
| 19:08 | asimjalis | I know where you are coming from. I might be taking an overly circuitous solution to this problem. |
| 19:08 | asimjalis | I could switch jobs. So that's another option. |
| 19:08 | carkh | what if someone in your team makes a change to the produced java code ? |
| 19:09 | asimjalis | I'll have to quickly backport it. |
| 19:10 | carkh | also you'll be debugging java code and correcting lisp code ... this will be annoying |
| 19:10 | asimjalis | Or maybe write a Java to Jaja translator that goes backwards (where Jaja is a tentative name for this Clojure-esque Java). |
| 19:10 | carkh | error at line 45 which is line 2 of your lisp code |
| 19:11 | hiredman | deliver java code that drives a "library" that you provide as a jar |
| 19:11 | hiredman | you can call clojure's eval from java :) |
| 19:12 | asimjalis | So I own a whole module at work. No one else modifies it very much. Everyone lives in their own modules. So this kind of thing does not happen very much. Once in a while some small change bubbles across the whole system. |
| 19:13 | asimjalis | The problem is that this is a shipping product -- there is not much interest in management to add Clojure to the code-base. |
| 19:13 | hiredman | "I'd like to start replacing some of my java with a dsl" |
| 19:13 | hiredman | you've asked? |
| 19:13 | asimjalis | Maybe I just suck at selling. Anyway, I made a case and it was politely declined. |
| 19:13 | asimjalis | Yes. I actually brought it up with my manager. |
| 19:14 | hiredman | :/ |
| 19:14 | carkh | if yuou leave tha company they need to find someone that will be able to take ownership on your code |
| 19:14 | asimjalis | He did say though that if there was a compelling feature that could be done with Clojure that couldn't be done with Java or would be nearly impossible with Java then I'd have a stronger case. |
| 19:15 | asimjalis | Yeah. So I see his point. They don't want to turn the code base into a Tower of Babel. |
| 19:15 | carkh | well ...closures is one |
| 19:15 | carkh | and persistent data structures |
| 19:15 | asimjalis | What's a customer-facing feature that closures could enable? |
| 19:15 | carkh | less bugs =P |
| 19:15 | hiredman | "witing java makes work so horrible that I do additional unpaid work creating frameworks to generate java code from nicer languages" |
| 19:16 | hiredman | writing |
| 19:16 | asimjalis | This captures my feelings. |
| 19:16 | carkh | what language could provide a customer-facing feature that unique to it ? |
| 19:17 | hiredman | anyway, java isn't that bad if you just ignore the type system |
| 19:17 | hiredman | do everything via runnables and callables |
| 19:17 | asimjalis | He gave me the example of ActionScript which enabled some new flashy UI features that were not possible with JSPs and Javascript. |
| 19:17 | hiredman | lots of unsafe casts everwhere |
| 19:18 | asimjalis | carkh: He gave me the example of ActionScript which enabled some new flashy UI features that were not possible with JSPs and Javascript. |
| 19:18 | carkh | it's not the language but the platform |
| 19:18 | asimjalis | True. |
| 19:18 | carkh | but yes i see the point |
| 19:20 | asimjalis | carkh: So theoretically I don't see how Clojure could provide a concrete user-level feature that Java could not provide. Although I suspect that many features will just be very complicated and hard to write in Java and might be easier in Clojure. |
| 19:20 | asimjalis | carkh: So there is a stereotype that Lispy languages are better for AI. Is this really true? Theoretically you can make decision trees and prune them in any language. |
| 19:20 | hiredman | well, you'll end up reimplementing clojure |
| 19:21 | asimjalis | We are using a C library called SVM-Light for Machine Learning. |
| 19:21 | carkh | asimjalis: lisps where used for ai because of garbage collection and list processing ....every other language has that now |
| 19:22 | carkh | maybe macros played a role too i don't know |
| 19:23 | asimjalis | carkh: Yes, it seems like you can do it in Java if you wanted to. Although I still thing the fluidity of design that Clojure gives you will make it easier to converge to a good design and solution. So the development speed and product quality and flexibility might be higher |
| 19:23 | hiredman | clojurebot: the evolution of lisp? |
| 19:23 | clojurebot | my lisp machine is the jvm |
| 19:23 | hiredman | clojurebot: you suck |
| 19:23 | clojurebot | Titim gan éirí ort. |
| 19:23 | hamza | asimjalis: since in lisp code is data, it is really trivial for lisp programs to read and modify them selfs. |
| 19:24 | hiredman | I have a (pdf)copy of some memo from MIT where someone said "I ask for examples of real world uses of lisp, not ai since we all know ai isn't real, but got no responses, so obviously lisp has no real world applications" |
| 19:25 | carkh | symbols and keywords word decisive for ai too i think |
| 19:25 | carkh | word->were |
| 19:25 | asimjalis | But things like development-speed and flexibility are so fuzzy. |
| 19:26 | carkh | symbols and keyword enable the data is code counterpart to code is data |
| 19:26 | asimjalis | carkh: The data drives the code? |
| 19:26 | carkh | right |
| 19:26 | carkh | like hum ...in those html libraries for instance |
| 19:27 | asimjalis | hum? Is that a library? |
| 19:27 | carkh | you know type this : [:h1 "hello world"] and it gets transofrmed to html |
| 19:27 | asimjalis | Right. |
| 19:27 | carkh | that's a simplistic example i guess |
| 19:28 | asimjalis | Right. I know what you mean about [:html ...]. ("Hum" was just a sound.) |
| 19:28 | carkh | ah ...hehe sorry |
| 19:29 | asimjalis | The way libraries are being named right now every typo could potentially be a library or project name. Can't be too careful. |
| 19:30 | kiras | how do you know about project hum? |
| 19:31 | carkh | who doesn't ? |
| 19:32 | kiras | i see... |
| 19:33 | carkh | http://www.dcs.qmul.ac.uk/research/imc/hum/ |
| 19:33 | carkh | =) |
| 19:34 | kiras | lol |
| 19:35 | asimjalis | Heh. |
| 19:36 | kiras | so is leiningen pretty much the standard build tool for clojure projects at this point? |
| 19:36 | The-Kenny | kiras: I think so |
| 19:37 | hiredman | there is a very vocal maven faction |
| 19:38 | carkh | so i'm the only one using ant i guess =/ |
| 19:38 | glogic | carkh: i use ant |
| 19:38 | glogic | carkh: heh |
| 19:38 | kiras | heh |
| 19:38 | kiras | ok |
| 19:38 | kiras | good to know |
| 19:38 | glogic | kiras: ya file that away right |
| 19:38 | glogic | kiras: lol |
| 19:38 | kiras | lol |
| 19:43 | glogic | http://en.wikipedia.org/wiki/Cheney's_algorithm |
| 19:43 | glogic | cheney was a crazy kind of guy |
| 19:44 | glogic | my head hurts |
| 19:45 | asimjalis | I stopped using leiningen because it wouldn't let me easily include a local jar file that was not published on git -- for example see http://stackoverflow.com/questions/2404426/leiningen-how-to-add-dependencies-for-local-jars |
| 19:45 | asimjalis | I built using a straight bash script -- yeah it's very old-fashioned |
| 19:47 | tomoj | you can just install a jar into your local maven repo |
| 19:47 | tomoj | of course, no one else will be able to build the project, then, unless they also install these jars |
| 20:05 | asimjalis | Is clojure being used for machine learning or document classification by anyone? |
| 20:05 | asimjalis | Any references would be great. |
| 20:06 | hiredman | the big one would be flightcaster |
| 20:06 | hiredman | ~google flightcaster |
| 20:06 | clojurebot | First, out of 2160 results is: |
| 20:06 | clojurebot | FlightCaster |
| 20:06 | clojurebot | http://flightcaster.com/ |
| 20:08 | tomoj | I heard some of their ml stuff was getting into incanter |
| 20:28 | tomoj | the algorithm I'm implementing uses a global incrementing counter. I was thinking of just using gensym, as all that really matters is that the values are unique, but they need to be unique across jvm restarts |
| 20:28 | tomoj | ideas? |
| 20:29 | tomoj | fairly easy to do the same old incrementing counter with an atom, but you run into trouble across jvm restarts |
| 20:29 | carkh | store it in a file =P |
| 20:29 | hiredman | uuid |
| 20:30 | hiredman | gensyms are really not that unique |
| 20:30 | carkh | tho how slow is it to make an uuid ? |
| 20:31 | hiredman | uh, why would it be slow? |
| 20:31 | hiredman | uuidgen 0.00s user 0.00s system 67% cpu 0.006 total |
| 20:31 | carkh | i don't know never really looked intop it , surely needs a system call to get time, and maybe another to get mac address ? |
| 20:31 | tomoj | reading java.util.UUID |
| 20:33 | asimjalis | The mac address requires reading the network card. |
| 20:33 | asimjalis | So it is expensive. |
| 20:34 | asimjalis | But you could get the UUID once -- and then append your counter to it. So this way it's a one-time cost for the UUID call. |
| 20:34 | hiredman | why do you think a uuid includes a mac address? |
| 20:34 | tomoj | I can make 10000 UUIDs in 274ms |
| 20:34 | tomoj | plenty quick enough for me |
| 20:35 | carkh | Version 1 (MAC address) |
| 20:35 | asimjalis | There are 4 classes of UUIDs. If you use the MAC address you guarantee uniqueness. Version 1 uses the MAC address. The others don't. http://en.wikipedia.org/wiki/Universally_Unique_Identifier |
| 20:35 | asimjalis | Wait 5, not 4. |
| 20:36 | hiredman | the javadocs don't mention mac addresses at all |
| 20:36 | carkh | looks like version 4 would be the fastest ? |
| 20:36 | asimjalis | This is what Windows does. |
| 20:36 | carkh | java's uuid aren't complete |
| 20:36 | hiredman | so? |
| 20:36 | asimjalis | But it might cache the MAC address so multiple UUIDs might not be that expensive. |
| 20:36 | asimjalis | I don't know how it's implemented. |
| 20:36 | tomoj | I'm using type 4 (pseudorandom), and I don't care :) |
| 20:37 | carkh | anyways, quick enough for tomoj =P |
| 20:37 | hiredman | I'm saying who cares about mac addresses if don't need to? |
| 20:37 | carkh | well i just discovered that not every uuid uses the mac address =P |
| 20:38 | carkh | that's why i said _maybe_ |
| 20:38 | carkh | looks like not every uuid uses time either =P |
| 20:38 | asimjalis | Although the Wiki says that Java uses Versions 3 or 4: ``Java: The J2SE 5.0 release of Java provides a class that will produce 128-bit UUIDs, although it only implements version 3 and 4 generation methods, not the original method (due to lack of means to access MAC addresses using pure Java).'' |
| 20:39 | carkh | anyways 10k uuids in 250ms is very slow |
| 20:40 | carkh | compared to incrementing an integer |
| 20:40 | tomoj | sure |
| 20:40 | carkh | so it all depends on the use case i guess |
| 20:40 | hiredman | persisting + incrementing an integer |
| 20:40 | tomoj | but it will allow me to focus on the important stuff for now |
| 21:44 | dcnstrct | I finally figured out the bizarre problem I had with lein that was making it never work.. |
| 21:44 | dcnstrct | it boils down to this: don't do sudo lein self-install |
| 21:44 | dcnstrct | unless you intend on using lein as root |
| 21:44 | dcnstrct | I don't know why I would have done that anyways... so insecure.. I guess I wasn't thinking |
| 21:45 | dcnstrct | works great now though :) |
| 21:54 | tomoj | dcnstrct: what's wrong with lein self-install? |
| 22:01 | _ato | tomoj: he ran it with sudo, so presumably it either installed into /root or messed up the permissions on ~/.m2 |
| 22:02 | tomoj | oh, I missed the sudo |
| 22:02 | tomoj | of course |
| 22:02 | tomoj | I've been wondering how you might set up a system-wide lein |
| 22:02 | Licenser | greetings |
| 22:03 | Licenser | hey _ato I'd wanted to ask for another clojars featre :P |
| 22:03 | Licenser | *feature |
| 22:03 | tomoj | lein always uses ~/.m2 ? |
| 22:04 | _ato | if you set M2_HOME it'll probably use somewhere else |
| 22:04 | _ato | Licenser: ok |
| 22:04 | _ato | Licenser: what's the feature? |
| 22:04 | Licenser | _ato: very simple thing, a hash of the current feed.clj.gz so people don't download it twice |
| 22:04 | Licenser | it's more to save clojars bandwith then for compfort :P |
| 22:05 | _ato | ah, good idea, I'm surprised that didn't occur to me |
| 22:05 | _ato | just a sec |
| 22:05 | Licenser | well must not be a hash can be anything that identifies if the feed.clj changed |
| 22:07 | Licenser | _ato: it didn't occured to you so it can be a team effort :P |
| 22:08 | _ato | http://clojars.org/repo/feed.clj.gz.md5 http://clojars.org/repo/feed.clj.gz.sha1 |
| 22:08 | tomoj | etag? |
| 22:08 | Licenser | _ato: thank you :) |
| 22:13 | defn | http://floating-point-gui.de/ |
| 22:13 | Licenser | _ato: with this I can make add and search automatically check for new versions and get them :) |
| 22:14 | Licenser | greetings defn :) |
| 22:14 | defn | hello sir! |
| 22:14 | defn | ,(+ 0.2 0.1) |
| 22:14 | clojurebot | 0.30000000000000004 |
| 22:14 | defn | hehe, this is interesting... |
| 22:15 | Licenser | that is why floats are evil! |
| 22:15 | Licenser | defn: are you using lein search already? :P I made it specially for you! |
| 22:15 | _ato | tomoj: yeah good point, I should make it only touch the file when it actually differs, then the etag and last modified will be correct as well |
| 22:15 | chouser | ,(+ 2/10 1/10) |
| 22:15 | clojurebot | 3/10 |
| 22:16 | defn | chouser: oh of course! i didn't consider clojure's rationals. |
| 22:16 | defn | chouser: either way i was interested as I didn't know about this problem tbqh |
| 22:16 | defn | chouser: the latest edit of JoC looks great btw |
| 22:16 | clojurebot | paredit commands is http://mumble.net/~campbell/emacs/paredit.html |
| 22:17 | defn | Licenser: where do i go to get lein search? |
| 22:17 | defn | is it in the main repo? |
| 22:17 | Licenser | defn: add [lein-search "0.2.0"] to your dev deps :) |
| 22:17 | defn | ooo! |
| 22:17 | Licenser | :) |
| 22:17 | chouser | defn: great, thanks. should be a substantial treatment of floating point numbers in there. |
| 22:18 | Licenser | JoC |
| 22:18 | defn | chouser: excellent. also i love your dr. seuss quote in there -- the one about beetle battle muddle...something like that |
| 22:18 | Licenser | ? |
| 22:19 | defn | Licenser: Joy of Clojure -- chouse and fogus' book |
| 22:19 | Licenser | oh |
| 22:19 | Licenser | is it out? |
| 22:19 | defn | the first 5 chapters are so far |
| 22:19 | chouser | defn: yeah, fogus found that quote -- fit perfectly. |
| 22:20 | Licenser | it is open source or is there like a pre purchase preview? |
| 22:21 | defn | pre purchase preview |
| 22:21 | Licenser | can someone give me a link? I am curiose :P |
| 22:21 | defn | of course -- one second |
| 22:22 | defn | http://www.manning.com/fogus/ |
| 22:22 | chouser | Licenser: http://joyofclojure.com/ |
| 22:22 | Licenser | I mean of the purchase page not the preview of caus |
| 22:22 | Licenser | thanks mates |
| 22:23 | defn | chouser: im really excited for the types,protocols, and reify section, and the concurrency /mutation idioms section |
| 22:23 | defn | the descriptions of "when to use..." make me most excited i think |
| 22:24 | Licenser | neat |
| 22:24 | chouser | defn: I'm working on the types,protocols, and reify right now. The hard part, as always, is coming up with good examples. |
| 22:25 | Licenser | Neat |
| 22:26 | defn | chouser: i hope i dont presume too much but i am somewhat curious about using examples from JoC in my walton project. Obviously, as you just said, finding good examples is incredibly time consuming. Are there restrictions that preclude my use of the examples in JoC or Stuart's book, for instance? Is it a matter of EPL? The publisher? |
| 22:34 | asimjalis | I am reading the first chapter (the free preview). Looks pretty interesting. Looking forward to it. |
| 22:34 | asimjalis | What is the Walton project? |
| 22:35 | Licenser | walton is an awsome project to let you find example code |
| 22:35 | defn | http://github.com/defn/walton , http://getclojure.org:8080/examples/let (replace let with whatever function you'd like examples for) |
| 22:35 | defn | Licenser: you are too kind |
| 22:35 | defn | :) |
| 22:36 | Licenser | and I didn't even start :P |
| 22:38 | chouser | defn: standard copyright rules, whatever that means in your case. |
| 22:38 | Licenser | defn: it gets cooler and cooler |
| 22:40 | chouser | defn: actually, I think the source snippets from Halloway's book are all open source on github |
| 22:41 | chouser | I don't think ours are yet, though that's something I suppose we should look into. |
| 22:46 | Licenser | neat neat! |
| 22:47 | Licenser | is there something like tree-map I missed? |
| 22:52 | Licenser | hmm is there a way to 'appy' things to a form |
| 22:52 | Licenser | ? |
| 22:54 | Licenser | I'd need to do something like (apply . object method args) |
| 22:54 | Licenser | hmm defn I just had an idea for walton |
| 22:55 | Licenser | since you use click to expand count the clicks on every string and sort them by the number of clicks :) |
| 22:56 | chouser | Licenser: if you don't know the number of args at compile time, you can use Reflector. |
| 22:56 | Licenser | with a special form? |
| 22:57 | chouser | no, for a method call |
| 22:57 | Licenser | or instead of . |
| 22:57 | chouser | right |
| 22:57 | Licenser | ah sneaky sneaky |
| 22:57 | Licenser | thank you chouser |
| 22:57 | chouser | there's nothing like apply that would work for arbitrary special forms. |
| 22:57 | Licenser | geez clj-sandbox will be slow :P |
| 22:57 | hiredman | you can always use eval to generate a function that does what you want |
| 22:58 | chouser | yeah, that's a good idea too |
| 22:58 | Licenser | hmm true too and a very neat idea hiredman :) |
| 22:58 | Licenser | sweet! |
| 22:59 | Licenser | but is this save or am I opening up a hole *ponder* |
| 23:00 | hiredman | if you wanted to be safe you shouldn't have left home this morning |
| 23:00 | asimjalis | chouser: I tried (infix 1 + 2 + 3) and it didn't work. Where is this defined? |
| 23:00 | asimjalis | ,(infix 1 + 2 + 3) |
| 23:00 | clojurebot | java.lang.Exception: Unable to resolve symbol: infix in this context |
| 23:01 | chouser | asimjalis: infix is defined only in the book. It's just an example, not really meant to be used. |
| 23:01 | asimjalis | ok |
| 23:02 | Licenser | hiredman: I am sitting in my bed :P |
| 23:02 | asimjalis | Okay. I just saw that. It was on the next page. |
| 23:03 | chouser | asimjalis: ah. yeah, sometimes the example usage comes before the code. |
| 23:04 | defn | Licenser: lein search is awesome! thank you! |
| 23:04 | Licenser | defn: :) thank _ato too he's done a hell lot on the clojars side to make it happen |
| 23:05 | defn | _ato: thanks much for the work on lein search -- it's a very helpful utility |
| 23:05 | Licenser | defn: it makes it more gem like I feel :P at lest there is something neat as search and add now |
| 23:20 | Licenser | well time to go to work see you alter people |
| 23:20 | Licenser | *later |
| 23:24 | asimjalis | See ya. |
| 23:25 | asimjalis | Clojure is such a dangerous addiction. I almost wish there was a kind of warning label on it. You might not be able to go back to programming as usual after this. |
| 23:25 | asimjalis | It's too late for me now. |
| 23:25 | asimjalis | Also I am half-joking (obviously). |
| 23:28 | asimjalis | Maybe this is the difference: When I am programming in Java for a while now I have resigned myself to the realization that almost all code is one-off -- it doesn't matter how it's designed it won't be reused. But with Clojure I feel like the code is always so general that I can't imagine not reusing it again. It feels a lot more valuable somehow. |
| 23:30 | glogic | asimjalis: what's usual? |
| 23:31 | glogic | asimjalis: i'm concerned i can't go back to programming unusual |
| 23:31 | SirNick | Is there anyway to setup lein so that it works something like fsc, Scala's fast compiler, so the startup for the compiler doesn't take so long? |
| 23:32 | glogic | when people ask "what's your favorite compiler implementation" i'm going to jsut start saying "Eclipse!" |
| 23:32 | glogic | feel free to replace eclipse with whatever your favorite huge code generator / editor is |
| 23:34 | glogic | IDE etc.. |
| 23:35 | asimjalis | The code bloat creates two problems: (a) it takes a lot of time to create it (b) it hides the essense of what's going on -- in Eclipse I constantly feel like I am looking for a lost child in a mall. |
| 23:36 | glogic | asimjalis: aren't you? |
| 23:36 | glogic | asimjalis: maybe, Eclipse makes you feel like you ARE the lost child in the mall |
| 23:36 | glogic | lol |
| 23:36 | asimjalis | Yes. The child is my train of thought. It's so interruptive. |
| 23:37 | albino | lost child looking for parentage? |
| 23:37 | glogic | this was pretty awesome btw: http://www.pidjin.net/2010/04/11/stop-me-if-i-can/ |
| 23:40 | asimjalis | That's funny. |
| 23:41 | glogic | asimjalis: right |
| 23:43 | asimjalis | How to I mention on my resume that I only want to work with Clojure without sounding like some kind of a moron. What's a polite way to say this? |
| 23:43 | glogic | asimjalis: say you'er a java programmer, just fail to mention you program java by way of Clojure |
| 23:44 | asimjalis | It sounds kind of fanboy-ish and immature. I've always listed the languages I've programmed in. |
| 23:44 | asimjalis | I think it is fanboy-ish and immature if it was said about any other language. But Clojure needs to be an exception. |
| 23:45 | asimjalis | I realize this is all very inconsistent. Hence my dilemma. |
| 23:46 | glogic | i think the simplest thing is to do what you've always done, but add Clojure, then in interviews it will make an interesting conversation piece, which you might be able to convince new people to also use Clojure |
| 23:46 | glogic | adding it to your list ofp rogramming languags will make you sound interesting (as lame as that sounds) |
| 23:47 | tomoj | I happened to mention clojure only to discover that my CTO loves it and had done SICP in clojure |
| 23:47 | glogic | see there you go |