2009-03-18
| 00:30 | timothypratley | namespace question... I've got a file that's getting too large so I split it (lets call them A.clj and B.clj), A.clj says (ns A (:use B)) B has a function that references a function in A. I tried to (declare A/function) but that complains that the namespace doesn't exit (correct)... is there a better way? |
| 00:36 | cmvkk | assuming you just split the file because it was too big, |
| 00:36 | cmvkk | you can just have B.clj use (in-ns 'A) and load it from the bottom of A |
| 00:36 | cmvkk | which is how the clojure.core namespace does it i think |
| 00:36 | timothypratley | hmmm I can (ns A) (declare function) then (ns B) (A/function) |
| 00:37 | timothypratley | cmvkk: just use the same namespace for both files?? |
| 00:38 | cmvkk | it definitely works... |
| 00:38 | Raynes | markgunnels: It grows more every day. Install install install! |
| 00:40 | timothypratley | cmvkk: can you clarify the 'load it from the bottom' part? I've looked in proxy_core.clj and core.clj but I don't see how proxy_core.clj gets loaded (unless its ant magic) |
| 00:41 | cmvkk | it's above the futures section, so it's not at the exact bottom of core.clj |
| 00:41 | cmvkk | but i think it's just a call to (load "core_proxy") |
| 00:41 | timothypratley | oh i see it |
| 00:42 | timothypratley | thanks! |
| 00:58 | pstickne | are there some (decent) clojure (micro) benchmarks? I'm only finding cruft on google. |
| 00:59 | durka42 | they're scattered around... |
| 01:00 | durka42 | you can probably find some in the google group |
| 01:04 | pstickne | I'm mostly just curious what affect using boxed types has. |
| 01:29 | pstickne | wow :p |
| 01:29 | pstickne | I didn't realize clojure had so much synchronization support. |
| 01:29 | pstickne | Neet. |
| 01:29 | pstickne | Neat, even. |
| 01:45 | Raynes | "@Rayne I've tried to fall in love with clojure, but it just hasn't clicked for me. I get kind of a "you look an awful lot like a woman who once stole my heart, but I know you're really java in drag" discord." |
| 01:46 | Raynes | I wonder how many people have turned down Clojure because of a dislike for Java. |
| 01:46 | durka42 | what happens to clojurebot's twitter following, anyway |
| 01:46 | Raynes | Shame. |
| 01:46 | durka42 | yeah |
| 01:47 | cmvkk | It seems like it might be a prevalent opinion...I understand where they're coming from but it's unfortunate |
| 01:47 | durka42 | clojure makes java bearable :) |
| 01:48 | Raynes | Clojure makes Java unnecessary. |
| 01:49 | Raynes | I wish there was a Haskell implementation on the JVM. That would be neat. |
| 01:49 | slashus2 | Raynes: Write one :-) |
| 01:49 | Raynes | I know YHC can generate CLR bytecode. |
| 01:49 | slashus2 | in clojure |
| 01:50 | Raynes | slashus2: I'm way to inexperienced for that :| |
| 01:50 | durka42 | http://jaskell.codehaus.org/ is something |
| 01:50 | durka42 | not entirely sure what, exactly |
| 01:50 | Raynes | That's not exactly what I had in mind. |
| 01:50 | Raynes | "Scripting language" isn't what I have in mind I mean. |
| 01:53 | hiredman | slashus2: I haven't looked at the JFrame thing, the box I run clojurebot on is headless |
| 01:54 | hiredman | ,(javax.swing.JFrame.) |
| 01:54 | clojurebot | java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it. |
| 01:54 | slashus2 | hiredman: I fixed it by modifying the de-fang method |
| 01:55 | slashus2 | adding doto |
| 01:56 | slashus2 | de-fang doesn't check at the top level, it does a macroexpand-1 |
| 01:57 | slashus2 | I just made it check the beginning form. |
| 01:57 | slashus2 | So adding doto will work. |
| 02:02 | hiredman | :( |
| 02:03 | hiredman | that is silly |
| 02:03 | hiredman | doto is just a let |
| 02:04 | hiredman | so you can by-pass by just using a let |
| 02:05 | hiredman | ,(let [x (JFrame.) _ (.setSize x 800 600) _ (.setVisible x true)] x) |
| 02:05 | clojurebot | java.lang.IllegalArgumentException: Unable to resolve classname: JFrame |
| 02:06 | hiredman | figuring out how to remove the permissions to use classes in java.awt would be a better idea |
| 02:06 | hiredman | plus if you figure that out you can tell me |
| 02:10 | harpastum | clojurebot automatically runs clojure forms? |
| 02:11 | harpastum | ,(+ 1 1) |
| 02:11 | clojurebot | 2 |
| 02:11 | harpastum | sweet |
| 02:11 | hiredman | ,(def a 1) |
| 02:11 | clojurebot | DENIED |
| 02:11 | harpastum | ouch |
| 02:11 | harpastum | ,(def foo 13) |
| 02:11 | clojurebot | DENIED |
| 02:12 | harpastum | no defs allowed? |
| 02:12 | hiredman | nope |
| 02:12 | harpastum | so no defns either? |
| 02:12 | hiredman | which is why de-fang uses macroexpand, things like defn expand to a def call, so I can just deny def |
| 02:13 | harpastum | (defn hello [] (println "hello")) |
| 02:13 | harpastum | forgot the comma. Oh well |
| 02:13 | hiredman | ,(macroexpand-1 '(defn hello [] (println "hello")) |
| 02:13 | clojurebot | EOF while reading |
| 02:13 | hiredman | ,(macroexpand-1 '(defn hello [] (println "hello"))) |
| 02:13 | clojurebot | DENIED |
| 02:13 | hiredman | ah, yes, well |
| 02:14 | cmvkk | we need multiple-line inputs. |
| 02:14 | hiredman | No |
| 02:14 | cmvkk | heh |
| 02:14 | cmvkk | because it's hard to do or because it's harmful? |
| 02:14 | harpastum | ,(some #(= % "harpastum") '("hiredman" "cmvkk" "harpastum"))) |
| 02:14 | clojurebot | true |
| 02:15 | harpastum | pretty cool |
| 02:15 | durka42 | cmvkk: it'd be really hard to follow :\ |
| 02:15 | Raynes | Oh boy. |
| 02:16 | durka42 | why is macroexpand disallowed, though? |
| 02:16 | harpastum | hahahahah. i just sent a private message to clojurebot |
| 02:16 | harpastum | clojurebot: BUENOS DING DONG DIDDLY DIOS, fRaUline harpastum |
| 02:16 | clojurebot | Huh? |
| 02:16 | Raynes | The Making Lancet Targets Run Only Once part part of the Concurrency chapter is screwed up rather bad. |
| 02:16 | hiredman | ,(pl (?map (replicate 3 (?apply vector $ (?map range $ 10 inc � inc � inc) call � ?* $ 10 � call � (?+ -2) map)) shuffle)) |
| 02:16 | durka42 | what would be cool is modification of the last expression a la that c++ bot |
| 02:16 | clojurebot | ((20 40 80 10 30 60 70 90 50 100) (10 60 40 50 80 100 30 20 70 90) (80 50 70 10 40 100 30 60 20 90)) |
| 02:17 | Raynes | He says hes using an Agent in the example but he uses an Atom. And there are a few grammatical errors. Worst I've seen in the book. |
| 02:17 | hiredman | durka42: macroexpand is not disallowed, it just pukes on anything with 'def in it |
| 02:17 | durka42 | oh |
| 02:17 | Raynes | ~And suddenly... |
| 02:17 | clojurebot | CLABANGO! |
| 02:18 | harpastum | ,(+ 2 2) |
| 02:18 | clojurebot | 4 |
| 02:18 | durka42 | (+ 2 3) |
| 02:18 | clojurebot | *suffusion of yellow* |
| 02:18 | Raynes | He also says the function takes an agent and a function but only takes a function o.o |
| 02:18 | harpastum | (+ 2 2) |
| 02:18 | clojurebot | 4 |
| 02:19 | harpastum | English |
| 02:19 | durka42 | Raynes: do you have the latest beta? |
| 02:19 | Raynes | Yup. |
| 02:22 | Raynes | I might be missing something but what he says after that paragraph has nothing to do with agents. I might just not be understanding what he means. :\ |
| 02:25 | durka42 | well, anyway, goodnight |
| 02:30 | hiredman | !!!!! |
| 02:31 | hiredman | unicode 5.1 added the inverted interrobang |
| 02:31 | hiredman | ? |
| 02:32 | hiredman | truely we are living in the future |
| 02:34 | harpastum | Almost as good as the |
| 02:34 | harpastum | 'reversed rotated floral heart bullet' |
| 02:34 | harpastum | ? |
| 02:34 | harpastum | i hear there was a lot of demand that it be included |
| 02:35 | hiredman | clojurebot: what? |
| 02:35 | clojurebot | what is latest |
| 02:36 | hiredman | clojurebot: what is <reply>?Que? |
| 02:36 | hiredman | hmmm |
| 02:36 | hiredman | clojurebot: what? |
| 02:36 | clojurebot | ?Que? |
| 02:37 | Raynes | "The first rule of the Macro Club is: Don't Write Macros." |
| 02:37 | Raynes | Well, if I was to stop reading there, it would save me time not having to read that chapter. :p |
| 02:43 | cmvkk | i've heard people say before, "don't write a macro unless you *absolutely have to*" |
| 02:43 | cmvkk | but i've never understood the rationale behind that. i mean, really, you *never* have to write a macro, right? |
| 02:44 | Raynes | You would need to if you needed to have something that didn't evaluate it's parameters before using them I suppose. |
| 02:45 | Raynes | But I'm sure you could design /around/ needing that thing. I don't know, I guess you would never need too... |
| 02:45 | cmvkk | right well, i guess that's what they mean by that. |
| 02:45 | cmvkk | but "need to" is such a strong wrod, when 99% of programming languages don't even have macro facilities at all. |
| 02:45 | Raynes | Most languages have ways around that. |
| 02:46 | Raynes | Haskell is totally lazy, so it doesn't evaluate it's arguments by default. |
| 02:47 | Raynes | I would guess that it's optional. |
| 02:47 | Raynes | The macros I mean. |
| 02:47 | cmvkk | right, well, i guess what i'm saying is that people like to make a big deal of acting like macros are a 'last ditch option', but |
| 02:47 | cmvkk | i don't feel bad about writing macros if it makes the code look nicer or whatever. |
| 02:47 | Raynes | I'm not experienced enough to really knwo. :| |
| 02:48 | Raynes | People say gotos are the devil - People still use them. |
| 02:48 | Raynes | know* |
| 02:48 | cmvkk | I suspect i'm not either, and that is why my code always contains lots of crazy macros. |
| 02:49 | cmvkk | at least this time, i don't have macros that expand into other macros which have macros in their expansion code, etc... |
| 02:51 | Raynes | Is there a reason that Stu writes (defmacro [expr form] (list 'if expr nil form)) instead of (defmacro [expr form] (if expr nil form))? They work the same it seems, but I'm new to this macrofoo. |
| 02:51 | hiredman | woa |
| 02:51 | hiredman | no |
| 02:51 | cmvkk | they don't work the same, actually: |
| 02:51 | hiredman | those are both different |
| 02:52 | cmvkk | expr would never get evaluated inside the expander code (or that's how it seems to work in clojure) |
| 02:52 | Raynes | Well you see, he didn't explain the difference so I didn't know... |
| 02:52 | hiredman | it is import to remember that the result of the macro expression is evaluated as code |
| 02:52 | hiredman | important |
| 02:55 | hiredman | most people would write something like (defmacro [expr form] `(if expr nil form)) instead of (defmacro [expr form] (list 'if expr nil form)) |
| 02:55 | hiredman | but making the list like that is a good way to make what the macro does very explicit |
| 02:57 | Raynes | He explains it a page later, I was just impatient. |
| 02:58 | cmvkk | funnily enough, your example works though :/ |
| 02:58 | hiredman | cmvkk: only for some values of works |
| 02:59 | Raynes | Still works ;) |
| 02:59 | cmvkk | in the sense that it evals expr enough that it will only return nil when expr is true |
| 02:59 | cmvkk | and will return form when expr is false |
| 02:59 | Raynes | A car with no tires still works. |
| 03:00 | cmvkk | i.e. it works in the repl, but i still don't feel like i have a good grip on when clojure will or will not evaluate objects passed to macros. |
| 03:00 | cmvkk | in common lisp, i think it would always work. |
| 03:28 | Raynes | LOL! |
| 03:30 | Raynes | "If the preceding sections did not convince you of this, the Lancet example at the end of the chapter is more complex still, and a few of the macros in Clojure itself are extremely complex. (If none of the macros in Clojure seem complex to you, my company is hiring.) |
| 03:30 | Raynes | " |
| 03:34 | Raynes | I just realized he never explained the meaning of declare. |
| 03:34 | Raynes | :| |
| 03:36 | cmvkk | ,(doc declare) |
| 03:36 | clojurebot | "([& names]); defs the supplied var names with no bindings, useful for making forward declarations." |
| 03:36 | Raynes | I read that. :p |
| 03:37 | Raynes | But if Stu was top have explained it he would of told me where that would be useful. |
| 03:37 | cmvkk | that's true. |
| 03:43 | Raynes | ... |
| 03:43 | Raynes | Now he's explaining declare. |
| 03:43 | Raynes | He never ceases to surprise me in this book. |
| 05:17 | Lau_of_DK | Im walking a line-seq in a (for [line *line-seq*]) and this borks somewhere along the way, how do get the line count where it fails ? |
| 05:25 | hiredman | ~jdoc java.io.LineNumberReader |
| 05:29 | Lau_of_DK | hiredman, when Im going through my for-loop, the 'line' object, is just a string, and after the LineNumberReader goes through line-seq, its a lazy-seq |
| 05:32 | cgrand | Lau_of_DK: but if you keep a ref to the LineNumberReader then you can call .getLineNumber on it |
| 05:33 | Lau_of_DK | oh thats right - I just bailed out and kept a ref of a counter, and look at its value when it failed |
| 05:34 | hiredman | http://tapestryjava.blogspot.com/2009/03/clojure-at-oscon.html |
| 05:35 | hiredman | oh, god, that is from, uh seven days ago |
| 06:16 | cow-orker | in the make-adder example (defn make-adder [x] (let [y x] (fn [z] (+ y z)))), is it necessary to use the let form and bind y? won't (def make-adder [x] (fn [y] (+ x y))) work in the same way? |
| 06:17 | cgrand | cow-orker: the let is unneeded |
| 06:20 | cow-orker | thanks! That is what testing showed me as well, was just wondering if there was some detail I'd missed... :-) |
| 06:20 | cgrand | where did you find this example? |
| 06:21 | cow-orker | ftp://lispnyc.org/meeting-assets/2007-11-13_clojure/clojuretalk.pdf - slide 20 |
| 06:24 | cgrand | it was maybe intended to show that locals were closed over |
| 06:26 | cow-orker | yes that might be it.... |
| 06:27 | cow-orker | although I've done some lisp work many years ago I'm new to clojure (and java as well). I must say... it is _very_ nice :) |
| 06:27 | hiredman | :) |
| 08:11 | cemerick | rhickey: thanks for applying the patch for #94 -- I hope the diff ended up being recent enough so as to not be troublesome. |
| 08:12 | rhickey | cemerick: I couldn't use it as-is, as it used set/union before set is avalable, i.e. Clojure didn't build |
| 08:13 | cemerick | damn. That's what I get for writing patches in the REPL. |
| 08:13 | rhickey | :) |
| 08:13 | cemerick | rhickey: sorry about that. :-( |
| 08:13 | rhickey | np |
| 08:21 | cemerick | it's interesting, I never think to use into. I guess I should fix that. |
| 08:45 | rhickey | more qcon coverage: http://steve.vinoski.net/blog/2009/03/18/qcon-london-the-best-one-yet/ |
| 08:46 | rhickey | this yesterday: http://constc.blogspot.com/2009/03/relativity-of-simultaneity.html |
| 09:16 | gnuvince | rhickey: it seems like you made quite the splash :) |
| 09:17 | rhickey | the Erlang folks were great, very receptive to Clojure |
| 09:29 | rhickey | gnuvince: with your perf problem the other day - you were on JDK6? |
| 09:33 | gnuvince | rhickey: yes. |
| 09:33 | rhickey | could you try it on JDK5? |
| 09:34 | rhickey | it uses refs? |
| 09:34 | gnuvince | No refs. |
| 09:34 | gnuvince | (No agents or atoms either) |
| 09:35 | rhickey | ok, nevermind |
| 09:37 | gnuvince | For the moment being, my my best guess is that *I* am the problem and I need to figure out what I did wrong. |
| 09:43 | digash` | looks like IBM is going to by Sun, long live JVM |
| 09:43 | rhickey | is it a done deal? I saw the rumors |
| 09:44 | digash` | they made an offer of 6.5B |
| 09:44 | digash` | 1B for MySQL, 6.5B for Sun, interesting times. |
| 09:52 | cgrand | rhickey: I'm sorry for the regressions I introduced with my half-baked patch to proxy |
| 09:53 | rhickey | cgrand: no problem, it just ended up being more subtle than it seemed |
| 09:53 | rhickey | it is the trunk after all |
| 09:56 | Chouser | 2 days from original patch through regression discovery to final fix. not shabby at all. |
| 09:59 | Chouser | our unit tests live and breathe. |
| 10:00 | rhickey | and think |
| 10:01 | cgrand | ,(into {} [{1 2 3 4} {5 6}]) |
| 10:01 | clojurebot | {5 6, 3 4, 1 2} |
| 10:03 | cgrand | it suprised me: I had forgotten that you can conj a map onto another one |
| 10:03 | Chouser | me too |
| 10:03 | Chouser | I saw someone conj two maps yesterday (I think) and was startled. |
| 10:04 | rhickey | a map entry is just a single item map, in some sense |
| 10:04 | Chouser | ,(conj {1 2} {3 4 5 6}) |
| 10:04 | clojurebot | {5 6, 3 4, 1 2} |
| 10:04 | rhickey | seems in keeping with conjoin |
| 10:05 | Chouser | I'm not complaining. |
| 10:05 | cgrand | neither |
| 10:05 | rhickey | I didn't think you were :) |
| 10:07 | rhickey | seems better than all of Sun falling by the wayside? |
| 10:07 | Chouser | can a java class have a method foo(A) and also foo(Object)? I'm guessing not. Is it best to answer such questions by experimenting in .java? |
| 10:08 | cemerick | yeah, if it's a question of saving the JVM ecosystem, then I'm all for it. I didn't think we were at that point yet, tho. |
| 10:09 | cemerick | Chouser: I *think* both can exist, but only the Object overload will be dispatched to...?? |
| 10:09 | rhickey | Sun's already open sourced all the crown jewels, so just a service co like IBM |
| 10:09 | cgrand | Chouser: both exists and depending on the casting, one or the other will be targeted |
| 10:10 | Chouser | fun. perhaps I'm biting off to much trying to do the auto-hinting right now. :-) |
| 10:10 | Chouser | too much |
| 10:14 | cgrand | Chouser: http://aruld.info/synthetic-methods-in-java/ |
| 10:15 | Chouser | cgrand: thanks |
| 10:20 | Chouser | So let's say LockEx and LockExImpl are imported, and I have an unhinted expression (.lockEx t m) |
| 10:20 | Chouser | (just thinking aloud here...) |
| 10:22 | lisppaste8 | digash` pasted "which one is it going to call?" at http://paste.lisp.org/display/77224 |
| 10:22 | Chouser | I can find LockEx.lockEx(T), LockExImpl.lockEx(LockExImpl), and LockExImpl(Object) |
| 10:22 | digash` | Chouser: it is my favorite interview question :) |
| 10:23 | Chouser | digash`: seems obvious, which probably means I fail the interview. |
| 10:24 | cgrand | Chouser: find where? in class files? if yes, there's no LockEx.lockEx(T) |
| 10:24 | digash` | Chouser: it is the same as foo(A) and foo(Object) question you had. |
| 10:25 | Chouser | digash`: oh, indeed. and I guessed correctly. :-) |
| 10:25 | digash` | Chouser: ok, you are hired. |
| 10:26 | Chouser | cgrand: why is that? interfaces get class files, normally, don't they? |
| 10:27 | cgrand | cgrand: it's the T that made me react :-) |
| 10:31 | Chouser | sorry, my java is so weak... so is "void lockEx(T t);" on that page incorrect somehow? should it be (Object t) or something? |
| 10:35 | rhickey | Chouser: generic types are erased when compiled |
| 10:38 | Chouser | Does LockEx need to be declared as LockEx<T> ? |
| 10:39 | Chouser | if I do that it compiles, and I see a LockEx.lockEx(Object) method |
| 10:42 | cgrand | Chouser: yes it needs to be declared as LockEx<T> |
| 10:42 | rhickey | well, LockEx<Something> |
| 10:43 | rhickey | I guess T is used in the body |
| 10:44 | Chouser | ok |
| 10:44 | rhickey | That's a very gnarly example |
| 10:45 | Chouser | good. :-) so, at clojure compile time I'll be able to see LockEx.lockEx(Object), LockExImpl.lockEx(LockExImpl), and LockExImpl(Object) |
| 10:45 | rhickey | FYI, the rules are totally different in C# |
| 10:45 | Chouser | in which case I could make (.lockEx t m) point to only the first of those and be all set. |
| 10:45 | Chouser | rhickey: ah, ok. |
| 10:46 | Chouser | you mentioned a pluggable reflector, but I think the compojure.lang.Reflector interface may be a notch or two too low for this kind of thing. |
| 10:46 | rhickey | so this is a job for the reflector |
| 10:47 | rhickey | any type resolution logic in the compiler needs to move to the reflector |
| 10:48 | Chouser | ok |
| 10:48 | rhickey | e.g. subsumes |
| 10:56 | cconstantine | given something like (23/2), how do I turn that into a whole number (doing some kind of rounding obviously)? |
| 10:59 | dliebke | ,(Math/round (float 23/2)) |
| 10:59 | clojurebot | 12 |
| 10:59 | dliebke | seems ugly, but it works |
| 11:00 | cconstantine | thanks :) |
| 11:01 | cconstantine | and my program only has to do it once, so the multiple conversions isn't huge |
| 11:07 | Guest29794 | cconstantine: you may also want to check out clojure.contrib.math.clj |
| 11:07 | cconstantine | where's the docs for controb? |
| 11:07 | cconstantine | contrib |
| 11:09 | Guest29794 | not sure there is one. i just grep the svn directory |
| 11:09 | cconstantine | :/ I was afraid of that. ok. Thanks |
| 11:11 | cconstantine | The joys of working in a fresh new language :) |
| 11:11 | danlarkin | the source is pretty good documentation :) for contrib at least |
| 11:11 | ffailla_ | i have a hierarchical data structure made up of maps and seqs, and would like to perform a function on all the leaves. Does anyone know of a built in clojure function that will recurse through my structure and give me the leaves, or allow me to run a function on the leaves? |
| 11:12 | cconstantine | danlarkin: that's good to hear |
| 11:14 | Chouser | ffailla_: clojure.contrib.walk might have something useful |
| 11:15 | brianh2 | ffailla: there's also the clojure.zip |
| 11:18 | cgrand | ffailla_: there's also tree-seq |
| 11:40 | ffailla_ | Chouser: walk will do what I need, thanks to everyone for your reponses |
| 12:05 | te | hello all |
| 12:05 | cgrand | hello |
| 12:05 | te | how goes the struggle |
| 12:05 | cgrand | ? |
| 12:09 | te | the clojure struggler |
| 12:09 | te | together we can win! |
| 12:28 | notfonk | Hey there |
| 12:28 | notfonk | has anybody experience with vimclojure ? |
| 12:28 | notfonk | i'm struggling to make it work :| |
| 12:34 | ozzilee | I'm having a problem compiling an application that uses clojure-json, and I'm not sure where to start: |
| 12:34 | ozzilee | java.lang.ClassNotFoundException: org.danlarkin.json.encoder$map_entry_QMARK___1 (json.clj:26) |
| 12:35 | ozzilee | I'm pretty much at a loss. |
| 12:35 | danlarkin | ozzilee: I haven't tested clojure-json in a while, lemme see if it works for me |
| 12:37 | danlarkin | tests pass and compile works for me |
| 12:38 | danlarkin | ozzilee: does it work without AOT compiling? |
| 12:40 | ozzilee | danlarkin: Yeah, it works fine without AOT. |
| 12:40 | ozzilee | I'm trying to compile a compojure app to deploy to tomcat. |
| 12:41 | danlarkin | could you pastebin your build.xml? assuming you're using ant |
| 12:44 | lisppaste8 | ozzilee pasted "clojure-json AOT" at http://paste.lisp.org/display/77230 |
| 12:46 | danlarkin | with this configuration either the clojure-json source or .jar would have to be in src/ or WEB-INF/lib/ |
| 12:46 | ozzilee | If I take out the (:require (org.danlarkin [json :as json])) from my project's namespace, I end up with a "No such namespace: json" error, which I would expect. |
| 12:46 | ozzilee | danlarkin: Yes, clojure-json.jar is in WEB-INF/lib/ |
| 12:47 | danlarkin | Hm |
| 12:47 | ozzilee | I guess I should go through and start commenting stuff out until it compiles... |
| 12:49 | danlarkin | are you sure that the clojure-json.jar is actually being included on the classpath for clojure.lang.Compile? I am not familiar enough with ant xml to be sure |
| 12:51 | ozzilee | danlarkin: Pretty sure. |
| 12:51 | ozzilee | The rest of the jars seem to be. |
| 12:52 | danlarkin | did you jar clojure-json with -Dclojure.jar? |
| 12:52 | danlarkin | what happens if you try it the opposite way |
| 12:53 | ozzilee | Not sure. Give me a couple minutes, have to deal with some unrelated nonsense. |
| 12:55 | danlarkin | sure. If this is a problem with clojure-json I want to fix it |
| 12:58 | notfonk | anybody could give me some insight on a vimclojure problem ? |
| 13:02 | hiredman | notfonk: I've only got a few minutes, it is generally better to just ask the question instead of asking meta questions (can I ask this question? does anyone know about this question? etc) |
| 13:02 | hiredman | so ask away |
| 13:04 | notfonk | ok |
| 13:04 | notfonk | i've got an error many people had : |
| 13:04 | notfonk | when launching vim with vimclojure activated |
| 13:04 | notfonk | E605: Exception non intercept�e : Couldn't execute Nail! /home/ |
| 13:04 | notfonk | notfonk/.vim/./ng de.kotka.vimclojure.nails.NamespaceOf |
| 13:05 | notfonk | i checked everything in the related topics |
| 13:05 | notfonk | the ng server is running, my classpath is good AFAIK |
| 13:05 | notfonk | i checked the vimclojure and it looks allright, but i may be wrong on that |
| 13:06 | notfonk | but i hadn't any compil errors |
| 13:06 | notfonk | but when i do "ng |
| 13:06 | notfonk | de.kotka.vimclojure.nails.NamespaceOfFile " |
| 13:06 | notfonk | i get this |
| 13:06 | hiredman | is the ng binary in /home/notfonk/.vim/./ng, does the file you are editing have a correct namespace declaration and is that namespace in the classpath passed to the nailgun server? |
| 13:06 | notfonk | java.lang.NoClassDefFoundError: clojure/lang/IFn at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at com.martiansoftware.nailgun.NGSession.run(Unknown Source) |
| 13:06 | notfonk | Caused by: java.lang.ClassNotFoundException: clojure.lang.IFn at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) |
| 13:06 | ozzilee | danlarkin: I believe I just used 'ant' or 'ant jar' to build clojure-json into a jar. |
| 13:07 | notfonk | at java.lng.ClassLoader.loadClass(ClasCsLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 3 more the ng is in the right place |
| 13:07 | hiredman | notfonk: what about "ng clojure.main" |
| 13:07 | notfonk | gonna try that |
| 13:08 | danlarkin | ozzilee: ok, try compiling clojure-json with -Dclojure.jar=/path/to/clojure.jar |
| 13:08 | notfonk | hiredman : it doesn't find it either |
| 13:08 | notfonk | 17:59 -!- jbomo [n=dkd@pool-71-108-227-15.lsanca.dsl-w.verizon.net] has quit [Read error: 104 (Connection reset by |
| 13:09 | ozzilee | danlarkin: ant -Dclojure.jar=/path/to/clojure.jar ? |
| 13:09 | notfonk | the strange thing is that i run the server in the same terminal |
| 13:09 | danlarkin | ozzilee: yup |
| 13:09 | notfonk | and there it founds everything it needs |
| 13:09 | hiredman | notfonk: so something is wrong classpath wise, the nailgun server instance cannot find the clojure classes |
| 13:10 | notfonk | yeah it seems so, but my CLASSPATH env variable works for java |
| 13:10 | notfonk | that's what i don't get |
| 13:11 | hiredman | how are you starting the nailgun server? |
| 13:12 | notfonk | /home/notfonk/.vim/ng clojure.main |
| 13:12 | notfonk | that's it |
| 13:12 | notfonk | ah sorry |
| 13:12 | hiredman | that is the nailgun client |
| 13:12 | notfonk | i have a scriptfile |
| 13:12 | notfonk | java -cp $CLOJURE_JAR:$CLOJURE_CONTRIB:$CLOJURE_VIM com.martiansoftware.nailgun.NGServer 127.0.0.1 |
| 13:13 | notfonk | and i defined the three variables |
| 13:13 | notfonk | although if i launch it from the cli directly without -cp it works |
| 13:13 | notfonk | since my classpath is ok |
| 13:13 | notfonk | i'm getting a bit confused, sorry about the hectic postings -_- |
| 13:14 | hiredman | sorry I've got to run, hopefully someone else will be a long shortly |
| 13:14 | ozzilee | danlarkin: Hmm well I've got things pretty well commented away to nothing at the moment, still won't compile, let me go down this path a bit further to see if I can get something to compile. |
| 13:15 | notfonk | np, ty hired |
| 13:15 | notfonk | i don't see any way out anyway, think i'm gonna drop if 'till tomorrow |
| 13:17 | notfonk | hah ! |
| 13:17 | danlarkin | ozzilee: let me know if you come to any conclusions |
| 13:17 | notfonk | i restarted my server directly from the cli and now "ng clojure.main" works |
| 13:20 | notfonk | ok i solved it, looks like my script was the problem |
| 13:20 | notfonk | when i start the server directly from the cli everything works fine |
| 13:35 | ozzilee | danlarkin: I've concluded that I need a break and something to eat. I don't think the problem is with the json library, more likely I've got something set up wrong. Thanks for the help. |
| 13:36 | danlarkin | ozzilee: I'll be here for a few more hours if you do end up fixing it |
| 13:36 | danlarkin | or if it turns out to be my fault after all |
| 13:38 | ozzilee | danlarkin: Sounds good, I'll let you know what I find. |
| 14:18 | hiredman | ~logs |
| 14:18 | clojurebot | logs is http://clojure-log.n01se.net/ |
| 14:23 | danlarkin | did someone post a link to rich's qcon presentation yesterday or the day before? I seem to remember it but can't find it |
| 14:25 | bitbckt | it would be wonderful if clojurebot delicioused any links seen in the channel not posted by itself |
| 14:25 | dliebke | http://qconlondon.com/london-2009/file?path=/qcon-london-2009/slides/RichHickey_PersistentDataStructuresAndManagedReferences.pdf |
| 14:25 | bitbckt | like that one |
| 14:25 | durka42 | clojurebot: qcon slides is http://qconlondon.com/london-2009/file?path=/qcon-london-2009/slides/RichHickey_PersistentDataStructuresAndManagedReferences.pdf |
| 14:25 | clojurebot | Roger. |
| 14:29 | danlarkin | dliebke: thanks |
| 14:29 | dliebke | np, I wish I could have heard the talk :) |
| 14:45 | Raynes | "Emacs is a little too simple for my taste." |
| 14:45 | Raynes | It's okay, he's new. |
| 14:45 | Raynes | :| |
| 14:45 | p_l | Raynes: then switch such a person to TECO |
| 14:46 | durka42 | M-x butterfly |
| 14:46 | p_l | nah, ITS TECO.... every key is a command key! :P |
| 14:55 | danlarkin | Hm. sun cloud http://www.tbray.org/ongoing/When/200x/2009/03/16/Sun-Cloud |
| 15:00 | kotarak | ,(if (drop 3 '(1 2 3)) true false) |
| 15:00 | clojurebot | true |
| 15:00 | kotarak | ,(drop 3 '(1 2 3)) |
| 15:00 | clojurebot | () |
| 15:01 | danlarkin | ,(boolean '()) |
| 15:01 | clojurebot | java.lang.NoClassDefFoundError: clojure/lang/PersistentList$EmptyList$1 |
| 15:01 | danlarkin | pah |
| 15:02 | danlarkin | ,(type (drop 3 '(1 2 3))) |
| 15:02 | clojurebot | clojure.lang.LazySeq |
| 15:12 | Lau_of_DK | Hi guys |
| 15:18 | hiredman | anyone know how I can change the user-agent of a urlconnection? |
| 15:19 | hiredman | actually, HttpURLConnection |
| 15:20 | danlarkin | connection/setRequestProperty |
| 15:20 | danlarkin | well you get the idea |
| 15:20 | danlarkin | I guess it's not a static method |
| 15:21 | danlarkin | (.setRequestProperty connection "User-Agent" "foo") |
| 15:32 | hiredman | *sigh* |
| 15:32 | hiredman | still getting a 401 from delicious |
| 15:33 | durka42 | sorry, you are not authorized to enjoy food |
| 15:35 | hiredman | and, of course, if I paste the url into firefox it goes through just fine |
| 15:36 | danlarkin | curious |
| 15:36 | durka42 | cookie? |
| 15:42 | hiredman | ugh |
| 15:42 | hiredman | the url also works if I use "fetch" |
| 15:42 | hiredman | I guess I could just shell out |
| 15:48 | ozzilee | danlarkin: Solved my problem. You have to include the build directory in the classpath when compiling. My mistake. |
| 15:48 | danlarkin | d'oh! |
| 15:49 | danlarkin | ozzilee: well I'm glad to hear you got it figured out |
| 15:52 | ozzilee | Yeah. This stuff can be a bear to debug sometimes. But I will remember next time, just like I remember that "java.lang.ArrayIndexOutOfBoundsException: 5" means misformed XML for lazy-xml/emit. |
| 15:54 | danlarkin | aye I know what you mean |
| 15:55 | ozzilee | Also, "Don't know how to create ISeq from: <whatever>" means "Good luck finding this one, sucker." :-) |
| 15:55 | Chouser | drat |
| 15:56 | ozzilee | But now it works, and your json lib works fine, thanks for writing that, btw. |
| 16:03 | Raynes | "I'd venture that it's [Ruby on rails] at least as eye-opening as something based on LISP or Smalltalk or Haskell, but probably more practical because you may actually end up using it at a job or for contract work. Clojure, Seaside, and HAppS sound really cool, but until one of them really catches on, you're unlikely to ever use any of that stuff again in your career unless you're a computer... |
| 16:03 | Raynes | ...science PhD working with other PhD's." |
| 16:03 | Raynes | Sorry, didn't realize that was so long. |
| 16:03 | rhickey | Raynes: said where? |
| 16:04 | Raynes | Stackoverflow.com The home of the career codemonkeys. :\ |
| 16:05 | Raynes | http://stackoverflow.com/questions/656987/tired-of-asp-net-which-of-the-following-should-i-learn-and-why to be specific. |
| 16:05 | Raynes | 2 people including me recommended Clojure and didn't get a single vote up. ._. |
| 16:06 | danlarkin | SO is a good idea but it's filled with zealots |
| 16:06 | Raynes | Agreed. |
| 16:07 | Lau_of_DK | Hmm Raynes - I found this photo of you, and now I see why people dont vote for you so much http://photo.net/photodb/photo?photo_id=2490048 |
| 16:08 | Raynes | Oh noes. I've been found out. |
| 16:08 | kotarak | There was a question on how to remember what values true and false are. There were several answer explaining, that false is zero and true anything else. And the only sane answer, which didn't chime in in the number stuff, didn't get a single vote... Well. With the blind the one-eye is king. |
| 16:09 | Raynes | Well, the thing is normally when you recommend Clojure and other functional languages others support you and vote you up. I guess they assumed that he want something "Practical" and something he can use in his "Career" and we all know, Clojure is NOT practical! |
| 16:09 | Lau_of_DK | Funny discussion this is "We're the best, but nobody gets us" |
| 16:09 | Lau_of_DK | Reminds me of the blessed Common Lisp days :) |
| 16:10 | Raynes | I have 14 votes up for answering a question an explaining what let does to someone. |
| 16:11 | Raynes | Er, not explain what let will /do/ to someone, explaining what let does in a program to someone :p |
| 16:12 | Lau_of_DK | oh ok.. |
| 16:12 | Lau_of_DK | :) |
| 16:13 | Lau_of_DK | "Well, if you use let in an anonymous function, it will in fact attack your manager, and THATS why you should use Clojure" |
| 16:17 | cemerick | has there really not been a "Going to ILC 2009?" thread on the google group? I'll start one, but I figured it'd already be one up. |
| 16:17 | cemerick | s/it'd/there'd |
| 16:19 | Raynes | Who voted me up? |
| 16:19 | Raynes | They deserve a hug. |
| 16:21 | Raynes | Someone else voted me up O.O |
| 16:21 | hiredman | clojurebot: delicious is http://delicious.com/clojurebot |
| 16:21 | clojurebot | Ok. |
| 16:23 | Raynes | Er wait, only one person, the last vote up was on a different question. |
| 16:23 | hiredman | http://delicious.com/clojurebot is clojurebot's feed of urls from channels, it tags with channel and nick of where the url came from |
| 16:24 | Raynes | Someone voted up a (stupid) question I asked 2 days ago. Neat. |
| 16:26 | hoeck | hiredman: cool! |
| 16:28 | Raynes | I managed to get one of the people who think that OOP is the God of the programming world interested in Clojure. Took me 2 hours of coercing to do it but I managed it. |
| 16:34 | bitbckt | hiredman: my hero |
| 16:35 | danlarkin | I like the turnaround on clojurebot features |
| 16:35 | bitbckt | danlarkin: me too! |
| 16:36 | hiredman | I am all about low hanging fruit |
| 16:37 | bitbckt | hiredman: subscribing to #clojure URLs is oh-so-tasty |
| 16:42 | hiredman | once rhickey posts a link, there will be an rhickey tag, so you can subscribe to links posted by rhickey in #clojure |
| 16:44 | bitbckt | and this makes me a happy boy |
| 16:46 | danlarkin | that's pretty neat |
| 16:46 | danlarkin | good feature |
| 16:47 | hiredman | yeah, I have seen a similar ircbot feature, that did not use delicious, I think tag by channel and by nick is a winner |
| 17:09 | hiredman | eh? |
| 17:09 | drewr | I have a process that's normally around 60MB on my laptop (OS X); it's 1000MB on the server. |
| 17:09 | walters | drewr: in what respect? |
| 17:09 | hiredman | oh, that rss |
| 17:10 | drewr | It loads a 4MB file into memory and serves info from it via Jetty. |
| 17:10 | walters | drewr: ok...one thing to keep in mind is that Apple's JVM is different from Sun JDK/OpenJDK |
| 17:10 | drewr | True, but why would the kernel provision that much extra? |
| 17:10 | walters | drewr: there are other possible major variables; is your server 64 bit? |
| 17:10 | drewr | Yes. |
| 17:10 | walters | that makes a big difference |
| 17:10 | walters | it will kick the jvm into --server mode by default |
| 17:11 | walters | and of course pointers are bigger |
| 17:11 | walters | (upcoming pointer compression will be cool) |
| 17:12 | drewr | I can understand all that, but 1GB? That's pretty outrageous. |
| 17:12 | walters | right, agreed |
| 17:12 | walters | it seems to me there's some sort of leak there |
| 17:12 | drewr | I need to watch it to see how much it's actually growing. |
| 17:12 | walters | e.g. are you using the same libraries and same versions thereof? |
| 17:13 | drewr | Yeah, I just deploy a jar with everything the same as the dev env. |
| 17:13 | Raynes | I think walters is Walter Bright undercover because he doesn't want the D programmers to know that Clojure is his secret pleasure. |
| 17:14 | walters | heh |
| 17:14 | walters | no, i'm just a gnome developer interested in languages |
| 17:14 | Raynes | Sure you are - Mister Bright. |
| 17:15 | walters | drewr: well, i'd try something like https://visualvm.dev.java.net/ there's a variety of tools out there |
| 17:16 | drewr | walters: Thanks. |
| 17:20 | tashafa | hello all |
| 17:23 | walters | drewr: oh, one other important thing to keep in mind is the default ergonomics |
| 17:23 | walters | drewr: http://java.sun.com/docs/hotspot/gc5.0/ergo5.html |
| 17:24 | walters | drewr: basically if your server has say 16G of ram, the JVM default heap size is going to be a lot larger than on your 1G laptop |
| 17:24 | walters | well if you're running OS X on a laptop you probably have at least 4G to make the OS run ;) |
| 17:25 | drewr | It does just fine with 3G :-) |
| 17:28 | drewr | According to the ergo site, the initial heap size should be 1/64th of the physical mem, which is around 175m for this box. |
| 17:30 | walters | drewr: *initial* - not maximum |
| 17:31 | walters | drewr: if you haven't set any other constraints the JVM will fill up to the maximum for most collectors AIUI |
| 17:31 | drewr | That's what it seems like. |
| 17:31 | drewr | Is it common to limit heap size or is that not recommended? |
| 17:32 | walters | it's all pretty busted - what we really want is for the VM to get memory pressure notifications from the kernel, and know when to GC more intelligently |
| 17:32 | drewr | I can do it with an external parent process but I'd rather not kill the child. |
| 17:32 | drewr | Yes! |
| 17:32 | walters | yeah, it's very common to set -Xmx in JVM launching scripts |
| 17:50 | Raynes | Exactly 100 users in #Scala. |
| 17:50 | Raynes | First time I've seen it that high since everybody thought Tony Morris offed himself. |
| 18:29 | Raynes | "Here's one way to reimplement null -> def mynull = error("you know you're going to get an NPE eventually anyway, so I'm just saving you the trouble.")" |
| 18:39 | brennanc | why can't I do (map #([%]) [1 2 3])? |
| 18:40 | brennanc | I have to do (map (fn [x] [x]) [1 2 3]) |
| 18:42 | hiredman | clojurebot: #()? |
| 18:42 | clojurebot | #() is not a replacement for fn |
| 18:42 | hiredman | brennanc: it is because of what #() is |
| 18:42 | hiredman | (macroepand-1 '#(foo)) |
| 18:42 | hiredman | ,(macroepand-1 '#(foo)) |
| 18:42 | clojurebot | java.lang.Exception: Unable to resolve symbol: macroepand-1 in this context |
| 18:42 | hiredman | ,(macroexpand-1 '#(foo)) |
| 18:42 | clojurebot | (fn* [] (foo)) |
| 18:43 | hiredman | ,(macroexpand-1 '#([x])) |
| 18:43 | clojurebot | (fn* [] ([x])) |
| 18:43 | kotarak | #(vector x) |
| 18:43 | hiredman | so [x] is being called as a function with no arguments |
| 18:43 | kotarak | ,(map #(vector %) [1 2 3]) |
| 18:43 | clojurebot | ([1] [2] [3]) |
| 18:43 | hiredman | ,(map vector (range 3)) |
| 18:43 | clojurebot | ([0] [1] [2]) |
| 18:44 | brennanc | I think I get it |
| 18:45 | hiredman | clojurebot: function literals is <reply>Function literals are cute, but overused |
| 18:45 | clojurebot | Ok. |
| 18:48 | kotarak | clojurebot: reader syntax of collections is <reply>Reader syntax of collections has gotchas |
| 18:48 | clojurebot | Ack. Ack. |
| 18:48 | brennanc | are you guys programming clojurebot to respond to things right there? |
| 18:49 | brennanc | clojurebot: function literals? |
| 18:49 | clojurebot | Function literals are cute, but overused |
| 18:49 | brennanc | hmm, cool |
| 18:49 | Chousuke | hiredman could really *program* it to respond to things. it's running in a repl :P |
| 18:50 | Chousuke | in fact I think he sometimes does that. new features just appear |
| 18:51 | brennanc | I was just glancing at the "Eliza" AI program last night from PAIP |
| 18:51 | jhawk28 | clojurebot: well? |
| 18:51 | clojurebot | Gabh mo leithsc�al? |
| 18:51 | brennanc | that would be a trip |
| 19:19 | drewr | walters: visualvm ftw. It showed me that the size of all the objs used by my program was only 16m :-) |
| 19:22 | walters | drewr: ah, so it probably is just that your program generated garbage until the jvm got close to the max 1G heap, then collected but is unable to shrink the heap |
| 19:23 | drewr | Yeah, because the usage was up to 200m before I GCed it. |
| 19:24 | drewr | http://img11.imageshack.us/img11/6507/cljzipheap.png |
| 19:25 | drewr | That cliff at the right is where I hit the GC button. |
| 19:34 | Mec | what would the regex be for checking of a string doesnt contain a specific character? |
| 19:37 | durka42 | ,(map #(re-find #"^[^a]*$" %) ["this string contains an a" "this string does not"]) |
| 19:37 | clojurebot | (nil "this string does not") |
| 19:38 | durka42 | or you could just search for the character and invert the result... |
| 19:38 | Mec | weird, i thought ^[^a] would only check if a was the first character |
| 19:38 | durka42 | ^ says at the beginning |
| 19:38 | durka42 | [^a] says anything but \a |
| 19:39 | durka42 | * says zero or more times |
| 19:39 | durka42 | $ says end of string |
| 19:39 | Mec | ahh right right now i see |
| 20:13 | Mec | ,(Integer. (apply str (reverse (seq (str 543))))) |
| 20:13 | clojurebot | 345 |
| 20:13 | Mec | any thoughts on a better way? |
| 20:16 | durka42 | hmm, putting digits back together is pretty easy |
| 20:16 | durka42 | ,(reduce #(+ (* 10 %1) %2) [1 2 3]) |
| 20:16 | clojurebot | 123 |
| 20:16 | durka42 | how to get them apart in the first place, though |
| 20:17 | Mec | they're characters after calling (reverse) not integers |
| 20:18 | Mec | ,(reverse (str 123)) |
| 20:18 | clojurebot | (\3 \2 \1) |
| 20:18 | jsankey | take them apart by dividing by 10? |
| 20:20 | durka42 | yeah |
| 20:20 | durka42 | ,(loop [n 123 rev 0] (if (< n 1) rev (recur (int (/ n 10)) (+ (* 10 rev) (mod n 10))))) |
| 20:20 | clojurebot | 321 |
| 20:21 | durka42 | i wonder if there's a more expressive way to express that |
| 20:21 | Mec | ,(time (loop [n 123456789 rev 0] (if (< n 1) rev (recur (int (/ n 10)) (+ (* 10 rev) (mod n 10)))))) |
| 20:21 | clojurebot | 987654321 |
| 20:21 | clojurebot | "Elapsed time: 2.531 msecs" |
| 20:22 | durka42 | ,(time (Integer. (apply str (reverse (seq (str 123456789)))))) |
| 20:22 | clojurebot | 987654321 |
| 20:22 | clojurebot | "Elapsed time: 0.435 msecs" |
| 20:22 | Mec | interesting |
| 20:22 | Mec | > ,(time (Integer. (apply str (reverse (str 123456789))))) |
| 20:22 | Mec | ,(time (Integer. (apply str (reverse (str 123456789))))) |
| 20:22 | clojurebot | 987654321 |
| 20:23 | clojurebot | "Elapsed time: 0.353 msecs" |
| 20:23 | Mec | i'd have thought the math would be faster |
| 20:24 | jsankey | is there a way to get the whole and remainder parts of a rational, so you don't need to divide and mod separately? |
| 20:24 | Chouser | I don't think so. rem and quot are the way. |
| 20:24 | durka42 | ,(.numerator (/ 123 10)) |
| 20:24 | clojurebot | 123 |
| 20:25 | Chouser | ,(map #(% 7 4) [quot rem]) |
| 20:25 | clojurebot | (1 3) |
| 20:25 | Chouser | durka42: ooh. |
| 20:25 | Chouser | o |
| 20:25 | Chouser | oh |
| 20:25 | durka42 | no that wasn't it, my mistake |
| 20:25 | durka42 | quot makes it a lot faster actually |
| 20:26 | durka42 | ,(time (loop [n 123456789 rev 0] (if (< n 1) rev (recur (quot n 10) (+ (* 10 rev) (mod n 10)))))) |
| 20:26 | clojurebot | 987654321 |
| 20:26 | clojurebot | "Elapsed time: 0.816 msecs" |
| 20:26 | durka42 | ,(time (loop [n 123456789 rev 0] (if (< n 1) rev (recur (quot n 10) (+ (* 10 rev) (rem n 10)))))) |
| 20:26 | clojurebot | 987654321 |
| 20:26 | clojurebot | "Elapsed time: 0.748 msecs" |
| 20:26 | Mec | ya rem is slightly faster than mod too |
| 20:26 | durka42 | the obvious way is still faster :) |
| 20:27 | Mec | i wouldnt call: turning a number into a string into a sequence, reverse, back to string to int obvious :D |
| 20:27 | durka42 | you would think the basic operations would be the same |
| 20:27 | durka42 | int->string by dividing and modding by 10 |
| 20:27 | durka42 | string->int by multiplying and adding |
| 20:27 | durka42 | but it's implemented in native code |
| 20:28 | durka42 | FSVO native |
| 20:29 | Mec | ,(Integer. "6952014971") |
| 20:29 | clojurebot | java.lang.NumberFormatException: For input string: "6952014971" |
| 20:29 | Mec | what should i use instead of integer? |
| 20:30 | forest | too big |
| 20:30 | forest | Long will be fine |
| 20:31 | Mec | naw still too small, what's the class for bignum or bigint, whatever it is |
| 20:31 | forest | BigInteger |
| 20:31 | Mec | there we go, thanks |
| 21:05 | Mec | any thoughts why (count string) is faster than (.length string) |
| 21:05 | Chouser | I don't buy it. :-) |
| 21:07 | Chouser | oh. reflection |
| 21:08 | Mec | hmm |
| 21:08 | Mec | makes sense i spose |
| 21:09 | Chouser | (.length #^String x) is about 4 or 5 times faster (count x) |
| 21:10 | Mec | that gives me a couple of errors |
| 21:10 | Chouser | (.length x) for unhinted x is about 100 times slower than (count x) |
| 21:10 | Mec | (.length #^String "123") |
| 21:11 | Mec | hmm did i kill it |
| 21:11 | Mec | ,(.length #^String "123") |
| 21:11 | clojurebot | Metadata can only be applied to IMetas |
| 21:11 | Chouser | ,(let [x "123"] (.length #^String x)) |
| 21:11 | clojurebot | 3 |
| 21:13 | Mec | ,(let [x (apply str (take 1000 (repeat 1)))] (time (.length x)) (time (.length #^String x)) (time (count x))) |
| 21:13 | clojurebot | 1000 |
| 21:13 | clojurebot | "Elapsed time: 0.216 msecs" "Elapsed time: 0.092 msecs" "Elapsed time: 0.0060 msecs" |
| 21:14 | Chouser | it's hard to get consistent results from microbenchmarks, especially on the JVM |
| 21:15 | Mec | true |
| 21:16 | Chouser | so it's good to put the the code you want to run in a function and call it lots of times each time you call it, make sure it's doing enough iterations to last at least a tenth of a second |
| 21:16 | Chouser | make sure your processor doesn't change speeds |
| 21:17 | Chouser | when you can run the same code a few times in row and get roughly the same number, then note that and try your next test case. |
| 21:20 | dreish | I like the word "performant", because it's like shorthand for "I don't know what I'm talking about, don't bother listening to me." |
| 21:21 | Chouser | heh |
| 21:27 | Mec | is there a version of max that would work for strings? |
| 21:29 | durka42 | depends what you mean by the maximum string :p |
| 21:29 | durka42 | there's the new max-key |
| 21:29 | Mec | using compare |
| 21:30 | Chouser | gnuvince: have I dropped the ball greatest/least ? |
| 21:33 | Chouser | the github project is gone. :-( |
| 21:35 | gnuvince_ | Chouser: yeah, I deleted it. I still got a copy on my hard drive, you want? |
| 21:35 | Chouser | gnuvince_: where did we leave it? I thought i was suppose to look it over and put it in contrib. |
| 21:36 | gnuvince_ | The issue sort of just died. |
| 21:36 | gnuvince_ | I'll put the repo back up. |
| 21:39 | Raynes | I'm one chapter away from completing Programming Clojure |
| 21:39 | jsankey | any zip/xml-zip gurus out there? |
| 21:40 | jsankey | should it be possible for (remove (next (down loc))) to throw an NPE if (node (next (down loc))) gives me back something sensible? |
| 21:40 | gnuvince_ | Chouser: http://github.com/gnuvince/clojure-greatest-smallest/tree/master |
| 21:40 | Chouser | gnuvince_: I think the functionality is very useful. |
| 21:50 | jsankey | more specifically: i have xml like <root><foo/><bar/><baz/></root>, and a function to remove by tag name |
| 21:50 | jsankey | if i i remove :foo it works, but :bar and :baz both give NPEs |
| 21:51 | jsankey | any pointers greatly appreciated (totally new to clojure and .zip) |
| 21:54 | Chouser | ,#'remove |
| 21:54 | clojurebot | #'clojure.core/remove |
| 21:54 | Chouser | ,#'clojure.zip/remove |
| 21:54 | clojurebot | #'clojure.zip/remove |
| 21:55 | Chouser | jsankey: which remove are you using? |
| 21:55 | jsankey | Chouser: zip.remove |
| 21:59 | jsankey | the tag stripping function is:(defn strip [root tag] |
| 21:59 | jsankey | (loop [loc root] |
| 21:59 | jsankey | (if (zip/end? loc) |
| 21:59 | jsankey | (zip/root loc) |
| 21:59 | jsankey | (let [node (zip/node loc)] |
| 21:59 | jsankey | (recur (zip/next (if (= (:tag node) tag) |
| 21:59 | jsankey | (zip/remove loc) |
| 21:59 | jsankey | loc))))))) |
| 22:08 | slashus2 | ugh |
| 22:11 | hiredman | adding a (-> loc zip/node println) can be helpful for debugging |
| 22:12 | jsankey | hiredman: thanks, i'll try it |
| 22:14 | hiredman | ,(require '[clojure.zip :as zip]) |
| 22:14 | clojurebot | nil |
| 22:14 | hiredman | ugh |
| 22:16 | hiredman | the idea of futzing with xml/parse until it reads from a string is very discouraging |
| 22:16 | jsankey | hmmm, it just shows the bar node i expect before the 'splosion |
| 22:17 | hiredman | I think remove on bar will try to return foo which has been removed |
| 22:18 | hiredman | I would print the output of the remove |
| 22:18 | cconstantine | What's the replacement for lazy-cons? |
| 22:19 | hiredman | lazy-seq |
| 22:19 | jsankey | hiredman: it happens when just removing :bar, without touching :foo |
| 22:19 | cconstantine | it's not in the docs... whats the api? |
| 22:19 | hiredman | ,(doc lazy-seq) |
| 22:19 | clojurebot | "([& body]); Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequent seq calls. Any closed over locals will be cleared prior to the tail call of body." |
| 22:19 | cconstantine | ah, 'doc' appears useful :) |
| 22:19 | hiredman | the web site api reflects the last release |
| 22:20 | jsankey | you can feed a string to xml/parse by wrapping it in java crud: (java.io.ByteArrayInputStream. (.getBytes "str")) |
| 22:20 | Chouser | ,(-> "<root><foo/><bar/><baz/></root>" java.io.StringReader. org.xml.sax.InputSource. clojure.xml/parse clojure.zip/xml-zip clojure.zip/down clojure.zip/remove) |
| 22:20 | clojurebot | java.lang.NoClassDefFoundError: clojure/zip$xml_zip__5926$fn__5928 |
| 22:21 | Chouser | oh |
| 22:21 | hiredman | ,(import 'java.io.ByteArrayInputStream) |
| 22:21 | clojurebot | nil |
| 22:21 | hiredman | ,(import 'org.xml.sax.InputSource) |
| 22:21 | clojurebot | nil |
| 22:21 | cconstantine | hiredman: Firefox's find can't find lazy-seq in the api doc |
| 22:21 | Chouser | anyway, that works. but if you put clojure.zip/next before the remove, NPE |
| 22:21 | hiredman | cconstantine: as I said, the website api reflects the latest release |
| 22:22 | hiredman | which was back in december |
| 22:22 | cconstantine | hiredman: ahhh, and if I pulled from svn I may have something newer than 'latest' |
| 22:22 | cconstantine | hiredman: ok, thanks :) |
| 22:22 | hiredman | you have svn, not a release |
| 22:27 | jsankey | probably an faq: but how do i get to the line of clojure code where the npe occurs? |
| 22:27 | pstickne | is there a yacc and/or well-documented p-c library and/or other tool for creating a simpler parser? |
| 22:27 | Chouser | (.printStackTrace *e) |
| 22:28 | pstickne | I found fnparse and the parser from kotka (based on haskell's p-c?) |
| 22:28 | pstickne | But they are both only barely documented. |
| 22:28 | Chouser | I've heard good things about fnparse |
| 22:29 | pstickne | I guess I'll sit down with it a bit longer then :) |
| 22:29 | jsankey | ah - sorry - i see if i learn how to use SLIME i can dig a little |
| 22:37 | pstickne | how can I add a path to closure files so they will be found? e.g. my source is foo.clj and I want to access fnparse/src/fqnstartshere |
| 22:37 | jsankey | i see (slowly) that the codepath is triggered by the loc having left siblings |
| 22:38 | pstickne | do I need to rely on the classpath? :( |
| 22:43 | Chouser | 'branch?' returns true, but 'down' NPEs |
| 22:43 | jsankey | yeah, something like that |
| 22:44 | hiredman | pstickne: the path to fnparse needs to be on the classpath, then you can use require or use |
| 22:44 | pstickne | hiredman: darn, I wish I could ditch that wretched thing :) |
| 22:44 | jsankey | so if i replace branch? with false for this simplistic case it works |
| 22:45 | jsankey | i think perhaps the test needs to be more than just branch? i.e. branch? and has at least one child? |
| 22:45 | hiredman | ~jar directory |
| 22:45 | clojurebot | with java6(jdk1.6) CLASSPATH can contain a "*" so /jar/dir/* will suck in all the jars in the /jar/dir directory, this also works with swank-clojure-extra-classpaths in emacs, alternatively you can use this shell snippet: find .jars/ -type f -name \*.jar -print0|xargs -0|sed "s/ /:/g" |
| 22:45 | jsankey | admittedly i am in way over my head atm :) |
| 22:46 | hiredman | ~namespace |
| 22:46 | hiredman | clojurebot: eh? |
| 22:46 | clojurebot | It's greek to me. |
| 22:46 | hiredman | clojurebot: namespace |
| 22:46 | hiredman | clojurebot: namespaces |
| 22:46 | 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 |
| 22:47 | Chouser | jsankey: the implementation of 'branch?' depends on the kind of tree |
| 22:47 | pstickne | arg. |
| 22:48 | pstickne | is there a closure-contrib single-file download somewhere? :( |
| 22:48 | Chouser | for xml, it's (complement string?) |
| 22:49 | jsankey | Chouser: according to the docs, branch? can return true even if there are no children atm |
| 22:49 | pstickne | well, this sucks :( |
| 22:49 | jsankey | Chouser: which seems like bad news for the -> down rightmost that it can trigger? |
| 22:50 | Chouser | hm... |
| 22:51 | jsankey | if i make it: (and (branch? loc) (not (empty? (children loc)))) it works |
| 22:51 | jsankey | for some value of works, anyway |
| 22:51 | hiredman | ,(pl inc $ inc $ inc $ 0) |
| 22:51 | clojurebot | 3 |
| 22:51 | pstickne | svn: OPTIONS of 'http://clojure-contrib.googlecode.com/svn/trunk': Could not resolve hostname `clojure-contrib.googlecode.com': Host not found (http://clojure-contrib.googlecode.com) :( |
| 22:52 | hiredman | ontrib |
| 22:52 | hiredman | grrr |
| 22:52 | Drakeson` | what is the inverse of prxml? |
| 22:52 | hiredman | ~contrib |
| 22:52 | clojurebot | contrib is http://code.google.com/p/clojure-contrib/ |
| 22:52 | pstickne | code.google.com/* stuff usually contains the most useless outdated links in my experience :( |
| 22:52 | hiredman | hmmm |
| 22:53 | Drakeson` | (clojure.contrib.prxml) |
| 22:53 | Chouser | jsankey: i think that might be the right fix |
| 22:53 | hiredman | pstickne: my svn checkout of contrib works fine |
| 22:54 | jsankey | Chouser: if it is, i would consider it a fluke, as it is 3am here and i'm starting to get parens etched into my retinas ;) |
| 22:54 | pstickne | svn: Server sent unexpected return value (400 Bad Request) in response to OPTIONS request for 'http://code.google.com/p/clojure-contrib' :( |
| 22:54 | Chouser | jsankey: would you mind writing up a runnable example that demonstrates the problem, posting it to the google group? |
| 22:54 | pstickne | hiredman: can I get the command you used? :p |
| 22:55 | jsankey | np, i'll do so (later) in the morning |
| 22:55 | hiredman | pstickne: well I already have it checkout so I just "svn up" |
| 22:55 | hiredman | ugh, something is very wrong with quotes here |
| 22:55 | pstickne | hiredman: can I grab the url via svn info? :) |
| 22:56 | jsankey | Chouser, hiredman: thanks for your help, i'm out for the night |
| 22:57 | hiredman | pstickne: it is the same url that is on the source page of the googlecode site |
| 22:57 | pstickne | hiredman: then why is it giving me such odd errors :( |
| 22:58 | pstickne | oh, I give up. it works now. stupid DNS fail. |
| 22:58 | hiredman | ~works on my machine |
| 22:58 | clojurebot | http://haacked.com/images/haacked_com/WindowsLiveWriter/IConfigMapPathIsInaccessibleDueToItsProt_1446B/works-on-my-machine-starburst.png |
| 23:03 | Raynes | ~The phone rang and nobody was there, as I put down the phone... Suddenly... |
| 23:03 | clojurebot | No entiendo |
| 23:03 | Raynes | o_o |
| 23:06 | hiredman | from amidst the confusion, sudden... |
| 23:07 | pstickne | and of course fnparse has an error with the current version of clojure/contrib :( |
| 23:09 | Raynes | Oh no. |
| 23:09 | Raynes | The world shall surely end! |
| 23:10 | pstickne | Raynes: :( |
| 23:10 | Raynes | I'm just kidding, I feel your pain. |
| 23:11 | pstickne | there is definitely something good about object-qualified names :( |
| 23:12 | pstickne | and same for static types.. |
| 23:12 | pstickne | (next tokens) is what dies :( |
| 23:13 | Chouser | you've got clojure from svn? |
| 23:18 | pstickne | Chouser: the 20081217 jar from the main site |
| 23:19 | pstickne | Trying the svn now with fingers crossed... |
| 23:19 | pstickne | Err... uck. I don't want to build it :p |
| 23:20 | pstickne | oh, maven, yay! |
| 23:21 | pstickne | hmm, it's also tagged 20081217 :( |
| 23:21 | Raynes | pstickne: Building it is as simple as typing ant build :p no special stuff. Or maven. |
| 23:22 | Drakeson | how do you write build.xml files? do you do it by hand? is there a clojure tool to create build.xml files? |
| 23:22 | pstickne | Raynes: just built it, that was even simpler then I thought \o/ |
| 23:22 | pstickne | And it works \o/ |
| 23:23 | pstickne | (So what /is/ next? The API only shows something wrt. hierarchies) |
| 23:23 | Raynes | Build.xml is an ant build script. You write them by hand. I don't suppose there is a tool to create them, IDE's generate them for building though, but not quite what you are thinking about. |
| 23:23 | durka42 | pstickne: do the same for contrib :) |
| 23:24 | Raynes | durka42: Didn't he /have/ to? You can't download C-C. |
| 23:24 | Raynes | There are no releases the last time I checked >_> |
| 23:24 | durka42 | meh? oh, i thought he was talking about building the main clojure |
| 23:24 | durka42 | that'll teach me to jump into the middle of conversations |
| 23:24 | Raynes | He did build the main Clojure. |
| 23:25 | Raynes | But in order to get Clojure-Contrib you have to svn it I thought. |
| 23:25 | durka42 | as far as i know |
| 23:25 | pstickne | yeah, I had to get c-c from svn -- but no build for it |
| 23:25 | pstickne | (or at least none I ran :p) |
| 23:25 | Raynes | There is a build file for it. |
| 23:25 | Chouser | there is one, but you hardly ever need it. |
| 23:26 | Raynes | It just .jars it. |
| 23:26 | Chouser | pstickne: the web site largely documents the release. now you're on svn trunk, you're way ahead of all that. :-) |
| 23:26 | Raynes | Isn't much use for it, it doesn't compile it or anything it just jars it. I jarred it because netbeans borks on folders. |
| 23:26 | pstickne | Chouser: O.o |
| 23:26 | durka42 | you can get it to compile them |
| 23:26 | Chouser | pstickne: so get used to using the doc and find-doc functions |
| 23:26 | Raynes | (doc cons) |
| 23:26 | clojurebot | Returns a new seq where x is the first element and seq is the rest.; arglists ([x seq]) |
| 23:27 | pstickne | Chouser: just from the repl? |
| 23:27 | Chouser | pstickne: you can read http://clojure.org/lazy for a sense of some of the big changes since the last release |
| 23:27 | Chouser | pstickne: yes |
| 23:27 | Raynes | ,(find-doc "cons") |
| 23:27 | clojurebot | java.lang.NoClassDefFoundError: clojure/core$ns_interns__4302$fn__4304 |
| 23:27 | Raynes | Well, you get the point. |
| 23:27 | pstickne | thanks :) |
| 23:28 | Raynes | You're welcome. |
| 23:28 | durka42 | at this point Chouser should plug his c.c.repl-utils |
| 23:28 | Raynes | After I read this, I will have knowledge of every major feature in Clojure. |
| 23:28 | Chouser | I'll go to bed instead. |
| 23:28 | Raynes | \o/ |
| 23:43 | stuhood | whats the function that generates an output sequence that alternates between input sequences? |
| 23:44 | cmvkk | interleave? |
| 23:44 | stuhood | ahh |
| 23:45 | stuhood | cmvkk: thanks a lot! |
| 23:45 | stuhood | synonyms, oi |