2010-01-25
| 00:01 | tolstoy | what does "keep an index" mean? Adding up something for each row? (Which could be done in SQL itself, which is why I'm confused.) |
| 00:01 | somnium | nosql! |
| 00:01 | alexyk | tolstoy: it's not SQL, it's mongo! |
| 00:01 | alexyk | getlostsql! |
| 00:01 | tolstoy | Heh. |
| 00:02 | tolstoy | I guess I was thinking that you could have a fn that took a row, and a results map, and returned a new map with the row's data added in (as necessary). |
| 00:02 | tolstoy | Then just use reduce. |
| 00:02 | tolstoy | I mean, map reduce, eh? |
| 00:03 | alexyk | reduce works, but somehow I found that passing around the transient res is not much speedup |
| 00:03 | alexyk | the while works a transientr |
| 00:03 | tolstoy | Ah, so, you're past getting it work. Now you want to do the ugly optimization? :) |
| 00:04 | somnium | can just move the while condition into a when in loop-recur? |
| 00:04 | alexyk | somnium: forgot how loop looks :) |
| 00:04 | alexyk | (doc loop) |
| 00:04 | clojurebot | "([bindings & body]); Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respective init-exprs or parts therein. Acts as a recur target." |
| 00:05 | alexyk | ha -- 1.1.0 sends to RTFurl |
| 00:05 | tolstoy | That explanation is nice and clear. |
| 00:05 | alexyk | so where do we inc some i? |
| 00:06 | alexyk | in the binding? |
| 00:06 | tolstoy | (loop [i 0] ..... (recur (inc i))) |
| 00:07 | alexyk | ah ok |
| 00:07 | tolstoy | maybe (loop [cursor (init) i 0] .... (recur cursor (inc i))) |
| 00:08 | tolstoy | (let [cursor (init)] (loop [i 0} ... (recur (inc i))) ;; no idea what's better style, or faster. Heh. |
| 00:08 | somnium | the cursor mutates on its own, so no sense in passing it |
| 00:08 | alexyk | yep |
| 00:08 | tolstoy | right |
| 00:08 | somnium | maybe the JIT can handle those details |
| 00:16 | alexyk | so if loop doesn't see recur, it just falls through, as let? |
| 00:16 | somnium | yeah, no complaints from the compiler |
| 00:17 | somnium | maybe well get real TCO some day off in the future (or a clojure-in-scheme implementation) |
| 00:20 | wilig | technomancy: Mind if I try my hand at some of the tickets on swank-clojure? |
| 00:20 | hiredman | there are patches that add tailcalls to the jvm already |
| 00:22 | alexyk | how do I check that something is a number? |
| 00:22 | hiredman | (doc number?) |
| 00:22 | clojurebot | "([x]); Returns true if x is a Number" |
| 00:23 | somnium | hiredman: ooh, any jvm-download to play with? |
| 00:24 | alexyk | thx |
| 00:25 | hiredman | somnium: no, and it's not automatic tailcalls, you have to emit special bytecode so the clojure compiler would need to add support for it |
| 00:26 | hiredman | http://weblogs.java.net/blog/forax/archive/2009/12/18/tailcall-anyone |
| 00:27 | somnium | good timing for ccinc at any rate |
| 00:29 | hiredman | cinc could happen right now, it's just a matter of priorities |
| 00:31 | hiredman | it could have happened even earlier too, I think rhickey is just focused on making clojure "good" and cinc is just a subgoal |
| 00:32 | somnium | I wonder if the java regex syntax will linger once clojure is on multiple platforms |
| 00:32 | hiredman | clojure is tied to the jvm |
| 00:32 | somnium | Im mostly interested in seeing what the 'kernel' comes out looking like |
| 00:32 | hiredman | I don't that will change |
| 00:32 | hiredman | doubt |
| 00:33 | hiredman | the clr version is also "clojure" it is "clojure.NET" |
| 00:33 | hiredman | er |
| 00:33 | hiredman | the clr version is not |
| 00:33 | hiredman | bleh |
| 00:33 | somnium | Im not terribly concerned with how its called :) |
| 00:34 | somnium | more what it can do and how its different |
| 00:37 | hiredman | the point is the clr version is different |
| 00:38 | somnium | ah, so you mean clojure on the jvm is unlikely to change |
| 00:38 | hiredman | it's unlikely to change its regex support |
| 00:39 | somnium | does the clr use the same regex notation? (I have no idea what .NET regex is like) |
| 00:39 | hiredman | I think I recall seeing in an email dmiller talking about adding someway to specify stack allocation on the clr |
| 00:39 | hiredman | the jvm doesn't support that so clojure can't do that |
| 00:40 | hiredman | clojure.net can |
| 00:40 | hiredman | I don't know too much about clojure.net either |
| 00:40 | alexyk | somnium: I got the name of the option to dissoc :_id :_ns! |
| 00:40 | hiredman | infact, it may actually be called clojureCLR |
| 00:41 | somnium | ccinc should make it easier(possible) to support those kind of host-specific special forms |
| 00:41 | somnium | just a new ticket on assembla a few days ago I saw |
| 00:42 | alexyk | dismongo |
| 00:42 | somnium | alexyk: sounds like a tropical ailment |
| 00:42 | alexyk | Microsoft Clojure# 7 |
| 00:42 | somnium | :D |
| 00:43 | alexyk | now with ActiveFn(tm) |
| 00:44 | alexyk | and family license pack, up two repls on a Windows 7 locla network |
| 00:46 | hiredman | Windows Evaluator Explorer |
| 00:46 | hiredman | WEE! |
| 00:50 | somnium | what to call a scheme-to-C impl? PLTClojure is just not sexy |
| 00:50 | somnium | cleme |
| 00:50 | alexyk | clo#ure |
| 00:50 | somnium | how do you pronounce that one? |
| 00:51 | alexyk | "violate the EULA and go to jail == #" :) |
| 00:52 | somnium | I worked in at least one office that kept a a lone copy of XP locked in a storage closet |
| 00:54 | alexyk | is there a core fun to return a seq with nth element removed? |
| 01:00 | alexyk | ,(letfn [(without [s n] (concat (take n s) (drop (inc n) s)))] (without (range 10) 4)) |
| 01:00 | clojurebot | (0 1 2 3 5 6 7 8 9) |
| 01:25 | alexyk | I can manually destructure a map and convert it to a vector like below. Now what if the keys is a parameter? |
| 01:25 | alexyk | ,(let [{:keys [a b]} {:a 1 :b 2}] [a b]) |
| 01:25 | clojurebot | [1 2] |
| 01:25 | alexyk | I can say :keys myparam, but what do I stick into the body? |
| 02:10 | LauJensen | Morning team |
| 02:16 | replaca | hey lau |
| 02:54 | webben | Does anyone know what's happening with Waterfront? Did it cease development early last year? |
| 02:59 | somnium | I think the developer started using emacs |
| 03:00 | webben | ah interesting |
| 04:00 | AWizzArd | ~seen rhickey |
| 04:00 | clojurebot | rhickey was last seen quiting IRC, 287 minutes ago |
| 04:11 | esj | Morning all |
| 04:11 | esj | Nickserv is a bit feisty this am. |
| 04:14 | cgrand | esj: Morning |
| 08:25 | G0SUB | need help with enlive... |
| 08:26 | G0SUB | once I have used select to get a part of a page, can I run select on the selection again? |
| 08:26 | G0SUB | that capability will be really useful. |
| 08:38 | cemerick | G0SUB: yeah, that shouldn't be a problem |
| 08:38 | cemerick | select is just working over a tree of nodes, and returns a tree of nodes, so those operations can be composed at will |
| 08:39 | G0SUB | cemerick: well, it didn't work for me. may be I did something wrong. |
| 08:39 | G0SUB | cemerick: also, I need to use an nth-child selector. is that possible? |
| 08:40 | cemerick | G0SUB: one sec, I'll see if I can get a simple example together |
| 08:40 | G0SUB | cemerick: sure. many thanks. |
| 08:52 | cemerick | G0SUB: yeah, super-easy: (-> "http://www.penny-arcade.com/comic/" java.net.URL. html-resource (select [:div]) (select [:a]) count) |
| 08:53 | cemerick | that gives all links that are descendants of divs |
| 08:53 | G0SUB | cemerick: looking |
| 08:54 | cemerick | I've not used nth-child, but I'll assume that that will drop in however you'd expect |
| 08:54 | cemerick | e.g. to parallel how CSS works, that is |
| 08:55 | cemerick | G0SUB: yeah, changing the first select to (select [[:div (nth-child 3)]]) yields a count of matching links of 14, rather than 67 |
| 08:56 | cemerick | (not positive that's correct, but seems perfectly reasonable) |
| 08:56 | G0SUB | cemerick: the nth-child syntax is interesting |
| 08:57 | cemerick | G0SUB: interesting, as in different than the analogous css? |
| 08:58 | G0SUB | cemerick: yes. and is it documented? |
| 08:58 | cemerick | cgrand: parenthetically, why take nodes as the first argument to select? I *really* want to use ->> and drop a bunch of maps and then a reduce on the end of a series of selects. |
| 08:58 | G0SUB | cemerick: +1 |
| 08:58 | cemerick | G0SUB: here, I think: http://enlive.cgrand.net/syntax.html (linked from http://wiki.github.com/cgrand/enlive/) |
| 08:59 | G0SUB | cemerick: ah |
| 09:01 | cgrand | cemerick: G0SUB: because select predates ->> :-) |
| 09:01 | cgrand | you can always use the -> ->> combo |
| 09:01 | G0SUB | cgrand: hehe :) |
| 09:02 | cemerick | cgrand: boo! ;-) |
| 09:02 | cgrand | (-> url (select XXX) (select YYY) (->> (map foo) (reduce bar zero))) |
| 09:03 | chouser | oh. my. |
| 09:03 | chouser | Why had I never considered putting a ->> inside a -> ? |
| 09:04 | cemerick | yeah, that's a new one on me, too :-) |
| 09:04 | cemerick | cgrand: anyway, I'd +1 swapping the arg order if you're game. |
| 09:06 | cgrand | I'd like to modify -> and ->> to make the recognize each other so as to switch between thread first and thread last |
| 09:06 | cgrand | so my latest snippet would become (-> url (select XXX) (select YYY) ->> (map foo) (reduce bar zero)) |
| 09:07 | cemerick | huh |
| 09:07 | cemerick | so crazy, it just might work. |
| 09:09 | chouser | why not just have each fn (since they can hold metadata now) declare its threading arg position, then have a single universal -> |
| 09:09 | cemerick | chouser: that's not too magical? |
| 09:10 | chouser | definitely too magical. |
| 09:10 | cgrand | One of my pet peeve is that one can currently upgrades a thread-first to a thread-last using the ->> inside a -> trick. The other way is impossible. |
| 09:11 | cgrand | chouser: it may break some existing code but it's an interesting idea |
| 09:16 | chouser | I guess my postfix locals example would quit working. |
| 09:19 | jcromartie | what's the best way to make a map from a seq? |
| 09:19 | chouser | jcromartie: depends on the shape of the seq |
| 09:19 | chouser | jcromartie: ([:a 1] [:b 2])? (:a 1, :b 2)? ((:a :b) (1 2))? |
| 09:20 | jcromartie | it's a seq of hash-maps |
| 09:20 | chouser | so ({:a 1} {:b 2, :c 3}) and you want {:a 1, :b 2, :c 3}? |
| 09:20 | jcromartie | and value of one of the keys of these maps will become the key for the new hash-map |
| 09:20 | jcromartie | not quite |
| 09:21 | jcromartie | ({:a "foo", :b 2}) would become {"foo" {:b 2}} |
| 09:21 | jcromartie | I'm thinking reduce |
| 09:22 | chouser | I think I need more info. Is :a another input to this function, or else how is it treated differently from :b? |
| 09:22 | chouser | but yes, likely reduce or into |
| 09:22 | jcromartie | got it |
| 09:23 | jcromartie | (reduce (fn [x v] (assoc x (:name v) v)) {} @*venues*) |
| 09:23 | jcromartie | BTW, (doc reduce) doesn't mention it, but is there a lazy version? |
| 09:23 | chouser | can't be |
| 09:24 | jcromartie | oh? |
| 09:24 | chouser | in this case, for example, you're producing a map. Map objects aren't lazy. |
| 09:24 | jcromartie | yah |
| 09:24 | jcromartie | nevermind then :P |
| 09:24 | chouser | :-) |
| 09:24 | jcromartie | I suppose if I were producing a seq I'd be using map |
| 09:26 | chouser | this might work too: (into {} (for [v @*venues*] [(:name v) v])) |
| 09:27 | cgrand | jcromartie: shouldn't you dissoc :name too? |
| 09:27 | jcromartie | not in this case |
| 09:30 | jcromartie | actually I'm kind of torn on how to store this |
| 09:30 | G0SUB | cgrand: I am trying to scrape the Company column from http://money.rediff.com/tips/2010/01/20 |
| 09:30 | G0SUB | cgrand: code is here ... http://paste.lisp.org/display/93872 |
| 09:30 | jcromartie | I guess if order doesn't matter it's probably best to store a hash-map of ids, if I will be accessing it by id most often |
| 09:30 | G0SUB | I am not sure why I am getting all these nils |
| 09:31 | G0SUB | any advice will be appreciated. |
| 09:31 | G0SUB | I think my selectors are wrong |
| 09:31 | jcromartie | the content is displayed by JS |
| 09:31 | jcromartie | could that be why? |
| 09:31 | G0SUB | jcromartie: yes, but there is some markup. |
| 09:32 | G0SUB | jcromartie: I am getting the data, but some extra nils. that is the problem. |
| 09:33 | G0SUB | I am not sure if I am using nth-of-type correctly |
| 09:34 | chouser | jcromartie: btw, what you've got is very close to (clojure.set/index @*venues* [:name]) |
| 09:34 | jcromartie | hmm |
| 09:34 | jcromartie | interesting |
| 09:35 | jcromartie | I'll check it out, that's probably better for my case |
| 09:35 | chouser | the keys look like {:name "foo"} though, rather than just "foo" |
| 09:36 | jcromartie | hmm |
| 09:40 | cgrand | G0SUB: looking at it right now, the nil are cause by the selection of the "View" links, looking what's wrong with those selectors |
| 09:40 | G0SUB | cgrand: thanks. I am investigating too. |
| 09:44 | cgrand | G0SUB: ok, found it, let me paste it |
| 09:48 | cgrand | G0SUB: http://paste.lisp.org/display/93872#2 the problem was with (select [:td (nth-of-type 1)]) |
| 09:49 | G0SUB | cgrand: ah, I never understood the syntax properly. many thanks. |
| 09:49 | cgrand | CSS numbering starts at 1 |
| 09:49 | G0SUB | cgrand: btw, is there anyway the :a selector can be combined with the :td one? |
| 09:51 | cgrand | and in [:td (nth-of-type 1)], (nth-of-type 1) applies to a descendant of :td not to td itself, you have to wrap them in a vector to have a "and" (while the outermost selector always mean chaining) |
| 09:51 | G0SUB | cgrand: understood now. thanks a lot. |
| 09:52 | cgrand | G0SUB: just (select [[:td (nth-of-type 1)]]) to (select [[:td (nth-of-type 1)] :a]) |
| 09:53 | cgrand | (and remove the other select of course) |
| 09:53 | G0SUB | yeah |
| 09:53 | G0SUB | the issue was with the nested vector |
| 09:53 | cgrand | err I mean (select [[:td (nth-of-type 2)] :a]) with a 2 not a 1 |
| 09:54 | G0SUB | cgrand: got it :) |
| 09:56 | G0SUB | cgrand: is there an easy way to select the :content directly? something like text in xpath? |
| 09:58 | cgrand | G0SUB: sure: text for a single node or texts for a seq of nodes |
| 09:58 | G0SUB | ok |
| 09:59 | cgrand | (-> url (select XXX) texts) |
| 10:01 | G0SUB | cgrand: is texts public? |
| 10:02 | cgrand | did you get enlive from clojars? |
| 10:02 | G0SUB | yes |
| 10:04 | cgrand | oops, it is slightly out of date |
| 10:04 | G0SUB | cgrand: can you kindly push a new version? |
| 10:05 | cgrand | but texts is simply (defn texts [nodes] (map text nodes)) and you have #'text, right? |
| 10:05 | cgrand | G0SUB: not right now, I'm sorry |
| 10:06 | G0SUB | cgrand: no problem. |
| 10:06 | G0SUB | cgrand: yes, but I want to get rid of the unnecessary map |
| 10:07 | cgrand | in the mean time, use your own "texts" (pasted above) or get enlive from github |
| 10:07 | cgrand | "the unnecessary map"? |
| 10:09 | G0SUB | cgrand: the map to get the texts inline. anyway, I will write my own texts. thanks. |
| 10:12 | cemerick | nice |
| 10:12 | cemerick | stuartsierra: I've got a rough patch for duck-streams that adds a dispatch to reader for Seqable -- interested? |
| 10:15 | G0SUB | how do I do a case insensitive regex matching in Clojure? |
| 10:15 | cemerick | G0SUB: use the 'i' flag in your regex |
| 10:16 | G0SUB | cemerick: any examples? |
| 10:16 | chouser | #"(?i)foo" |
| 10:16 | G0SUB | ok |
| 10:18 | cemerick | about the only thing I miss from python's is named groups |
| 10:19 | chouser | yeah. but hardly anything has named groups |
| 10:20 | chouser | I once chose python for a project exclusively because of the named groups. They were needed for the little DSL I wanted. |
| 10:21 | jcromartie | I still can't believe that the iPhone SDK doesn't ship with any regex capabilities. |
| 10:21 | cemerick | chouser: I mean the feature where you can name capturing groups, and retrieve them by their name, rather than idx. |
| 10:22 | cemerick | stuff like the numeric regexes in the reader scream for something like that |
| 10:23 | stuartsierra | cemerick: how does it convert a Seqable to a reader? |
| 10:25 | cemerick | lisppaste8: url? |
| 10:25 | cemerick | the bot is dead :-/ |
| 10:26 | cemerick | stuartsierra: http://paste.lisp.org/display/93877 compose-paths would need to turn into a multimethod dispatching on the first arg -- the String case would reuse URL/File creation bits from the String case of reader. |
| 10:27 | chouser | cemerick: yes |
| 10:27 | chouser | cemerick: I knew exactly what you meant |
| 10:28 | cemerick | chouser: ah, I didn't grok the 'hardly anything' msg. |
| 10:28 | chouser | I mean, almost no regex engines support the named groups |
| 10:28 | cemerick | right, I get what you were saying now |
| 10:29 | cemerick | Python's is the only one I know of. |
| 10:29 | cemerick | and the regex engine I wrote :-P |
| 10:29 | chouser | the syntax is ugly, but that's hardly new for a regex feature. :-P |
| 10:29 | cgrand | chouser: cemerick: http://paste.lisp.org/display/93878 :-P |
| 10:29 | stuartsierra | cemerick: So the idea is that (reader ["foo" "bar" "baz"]) would return (BufferedReader. (FileReader. (File. "foo/bar/baz"))) ? |
| 10:30 | cemerick | stuartsierra: roughly, though File/URL would handle the canonicalization. |
| 10:31 | cemerick | cgrand: Looks nifty. Forgot contrib.core/-?> and (soon to come, hopefully) -?>> |
| 10:32 | cemerick | That's the only downside to parsing the forms, I suppose. |
| 10:32 | stuartsierra | cemerick: I dunno, that looks a bit too magical to me. |
| 10:32 | cemerick | i.e. having to be explicit about which threading forms are supported |
| 10:33 | cgrand | cemerick: unless you register them all in a *threading-forms* var |
| 10:33 | cemerick | stuartsierra: heh, fair enough |
| 10:33 | cemerick | cgrand: I think you forgot the ;-) in that one |
| 10:33 | cemerick | ;-) |
| 10:34 | chouser | hm... would these all play nicely with destructuring-> ? |
| 10:35 | cemerick | stuartsierra: I've just been accumulating seqs of file paths all over the place, and doing (-> some-seq path-norm-fn slurp*) too much. :-) |
| 10:35 | cgrand | chouser: is your patch on assembla? |
| 10:35 | stuartsierra | cemerick: doesn't c.c.java-utils/file do that? |
| 10:35 | chouser | cgrand: http://www.assembla.com/spaces/clojure/tickets/211 |
| 10:35 | chouser | I think it might "just work" |
| 10:37 | cgrand | chouser: me too |
| 10:37 | cgrand | more destructuring fun! ;-) |
| 10:39 | cgrand | chouser: btw I realized that -> and ->> could be shadowed but thankfully we have &env now |
| 10:39 | jcromartie | is it OK to throw exceptions in clojure |
| 10:39 | jcromartie | ? |
| 10:39 | cemerick | stuartsierra: didn't know about that, but file doesn't handle URLs *shrug* |
| 10:40 | jcromartie | I don't really see any special attention paid to it in the docs |
| 10:40 | alexott | is anybody know - who now maintains clojars? mail, specified at site isn't working |
| 10:41 | chouser | jcromartie: sure, throw try and catch all work |
| 10:41 | jcromartie | ah, throw is a special form, then? |
| 10:41 | chouser | yes |
| 10:41 | jcromartie | I was expecting a macro or function ("Unable to resolve symbol: throw in this context") in my search |
| 10:42 | cemerick | huh, I didn't notice as-url before though |
| 10:42 | jcromartie | fun with throw... |
| 10:42 | jcromartie | ,(throw) |
| 10:42 | clojurebot | java.lang.NullPointerException |
| 10:42 | chouser | heh. reasonable default. :-) |
| 10:42 | jcromartie | that's the worst thing in Java, hands down |
| 10:42 | chouser | ,(throw (Exception. "do not want")) |
| 10:42 | clojurebot | java.lang.Exception: do not want |
| 10:44 | jcromartie | where are the various REPL vars documented? |
| 10:46 | stuartsierra | jcromartie: dysinger maintains clojars I think |
| 10:46 | jcromartie | wrong guy, stuartsierra |
| 10:46 | jcromartie | alexott: |
| 10:46 | stuartsierra | oh |
| 10:46 | stuartsierra | right |
| 10:46 | jcromartie | *1 *2 *3 *e |
| 10:46 | jcromartie | is that it? |
| 10:49 | stuartsierra | *warn-on-reflection* |
| 10:50 | stuartsierra | *print-dup* |
| 10:53 | jcromartie | those arent' repl-specific, though |
| 10:54 | jcromartie | how long has *print-dup* been around? |
| 10:54 | jcromartie | I ran into some issues printing cycles |
| 10:55 | stuartsierra | *print-dup* has been around for a long time, not well documented |
| 10:55 | jcromartie | hmm, but I guess *print-dup* doesn't do what I think it does |
| 10:55 | stuartsierra | I don't think Clojure can print cycles. |
| 10:55 | alexott | stuartsierra: thanks, i'll write to him |
| 10:56 | stuartsierra | alexott: Oh, wait, there's someone else |
| 10:56 | stuartsierra | "_ato" I think |
| 10:56 | stuartsierra | Whoever that is. |
| 10:57 | jcromartie | ,(let [x (ref {}) y (ref {})] (dosync (alter x assoc :y y)) (dosync (alter y assoc :x x)) x) |
| 10:57 | clojurebot | #<Ref@ff78e9: {:y #<Ref@5b1cff: {:x #<Ref@ff78e9: {:y #<Ref@5b1cff: {:x #<Ref@ff78e9: {:y #<Ref@5b1cff: {:x #<Ref@ff78e9: {:y #<Ref@5b1cff: {:x #<Ref@ff78e9: {:y #<Ref@5b1cff: {:x #<Ref@ff78e9: {:y #<Ref@5b1cff: {:x #<Ref@ff78e9: {:y #<Ref@5b1cff: {:x #<Ref@ff78e9: {:y #}>}>}>}>}>}>}>}>}>}>}>}>}>}>}> |
| 10:57 | jcromartie | clojurebot: was that fun? |
| 10:57 | clojurebot | No entiendo |
| 10:57 | jcromartie | I find it interesting that it stops at some point |
| 10:57 | chouser | jcromartie: http://paste.lisp.org/display/83647 |
| 10:58 | chouser | jcromartie: the {:y #} is because of *print-level* |
| 10:58 | jcromartie | ah |
| 10:59 | jcromartie | handy |
| 11:01 | DeusExPikachu | when structuring a lib, for example, (ns foo (:use bar.core)), clojure tries to load /foo/core, instead of /foo/core.clj, any other filename except core seems to work. Is the symbol core special? |
| 11:01 | Chousuke | core should work just fine |
| 11:02 | Chousuke | many libraries use similar naming |
| 11:02 | DeusExPikachu | hmmm must be something else in my code, nm |
| 11:13 | CalJunior | I would like to create a subvector from an existing vector on multiple non-contiguous indices like so: (nth [10 12 13 14 15] '(1 3)) and return (12 14) |
| 11:13 | jcromartie | oi vey... what's a good way to find EOF-while-reading errors? |
| 11:13 | jcromartie | or rather the source of them |
| 11:15 | jcromartie | Emacs indentation! |
| 11:15 | jcromartie | huzzah! |
| 11:15 | CalJunior | I would like to create a subvector from an existing vector on multiple non-contiguous indices like so: (nth [10 12 13 14 15] '(1 3)) and return (12 14) but I get an exception. |
| 11:16 | stuartsierra | clojure-contrib master branch is now converted to Maven. |
| 11:16 | chouser | CalJunior: try 'map' instead of 'nth' |
| 11:16 | jcromartie | CalJunior: why do you think nth takes a list of indexes? |
| 11:17 | CalJunior | map, thanks |
| 11:17 | stuartsierra | I think what you want is (map #(get the-vector %) [10 12 13 14 15) |
| 11:17 | CalJunior | jcromartie: I just did. |
| 11:17 | chouser | stuartsierra: vectors are fns |
| 11:17 | chouser | :-) |
| 11:17 | chouser | ,(map [10 12 13 14 15] '(1 3)) |
| 11:17 | stuartsierra | yeah |
| 11:17 | clojurebot | (12 14) |
| 11:18 | stuartsierra | oh, yeah |
| 11:18 | stuartsierra | that looks funny, but it works |
| 11:18 | CalJunior | clojure: if it's not simple, you're not doing it right :-) |
| 11:19 | chouser | seriously. That's deliciously close to true. |
| 11:20 | DeusExPikachu | hmmm, I don't think, in swank-clojure.jar, namespace-to-path accounts for proper the possibility of needing to translate from underscore to hyphen when going from pathname to namespace |
| 11:21 | dabd | is clojure-contrib master in sync with clojure 1.1.0? |
| 11:21 | DeusExPikachu | cause I'm getting a "no namespace: foo_bar.core found", for the ns foo-bar.core defined in file /foo_bar/core.clj |
| 11:26 | stuartsierra | dabd: no, it's in sync with Clojure master |
| 11:26 | stuartsierra | dabd: there are 1.0.x and 1.1.x branches of contrib that map to corresponding versions of Clojure |
| 11:29 | dabd | is it recommended to use clojure + clojure-contrib 1.1.0 or clojure + clojure-contrib master? |
| 11:29 | DeusExPikachu | to be more precise, the call to ns-name in namespace-to-path is being fed foo_bar.core, which doesn't exists, I believe this is traced to the (.getClassName frame) in source-location-for-frame |
| 11:30 | Chousuke | hmmh |
| 11:31 | stuartsierra | dabd: depends on what you want. If you want a stable target, use 1.1.0. If you want to play with deftype/defprotocol, use master. |
| 11:33 | dabd | stuartsierra: thx |
| 11:34 | angerman | does clojrue support an easy way to merge two functions? |
| 11:34 | stuartsierra | merge how? |
| 11:34 | angerman | e.g. we have empty? now I want to extend empty? for another type. |
| 11:34 | angerman | basically a multifn |
| 11:35 | stuartsierra | angerman: that is not possible right now, but will be possible with the addition of protocols |
| 11:35 | Chousuke | you can redefine functions though, but doing that for core fns is rather evil :P |
| 11:35 | angerman | stuartsierra: ok. For now it would work if every function was a multifn dispatching on input type |
| 11:35 | stuartsierra | angerman: yes, but they aren't :) |
| 11:36 | angerman | Chousuke: yep. like using clojure core, except empty or renaming empty and wrapping it. |
| 11:36 | angerman | ok. so protocols are the way to get that |
| 11:36 | angerman | good to know |
| 11:36 | Chousuke | but (let [old-empty empty?] (alter-var-root #'empty? (constantly (fn [...] (...)))) |
| 11:36 | stuartsierra | look at my Tuple examples for how that can be done with deftype/defprotocol |
| 11:37 | jcromartie | yay for atomic file saves |
| 11:37 | angerman | Chousuke: ohh, i've never dug that deep down. |
| 11:37 | Chousuke | very evil, but possible :P |
| 11:37 | jcromartie | I want to be able to ^C my server |
| 11:37 | angerman | stuartsierra: thanks. |
| 11:37 | jcromartie | and not lose data |
| 11:37 | angerman | jcromartie: doesn't ^C just send a signal to the process? |
| 11:37 | DeusExPikachu | for swank-clojure, is inspecting and evaling in the debugger not supported? |
| 11:38 | jcromartie | yeah but if it's in the middle of something like duck-streams/spit it will leave me with a junk file |
| 11:38 | Chousuke | jcromartie: you can't do file writes atomically but renames are possible as far as I know. |
| 11:38 | jcromartie | I'm saving with a watch on a ref instead of using a database |
| 11:38 | jcromartie | yes |
| 11:38 | jcromartie | that's what I mean |
| 11:38 | angerman | jcromartie: hmm. can you not catch the ^C signal, do cleanup and exit? |
| 11:38 | jcromartie | I dunno |
| 11:39 | jcromartie | haven't tried it |
| 11:39 | jcromartie | yeah it sends a signal |
| 11:39 | jcromartie | but this is a compojure app |
| 11:39 | jcromartie | not sure how to wire that up |
| 11:40 | stuartsierra | signal-handling is OS-specific, you need classes in sun.* to do it |
| 11:41 | angerman | and then it's probably though the application server layer that's killing the servelts |
| 11:47 | replaca | angerman: ^c is sigint |
| 11:48 | angerman | replaca: ohh. thanks. I hope it sticks this time :D |
| 11:48 | replaca | sigterm is what kill sends by default. There's no keyboard version of it |
| 11:48 | angerman | and sigkill is -9? |
| 11:49 | replaca | yeah, |
| 11:50 | replaca | but you can't catch it |
| 11:51 | jcromartie | ah, yikes, apparently duck-streams can't write Date objects? |
| 11:51 | jcromartie | that's kind of critical |
| 11:52 | angerman | (.toString date-obj)? |
| 11:52 | angerman | I'm sure it can write that one |
| 11:52 | replaca | jcromartie: I think that's kind of orthogonal to duck-streams |
| 11:52 | replaca | jcromartie: duck-streams just gives you readers and writers |
| 11:53 | jcromartie | so I need to transform every Date tucked into every nook and cranny of my data and also somehow catch them on the way back in |
| 11:53 | jcromartie | sounds like fun |
| 11:53 | replaca | jcromartie: That's generally true of Java objects in Clojure :-( |
| 11:54 | hiredman | jcromartie: what do you mean duck-streams can't write Date objects? |
| 11:54 | jcromartie | so there's no Clojure-y way to use dates, I take it? |
| 11:54 | jcromartie | I mean it writes an unreadable form |
| 11:54 | replaca | we really needs to have some sort of hybrid serializer |
| 11:54 | hiredman | I don't really use ds but I believe it just provides a stream |
| 11:54 | hiredman | it's up to you to do the reading and writing |
| 11:54 | jcromartie | yeah |
| 11:54 | jcromartie | I guess I could store timestamps |
| 11:55 | replaca | jcromartie: that's right - dates are just java objects to clojure |
| 11:55 | chouser | You can add a readable print method for Dates if you want. |
| 11:55 | hiredman | objects are printed using the print-method multimethod so you can add your own dispatch to that |
| 11:55 | jcromartie | ah |
| 11:57 | replaca | chouser, hiredman: good call |
| 11:58 | angerman | jcromartie: did you look at the astraction crafting from Full Disclojure? |
| 11:58 | jcromartie | no |
| 11:59 | jcromartie | I'm reading/writing dates now though |
| 11:59 | jcromartie | (defmethod print-method java.util.Date ...) |
| 12:00 | angerman | jcromartie: well idea behind the episode is representing Date classes as Long values. |
| 12:00 | jcromartie | ah |
| 12:01 | angerman | -> http://vimeo.com/8801325 |
| 12:04 | stuartsierra | clojure-contrib 1.0.0 and 1.1.0 final releases are up! ZIPS at http://code.google.com/p/clojure-contrib/ and Maven artifacts at http://build.clojure.org/releases |
| 12:05 | chouser | yay! |
| 12:05 | chouser | stuartsierra: thank you so much for doing that. |
| 12:05 | technomancy | thanks stuart! |
| 12:06 | stuartsierra | You're welcome, all. |
| 12:06 | LauJensen | technomancy - How do I get swank-clojure to work with latest pulls of c & c-contrib ? |
| 12:08 | jcromartie | brilliant stuff angerman thanks |
| 12:09 | angerman | jcromartie: it's one of the really worthwhile screencasts, doing a great tribute to clojure |
| 12:09 | jcromartie | much better than my printing a Date constructor :P |
| 12:12 | angerman | you just hav to print (date <long-date-format>) though I think |
| 12:12 | angerman | I'm still not sure it's sufficient if you need TZ info |
| 12:12 | hiredman | #=(date long) |
| 12:13 | hiredman | #= is read time evaluation |
| 12:14 | angerman | that was supposed to be a :) smily |
| 12:21 | esj | angerman: yeah, right this very moment Sean is working on putting TZ content into this library within Incanter. |
| 12:22 | angerman | java -> file -> libsvm -> file -> java -> ... seems just not "perfect" |
| 12:25 | StartsWithK | (defn str-plus [(-> (Integer/parseInt a)) (-> (Integer/parseInt b))] (+ a b)) in the 1.2 this will work? why? |
| 12:26 | Chousuke | it will? |
| 12:26 | StartsWithK | .. without a wrong place for right paren |
| 12:26 | StartsWithK | i just looked at destructuring -> and ->> patch |
| 12:26 | Chousuke | ah, right, that. |
| 12:26 | StartsWithK | and it will apply to fn to |
| 12:26 | Chousuke | well, it's just an extension to the existing destructuring syntax |
| 12:26 | StartsWithK | hmm |
| 12:26 | StartsWithK | why? |
| 12:26 | clojurebot | http://clojure.org/rationale |
| 12:27 | Chousuke | StartsWithK: probably because it's sometimes useful to apply functions to things. |
| 12:28 | StartsWithK | (let [(-> str a) 1]) vs (let [a (str 1)]), the second one is even shorter |
| 12:28 | StartsWithK | Chousuke, in function arguments? don't we have a better place for that |
| 12:28 | StartsWithK | like function body.. |
| 12:29 | chouser | StartsWithK: that patch is not approved |
| 12:29 | Chousuke | chouser: it is in approved backlog though. |
| 12:29 | StartsWithK | yet :) |
| 12:30 | StartsWithK | i can't write any expression that would be shorter with that extension, maybe i'm not trying that hard |
| 12:30 | StartsWithK | is extra 'let' that a big of the deal for people? |
| 12:32 | Chousuke | probably not. |
| 12:32 | StartsWithK | (defn str-plus [a b] (+ (Integer/parseInt a) (+ (Integer/parseInt b)))) is shorter, (let [a (str 1)]) too |
| 12:32 | chouser | StartsWithK: it gets more interesting with more deeply-nested destructuring |
| 12:32 | StartsWithK | chouser, example? |
| 12:33 | StartsWithK | (defn str-plus-in-map [{(-> (Integer/parseInt) a) :num} {(-> (Integer/parseInt) b) :num}] (+ a b)) |
| 12:34 | StartsWithK | (defn str-plust-in-map [{a :num} {b :num}] (+ (Integer/parsInt a) (Integer/parseInt b))) |
| 12:34 | StartsWithK | still shorter, and more readable |
| 12:54 | jcromartie | man, that abstraction grafting video was great |
| 14:01 | dsop | hmm I'm new to clojure and lisp at all and I have a question. I try to do a (gen-class) so I create a (ns) and use an import but in the defn the types imported cannot be resolved |
| 14:04 | hiredman | eh? |
| 14:05 | dsop | so I'm not sure how to import a class from a java lib like foo.bar.Baz and then use just the reference Baz in the further code |
| 14:06 | technomancy | cemerick: I usually do sound effects whenever I type them |
| 14:07 | hiredman | dsop: using ns or just using import? |
| 14:07 | cemerick | dsop: (import 'foo.bar.Baz) at the repl, or (:import foo.bar.Baz) in ns |
| 14:07 | dsop | using ns |
| 14:07 | hiredman | (:import (foo.bar Baz)) |
| 14:08 | hiredman | I mean, cemerick's will work, but java being java you will want to import more classes from the package |
| 14:08 | cemerick | I'm guessing it's one step at at time in the early days :-) |
| 14:08 | dsop | hmm probably. In that case I try to access an enum from a class |
| 14:09 | dsop | :) |
| 14:09 | cemerick | that'd be Classname/ENUM_VALUE |
| 14:10 | dsop | arg |
| 14:15 | joshua-choi | Is there a standard sequence function so that (mystery [4 5 6] [2 3 4]) -> ((4 2) (5 3) (6 4))? |
| 14:15 | chouser | ,(map list [4 5 6] [2 3 4]) |
| 14:15 | clojurebot | ((4 2) (5 3) (6 4)) |
| 14:15 | joshua-choi | Ah, thanks |
| 14:16 | cemerick | dsop: no worries :-) |
| 14:18 | dsop | cemerick: so it should be http://pastebin.com/m7717b71e |
| 14:19 | cemerick | dsop: type is an inner enum? |
| 14:19 | cemerick | Centrality.Type, that is? |
| 14:19 | dsop | yes |
| 14:20 | cemerick | If so, it needs to be specified as Centrality$Type in the import (java inner classes are delineated by $ in the JVM -- javac just plasters over it for Java) |
| 14:20 | cemerick | Otherwise, that looks OK (though I certainly don't know anything about the APIs you're working with) |
| 14:21 | dsop | cemerick: works! thanks a lot |
| 14:21 | dsop | probably not the simples thing to start using closure with :) |
| 14:21 | cemerick | dsop: no problem :-D |
| 14:21 | cemerick | yeah, gen-class is definitely near the deeper end of the pool |
| 14:50 | cemerick | stuartsierra: it might be worth parameterizing the clojure version so that people can bounce back and forth using system properties if they're so inclined, and so that folks don't have to open a "scary" xml file to use a particular version *shrug* |
| 14:51 | cemerick | is there a reverse-map somewhere, or is (->> m (map reverse) (map vec) (into {})) the best there is? |
| 14:52 | stuartsierra | cemerick: yes, that's not a bad idea |
| 14:52 | stuartsierra | cemerick: clojure.set/map-invert |
| 14:52 | cemerick | I use clojure.version as the property, FWIW |
| 14:53 | cemerick | stuartsierra: thanks. Odd that it's in set. |
| 14:55 | stuartsierra | cemerick: Is there a simple way to allow people to "inject" their own clojure.jar as they would with the Ant build? |
| 14:57 | the-kenny | There's map-invert? Cool! |
| 14:57 | the-kenny | ,(use 'clojure.set) |
| 14:57 | clojurebot | nil |
| 14:57 | the-kenny | (doc map-invert) |
| 14:57 | clojurebot | "([m]); Returns the map with the vals mapped to the keys." |
| 14:57 | stuartsierra | I think you mean zipmap |
| 14:57 | cemerick | stuartsierra: I don't think so. You *might* be able to wire up a target that deployed a provided file locally, and then set the appropriate clojure.version to something unique. |
| 14:58 | the-kenny | stuartsierra: Uh, yeah. Sorry |
| 14:58 | stuartsierra | cemerick: nah, too complicated |
| 14:58 | cemerick | yeah, I agree |
| 14:59 | stuartsierra | ok, committed & pushed |
| 14:59 | cemerick | Ant is like a band-aid: one motion, right off! |
| 15:01 | LauJensen | clojurebot: ant is like a band-aid: one motion, right off! <cemerick> |
| 15:01 | clojurebot | Alles klar |
| 15:01 | cemerick | oh, good |
| 15:01 | cemerick | That's gonna end up being my epitaph now. :-P |
| 15:05 | stuartsierra | Should the clojure-contrib version string have a branch name in it, like Clojure? |
| 15:07 | chouser | what's the alternative? |
| 15:07 | chouser | alpha/beta? |
| 15:07 | the-kenny | Das teta |
| 15:07 | the-kenny | s/Das // |
| 15:08 | stuartsierra | Right now it's just "1.2.0-SNAPSHOT" |
| 15:10 | cemerick | stuartsierra: I don't think the branch names in versions have panned out very well. e.g. when new got merged into master, 1.1.0-master-SNAPSHOTs were being churned out after 1.1.0 was released, containing stuff from the new branch |
| 15:10 | stuartsierra | yeah, that was messy |
| 15:11 | stuartsierra | That was because no one updated the version numbers, though. |
| 15:11 | cemerick | insofar as what is on a branch can change, it doesn't seem like that should leak into the version |
| 15:11 | stuartsierra | The only advantage was the ability to create snapshots of different branches. |
| 15:12 | cemerick | yeah, but still; really, 1.1.0-new-SNAPSHOT probably should have been 1.2.0-SNAPSHOT from the beginning. |
| 15:12 | technomancy | branch names are valuable if there's a branch of clojure that breaks AOT-compatibility with master of the same snapshot version number |
| 15:12 | technomancy | if that happens again we should think about it |
| 15:12 | technomancy | but putting "master" in the version number seems superfluous; it should be considered the default |
| 15:12 | cemerick | technomancy: my point being, if that's about to happen, then the version numbers should diverge. |
| 15:13 | technomancy | why not put the branch in the version only for non-masters? |
| 15:13 | cemerick | that's a thought, as long as branch names never get reused |
| 15:14 | technomancy | if they get re-used within a single snapshot version then we're in trouble. =) |
| 15:15 | cemerick | sort of the opposite of what happened with 1.1.0-master-snapshot, but I'd say it's possible :-) |
| 15:17 | alexyk | I'm loading an array of triples [x y val], to be added to a graph {x {y val}}. Doing it via (assoc-in graph [x y] v) is painfully slow. How should I structure the transient to speed it up? |
| 15:17 | hiredman | vector |
| 15:18 | hiredman | (as in, "that is a vectory, not an array") |
| 15:21 | alexyk | vector, right. Should I have transient map of transient maps, or transient of regulars, or what? I have about 3 million top-level keys, with about 30 inner keys. |
| 15:24 | dsop | has someone tried yet to put clojure code into a jar file and load it dynamically to runtime? |
| 15:24 | dsop | I mean load the compile classes |
| 15:25 | dsop | it seems that I cannot convince the clojure class loader to search for the .clj file in the actual jar . the loader seems to try to load it with the system class loader |
| 15:25 | alexyk | what I think is seriously lacking is a transient multi-level map with a clear way to update a key on a path. So far it's not at all clear how to do that. |
| 15:25 | cemerick | dsop: if you have .clj files in a jar, you need to load them via RT.load -- at that point, they'll be compiled |
| 15:25 | cemerick | dsop: the jar needs to be on your classpath, regardless |
| 15:25 | chouser | alexyk: I think rhickey has a plan for that, currently called 'cells' |
| 15:26 | alexyk | chouser: super! |
| 15:26 | cemerick | ut oh, gonna tick off the constraints folks :-P |
| 15:26 | alexyk | I've killed two JVMs today with Clojure running out of swap with 64 GB RAM. Hope cells show up before my deadline of 2/2! :) |
| 15:26 | dsop | cemerick: hmm this would make the classloader code depend on clojure. with scala it works that you put the library.jar in your classpath and you then can load other scala classes dynamically |
| 15:26 | cemerick | I'd say it's time for binding* (serial-binding) |
| 15:26 | chouser | probably needs a better name |
| 15:26 | technomancy | oh, that's what cells are about. |
| 15:27 | chouser | well, that's one related feature |
| 15:27 | dsop | cemerick: so without the RT.load trick there is no way for me to load clojure compiled class files with let's say URLClassLoader |
| 15:27 | hiredman | you can drive the asm library in clojure to generate a classfile that has no dependency on clojure |
| 15:27 | cemerick | dsop: oh, you've AOT-compiled to classfiles already? |
| 15:28 | dsop | aehm |
| 15:28 | cemerick | if you've got a (:gen-class) form in your ns, and you've compiled that file so that .class files are emitted, then you can put those classfiles in a jar and access them using the name of the originating namespace (by default) |
| 15:29 | hiredman | cemerick: I imagine he is running (compile 'some.namespace), and then trying to goes his merry way using the generated class |
| 15:29 | dsop | hiredman: what other way then compile should i use? |
| 15:29 | hiredman | the problems with this are many, the most obvious being the class and the namespace have the same name |
| 15:29 | cemerick | hiredman: really? Scala doesn't do anything of the sort. |
| 15:30 | alexyk | what I'm pondering now is inserting into ConcurrentHashMap; but then I'd have to convert it to a {x {y val}} graph -- is there a way? |
| 15:30 | dsop | I use (:gen-class), (compile) and put the stuff into a jar |
| 15:30 | hiredman | cemerick: huh? |
| 15:30 | hiredman | dsop: best to be more specific about your process |
| 15:30 | hiredman | but gen-class is not for dynamic code generation |
| 15:30 | cemerick | dsop: good, so if you then add that jar to the classpath of whatever app you want to run, you can access those generated classfiles as if javac had produced them. |
| 15:32 | dsop | hiredman: I have a outdegree.clj with a gen-class. I then use (compile 'outdegree) to compile .class files from it, I put them into a jar file and try to load the outdegree.class using javas URLClassLoader which should resolve references to other .class files i nthe same jar |
| 15:32 | hiredman | dsop: the first problem you need to addess is your namespace |
| 15:32 | hiredman | ~compile |
| 15:32 | clojurebot | the unit of compilation in clojure is the namespace. namespaces are compiled (not files). to compile a namspace the namespace needs to be on the classpath and so does ./classes/ (and the directory needs to exist) because clojure writes the class files to that directory. http://clojure.org/compilation |
| 15:33 | dsop | hiredman: now in this case it aborts with FileNoutFound Cannot locate outdegree_init.class or outdegree.clj on classpath |
| 15:33 | hiredman | dsop: read from clojurebot |
| 15:34 | hiredman | are you sure you need to gen-class? |
| 15:34 | hiredman | if you don't, then don't |
| 15:34 | dsop | hiredman: yes I already did that |
| 15:34 | hiredman | dsop: nah, you obviously didn't |
| 15:34 | dsop | hiredman: yes, because I the plugin mechanism that uses the URLClassLoader doesn't know about clojure |
| 15:35 | hiredman | oh |
| 15:35 | hiredman | sorry |
| 15:35 | hiredman | wrong one |
| 15:35 | hiredman | ~namespace |
| 15:35 | clojurebot | excusez-moi |
| 15:35 | hiredman | ~namespaces |
| 15:35 | clojurebot | namespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it |
| 15:35 | hiredman | thats the one |
| 15:36 | dsop | hiredman: I use the ns name net.experimentalworks.clojure.outdegree. my file compiles to net/experimentalowrks/clojure/outdegree.class (and all other auto classes, etc) I then put this net/ dir in the jar |
| 15:36 | hiredman | ok |
| 15:37 | dsop | java loads it, it then calls colojure.lang.RT to complete the process and RT fails as it searches the standard class loader |
| 15:37 | dsop | if I don't load it dynamically but put the jar into the classpath during startup it works |
| 15:37 | hiredman | again |
| 15:37 | hiredman | please be clear about what you are doing |
| 15:38 | hiredman | you are running launching the clojure repl then running compile, then trying to load the class file from a jar using a urlclassloader, all from the same repl session? |
| 15:39 | hiredman | dsop: sure, as I said earlier, gen-class is not for dynamic code generation |
| 15:39 | dsop | hiredman: no I have a outdegree.clj with a gen-class in it. I run compile from the REPL. then I close the repl session put the generated class files into a jar file (http://pastebin.com/d2eb94aa) Then I load the .jar file from a java application using URLClassLoader. |
| 15:40 | hiredman | dsop: ah |
| 15:40 | dsop | and then I try to instantiate net.experimentalworks.clojure.outdegree |
| 15:40 | cemerick | oh |
| 15:40 | cemerick | dsop: you need clojure on the classpath as well |
| 15:40 | hiredman | and you have clojure.jar on the classpath for the java app? |
| 15:40 | dsop | everything works unti lthe actual initialization. Also the Class<?> file is returned and loaded correctly |
| 15:40 | dsop | yes I have clojure in the classpath |
| 15:41 | hiredman | dsop: where is the exception? |
| 15:41 | hiredman | like, did you pastebin it somewhere? |
| 15:41 | dsop | one moment |
| 15:43 | StartsWithK | ,(-> 1) |
| 15:43 | clojurebot | 1 |
| 15:43 | StartsWithK | ,(->> 1) |
| 15:43 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args passed to: core$--GT--GT- |
| 15:44 | StartsWithK | shouldn't (->> 1) also return 1 |
| 15:44 | dsop | hiredman: cemerick http://pastebin.com/d242dbc4f |
| 15:44 | hiredman | dsop: looks like a classloader issue |
| 15:45 | dsop | hiredman: for me it looks that clojure always searches for the acutal _files_ in the system classloader |
| 15:45 | dsop | and the system class loader doesn't know about the jar at all |
| 15:45 | hiredman | dsop: well, presumably you have clojure.jar loaded with the system loader |
| 15:45 | dsop | yes for sure, otherwise .RT wouldn't be found |
| 15:46 | hiredman | I think the issue is clojure.jar and your jar have different classloader roots |
| 15:46 | hiredman | so they can't interact with each other |
| 15:46 | dsop | yes for sure they have |
| 15:46 | dsop | the clojure.jar is loaded by the system loader |
| 15:46 | dsop | but that brings me to an idea |
| 15:46 | cemerick | hiredman: but net.experimentalworks.clojure.outdegree is being loaded just fine, just not __init -- seems like all the generated classfiles aren't making it into the jar |
| 15:46 | dsop | hiredman: thanks so far for the help |
| 15:46 | cemerick | dsop: ^^ meant for you |
| 15:47 | hiredman | cemerick: yeah, the init stuff fails to load because it tries to talk to clojure |
| 15:47 | dsop | cemerick: yes but the __init file is in the jar |
| 15:47 | hiredman | and it's classloader doesn't know clojure |
| 15:47 | hiredman | or something |
| 15:47 | dsop | it's because the RT earches for the __init file |
| 15:47 | dsop | hiredman: yes I guess so too, thanks for the help |
| 15:48 | cemerick | hiredman: if that were true, then it should fail in net.experimentalworks.clojure.outdegree.<clinit> trying to get access to Var/RT |
| 15:48 | dsop | I proberbly do nasty stuff here :) |
| 15:48 | hiredman | cemerick: right |
| 15:48 | hiredman | new theory |
| 15:48 | dsop | cemerick: the point is the urlclasloader can access the system class loader so it can load RT |
| 15:48 | hiredman | it's the check to see if the class file or the clj file is newer |
| 15:48 | dsop | but the RT doesn't know the urlclassloader |
| 15:48 | cemerick | dsop: you're running in Jetty, so you're a long way away from the system classloader |
| 15:49 | dsop | cemerick: true :) |
| 15:49 | cemerick | dsop: how are you providing your classpath to jetty? |
| 15:49 | dsop | cemerick: default classpaths in the WEB-INF/ directory, which is handled by gwt stuff |
| 15:49 | hiredman | RT's load stuff checks to see if the *.clj or the *.class is newer and loads the newest one |
| 15:50 | hiredman | so that might be the actual point of failure |
| 15:50 | hiredman | which is more promising |
| 15:50 | cemerick | dsop: and you have clojure.jar and your jar in WEB-INF/lib? |
| 15:50 | hiredman | (easier to deal with. maybe.) |
| 15:51 | dsop | cemerick: no I have clojure.jar in my WEB-INF/lib, but my jar is loaded dynamically from somewhere. It shouldn't be in the systems/jetty classpath |
| 15:51 | cemerick | well, there we go |
| 15:51 | cemerick | dsop: why? |
| 15:52 | dsop | cemerick: because you should put jars somewhere, reload the servlet and be able to load new jars without touching the .war file |
| 15:52 | dsop | cemerick: somekind of 'plugin system' |
| 15:52 | dsop | they basically just contain algorithms that should be loaded to runtime |
| 15:52 | cemerick | dsop: what is this "plugin system"? |
| 15:53 | dsop | cemerick: it's bascially just searching for jars in a directory and initializing a given class out of it, during runtime |
| 15:53 | cemerick | dsop: this is something you wrote? |
| 15:53 | hiredman | http://github.com/hiredman/clojure/blob/master/src/jvm/clojure/lang/RT.java#L402 <-- this is the exception you are seeing |
| 15:53 | hiredman | er |
| 15:54 | hiredman | http://github.com/richhickey/clojure/blob/master/src/jvm/clojure/lang/RT.java#L409 <-- this one |
| 15:55 | dsop | cemerick: yes. |
| 15:55 | dsop | hiredman: yes this is it |
| 15:55 | dsop | cemerick: I'm not saying it's perfec,t but it works for java and scala stuff so far |
| 15:56 | cemerick | dsop: then, in general, you've got a bug or design flaw in how you're integrating with your parent (jetty's) classloader |
| 16:20 | defn | ,(:macro (meta #'and)) |
| 16:20 | clojurebot | true |
| 16:21 | dnolen | *** You have joined channel #clojure [15:55] |
| 16:21 | dnolen | *** Topic for #clojure: Clojure, the Lisp that makes the JVM dynamic. See |
| 16:21 | dnolen | http://clojure.org or video at http://clojure.blip.tv . |
| 16:21 | dnolen | *** #clojure: topic set by jcowan, 17:18:57 2008/03/07 |
| 16:21 | dnolen | *** Users on #clojure: dnolen rfgpfeiffer fedito dnolen-rec dabd` mccraig |
| 16:21 | dnolen | mudphone mikehinchey LeNsTR slyrus grosours jcromartie dysinger |
| 16:21 | dnolen | perspectival ynniv jkkramer krumholt__ ior3k Raz_ dsop heow choas somnium |
| 16:21 | dnolen | mrsolo hipertracker Hali_303 caljunior Kyrus duncanm opqdonut boyd replaca |
| 16:21 | defn | uh oh' |
| 16:21 | dnolen | Ash rdd dnm_ jasapp_ spariev_ the-kenny Guest19765 Hun ghotli ntoll |
| 16:21 | cemerick | ah crap, not this again |
| 16:21 | dnolen | lghtng_away _mst kjalarr hiredman mariorz gregh rsynnott Leonidas shachaf |
| 16:21 | dnolen | erg morty rys aking rowth hobbsc lisppaste8 |
| 16:21 | defn | this could be very bad |
| 16:21 | dnolen | *** Users on #clojure: headlessClown cpfr AWizzArd murbank mrSpec fmu jjames |
| 16:21 | cemerick | dnolen: dude, you've been owned |
| 16:21 | dnolen | shmichael jpulakka tomaw__ webben hoeck durka42 Strika rberger cburroughs |
| 16:21 | dnolen | wtetzner Raynes mtm Modius corruptmemory lopex walters probablyCorey hone_ |
| 16:21 | dnolen | Knekk_ seangrove jbomo hipertracker-off danlarkin Chousuke therealadam |
| 16:21 | dnolen | morphling DeusExPikachu mabes dbx triddell romanb LauJensen StartsWithK |
| 16:21 | jcromartie | what the heck is that |
| 16:21 | dnolen | enebo stuartsierra wilig wlr Bjering_ froog_ st_ onion_ liebke ivan |
| 16:21 | defn | methinks someone doesn't know how to use emacs |
| 16:21 | jcromartie | I don't like it |
| 16:21 | dnolen | ivan_chernetsky fogus G0SUB |
| 16:21 | dnolen | *** Users on #clojure: jamie_alm jweiss jfkw_ cemerick blubber-- shrughes |
| 16:21 | dnolen | geramuk l_a_m technomancy|away cgrand OlegYch|h__ fractalis dalkvist defn |
| 16:21 | dnolen | janm zakwilson scottj ndimiduk Licenser pavelludiq lhitchon mrmargolis pdk |
| 16:21 | dnolen | tomoj npm hyp3rvigi1ant andreaja polypus eno sattvik esj datka hdurer |
| 16:21 | hiredman | no ops here (ever) either |
| 16:21 | dnolen | xandrews Holcxjo KarlThePagan2 Fingerzam Luyt Draggor redinger ttmrichter |
| 16:22 | dnolen | dmiller2718 fivebats chouser j0ni arbscht ambroff jonafan smyge thickey |
| 16:22 | dnolen | angerman jedediah bobo_ skeptomai|away |
| 16:22 | dnolen | *** Users on #clojure: scode frodwith jarpiain rotty turbo24prg lenbust |
| 16:22 | dnolen | syntaxman strlen dthomas peddie broquaint ocher noidi Apage43 dmiles_afk |
| 16:22 | jcromartie | who can kick him? |
| 16:22 | dnolen | bitbckt metric cp2 shr3kst3r drewr nareshov marten shawn_ nuba Aisling |
| 16:22 | jonafan | wat |
| 16:22 | jcromartie | anybody? |
| 16:22 | hiredman | no one |
| 16:22 | dnolen | raek yason danm__ Drakeson clojurebot piccolino abrooks brixen srcerer |
| 16:22 | jcromartie | fun |
| 16:22 | dnolen | ts00000 gbj`` albino hchbaw bhall unfo- cypher23 haptiK TheBusby felipe` |
| 16:22 | dnolen | clows gravity mtd joewilliams codemonkeyx mfoemmel _alex _BLINDWHITECRABS |
| 16:22 | technomancy | there's always /ignore, fellas |
| 16:22 | defn | sigh |
| 16:22 | dnolen | fgtech Intensity leafw s450r1 eivindu |
| 16:22 | dnolen | *** Users on #clojure: mikem nullman` sjbach @ChanServ |
| 16:22 | nuba | wth? |
| 16:22 | dnolen | <dsop> hiredman: yes this is it |
| 16:22 | dnolen | *** #clojure modes: +tncR |
| 16:22 | dnolen | *** #clojure was created on Tuesday 2007/12/11 17:04:26 |
| 16:22 | defn | he's almost done |
| 16:22 | dnolen | <dsop> cemerick: I'm not saying it's perfec,t but it works for java and scala |
| 16:22 | dnolen | stuff so far |
| 16:22 | dnolen | <cemerick> dsop: then, in general, you've got a bug or design flaw in how |
| 16:22 | dnolen | you're integrating with your parent (jetty's) classloader [15:56] |
| 16:22 | defn | nevermind |
| 16:22 | dnolen | *** seangrove (n=user@c-67-188-3-10.hsd1.ca.comcast.net) has quit: Remote |
| 16:22 | dnolen | closed the connection |
| 16:22 | dnolen | *** seangrove (n=user@c-67-188-3-10.hsd1.ca.comcast.net) has joined channel |
| 16:23 | Draggor | copy paste fail? |
| 16:23 | dnolen | #clojure [15:57] |
| 16:23 | dnolen | *** kotarak (n=mb@ip-81-210-163-176.unitymediagroup.de) has joined channel |
| 16:23 | dnolen | #clojure [15:58] |
| 16:23 | dnolen | *** technomancy (n=user@71-23-19-98.war.clearwire-wmx.net) has joined channel |
| 16:23 | dnolen | #clojure |
| 16:23 | dnolen | *** dabd` (n=user@wifi.ist.utl.pt) has quit: Read error: 113 (No route to |
| 16:23 | dnolen | host) [16:02] |
| 16:23 | dnolen | *** nathanmarz (n=marz@204.14.159.167) has joined channel #clojure [16:03] |
| 16:23 | dnolen | *** ikaros (n=ikaros@f051195105.adsl.alicedsl.de) has joined channel #clojure |
| 16:23 | defn | dnolen: you're ignored. sorry dude, but if you accidentally copy/pasted, you need to just quit your client so we don't have to read this garbage |
| 16:23 | dnolen | [16:04] |
| 16:23 | dnolen | *** _bob (n=bgr@dc5146e16c.adsl.wanadoo.nl) has joined channel #clojure [16:06] |
| 16:23 | dnolen | |
| 16:23 | defn | anywho -- what's up all? |
| 16:23 | datka | You can only sit back in abject horror as you're powerless to stop yourself |
| 16:23 | LeNsTR | dnolen: u'r idiot -_- |
| 16:23 | defn | datka: lol |
| 16:23 | ivan | no, you can close the connection |
| 16:24 | somnium | M-x butterfly gone horribly wrong? |
| 16:24 | kotarak | LeNsTR: watch your language. |
| 16:24 | LeNsTR | sorry |
| 16:24 | defn | wtf is butterfly? |
| 16:24 | Draggor | kill -9 is a beutiful thing |
| 16:24 | defn | I just see "Amazing physics going on..." |
| 16:25 | the-kenny | M-x butterfly is a parody to xkcd :) |
| 16:25 | kotarak | defn: http://xkcd.com/378/ |
| 16:25 | datka | That comic always bothered me because you wouldn't have a shortcut like that |
| 16:26 | Draggor | I should give vimclojure a shot again, unless there's something better |
| 16:26 | kotarak | Draggor: what is the problem with vimclojure? |
| 16:26 | defn | kotarak: :D |
| 16:26 | defn | Draggor: it's called Emacs |
| 16:26 | defn | ;) |
| 16:26 | Draggor | defn: I like my pinky finger too much to use emacs ;) |
| 16:27 | kotarak | Draggor: take your chance to tell the author how to imrpove it. |
| 16:27 | defn | Draggor: just make caps lock your control key and use your ring, sweet heart :) |
| 16:27 | Draggor | kotarak: Last time I attempted I just never got it working, though at the time my install was.. borked, so I should try again. |
| 16:27 | Draggor | defn: Ultimately, I am way too attached to my different modes (visual/command/edit/etc) |
| 16:28 | kotarak | Draggor: let me know, when you have a specific problem. |
| 16:28 | Draggor | defn: And no mod in emacs ever worked to my satisfaction |
| 16:28 | defn | nod -- it's okay, i just recommend emacs to people using clojure |
| 16:28 | defn | paredit + clojure mode + swank === win |
| 16:28 | Draggor | defn: I used it when I was at a lisp programming job for about a year, so I got ot know emacs well |
| 16:29 | defn | okay before this gets any further -- let's stop the editor wars |
| 16:29 | defn | ive had this discussion in here like 30-40 times i think so far heh |
| 16:29 | StartsWithK | kotarak, ant build.xml plz :) |
| 16:34 | defn | i do not "get" enlive at all |
| 16:35 | kotarak | StartsWithK: hmmm... not sure |
| 16:36 | cemerick | defn: let me know if you have any Q's. I'm no expert, but I'm enjoying enlive a *lot*. |
| 16:36 | defn | cemerick: ill have a couple in a minute here, im just getting the skeleton of this project to stand up |
| 16:37 | Draggor | kotarak: if I want to use compojure, do I swap the clojure.jar with the compojure.jar? |
| 16:37 | defn | and then i have a question im sure you can help me with that has been baffling me :\ |
| 16:37 | jcromartie | mmmm enlive |
| 16:37 | jcromartie | I'm using compojure too |
| 16:37 | cemerick | yeah, I was going to say... |
| 16:37 | kotarak | Draggor: dunno. Does compojure include clojure? Otherwise you need both. |
| 16:37 | cemerick | defn: there's a #compojure channel over there ----> |
| 16:38 | cemerick | no, compojure is just another clojure lib |
| 16:39 | Draggor | enlive looks purdy |
| 16:39 | defn | i dont understand how to get from tagsoup-ified output to actual HTML |
| 16:39 | kotarak | defn: with deftemplate |
| 16:40 | defn | that's weird to me -- why do i need a template if i dont want to transform the tagsoup at all |
| 16:40 | defn | im just trying to scrape a website, i dont care to transform it in the slightest |
| 16:40 | cemerick | defn: then just use html-resource and select |
| 16:41 | cemerick | defn: have you seen http://wiki.github.com/cgrand/enlive/ ? |
| 16:41 | kotarak | Draggor: what does purdy mean? |
| 16:42 | jcromartie | enlive_html.clj |
| 16:42 | jcromartie | it holds all of the secrets |
| 16:42 | jcromartie | deftemplate is a very simple macro |
| 16:42 | jcromartie | it's built on the template macro |
| 16:42 | Draggor | kotarak: usefull and the code looks nice (poor internet spelling of pretty) |
| 16:43 | Draggor | I think it's also a southern united states pronunciation of pretty as well. |
| 16:43 | jcromartie | it's a hillbilly/low-class accent |
| 16:43 | jcromartie | defn: you want emit* |
| 16:46 | defn | jcromartie: emit* gives me the "</" "a" ">" type output |
| 16:47 | defn | should i just apply str |
| 16:47 | jcromartie | yes |
| 16:47 | defn | ahhhh, here we go |
| 16:47 | defn | thanks jcromartie |
| 16:48 | defn | im building a scraper for the #clojure html irc logs |
| 16:48 | jcromartie | can you get the raw logs? |
| 16:48 | jcromartie | because that would be much easier |
| 16:48 | defn | you're telling me :) |
| 16:49 | defn | i dont believe there are raw logs but maybe... |
| 16:50 | defn | what i was really interested in is making a sort of extension of contrib.repl-utils |
| 16:50 | hiredman | my #clojure.log is 49 megs, but the formating is atrocious |
| 16:50 | defn | that would let you peek at mentions in irc of keywords etc. |
| 16:51 | hiredman | it changes through out the file to, as I switch irssi themes |
| 16:51 | defn | nod |
| 16:51 | defn | my logs are terrible as well |
| 16:51 | defn | and far from complete |
| 16:54 | defn | how would i removed an <a....> node with enlive |
| 16:55 | cemerick | defn: transform with [:a] (substitute nil) IIRC |
| 17:01 | defn | cemerick: could you give me an example? |
| 17:02 | defn | I see what you're saying but I'm not sure how to write it: (transform page-of-nodes (substitute [:a] nil)) |
| 17:02 | defn | something like that? |
| 17:02 | defn | i get nth not supported on this type |
| 17:03 | cemerick | defn: I've only ever used transformations in the context of deftemplate, so I'm not clear on the exact fns that you need to use for 'bare' replacement. But, this *might* help http://groups.google.com/group/enlive-clj/browse_frm/thread/b309171ebcc253b5 |
| 17:10 | cgrand | cemerick: nil is shorthand for (substitute nil) so you can do [:a] (when-let [url (:url data)] (set-attr :href url)) for example |
| 17:16 | cgrand | defn: (flatmap (transformation [:a] nil) nodes) |
| 17:17 | defn | cgrand: cool, exactr |
| 17:17 | defn | exactly what i was looking for |
| 17:17 | defn | thanks |
| 17:18 | dnolen | *** You have joined channel #clojure [15:55] |
| 17:18 | dnolen | *** Topic for #clojure: Clojure, the Lisp that makes the JVM dynamic. See |
| 17:18 | dnolen | http://clojure.org or video at http://clojure.blip.tv . |
| 17:18 | dnolen | *** #clojure: topic set by jcowan, 17:18:57 2008/03/07 |
| 17:18 | dnolen | *** Users on #clojure: dnolen rfgpfeiffer fedito dnolen-rec dabd` mccraig |
| 17:18 | dnolen | mudphone mikehinchey LeNsTR slyrus grosours jcromartie dysinger |
| 17:18 | dnolen | perspectival ynniv jkkramer krumholt__ ior3k Raz_ dsop heow choas somnium |
| 17:18 | dnolen | mrsolo hipertracker Hali_303 caljunior Kyrus duncanm opqdonut boyd replaca |
| 17:18 | dnolen | Ash rdd dnm_ jasapp_ spariev_ the-kenny Guest19765 Hun ghotli ntoll |
| 17:18 | LeNsTR | oh |
| 17:18 | dnolen | lghtng_away _mst kjalarr hiredman mariorz gregh rsynnott Leonidas shachaf |
| 17:18 | dnolen | erg morty rys aking rowth hobbsc lisppaste8 |
| 17:18 | dnolen | *** Users on #clojure: headlessClown cpfr AWizzArd murbank mrSpec fmu jjames |
| 17:18 | dnolen | shmichael jpulakka tomaw__ webben hoeck durka42 Strika rberger cburroughs |
| 17:18 | dnolen | wtetzner Raynes mtm Modius corruptmemory lopex walters probablyCorey hone_ |
| 17:18 | dnolen | Knekk_ seangrove jbomo hipertracker-off danlarkin Chousuke therealadam |
| 17:18 | dnolen | morphling DeusExPikachu mabes dbx triddell romanb LauJensen StartsWithK |
| 17:18 | dnolen | enebo stuartsierra wilig wlr Bjering_ froog_ st_ onion_ liebke ivan |
| 17:18 | dnolen | ivan_chernetsky fogus G0SUB |
| 17:18 | dnolen | *** Users on #clojure: jamie_alm jweiss jfkw_ cemerick blubber-- shrughes |
| 17:18 | dnolen | geramuk l_a_m technomancy|away cgrand OlegYch|h__ fractalis dalkvist defn |
| 17:18 | dnolen | janm zakwilson scottj ndimiduk Licenser pavelludiq lhitchon mrmargolis pdk |
| 17:18 | dnolen | tomoj npm hyp3rvigi1ant andreaja polypus eno sattvik esj datka hdurer |
| 17:18 | dnolen | xandrews Holcxjo KarlThePagan2 Fingerzam Luyt Draggor redinger ttmrichter |
| 17:19 | dnolen | dmiller2718 fivebats chouser j0ni arbscht ambroff jonafan smyge thickey |
| 17:19 | dnolen | angerman jedediah bobo_ skeptomai|away |
| 17:19 | dnolen | *** Users on #clojure: scode frodwith jarpiain rotty turbo24prg lenbust |
| 17:19 | jonafan | FUCK YOU. |
| 17:19 | dnolen | syntaxman strlen dthomas peddie broquaint ocher noidi Apage43 dmiles_afk |
| 17:19 | dnolen | bitbckt metric cp2 shr3kst3r drewr nareshov marten shawn_ nuba Aisling |
| 17:19 | Draggor | and the fail begins again |
| 17:19 | cpfr | oh come on |
| 17:19 | dnolen | raek yason danm__ Drakeson clojurebot piccolino abrooks brixen srcerer |
| 17:19 | dnolen | ts00000 gbj`` albino hchbaw bhall unfo- cypher23 haptiK TheBusby felipe` |
| 17:19 | dnolen | clows gravity mtd joewilliams codemonkeyx mfoemmel _alex _BLINDWHITECRABS |
| 17:19 | LeNsTR | need bot |
| 17:19 | hipertracker | jonafan: use /ignore dnolen |
| 17:19 | hiredman | I still have him on ignore |
| 17:19 | defn | same here |
| 17:19 | Raynes | What the hell? |
| 17:19 | Raynes | O_o |
| 17:19 | hipertracker | fucking bot |
| 17:20 | chouser | please watch your language, guys. |
| 17:20 | chouser | likely an honest mistake |
| 17:20 | hiredman | he's not a bot |
| 17:20 | scode | Probably just an accidental cut'n'paste. |
| 17:20 | Hun | twice? |
| 17:22 | dnolen_ | wowzers apologies |
| 17:22 | dnolen_ | emacs erc foobar |
| 17:22 | defn | dnolen_: i will unignore |
| 17:22 | dnolen_ | thx |
| 17:24 | jonafan | sorry, my circuits overloaded and i dropped an fbomb exception |
| 17:25 | defn | dnolen_: just FWIW, if you accidentally do that, just close your client -- on your end it looks like you pasted the whole thing, but on our ends it slowly scrolls one line..waits a second or two, posts the next line, etc. |
| 17:25 | defn | if you just cut your client you'll avoid (some of) the rage |
| 17:26 | dnolen_ | defn: yeah, I didn't realize what was going initially, and thought I'd closed the client but hadn't really |
| 17:26 | defn | nod -- no worries |
| 17:27 | chouser | in the end, not as bad as most editor discussions. |
| 17:27 | kotarak | :) |
| 17:27 | defn | lol chouser |
| 17:28 | the-kenny | chouser: You're right |
| 17:28 | chouser | if for no other reason than that I have a hard time ignoring editor discussions. :-/ |
| 17:48 | krumholt | did somebody just say "editor discussion"? :) |
| 17:48 | dnolen | funny enough that whole fiasco was caused by my newb handling of emacs the OS :) |
| 17:50 | Draggor | b'dum tish |
| 17:57 | zakwilson | So I need to write a custom smtp server. It's nothing too special; it just needs to have some hooks in to the mail delivery process. Any suggestions for libraries that do most of the work for me? |
| 18:02 | mabes | for some reason I can't get a request body from compojure: http://gist.github.com/286367 Any ideas on what I am doing wrong? |
| 18:04 | hiredman | don't you have to do -X PUT for curl? |
| 18:08 | mabes | hiredman: yeah, it looks like the data is coming across as form-params otherwise.. so the problem must be the curl command. I misunderstood the --data flag in the man pages.. Rereading the man page now.. |
| 18:23 | erikprice | How do I put a call to recur in the tail position if I only want the recursion to happen under certain conditions? Making my (recur) call one of the expressions of an (if) is invalid. |
| 18:23 | erikprice | (Sorry if that message is a repeat; I wasn't registered with the nickserv the first time.) |
| 18:24 | joshcheek | Hi, wanting to use Clojure for my AI course, but I can't figure out how to have it evaluate a file, all the instructions I've seen deal with the REPL. Can anyone link me to instructions for setting it up so I can just type "cloj my_file.clj" and have it execute? |
| 18:24 | dnolen | erikprice: making recur a position in if is not necessarily the problem. |
| 18:25 | erikprice | ah. In my case, I'm attempting to call recur in an 'if' at the end of an anonymous function. Is this incorrect usage of recur? |
| 18:25 | hiredman | ~dead simple setup |
| 18:25 | clojurebot | simple setup is http://www.thelastcitadel.com/dirt-simple-clojure |
| 18:25 | hiredman | the last line there |
| 18:25 | hiredman | if you tack the filename on the end of it, it will do what you want |
| 18:25 | dnolen | erikprice: can you paste the code? |
| 18:25 | joshcheek | thank you, hiredman and bot |
| 18:25 | erikprice | sure which pastebin do we use here |
| 18:25 | hiredman | erikprice: a function can have more that one tail |
| 18:26 | hiredman | each branch of an if is a tail |
| 18:26 | dnolen | doesn't matter really I like gist but people here tend to use http://paste.lisp.org/ |
| 18:27 | hiredman | lisppaste8: url? |
| 18:27 | erikprice | http://paste.lisp.org/+20GO |
| 18:28 | hiredman | that recur is not in the tail position |
| 18:28 | hiredman | I don't see what you are trying to do |
| 18:29 | hiredman | at all |
| 18:29 | erikprice | that is wrong |
| 18:29 | erikprice | apparently I made a typo. |
| 18:30 | hiredman | you have a function, that when called creates a function, and calls that function immediatly, which returns [] |
| 18:30 | hiredman | that is not going into the issue with recur |
| 18:30 | erikprice | after fixing my typo, I no longer get the compiler error about misusing recur - the function compiles. Pardon my boneheadedness. |
| 18:30 | hiredman | easier just to do (defn sift [s] []) |
| 18:31 | erikprice | This is the fixed version, FWIW: http://paste.lisp.org/+20GO/1 |
| 18:31 | erikprice | s/fixed version/version without typos/ |
| 18:32 | hiredman | is there a reason you use a fn like that instead of using loop/recur or reduce? |
| 18:32 | defn | I can remove all 'a' tags by doing (flatmap (transformation [:a] nil) my-resource) |
| 18:32 | defn | how would I remove all <a name...> tags? |
| 18:33 | defn | [:a {:name #"*"}]? |
| 18:33 | erikprice | @hiredman I tried using a reduce but I wasn't clever enough to figure out how to do it that way. I'm working on this exercise: http://fulldisclojure.blogspot.com/2010/01/code-kata-data-sifter.html |
| 18:34 | erikprice | My implementation doesn't work yet but at least I'm not getting the compiler error anymore. I'll have to revisit it. |
| 18:34 | erikprice | Thanks again. |
| 18:37 | hiredman | reduce can do fairly abitrarily complex things |
| 18:37 | hiredman | ar |
| 18:38 | hiredman | you would need use a vector and call seq or apply list at the end |
| 18:39 | hiredman | "After that, add the ability to take a vector/array as an input" is kind of ridiculous |
| 18:40 | hiredman | I mean, it's all seqable, so making it a big deal is dumb |
| 18:40 | defn | anyone know how to refer (in enlive) to <a name=...>? like [:a {:name}] seems like it would work but doesn't |
| 18:40 | hiredman | reduce will, out of the box, work on all of those types |
| 18:40 | hiredman | defn: well the reader would barf on that anyway |
| 18:40 | defn | yeah arrindexoutofbounds |
| 18:41 | hiredman | I would try {:name nil} but I don't know anything about enlive |
| 18:41 | defn | good idea |
| 18:41 | dnolen | defn : http://enlive.cgrand.net/syntax.html |
| 18:41 | defn | dnolen: thanks |
| 18:44 | defn | bah i still cannot figure this out -- what is wrong with me today |
| 18:45 | defn | (flatmap (transformation [:a] nil) my-tag-soup) works |
| 18:45 | defn | the tag-soup data looks like: ({:tag :p, :attrs nil, :content [{:tag :a, :attrs {:name "20:46"}, :content ["20:46"]}... |
| 18:45 | hiredman | sure |
| 18:46 | hiredman | that is how clojure.xml represents xml |
| 18:46 | defn | so what is [:a], really? {:tag :a}? |
| 18:46 | hiredman | what? |
| 18:46 | clojurebot | what is wrong with you |
| 18:46 | dnolen | defn: are you using enlive or no? |
| 18:46 | hiredman | clojurebot: thanks! |
| 18:46 | clojurebot | I don't understand. |
| 18:46 | defn | dnolen: correct |
| 18:47 | defn | hiredman: earlier I used transformation [:a] -- how does enlive see that? as {:tag :a}, no? |
| 18:47 | dnolen | defn: what is transformation? that's not an enlive function. something of your own? |
| 18:48 | defn | it is an enlive macro |
| 18:48 | defn | net.cgrand.enlive-html/transformation |
| 18:48 | defn | ([] [form] [form & forms]) |
| 18:49 | dnolen | defn: are you just trying to select some node are you trying to create some kind of custom transformation for your own use? |
| 18:49 | defn | i select some nodes.. I select [:div#main :p] |
| 18:50 | defn | the nodes it gives me back contain <a hrefs> and <a names> |
| 18:50 | defn | i want to remove all of the <a name> stuff |
| 18:51 | dnolen | defn: enlive has 'but' |
| 18:51 | dnolen | it's not a real css selector but it let's exclude nodes |
| 18:52 | defn | dnolen: the question still stands though -- how do i represent <a name> |
| 18:54 | dnolen | defn: looking to see if I have an example. |
| 18:56 | dnolen | [:a (attr? :name)] |
| 18:56 | dnolen | i think |
| 18:56 | dnolen | there's also the enlive ML if that doesn't work |
| 18:57 | defn | dnolen: I tried that earlier I think and didn't have any luck, but let me try again |
| 18:58 | defn | yeah it doesn't match |
| 18:58 | dnolen | what is the whole selector you are trying to use? |
| 18:59 | defn | (flatmap (transformation [:a (attr? :name)] nil) (select resource [:div#main :p])) |
| 18:59 | defn | that's the whole thing |
| 19:02 | dnolen | defn: did you try (select resource [:div#main :p (but [:a (attr? name)])]) ? |
| 19:02 | alexyk | so, with transient, if I declare one outside a loop as (let [res (transient {})] ... (loop ... (assoc! res x y)), I don't need to reassign (let [res (assoc! res ...)] ...) anymore, assoc! works on the existing, dirty, mutable, in-scope res, right? |
| 19:03 | dnolen | defn: oh I see |
| 19:03 | dnolen | defn: you want all children of those paragraphs just no links with names? |
| 19:04 | defn | yes |
| 19:04 | dnolen | more like this then, [:div#main :p :* (but [:a (attr? name)])] |
| 19:04 | defn | heh, the first version got me closer |
| 19:04 | dnolen | oops cause of typo |
| 19:04 | dnolen | more like this then, [:div#main :p :* (but [:a (attr? :name)])] |
| 19:05 | dnolen | :name instead of name |
| 19:05 | defn | yeah i had that |
| 19:05 | defn | hmmmmmm |
| 19:06 | defn | well this worked, but it's definitely not pretty: |
| 19:07 | defn | (flatmap (transformation [:* (attr? :name)] nil) my-resource) |
| 19:08 | defn | so maybe im picking the wrong selector before? |
| 19:08 | defn | dnolen: is :* the same as [:x [:y [:z]]] or just [:x] |
| 19:09 | defn | if i wanted to get to :z would I do [:* :*] |
| 19:15 | defn | dnolen: duh -- my fault -- i figured it out, i wanted to do (transformation [:p [:a (attr? :name)]] nil) |
| 19:18 | alexyk | the transient indeed works as described, dirty mutable thing |
| 19:26 | alexyk | hmm, freenode is pulsating again |
| 19:32 | joshcheek | Hi, trying to install Clojure. I followed http://www.thelastcitadel.com/dirt-simple-clojure but it doesn't seem to work http://grab.by/1Yca |
| 19:41 | chouser | joshcheek: probably shouldn't have both clojure.jar and clojure-1.1.0.jar |
| 19:42 | chouser | joshcheek: also might need to: export CLASSPATH |
| 19:43 | joshcheek | chouser: It loads the REPL now, thank you. |
| 19:44 | chouser | great! you're quite welcome. |
| 19:45 | joshcheek | chouser: I created a file "hello_world.clj" which houses the text '( println "hello world" )' What do I need to do to get Clojure to read this file? |
| 19:46 | joshcheek | (and print "Hello world") |
| 19:46 | chouser | try: java clojure.main -i hello_world.clj |
| 19:47 | joshcheek | chouser: Thank you, I'll quit bugging you now :) |
| 19:48 | chouser | not at all |
| 19:49 | chouser | if you feel very deeply grateful, consider picking up the book: http://joyofclojure.com |
| 19:49 | chouser | :-) |
| 19:51 | defn | chouser: any ETA on the next chapter or two? |
| 19:52 | chouser | defn: I don't think I can say anything useful except we're working on it |
| 19:54 | defn | chouser: cool cool, just thought id bug you about it :) |
| 19:55 | chouser | oh, I guess I can say that next up you can expect a re-working of the chapters already available, and then after that a chapter on composite types (the collections) |
| 19:59 | chouser | but all that has at least one round of editing before it goes on the MEAP |
| 19:59 | joshcheek | chouser: I didn't realize manning had a book for clojure, when I search Amazon, the only ones I've seen are the pragprog one (the one I picked up, which did not discuss how to do this), and one by apress, which also isn't out yet. Manning has a high standard of quality (in my experience with Ruby, at least), seems like it should be on that list :/ |
| 19:59 | chouser | and I have no sense yet of how long that'll take. |
| 20:00 | chouser | joshcheek: Manning has two Clojure books on the way. I don't know why they're not on amazon yet. |
| 20:02 | joshcheek | chouser: I'll keep my eye open for it. |
| 20:12 | alexyk | I've finally found a way to sweep through my mongo graph very quickly with a transient, just at top level. Alas, it returns only a map with 8 keys, instead of 3 million. Why? Any transient quirks? Here's the fun: http://paste.pocoo.org/show/170077/ |
| 20:14 | alexyk | it dutifully updates the nested map, non-transient one, for those first 8 keys -- the first in mongo stream. It walks all 37 million triples... And returns a puny res. |
| 20:14 | hiredman | alexyk: most likely you are bashing a transient in place |
| 20:15 | hiredman | I seem to recall the number 8 popuping in those cases |
| 20:15 | alexyk | hiredman: I do. Should I lay it comfortably on a sofa? |
| 20:15 | hiredman | no, you should use it just like you do the persitant version |
| 20:15 | alexyk | hiredman: you mean I still need to reassign it? |
| 20:15 | hiredman | it's not assignment! |
| 20:15 | alexyk | I've asked above and no one gave a damn |
| 20:15 | hiredman | did you read the page ontransients? |
| 20:16 | alexyk | so -- (let [res (assoc! res ...)] ...) ? |
| 20:16 | hiredman | http://clojure.org/transients |
| 20:16 | hiredman | read |
| 20:17 | alexyk | quick hack fiorst, read second |
| 20:18 | hiredman | it's not that much to read |
| 20:18 | alexyk | seems like adding res to recur will do |
| 20:18 | alexyk | did read it, just one example |
| 20:20 | alexyk | hmm |
| 20:20 | hiredman | possibly, I don't recall your code, but the key point is: design your algorithm for a persitant structure. if you need speed and it is threadsafe, you stick calls to transient and persistent in key places and suddenly it works for transients |
| 20:25 | alexyk | yep |
| 20:25 | alexyk | has to rebind it as persistent... example from TFurl works. Number 8 should go to FAQ or something. |
| 20:30 | hiredman | no |
| 20:31 | alexyk | hiredman: why not? thank you for catching it btw |
| 20:31 | hiredman | you don't call persistent until you are all done |
| 20:34 | alexyk | with the principled approach, yes |
| 21:19 | jasapp | is there a good introduction to protocols somewhere? |
| 21:26 | Raynes | Why doesn't (clojure.contrib.repl-utils/source doc) work anymore? |
| 21:27 | Raynes | jasapp: http://www.assembla.com/wiki/show/clojure/Protocols Pretty much covers it. |
| 21:27 | chouser | works for me. Are you sure you have core.clj on your classpath (not just the compiled .class files) |
| 21:29 | jasapp | Raynes: cool, thanks |
| 21:37 | Raynes | chouser: I have the clojure and clojure-contrib jars that leiningen downloaded on my classpath. |
| 21:37 | Raynes | chouser: I can (use ..) repl-utils but I cannot directly call a function from it without (use ..)ing it. |
| 22:01 | quizme | can somebody give me an example of how to use dochars ? |
| 22:03 | quizme | i'm trying to iterate on each character of a string |
| 22:03 | alexyk | I see working code like: (-> cursor .next .toClojure) -- can I omit parens if it's a single name? what's the rule? |
| 22:07 | Raynes | ,(doc ->) |
| 22:07 | clojurebot | "([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc." |
| 22:07 | Raynes | Inserts x as the second item in the first form, making a list of it if it is not a list already... |
| 22:11 | ztellman | a number of examples programs in Penumbra work under 1.1.0-new, and don't work under 1.2.0-master |
| 22:12 | ztellman | I'm willing to believe I was misusing something, but can someone give me any hints as to the differences between the two branches? |
| 22:12 | ztellman | specifically that might have to do with clojure.walk or applying metadata to vars? |
| 22:16 | chouser | huh. 1.2 is mostly backward compatible. |
| 22:16 | chouser | ztellman: can you point to a specific example? |
| 22:16 | ztellman | chouser: yes, but there's a lot of underlying code |
| 22:16 | chouser | hm. |
| 22:16 | ztellman | this relates specifically to the translation from s-exprs to GLSL shader code |
| 22:16 | chouser | maybe the stack trace? |
| 22:16 | ztellman | the stack trace just says that it can't infer the type of a particular variable |
| 22:17 | ztellman | in 1.1.0-new, it can; in 1.2.0-master, it can't |
| 22:17 | ztellman | the type is attached via metadata, which is why I think maybe that's the culprit |
| 22:18 | alexyk | Raynes: indeed, thx |
| 22:20 | chouser | ztellman: what's the specific error? |
| 22:21 | ztellman | chouser: I walk the tree, and the type inferences, and then check to see that every variable has a type |
| 22:21 | ztellman | in 1.2.0-master, it doesn't, and I throw an exception |
| 22:21 | ztellman | so it's not an exception from Clojure, if that's what you're angling for |
| 22:40 | ztellman | ok, I've figured out the difference |
| 22:41 | ztellman | in 1.2.0-master, (meta (second '(a #^b c))) returns nil |
| 22:41 | ztellman | in 1.1.0-new, it returns {:tag b} |
| 22:42 | ztellman | is this a bug, or just backwards incompatibility? |
| 22:42 | dnolen | backward incompat i think |
| 22:42 | dnolen | ^ is deprecated |
| 22:42 | dnolen | you should use meta |
| 22:42 | ztellman | dnolen: ^ to get meta, but to assign meta isn't #^ still the way to go? |
| 22:43 | dnolen | hmm, yeah, dunno about that. |
| 22:43 | ztellman | is there a new tag reader macro? |
| 22:43 | ztellman | I know a^int is the way forward, once ^ is no longer a reader macro for meta |
| 22:43 | ztellman | but I didn't think we were there yet |
| 22:43 | chouser | ztellman: it may be a bug |
| 22:44 | ztellman | chouser: is there anything else I can do to help with this, or can you take it from here? |
| 22:44 | chouser | ztellman: it'd probably be best to post a description to the google group. |
| 22:44 | ztellman | ok, will do |
| 22:44 | ztellman | thanks |
| 22:45 | chouser | I may have some time to look at it, but Rich can probably glance at it and have it fixed 10 minutes later. |
| 22:45 | ztellman | just to be clear, the dev group? |
| 22:45 | chouser | if you're on the dev group, sure. But either is fine. |
| 22:46 | chouser | (meta '#^b c) |
| 22:46 | chouser | looks like it may be all symbol metadata |
| 22:46 | chouser | oh. wait, nm. |
| 22:51 | tolstoy | When you override a method using proxy, is there a way to call the superclass' version of that method? proxy-super is for calling other methods, right? |
| 22:51 | tolstoy | Something like in Java: public void doSomething() { super.doSomething(); myStuff(); } |
| 22:52 | chouser | proxy-super can be used to call the same-named method too |
| 22:52 | chouser | beware it is not thread-safe. |
| 22:53 | tolstoy | Hm. I get some sort of error when I do that. Let me see if I can trap it. |
| 22:53 | tolstoy | (proxy [Something] [] (doSomething [] (proxy-super doSomething) (other-func))) |
| 22:53 | tolstoy | that should work? |
| 22:54 | chouser | I think so |
| 22:55 | tolstoy | Yeah, it's what I'd expect from the docs. |
| 22:58 | tolstoy | java.lang.UnsupportedOperationException |
| 22:58 | tolstoy | Hm. |
| 22:58 | chouser | that usually means the underlying method has no implementation. |
| 22:59 | defn | what are all the different types enumerated by metadata? |
| 22:59 | defn | like (:macro (meta #'and)) => true |
| 22:59 | defn | what other types of metadata like :macro exist? |
| 23:00 | chouser | it's an open set. you can add your own! |
| 23:01 | defn | sure i know, i guess i just mean does clojure.core have any others which describe what it is like :macro |
| 23:01 | chouser | I don't know of a complete list, but there aren't actually very many |
| 23:01 | chouser | :arglists, :tag, :doc ... |
| 23:01 | defn | sure, specifically im asking about other identifiers which are very closely related to :macro |
| 23:01 | defn | im not sure what to call that sort of identifier |
| 23:02 | chouser | the compiler needs that so it knows that a var is actually a macro, so deftype sets it. |
| 23:03 | defn | ah-ha! |
| 23:03 | defn | ,(doc deftype) |
| 23:03 | clojurebot | "clojure.contrib.types/deftype;[[type-tag constructor-name docstring? attr-map?] [type-tag constructor-name docstring? attr-map? constructor] [type-tag constructor-name docstring? attr-map? constructor deconstructor]]; Define a data type by a type tag (a namespace-qualified keyword) and a symbol naming the constructor function. Optionally, a constructor and a deconstructor function can be given as well, the defaults being |
| 23:04 | defn | why is it in contrib if this happens in core? |
| 23:04 | chouser | deftype was in contrib first, but meant something else. |
| 23:04 | defn | ah, for some reason i dont have deftype in my core |
| 23:04 | defn | maybe i have an old version of clojure? |
| 23:05 | chouser | defn: deftype is new in the master branch post 1.1 |
| 23:05 | defn | chouser: thanks |
| 23:05 | chouser | 1.2.0-master-SNAPSHOT |
| 23:05 | defn | many thanks |
| 23:05 | chouser | np |
| 23:05 | tolstoy | Ah, I made an interface which looks like a class I usually subclass. So, UnsupportedError. |
| 23:06 | wlr | chouser,ztellman: for me [*clojure-version* (meta (second '(a #^b c)))] => [{:interim true, :major 1, :minor 2, :incremental 0, :qualifier "master"} {:tag b}] |
| 23:07 | chouser | wlr: thanks. The change that apparently broke it was 430dd4fa711d0008137d7a82d4b4cd27b6e2d6d1 Tue Jan 19 |
| 23:10 | wlr | ah. ok. |
| 23:27 | alexyk | somnium: ping |
| 23:28 | alexyk | how do you convert a sorted-map back to a regular one? |
| 23:29 | defn | is there a way to go back? |
| 23:29 | chouser | (into {} a-map) |
| 23:29 | defn | oh duh |
| 23:30 | alexyk | ok |
| 23:38 | defn | (defn clojure-conversation [container] |
| 23:38 | defn | (doseq [k conversation] |
| 23:38 | defn | (conj container (text k)))) |
| 23:38 | chouser | nooo |
| 23:38 | defn | :) |
| 23:38 | chouser | is that some kind of sick joke? |
| 23:38 | chouser | :-P |
| 23:38 | defn | unfortunately no |
| 23:39 | chouser | you can never ignore the return value of 'conj' |
| 23:39 | defn | could you explain what you mean? the implications? |
| 23:39 | chouser | hm, not quite. More like: any code that ignores the return value of 'conj' is useless. |
| 23:39 | chouser | conj doesn't change anything. it creates a new collection instance and returns it |
| 23:40 | defn | oh wait i think i see |
| 23:40 | defn | when you conj onto something it return it, but our function will never know about the return from conj |
| 23:40 | defn | yes? |
| 23:40 | defn | returns* |
| 23:41 | chouser | right, conj does nothing except return a new value. doseq ignores everything returned by the expressions in its body and simply returns nil itself |
| 23:41 | chouser | thus your clojure-conversation will walk through 'conversation', heat up your processor, and return nil |
| 23:41 | defn | so i want a loop/recur |
| 23:42 | chouser | (into container (map text conversation)) |
| 23:43 | chouser | or loop/recur if you prefer more lines of code. |
| 23:43 | hiredman | you most likely want reduce |
| 23:56 | defn | thanks |