2009-09-07
| 03:50 | joha1 | I cannot find any example of connecting clojure.contrib.sql to an Oracle DB. Can anyone help? |
| 03:51 | joha1 | Is it possible/tested at all? |
| 04:00 | joha1 | nm, it works now |
| 04:07 | joha1 | added the Oracle DB info in http://en.wikibooks.org/wiki/Clojure_Programming/Examples/JDBC_Examples#Connection_Examples, in case someone else has a similar problem in the future |
| 04:37 | joha1 | From a DB I get strings like "(aaa bbb ccc)" which I want to convert to list/vectors or symbols, in this case (aaa bbb ccc) or similar. I tried variations of eval and apply but no luck. Any suggestions? |
| 04:39 | Chousuke | use read-string first |
| 04:39 | Chousuke | ,(doc read-string) |
| 04:39 | clojurebot | "([s]); Reads one object from the string s" |
| 04:39 | joha1 | ah, thanks |
| 04:39 | Chousuke | beware of #=() though |
| 04:40 | Chousuke | ,'#=(println "foo") ; read-time evaluation |
| 04:40 | clojurebot | foo |
| 04:40 | joha1 | ok, will keep it in mind. Should be enough for my needs anyway, so thanks again |
| 04:50 | jdz | or bind *read-eval* to false |
| 04:51 | jdz | ,(binding [*read-eval* false] (read-string "#=(println foo)")) |
| 04:51 | clojurebot | java.lang.RuntimeException: java.lang.Exception: EvalReader not allowed when *read-eval* is false. |
| 05:12 | LauJensen | Gents, can I have some thoughts? http://bestinclass.wordpress.com/2009/09/07/java-vs-clojure-lets-talk-ceremony/ |
| 05:22 | liwp | LauJensen: I just started reading, but just a quick comment: I don't think you should assert that "most functionality for the least amount of code" is always good. I think you mean that you don't want boiler plate code if you can avoid that, but that's not the same thing. E.g. J will give you very succint code, but no one will be able to read it after it's been written. Also, Haskell will give you very succint code, |
| 05:22 | liwp | but it takes a longer time to write that code. |
| 05:23 | LauJensen | Ok I see your point |
| 05:23 | LauJensen | It was meant in the context of ceremony |
| 05:24 | liwp | yeah, and it makes sense if you read it that way and I agree with the sentiment :-) |
| 05:24 | LauJensen | But if you can get to the bottom without strong grievances I'll post it on DZone :) |
| 05:25 | liwp | Ok, I'll get back to you when I'm done with it (might be a while, I'm at work) |
| 05:25 | LauJensen | Fair enough - Dont get in any trouble on my account :) |
| 05:26 | jdz | "since is a functional language" |
| 05:26 | LauJensen | thx |
| 05:26 | LauJensen | Very succint text |
| 05:26 | jdz | and the sentence should end with "in the core" i think |
| 05:27 | LauJensen | k |
| 05:27 | jdz | but i'm not native english speaker |
| 05:27 | LauJensen | Me neither :) |
| 05:27 | jdz | "not wanting win" -> "not wanting to win" |
| 05:28 | LauJensen | good catch |
| 05:28 | jdz | i wouldn't call let a macro |
| 05:28 | jdz | maybe just form |
| 05:28 | LauJensen | A true, its a special form |
| 05:29 | jdz | "it's" :) |
| 05:30 | liwp | LauJensen: I think you'll end up getting a lot of hatemail from Java developers!-) |
| 05:30 | jdz | "if i wanted ... I needed" -> "if i wanted ... I would need", but not completely sure |
| 05:30 | LauJensen | I certainly hope so |
| 05:30 | liwp | LauJensen: but more seriously, I think you're example has some holes in it |
| 05:30 | jdz | "your" |
| 05:30 | LauJensen | liwp: Like what? |
| 05:30 | liwp | LauJensen: e.g. the import list can be reaplaced with "import java.util.*" |
| 05:31 | LauJensen | liwp but to a different effect |
| 05:31 | liwp | LauJensen: I agree with you, but this is what the Java devs are going to say |
| 05:31 | LauJensen | True - Maybe I should prepare my defences |
| 05:32 | liwp | LauJensen: also the iterator creation is unnecessary with the new for syntax: for (String s : list) { ... } |
| 05:32 | liwp | which reduces a whole bunch of lines from your example |
| 05:32 | LauJensen | liwp: Spell it out for me |
| 05:32 | liwp | ~paste |
| 05:32 | clojurebot | lisppaste8, url |
| 05:32 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 05:33 | liwp | LauJensen: urgh, you're code is an image rather than text so I can't copy paste it! |
| 05:33 | LauJensen | sec |
| 05:33 | lisppaste8 | Lau pasted "for liwp" at http://paste.lisp.org/display/86700 |
| 05:33 | LauJensen | You can annote that |
| 05:34 | liwp | LauJensen: ok, give me a minute |
| 05:34 | LauJensen | you got it |
| 05:35 | lisppaste8 | liwp annotated #86700 "untitled" at http://paste.lisp.org/display/86700#1 |
| 05:37 | LauJensen | If you were to completely mimic the first one, you'd be down from 28 to 22. Thanks alot for the input - I didnt know :) |
| 05:37 | miha | ,(+ 1 2) |
| 05:37 | clojurebot | 3 |
| 05:37 | liwp | And the last thing is that you can probably use something like java.util.Arrays.asList() to create the original list from an array of literal Strings which will make your point about adding a new element to the list a bit moot |
| 05:37 | liwp | so that would take another ~5 lines away from the java example |
| 05:39 | liwp | LauJensen: so I do agree with you that Java forces a lot of ceremony on you, especially since everything must be in a class, but I think you should come up with a stronger example |
| 05:40 | LauJensen | liwp -I will dig into Java more in the coming weeks. Mainly what I was going for was something which had grounds for comparison in the approach itself - otherwise I could have stuck with my one-liner :) |
| 05:41 | lisppaste8 | liwp annotated #86700 "untitled" at http://paste.lisp.org/display/86700#2 |
| 05:41 | liwp | LauJensen: I think your java hatemail will include something like the last annotation |
| 05:41 | LauJensen | hehe, nice |
| 05:42 | liwp | that's 14 lines I think, so still longer than your clojure version |
| 05:42 | Chousuke | the java-like clojure code is not very idiomatic either I think. hmm. |
| 05:42 | LauJensen | 17 |
| 05:43 | liwp | but you can also fiddle with the formatting to make the Java shorter / clojure longer |
| 05:43 | liwp | LauJensen: Oh, one final thing is that your class name should be Capitalised |
| 05:44 | LauJensen | I think if I wanted to do a succint vs succint version, I would put your latest in the post liwp. But the point is not wether or not you can write succint java code, I think you can. Its on ceremony. And at the end of the day, you can do functional programming in QBasic if you want, but what does your language default to ? thats primarily the questions I want to raise |
| 05:44 | liwp | someone's going to point that out in your comments and call you a Java newby ;) |
| 05:45 | liwp | LauJensen: sure, and I agree with you, but I don't think you're going to convince a Java head of that with your current example |
| 05:45 | LauJensen | liwp: Dont ever get me wrong: I dont want converts :) |
| 05:46 | Chousuke | ,(reduce (fn [acc item] (if (some (partial = item) acc) acc (conj acc item))) [] ["foo" "bar" "zonk" "foo"]) ; explicit loops are ugly |
| 05:46 | clojurebot | ["foo" "bar" "zonk"] |
| 05:46 | jdz | comparing languages using small examples like that will inevitably turn into language flamewars |
| 05:46 | liwp | jdz: exactly |
| 05:47 | LauJensen | liwp: I'm extending the conclusion as we speak |
| 05:47 | Chousuke | reduce is something that's a basic functional tool so it's rather like the for loop special syntax in the java code :P |
| 05:47 | Chousuke | and you can't write a reduce in Java without even more ceremony. |
| 05:48 | LauJensen | Its updated, I think that'll discourage the first few haters |
| 05:48 | liwp | Chousuke: do you use partial and comp a lot? I love them in Haskell, but I don't like the look of them in Clojure at all. Plus the #() form is a good replacement for partial in most cases |
| 05:48 | Chousuke | I use #() most of the time I think |
| 05:49 | Chousuke | #(= item %) just looks a bit noisy |
| 05:49 | LauJensen | Chousuke: Your example is very nice for me, but for an uknowing crowd its perlishly nasty |
| 05:49 | Chousuke | LauJensen: the loop code is even worse though :P |
| 05:49 | liwp | heh, I'd prefer that, I think, to (partial = item)... |
| 05:49 | LauJensen | Its readable for people coming from imperative languages |
| 05:50 | Chousuke | LauJensen: but it looks noisy compared to the java loop :/ |
| 05:50 | Chousuke | (because it's denser) |
| 05:50 | eevar2 | LauJensen: why use a loop at all? |
| 05:50 | LauJensen | Hmm, yes... I'm reconsidering |
| 05:50 | LauJensen | Its not bad actually |
| 05:51 | Chousuke | include both, just to show that explicit loops are often not needed. |
| 05:51 | eevar2 | the Java approach would be something like Set uniques = new HashSet( arrayListOfStrings ); |
| 05:51 | liwp | eevar2: true! |
| 05:51 | Chousuke | eevar2: you mean like (vec (set arraylist))? |
| 05:51 | ol3 | ,(doc slurp) |
| 05:51 | clojurebot | "([f] [f enc]); Reads the file named by f using the encoding enc into a string and returns it." |
| 05:51 | liwp | like jdz said, these thing will inevitably end up in flame wars |
| 05:52 | LauJensen | Chousuke: I think I'll go with yours, I assume thats okay |
| 05:52 | Chousuke | sure. |
| 05:53 | eevar2 | Chousuke: yup. writing convoluted code for simple stuff like this makes both languages look bad ;) |
| 05:54 | eevar2 | s/convoluted/naive/ |
| 05:57 | ol3 | hello, clojure-bot supports an encoding for slurp my clojure did not. I have clojure 1.0, what is its default encoding? |
| 05:57 | jdz | depends on your JVM |
| 05:57 | jdz | and environment |
| 05:58 | jdz | but you can specify one with -Dfile.encoding when starting JVM |
| 05:58 | LauJensen | I updated the post. I think its good now :) |
| 05:59 | jdz | ol3: but relying on system supplied defaults will get you into trouble sooner or later, anyway |
| 05:59 | ol3 | I want to specify the encoding at runtime, so i don't use slurp, right? |
| 06:00 | jdz | i guess so |
| 06:00 | jdz | i have written a utility function for myself |
| 06:00 | jdz | should be somewhere on lisppaste |
| 06:01 | jdz | others also have provided their versions |
| 06:01 | jdz | dunno why the encoding stuff is not in the core |
| 06:02 | ol3 | maybe it will |
| 06:02 | ol3 | ,(doc slurp) |
| 06:02 | clojurebot | "([f] [f enc]); Reads the file named by f using the encoding enc into a string and returns it." |
| 06:02 | jdz | oh, see, you can specify the encoding :) |
| 06:02 | jdz | i still use my own version |
| 06:02 | jdz | http://paste.lisp.org/display/80970 |
| 06:03 | jdz | because i want to read compressed files |
| 06:04 | ol3 | but encoding is not in the 1.0 version |
| 06:04 | Chousuke | Why are you not using BufferedReader or something? :/ |
| 06:05 | jdz | because my Java-fu is lacking maybe |
| 06:05 | Chousuke | (BufferedReader. (InputStreamReader. (SomeInputStream. ...))) |
| 06:08 | LauJensen | ok guys, its live: http://www.dzone.com/links/java_vs_clojure_lets_talk_ceremony.html |
| 06:08 | LauJensen | Thanks a lot everybody for taking the time |
| 06:08 | ol3 | Chousuke: thanks, looks good |
| 06:09 | Chousuke | There might be more specialised readers than InputStreamReader though. |
| 06:09 | Chousuke | check the docs :) |
| 06:10 | jdz | ye, i use FileInputStream |
| 06:11 | jdz | but thanks for pointing this out |
| 06:11 | jdz | the buffering exercise was fun, anyway |
| 06:11 | Chousuke | LauJensen: your idiomatic clojure code is missing a [ |
| 06:12 | Chousuke | LauJensen: (let [lst "foo" "bar" ... |
| 06:12 | jdz | i was just learning Clojure at that time |
| 06:12 | LauJensen | thanks for staying awake Chousuke |
| 06:12 | eevar2 | LauJensen: why do you import java.util.List when you never use the interface? |
| 06:12 | LauJensen | eevar2: artifact, thanks for pointing it out |
| 06:15 | jdz | also, the indentation of clojure code is very un-ideomatic |
| 06:15 | jdz | and why is the code in images, anyway? |
| 06:16 | LauJensen | wordpress.com doesnt to very nice code highlighting |
| 06:16 | jdz | does it accept html? |
| 06:16 | LauJensen | yep |
| 06:17 | Chousuke | SVG images! |
| 06:17 | jdz | LauJensen: what editor are you using? |
| 06:17 | LauJensen | For? |
| 06:17 | jdz | making the code images |
| 06:18 | LauJensen | gnome-text |
| 06:18 | ol3 | you code use the <pre> tag, highlighting is overrated |
| 06:18 | LauJensen | ol3 alright, I'll try that the next time |
| 06:18 | LauJensen | images arent optimal |
| 06:19 | ol3 | if you really need highlighting, there is an htmlize package for emacs |
| 06:19 | ol3 | http://www.emacswiki.org/emacs/Htmlize |
| 06:20 | LauJensen | Sweeet :) |
| 06:21 | lisppaste8 | jdz pasted "ideomatic clojure code in emacs" at http://paste.lisp.org/display/86702 |
| 06:21 | jdz | using htmlize :) |
| 06:23 | jdz | and the let error is even preserved :) |
| 06:24 | ol3 | most of the time i do not use font-lock anymore... |
| 06:25 | jdz | pretty colors are essential for things published on the interwebs |
| 06:30 | ol3 | really? IMHO people only think there is an advantage in highlighting, because it looks nice/cool, but where is the real benefit? |
| 06:30 | LauJensen | speed |
| 06:30 | ol3 | speed? |
| 06:31 | LauJensen | yea, your eyes dont need to read everything, they bounce of the colors to the places you need to go, its grooooovy man :) |
| 06:32 | ol3 | I think this is an illusion, are there tests about this? |
| 06:32 | LauJensen | Dont need tests, its evident |
| 06:32 | jdz | i'm pretty sure having colors helps with navigation |
| 06:32 | Chousuke | the colours help make the structure clearer to me. |
| 06:33 | Chousuke | processing colour takes less mental effort than processing the actual text |
| 06:33 | Chousuke | so if I can ignore parts of code based on its colour, I am more efficient :) |
| 06:34 | Chousuke | and on the other hand, I might focus better on parts with an "important" colour |
| 06:34 | hiredman | at the very least rainbow parens are a must |
| 06:34 | jdz | not |
| 06:34 | Chousuke | not to me |
| 06:34 | hiredman | :/ |
| 06:34 | hiredman | they are great |
| 06:34 | Chousuke | I don't even look at parens much nowadays. |
| 06:34 | jdz | proper indentation is a must |
| 06:35 | Chousuke | I don't need to care which paren ends which expression because I know paredit takes care of that :) |
| 06:35 | ol3 | nope, the defn/defun is not important, it's at the beginning of the line anyway |
| 06:36 | ol3 | but nevermind, people are different |
| 06:36 | jdz | well, i'm more concerned with colorization of strings |
| 06:37 | Chousuke | the other thing is that colours are much more pleasant than just grey text |
| 06:37 | Chousuke | at least, when they have purpose. |
| 06:37 | _mst | the differences are interesting... I've always turned my syntax highlighting back to bold or not bold :) |
| 07:49 | ol3 | is there a standard way to update a map in a map? |
| 07:50 | ol3 | (dosync (alter map assoc :other-map (assoc (:other-map @map) :key :new-value))) |
| 07:50 | ol3 | |
| 07:51 | ol3 | @r |
| 08:00 | cgrand | (doc assoc-in) |
| 08:00 | clojurebot | "([m [k & ks] v]); Associates a value in a nested associative structure, where ks is a sequence of keys and v is the new value and returns a new nested structure. If any levels do not exist, hash-maps will be created." |
| 08:00 | cgrand | (doc update-in) |
| 08:00 | clojurebot | "([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created." |
| 08:01 | cgrand | ol3: (dosync (alter map assoc-in [:other-map :key] :new-value)) |
| 08:04 | ol3 | cgrand: thank you |
| 08:06 | ol3 | this is really cool! |
| 08:07 | ol3 | ,(assoc-in nil [:this :is :a :deep :structure] :value) |
| 08:07 | clojurebot | {:this {:is {:a {:deep {:structure :value}}}}} |
| 08:08 | cgrand | update-in and dissoc-in are cool too |
| 08:09 | ol3 | (doc dissoc-in) |
| 08:09 | clojurebot | "clojure.contrib.core/dissoc-in;[[m [k & ks as keys]]]; Dissociates an entry from a nested associative structure returning a new nested structure. keys is a sequence of keys. Any empty maps that result will not be present in the new structure." |
| 08:11 | ol3 | (doc dissoc-in) |
| 08:11 | clojurebot | "clojure.contrib.core/dissoc-in;[[m [k & ks as keys]]]; Dissociates an entry from a nested associative structure returning a new nested structure. keys is a sequence of keys. Any empty maps that result will not be present in the new structure." |
| 08:11 | ol3 | works even if keys are string |
| 08:13 | Chousuke | works with vectors too |
| 08:13 | Chousuke | at least, IIRC. |
| 08:14 | Chousuke | ,(update-in [2 [1 2 3]] [1 2] inc) |
| 08:14 | clojurebot | [2 [1 2 4]] |
| 08:19 | ol3 | why are references funcallable? |
| 08:20 | ol3 | just curious |
| 08:21 | cgrand | last time I asked, Rich told me to not rely on that -- it's undocumented |
| 08:22 | cgrand | I guess it may be some legacy from the time where refs and vars were the same thing |
| 08:23 | ol3 | so always use the @, ok |
| 08:57 | hamza | (doto frame (..) (.pack) (...)), pack call causes classcastexception? |
| 08:58 | hiredman | lisppaste8: url |
| 08:58 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 08:58 | hiredman | ↑ |
| 08:59 | lisppaste8 | hamza pasted "snake" at http://paste.lisp.org/display/86708 |
| 08:59 | hamza | it's the example from programming clojure.. |
| 09:01 | hiredman | what page? |
| 09:01 | jdz | the .pack call is commented out, though |
| 09:02 | hiredman | did you copy it out of the book, or have you tried from the source repo? |
| 09:02 | hamza | i copied from the book, i was testing if setSize would work thats why its commented out, with setSize it works but .pack causes exception |
| 09:04 | hiredman | ah |
| 09:04 | hiredman | you miscopied |
| 09:05 | hiredman | you are missing two * in game-panel |
| 09:05 | hiredman | hand copying a large chunk of code like can be troublesome |
| 09:06 | hamza | what am i missing? |
| 09:06 | hiredman | you are missing two calls to * |
| 09:06 | hiredman | the parens are there |
| 09:07 | hiredman | so you have two numbers there |
| 09:07 | hiredman | ,(1 2) |
| 09:07 | clojurebot | java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn |
| 09:07 | emacsen | What's the proper way to overload a function name that's used in the core? |
| 09:07 | hiredman | ^- |
| 09:07 | hiredman | ,(doc refer-clojure) |
| 09:07 | clojurebot | "([& filters]); Same as (refer 'clojure.core <filters>)" |
| 09:07 | hiredman | ,(doc refer) |
| 09:07 | clojurebot | "([ns-sym & filters]); refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to something else in the current nam |
| 09:08 | emacsen | thx |
| 09:08 | hiredman | refer-clojure has a corresponding :refer-clojure for the ns for |
| 09:08 | hiredman | form |
| 09:08 | emacsen | "name" fits my problemset too well |
| 09:09 | Jomyoot | How to define a function that takes variable number of inputs [a b] and [a b c] |
| 09:09 | Jomyoot | I cannot (defn) twice |
| 09:09 | Jomyoot | it erases the first (defn) |
| 09:09 | emacsen | Jomyoot, read the section on multiple arity |
| 09:09 | Jomyoot | in Java, I would just define the function twice with different inputs |
| 09:10 | emacsen | Jomyoot, functions can take multiple forms |
| 09:10 | hiredman | Jomyoot: there are many ways |
| 09:10 | emacsen | Jomyoot: http://clojure.org/functional_programming |
| 09:10 | achim | for example (defn foo ([a b] ...) ([a b c] ...)), or (defn foo [a b & [c]] ...) |
| 09:10 | emacsen | read the section on multiple arity |
| 09:11 | Jomyoot | thanks |
| 09:11 | hiredman | ,((fn ([a] a) ([a b] [a b])) 1) |
| 09:11 | clojurebot | 1 |
| 09:11 | hiredman | ,((fn ([a] a) ([a b] [a b])) 1 2) |
| 09:11 | clojurebot | [1 2] |
| 09:13 | emacsen | hiredman, thx for your help |
| 09:15 | emacsen | and what's the current prefered pretty-printer? |
| 09:16 | hiredman | ~scala (0 /: List(1,2,3))(_ + _) |
| 09:16 | clojurebot | Int = 6 |
| 09:17 | jdz | emacsen: clojure.contrib/pprint |
| 09:18 | liwp | hiredman: huh? |
| 09:18 | liwp | is that a reduce? |
| 09:18 | hiredman | I don't know scala |
| 09:18 | liwp | ok then :) |
| 09:18 | liwp | ~scala (0 /: List(1,2,3,4))(_ + _) |
| 09:18 | clojurebot | Int = 10 |
| 09:19 | liwp | I guess so |
| 09:19 | emacsen | clojure.contrib.pprint.PrettyWriter [Thrown class java.lang.ClassNotFoundException] |
| 09:19 | liwp | ~scala (1 /: List(1,2,3,4))(_ * _) |
| 09:19 | clojurebot | Int = 24 |
| 09:19 | ol3 | is the 'Programming Clojure' book good? |
| 09:19 | hiredman | you neeed to compile contrib properly |
| 09:19 | emacsen | hiredman, what do you mean by properly? :) |
| 09:20 | liwp | emacsen: with ant |
| 09:20 | hiredman | emacsen: run ant, and looking for a line with "Warning" in it, and follow the directions |
| 09:20 | emacsen | hiredman, ah, good point. I didn't compile clojure.contrib at all |
| 09:20 | emacsen | at least not the slime used one |
| 09:20 | jdz | emacsen: clojure.contrib.pprint/pprint i think the function is named |
| 09:20 | emacsen | thx |
| 09:20 | hiredman | well there is no clojure.contrib |
| 09:21 | Chouser | ~scala ( for( i <- 1 to 100 ) yield i * i ).foldLeft(0) ( _ + _ ) |
| 09:21 | clojurebot | Int = 338350 |
| 09:30 | AWizzArd | The class http://java.sun.com/products/javamail/javadocs/javax/mail/Flags.html has a field "Flag" which is a static inner class. This class has static fields, for example "SEEN". How can I name Flags.Flag.SEEN in Clojure? |
| 09:30 | Chousuke | AWizzArd: Flags§Flag/SEEN |
| 09:30 | Chousuke | er |
| 09:30 | Chousuke | $* |
| 09:30 | hiredman | haha |
| 09:31 | AWizzArd | Chousuke: unfortunately not |
| 09:31 | AWizzArd | ah |
| 09:32 | AWizzArd | what works is javax.mail.Flags$Flag/SEEN |
| 09:32 | AWizzArd | but Flags$Flag/SEEN not, although I imported Flags |
| 09:33 | AWizzArd | I get at java.lang.Exception: No such namespace: Flags$Flag when I do Flags$Flag/SEEN |
| 09:33 | cgrand | AWizzArd: you need to import Flags$Flag |
| 09:33 | AWizzArd | oh nice :) |
| 09:34 | AWizzArd | yes, that works |
| 09:34 | AWizzArd | thx |
| 09:47 | ol3 | is there a prog1 in clojure |
| 09:49 | hiredman | do |
| 09:49 | jdz | umm, not really |
| 09:49 | hiredman | ok |
| 09:49 | jdz | ,(doc do) |
| 09:49 | clojurebot | I don't understand. |
| 09:50 | ol3 | ,(doc 'do) |
| 09:50 | hiredman | ~progn |
| 09:50 | clojurebot | java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol |
| 09:50 | clojurebot | Excuse me? |
| 09:50 | hiredman | do is a special form |
| 09:50 | ol3 | to be more specific, i need a queue , one thread enques values another dequeues values |
| 09:50 | jdz | ol3: well you can write a simple macro with a let + do |
| 09:51 | AWizzArd | you could try a clojure.lang.PersistentQueue |
| 09:51 | jdz | ol3: then prog1 is completely not the tool for you |
| 09:51 | hiredman | ,(conj (clojure.lang.PersistentQueue/empty) 1) |
| 09:51 | clojurebot | java.lang.NoSuchFieldException: empty |
| 09:51 | hiredman | ,(conj (clojure.lang.PersistentQueue/EMPTY) 1) |
| 09:51 | clojurebot | (1) |
| 09:52 | hiredman | ,(peek (conj (clojure.lang.PersistentQueue/EMPTY) 1)) |
| 09:52 | clojurebot | 1 |
| 09:52 | hiredman | ,(pop (conj (clojure.lang.PersistentQueue/EMPTY) 1)) |
| 09:52 | clojurebot | () |
| 09:52 | hiredman | ,(pop (conj (clojure.lang.PersistentQueue/EMPTY) 1 2 3)) |
| 09:52 | clojurebot | (2 3) |
| 09:53 | AWizzArd | like lists, but you conj to the end |
| 09:53 | jdz | ,(conj (PersistentQueue/EMPTY) 1) |
| 09:53 | clojurebot | java.lang.Exception: No such namespace: PersistentQueue |
| 09:53 | ol3 | ah, this is exactly what i needed, thank you! |
| 09:53 | AWizzArd | right, it is undocumented and a little bit hidden :) |
| 09:54 | jdz | isn't clojure.lang used by default? |
| 09:54 | hiredman | nope |
| 09:54 | hiredman | ,(import 'clojure.lang.PersistentQueue) |
| 09:54 | clojurebot | clojure.lang.PersistentQueue |
| 09:54 | jdz | ,(conj (PersistentQueue/EMPTY) 1) |
| 09:54 | clojurebot | (1) |
| 09:54 | jdz | hehe, until next reboot i guess :) |
| 09:55 | AWizzArd | you could (import 'clojure.lang.PersistentQueue) first |
| 09:55 | AWizzArd | oh, hiredman was faster :) |
| 09:57 | jdz | is it possible to blow up clojurebot by importing too many namespaces? |
| 09:58 | Jomyoot | How to convert [1 2 3] into Java Array {1, 2, 3} |
| 09:58 | AWizzArd | ,(to-array [1 2 3]) |
| 09:58 | clojurebot | #<Object[] [Ljava.lang.Object;@57e9bb> |
| 09:59 | hiredman | ,(into-array [1 2 3]) |
| 09:59 | clojurebot | #<Integer[] [Ljava.lang.Integer;@150ad83> |
| 09:59 | AWizzArd | another alternative |
| 09:59 | hiredman | ,(into-array Integer/TYPE [1 2 3]) |
| 09:59 | clojurebot | #<int[] [I@196a671> |
| 09:59 | AWizzArd | ,(int-array 3 [1 2 3]) |
| 09:59 | Jomyoot | what's difference? |
| 09:59 | clojurebot | #<int[] [I@419710> |
| 09:59 | AWizzArd | Jomyoot: performance |
| 10:00 | Jomyoot | i think i need int-array |
| 10:00 | hiredman | Jomyoot: the type of the array |
| 10:00 | hiredman | the first one is an array of Objects |
| 10:00 | hiredman | the second an array of Integers, the third ints |
| 10:00 | Jomyoot | ,(int-array [1 2 3]) |
| 10:00 | clojurebot | #<int[] [I@bc03b> |
| 10:24 | ambient | anyone tried Clojure on the CLR? is it usable? |
| 10:32 | Fossi | as in .NET? |
| 10:33 | Fossi | i thought that was discontinued until new-new is done |
| 10:33 | ambient | oh ok :) |
| 10:33 | arbscht | really, when? |
| 10:33 | Fossi | i thought reimplementing all the persistent datastructures is just a little too painful :) |
| 10:34 | arbscht | looks active to me http://github.com/richhickey/clojure-clr/ |
| 10:34 | arbscht | don't use the one in contrib, that really is discontinued |
| 10:35 | dmiller2718 | ClojureCLR is active. It is usable, but I wouldn't use it for production use yet. |
| 10:35 | rsynnott_ | what's wrong with Clojure on the JVM, anyway? :) |
| 10:35 | dmiller2718 | Needs more people banging on it. |
| 10:35 | Fossi | ah. cool then |
| 10:36 | arbscht | dmiller2718: any plans to support mono? |
| 10:36 | rsynnott_ | seems like a hard project to get off the ground, given the limited CLR support on any platform other than Windows |
| 10:36 | Fossi | given that windows is still 90% of the market, maybe not so much |
| 10:37 | dmiller2718 | No reason why it can't be on Mono eventually. It's based on DLR, and that runs on Mono. There is a still a reliance on one class in vjslib (BigDecimal) that needs to be gotten rid of. |
| 10:38 | rsynnott_ | Fossi: rather less than 90% of the programmer market, though, and JVM works on 99.9% of the market |
| 10:41 | Fossi | well, deplying a java desktop app to windows is still a pain though |
| 10:42 | Fossi | although it is not so important anymore with the ubiquitious internet |
| 10:52 | AWizzArd | I have a big text file, which I currently load via read-lines. I would like to have Clojure compile that data into the .class file, so I don't have to deliver the text file. What is the idiom to do so? |
| 10:53 | liwp | AWizzArd: not exactly an answer to your question, but you could look into packaging the big text file into the jar that you distribute and then accessing it via the java resource methods |
| 10:53 | liwp | AWizzArd: i.e. the file would be 'hidden' from the user in the jar but still readable by the program |
| 10:54 | jdz | AWizzArd: or is it something like reading text file into Clojure (Java) data strutcures and then serializing them? |
| 10:56 | AWizzArd | It's text data which gets compiled into a regex |
| 10:58 | AWizzArd | what liwp suggested sounds doable, although it would be even nicer when during the load of the .class file all needed data is automtically loaded. |
| 10:58 | AWizzArd | In CL I would compile the regex and then dump an image for very fast load times. |
| 11:00 | AWizzArd | I already tried to make a single .clj file into which I put the long string. But it is too long and causes an exception :) |
| 11:19 | tomoj | AWizzArd: java.util.regex.Pattern implements Serializable |
| 11:20 | tomoj | oh but looks like they just serialize to the pattern string anyway |
| 11:24 | ol3 | "520um_die_ecke_gedacht_03.swf" |
| 11:24 | ol3 | (list "520um_die_ecke_gedacht_03.swf") |
| 11:24 | ol3 | oops, sry |
| 11:49 | Jomyoot | how do I access an inner java class ? |
| 11:49 | Jomyoot | A.B |
| 11:49 | Jomyoot | B is defined inside A |
| 11:50 | Jomyoot | A.B or (. A B) do not work |
| 11:50 | Jomyoot | A.B |
| 11:50 | Jomyoot | (. A B ) do not work |
| 11:50 | cgrand | A$B |
| 11:52 | Chousuke | Jomyoot: A$B, and you need to explicitly import the class |
| 11:52 | Chousuke | ~inner class |
| 11:52 | clojurebot | No entiendo |
| 11:52 | Chousuke | hmm |
| 11:52 | Jomyoot | darn |
| 11:52 | Jomyoot | thanks |
| 11:53 | Chousuke | clojurebot: inner class is <reply> To use an inner class Foo.Bar, import it with (import 'Foo$Bar), and you can refer to the class as Foo$Bar |
| 11:53 | clojurebot | 'Sea, mhuise. |
| 11:55 | Jomyoot | ,(int-array [ ]) |
| 11:55 | clojurebot | java.lang.NullPointerException |
| 11:55 | Jomyoot | ,(int-array [1]) |
| 11:55 | clojurebot | #<int[] [I@12bf469> |
| 11:55 | Jomyoot | now that's disturbing |
| 11:55 | Jomyoot | why cannot i have a int[] with size of 0 |
| 11:55 | Chousuke | ,(into-array Integer/TYPE []) |
| 11:55 | clojurebot | #<int[] [I@74bff8> |
| 11:56 | Chousuke | still, I suppose that is a bug. |
| 11:57 | ambient | is there any way to tab-complete java classes in clojure/emacs and rapidly jump to java classes documentation? |
| 11:57 | ambient | like (. frame <tab> lists all frame's methods |
| 11:57 | Jomyoot | ,(into-array Integer/TYPE [1 2 3]) |
| 11:57 | clojurebot | #<int[] [I@df980> |
| 11:58 | Jomyoot | is into-array Integer/TYPE the same as int-array? |
| 11:58 | ambient | or (FooJavaClass/<tab> also lists the possible options |
| 12:03 | Jomyoot | ,(int-array [1 2 3]) |
| 12:03 | clojurebot | #<int[] [I@1059fd6> |
| 12:06 | Fossi | doing something to the leaves of a tree. hints? |
| 12:07 | Jomyoot | #<Timestamp 2009-08-29 22:47:07.0> is a java.sql.TimeStamp, right? |
| 12:44 | hamza | anyone got etags to index .clj files? |
| 13:06 | emacsen | We can't escape durka42 ;) |
| 13:07 | durka42 | nope |
| 13:08 | LauJensen | Jomyoot: Yes |
| 13:14 | LauJensen | Gents, I was thinking of doing a follow up on this http://www.dzone.com/links/java_vs_clojure_lets_talk_ceremony.html either sticking with java/c# for a few posts or moving on to PHP/Python - any suggestions? :) |
| 13:30 | ambient | what i would be interested in is RoR or Django vs. web dev with Clojure |
| 13:32 | ambient | btw i think you could do distinct with just putting and getting items out of a set. (referring to that linked article) |
| 13:37 | LauJensen | Yea ok. Unfortunately I've only done webdev with C#/ASP, I'm blank on RoR/Django |
| 13:37 | LauJensen | (and ofc w. compojure) |
| 13:38 | ambient | i just think that Clojure being a lisp makes ORM and templating a bit different comparing to the traditional methods in OOP |
| 13:38 | arbscht | is compojure mature enough to warrant comparison? the api is unstable and even compojure.org isn't up yet |
| 13:43 | rsynnott_ | ambient: that's a framework issue to an extent |
| 13:43 | rsynnott_ | (it's not a language thing per se) |
| 13:43 | ambient | but with lisp i think there's a more direct connection at least for templating |
| 13:44 | rsynnott_ | well, there can be if you want it, I suppose |
| 13:44 | rsynnott_ | there doesn't really _have_ to be |
| 13:44 | rsynnott_ | (and in some cases it might be desirable to avoid it insofar as is possible) |
| 13:45 | ambient | i can't see the reasons for that |
| 13:49 | cgrand | ambient: when you say "but with lisp i think there's a more direct connection at least for templating" do you think of something like cl-who ? http://weitz.de/cl-who/ |
| 13:49 | ambient | afaik most frameworks are tightly bound to language features. i don't see the merit of abstracting to the level where frameworks become language independent |
| 13:50 | ambient | cgrand yes |
| 13:52 | rsynnott_ | ambient: many people might like to avoid using cl-who or an analagous clojure thing (does one exist?) |
| 13:52 | rsynnott_ | it's often desirable to have non-programmers edit templates, for instance |
| 13:53 | arbscht | compojure uses nested structures like cl-who |
| 13:53 | rsynnott_ | ah |
| 13:54 | cgrand | rsynnott_: several, eg http://github.com/mmcgrana/clj-html/tree/master and compojure.html |
| 13:54 | arbscht | but you're not limited to it, as with cl-who on hunchentoot |
| 13:55 | rsynnott_ | you're not limited to cl-who on hunchentoot |
| 13:55 | arbscht | right |
| 13:55 | rsynnott_ | (oh, sorry, I misread that) |
| 13:55 | snowwhite | ping |
| 13:56 | snowwhite | How can i check the type of an input in clojure? |
| 13:56 | arbscht | ,(class 42) |
| 13:56 | clojurebot | java.lang.Integer |
| 13:59 | snowwhite | How can i check the type of an input in clojure? Anyone? |
| 13:59 | arbscht | ,(type 42) |
| 13:59 | clojurebot | java.lang.Integer |
| 13:59 | arbscht | snowwhite: use one of those forms. type is more general (checks metadata before class) |
| 14:02 | cgrand | ambient: to have designers edit templates was a key design decision for enlive |
| 14:02 | LauJensen | I think making Compojure / ClojureQL the target for a few blog posts is a very good idea |
| 14:02 | Chouser | bah. I'm confused again about where delays are required for finger-trees. |
| 14:03 | Chouser | The bottom of page 7 says no delay is needed for cons/conj |
| 14:04 | Chouser | The only other operations discussed at that point are the deques (and the later operations are only O(log n) anyway, I think). So that suggests delays are needed for rest/pop |
| 14:06 | Chouser | rest/pop may recurse on deep-left/deep-right, so I've added a print there so I can see when descents happen -- and without any delays at all, they appear to happen at the pace described earlier on that page as what constitutes amortized O(1) time. |
| 14:06 | Chouser | so ... is delay needed at all? I'm sure I'm missing something... |
| 14:07 | ambient | cgrand it's a lot better than designers just designing static pages and the programmers making them function? |
| 14:07 | ambient | i've only worked in an environment where everyone knew how to code |
| 14:07 | ambient | who were doing webdev |
| 14:08 | cgrand | ambient: yes it's when the design change after you started to code |
| 14:09 | ambient | i see |
| 14:15 | rsynnott_ | it's often desirable to be able to have UI people modify templates without help |
| 14:23 | snowwhite | I am trying to parse the json string. Here is the code snippet. Can anyone through some light? |
| 14:24 | snowwhite | I am trying to parse the json string. Here is the code snippet http://pastebin.ca/1557501. I Can anyone through some light? |
| 14:24 | snowwhite | I am trying to parse the json string. Here is the code snippet http://pastebin.ca/1557501. Can anyone through some light? |
| 14:25 | slashus2 | snowwhite: Maybe you can refer to the implementation in clojure.contrib |
| 14:25 | danlarkin | snowwhite: that looks right to me, what's the problem? |
| 14:26 | slashus2 | snowwhite: Sorry, I thought you were trying to implement a json parser before I looked at your snippet. |
| 14:27 | snowwhite | danlarkin: How do i extract the email from that vector. Inside the vector, it's not a map so that i can access it using keys |
| 14:28 | danlarkin | ((first v) "email") |
| 14:30 | snowwhite | danlarkin, ? |
| 14:30 | danlarkin | ok, so you have a vector of two items, right? and each item has an "email" key and a "timestamp" key |
| 14:30 | danlarkin | so (first v) will be the first vector |
| 14:31 | danlarkin | and they you want the "email" key from that vector |
| 14:31 | danlarkin | s/they/then |
| 14:31 | danlarkin | did I misunderstand what you want? |
| 14:32 | danlarkin | sorry, (first v) will be the first hash-map, not first vector |
| 14:32 | snowwhite | I think it's not a hash-map any more |
| 14:33 | snowwhite | other i could have done (filter (fn [map] (get map :email)) data) |
| 14:33 | snowwhite | *otherwise |
| 14:33 | snowwhite | danlarkin, otherwise i could have done (filter (fn [map] (get map :email)) data) |
| 14:34 | danlarkin | no |
| 14:34 | danlarkin | the keys in your hash-maps are not keywords |
| 14:34 | danlarkin | they are strings |
| 14:35 | danlarkin | maybe that's where you're getting confused |
| 14:42 | snowwhite | danlarkin, (map (fn [d] (get d "email")) data) This should be the statement |
| 14:42 | arbscht | (map #(% "email") data) |
| 14:42 | snowwhite | danlarkin, Thanks for helping me in clearing up my doubts. - Cheers |
| 14:43 | snowwhite | arbscht, Exactly. Thanks |
| 14:46 | LauJensen | danlarkin: Now that you're all warmed up. What are the major benefits of using Compojure/Clojure vs Django ? |
| 14:46 | danlarkin | hahah ummmmmm can I defer my response? |
| 14:47 | LauJensen | sure |
| 14:48 | danlarkin | that is a loaded question :) |
| 14:48 | LauJensen | As always |
| 15:07 | ambient | LauJensen performance? java interop? |
| 15:08 | LauJensen | Any references that speak on performance? |
| 15:09 | danlarkin | LauJensen: is that to me? I had a stupid kernel panic, sorry |
| 15:10 | LauJensen | dan, ambient mentioned performance and java-interop |
| 15:10 | danlarkin | :-o |
| 15:13 | ambient | well nothing much except what can be found from google, http://berlinbrowndev.blogspot.com/2008/08/application-server-benchmarks-including.html |
| 15:14 | LauJensen | Very interesting... and very hard to compare graphs... Wonder why he picked a diffferent layout for each screenshot :) |
| 15:18 | LauJensen | But to be fair, you really only need one graph when you have something as clear as this: http://1.bp.blogspot.com/_syI_yyzTPG8/SJ5vxo4-qAI/AAAAAAAAAKU/cXblzLJRuAc/s1600-h/graph_django_default.png |
| 15:21 | ambient | yes, that is very clear |
| 15:23 | LauJensen | But I really dont like the trend of all the graphs, which is that PHP out performs everything else by a factor 10 |
| 15:37 | hiredman | well php is a very simple language |
| 15:40 | hiredman | I have a lisp interpreter in php and have been daydreaming^W thinking about a compiler that emits php |
| 15:40 | hiredman | if you want to target php |
| 15:40 | LauJensen | I dont |
| 15:41 | LauJensen | Just wondering, why a language that got hammered in the language shootout, suddenly wins so big |
| 15:43 | Fossi | great. i just discovered that emacs does not save back into jar files, even if it seems like it does |
| 15:43 | Fossi | so i can reimplement all those changes i made to the clojure-couchdb client yesterday |
| 15:43 | danlarkin | Fossi: what? I believe it does |
| 15:44 | hiredman | :( |
| 15:44 | hiredman | surely you made the changes to a git checkout, and commited the changes then built a jar :P |
| 15:45 | Fossi | didn't do the trick for me. i thought so too |
| 15:45 | Fossi | it said saving yesterday all the time, but today my changes are gone |
| 15:45 | Fossi | even unjar'ed |
| 15:45 | LauJensen | M-x recover-this-file ? |
| 15:45 | arbscht | LauJensen: I'd guess it's optimized for serving dynamic content, not all the things the language shootout tests for |
| 15:46 | danlarkin | maybe you're looking at a different jar, I've made modifications to a jar in emacs and they've persisted |
| 15:46 | Fossi | LauJensen: i save backups to /tmp/ which gets wiped :D |
| 15:46 | Fossi | danlarkin: might be. let me try to open from emacs |
| 15:47 | LauJensen | Fossi: Alright, not too bright :) |
| 15:47 | Fossi | nope, no luck |
| 15:48 | Chousuke | what's the point of saving backups to a place that gets deleted? :P |
| 15:48 | Fossi | but let me check if i have another copy around that might be the modified one |
| 15:50 | LauJensen | Chousuke: I think if Emacs decided it was best to delete the code, it probably made the right call :) |
| 16:00 | tomoj | I don't get it, how could emacs save into a jar? |
| 16:00 | tomoj | emacs can open jar files as if they're directories or something? |
| 16:05 | Chousuke | tomoj: why not? treating zip files as directories in not exactly a new idea. |
| 16:06 | tomoj | oh, archive-mode |
| 16:06 | tomoj | that's kinda neat |
| 16:07 | tomoj | seems like it would be better to do what hiredman said |
| 16:16 | Fossi | tomoj: yes, seems like it to me as well now :D |
| 16:16 | Fossi | did somebody get fuzzy-completions to work? |
| 16:17 | tomoj | Fossi: not using the starter kit? |
| 16:17 | tomoj | oh or do you mean in source buffers |
| 16:18 | Fossi | 1) no, i don't know about a starter kit and b) yes, i'd like it in source buffers |
| 16:18 | Chousuke | Fossi: works for me. |
| 16:18 | Chousuke | Fossi: you need a fairly recent SLIME though |
| 16:18 | Fossi | i can't figure it out. do i have to write a key binding and such? |
| 16:18 | tomoj | I don't have any completions at all in source buffers :( |
| 16:18 | Chousuke | C-c M-i should work at least |
| 16:19 | tomoj | somewhat fuzzy completion on the slime repl, though |
| 16:20 | Fossi | C-c M-i is undefined |
| 16:20 | Chousuke | wait, hm. |
| 16:20 | Chousuke | are we talking about the same thing, even? |
| 16:20 | Chousuke | There was a recent patch to swank-clojure that enable fuzzy completion through slime |
| 16:20 | Fossi | this: http://gist.github.com/179737 ? |
| 16:21 | Chousuke | yes |
| 16:21 | Chousuke | I had trouble getting it to work at first, but then it turned out to be because my SLIME was too old. |
| 16:21 | Fossi | i don't even get what to do with the file, apart from putting it into swank/commands/contrib/ |
| 16:22 | Chousuke | I just applied the patch with git :) |
| 16:22 | tomoj | your modeline should have "Slime[clojure]" in it |
| 16:23 | Chousuke | where did you install SLIME from? |
| 16:24 | Chousuke | I had SLIME cloned from technomancy's github repo, which turned out to be from May :/ |
| 16:24 | Chousuke | and it was too old |
| 16:24 | Fossi | my repl has REPL in it |
| 16:25 | Fossi | i have a slime checkout of 25 june |
| 16:25 | Chousuke | try upgrading |
| 16:26 | Chousuke | hopefully you have it from a git mirror so you can easily save the current state in a branch? :) |
| 16:26 | Fossi | ah, i can revert |
| 16:26 | Fossi | branching is for wussies |
| 16:26 | Chousuke | I wonder why anyone would use CVS nowadays. |
| 16:26 | Chousuke | or SVN. |
| 16:26 | Chousuke | except when forced to. |
| 16:27 | Chousuke | Well, SVN might be okay if you have to store binary files. |
| 16:28 | Fossi | my repl still says REPL |
| 16:28 | Fossi | nothing about SLIME[clojure] |
| 16:28 | Chousuke | oh, wait, the REPL buffer will say that |
| 16:28 | Chousuke | what about clojure buffers? |
| 16:29 | Chousuke | they should also say "Fuzzy" |
| 16:29 | Fossi | it says "Slime" |
| 16:29 | Chousuke | hmm. |
| 16:29 | snowwhite | Fossi, Nice article on Setting up Emacs & Clojure with Emacs Starter Kit http://freegeek.in/blog/2009/08/setting-up-emacs-clojure-with-emacs-starter-kit/ |
| 16:30 | Fossi | snowwhite: well, now that i have it set up more or less, i'm not sure i should use it |
| 16:30 | Chousuke | Fossi: can you even do M-x slime-fuzzy-complete-symbol? |
| 16:31 | Chousuke | how do you load slime from your config? |
| 16:31 | snowwhite | Fossi, Cool |
| 16:31 | Fossi | also, i have a ton of stuff in my .emacs and .emacs.d |
| 16:31 | Chousuke | if you do just (slime-setup), that won't work :/ |
| 16:31 | Chousuke | you need (slime-setup '(slime-fancy)) |
| 16:31 | Chousuke | to get the good stuff :) |
| 16:32 | Fossi | no slime-fu for me :\ |
| 16:33 | Fossi | actually, i guess my slime setup code is broken as is anyway |
| 16:33 | Fossi | i always have to M-x slime |
| 16:33 | Chousuke | that doesn't mean it's broken. |
| 16:33 | Chousuke | it's not automatic by default anyway |
| 16:37 | Chousuke | Fossi: http://github.com/Chousuke/emacs.d/blob/d826d63420dcdc90db639a4d3390a8c3773c8deb/init-clojure.el here's how I do it. |
| 16:42 | Fossi | Chousuke: ah, now it says slime[clojure] |
| 16:44 | Fossi | and C-c M-i is bound to fuzzy complete as well |
| 16:47 | Fossi | Chousuke: thanks, now i just have to find out what it actually completes :) |
| 17:52 | technomancy | Chousuke: so that fuzzy patch worked for you? |
| 17:52 | technomancy | I locked clojure-mode into using last-known-good revisions by default since so many people were complaining about breakage. |
| 17:52 | technomancy | but if there's a reason to update, I will definitely do it |
| 17:58 | Chousuke | technomancy: yeah, it does |
| 18:02 | technomancy | cool |
| 18:10 | ambient | *sigh* i dont know how to integrate java better to emacs but it's a bit laborious to browse the net for each method in each class when doing java interop |
| 18:15 | technomancy | ambient: do you know about the Slime inspector? |
| 18:15 | ambient | no |
| 18:15 | technomancy | C-c I over a java object, and it will list out all its methods |
| 18:16 | technomancy | been meaning to hook that into autocomplete, but the information is definitely there |
| 18:16 | technomancy | there's also a separate javadoc lookup package, but it's kind of awkward to use. |
| 18:16 | ambient | oh, i have to write that down :) |
| 18:16 | technomancy | yeah, it's super-helpful |
| 18:17 | ambient | thanks |
| 19:11 | prospero_ | ,(map println '(1 2 3)) |
| 19:11 | clojurebot | (nil nil nil) |
| 19:11 | prospero_ | hmm |
| 19:11 | prospero_ | that's not what I'm getting at my repl |
| 19:12 | hiredman | ~map |
| 19:12 | clojurebot | map is *LAZY* |
| 19:13 | prospero_ | yes, but doesn't it get evaluated at the repl? |
| 19:13 | hiredman | it does, while it is getting printed out |
| 19:13 | prospero_ | the output and printing is getting spliced together for me |
| 19:13 | prospero_ | ah |
| 19:13 | prospero_ | right |
| 19:13 | prospero_ | the result and the printing, rather |
| 19:13 | prospero_ | so that makes sense, I guess |
| 19:14 | prospero_ | if I want to separate them I need to write to a string or something, right? |
| 19:14 | hiredman | ,(doc with-out-str) |
| 19:14 | clojurebot | "([& body]); Evaluates exprs in a context in which *out* is bound to a fresh StringWriter. Returns the string created by any nested printing calls." |
| 19:15 | hiredman | but, you also have to watchout because map is lazy, and may be evauluated outside any dynamic bindings |
| 19:15 | prospero_ | so I should realize the seq with doall? |
| 19:15 | hiredman | for side effect things like printing doseq is better |
| 19:15 | hiredman | ,(doc seq) |
| 19:15 | clojurebot | "([coll]); Returns a seq on the collection. If the collection is empty, returns nil. (seq nil) returns nil. seq also works on Strings, native Java arrays (of reference types) and any objects that implement Iterable." |
| 19:15 | hiredman | ,(doc doseq) |
| 19:15 | clojurebot | "([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil." |
| 19:15 | prospero_ | I'm just trying to debug a recursive function |
| 19:16 | prospero_ | printing what's going on at each level |
| 19:16 | prospero_ | so with-out-str sounds like a good bet |
| 19:16 | hiredman | is there a reason you just don't print the results of the map? |
| 19:17 | hiredman | ,(prn (map inc (range 10))) |
| 19:17 | clojurebot | (1 2 3 4 5 6 7 8 9 10) |
| 19:17 | hiredman | or whatever list |
| 19:17 | prospero_ | I'm not actually using map, it was just a good way to demonstrate the behavior I was seeing |
| 19:17 | prospero_ | I'm walking a tree |
| 19:18 | prospero_ | anyways, with-out-str seems to be working |
| 19:18 | prospero_ | thanks |
| 20:36 | technomancy | does anyone use the subprocess support included in clojure-mode rather than the full-fledged SLIME support? |
| 20:36 | technomancy | never actually heard of anyone using it |
| 20:37 | Chousuke | subprocess support? |
| 20:37 | technomancy | it's got some simplistic support for running Clojure in a subprocess and sending the current buffer to it |
| 20:37 | technomancy | a small subset of what slime offers |
| 20:38 | Chousuke | isn't that what inferior-lisp is for? :/ |
| 20:40 | Chousuke | technomancy: have you considered adding support for launching multiple slime instances with clojure-project? |
| 20:40 | Chousuke | or should I say Clojure instances :/ |
| 20:43 | Chousuke | Hm, gotta go to sleep. later. |
| 20:46 | technomancy | Chousuke: I'd accept a patch, but I run one Emacs instance per project myself. |
| 20:46 | technomancy | so I would be unlikely to add it myself |
| 20:46 | technomancy | I guess what I'm talking about in clojure-mode is the inf-lisp integration |
| 20:57 | somnium | any vimclojure users online? |
| 21:31 | somnium | is there a std library function to return the first item in a seq for which a pred returns true? |
| 21:31 | somnium | (I wrote one but would be embarassed to show it...) |
| 21:35 | shachaf | somnium: Why? |
| 21:36 | somnium | because its ugly, and its an extremely typical operation :) |
| 21:36 | somnium | ,(first (drop-while #(x < 5) [1 2 3 4 5 6 7 8 9])) |
| 21:36 | clojurebot | java.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--4159$fn |
| 21:37 | somnium | gr |
| 21:37 | somnium | ,(first (drop-while #(% < 5) [1 2 3 4 5 6 7 8 9])) |
| 21:37 | shachaf | somnium: Well, if the functions are lazy then that should be fine. |
| 21:38 | somnium | whered he go... |
| 21:38 | somnium | ah, true, I forgot about that |
| 21:38 | somnium | still haven't quite grasped laziness |
| 21:38 | shachaf | I don't know anything about Clojure, though; I should probably not have spoken in the first place. :-) |
| 21:39 | somnium | ,(print "still here?") |
| 21:39 | clojurebot | still here? |
| 21:40 | hiredman | clojure is not lazy |
| 21:40 | somnium | ,(first (drop-while #(< % 5) [1 2 3 4 5 6 7 8 9])) |
| 21:40 | hiredman | lazy sequences are lazy |
| 21:40 | shachaf | hiredman: I read "Most of the sequence library functions are lazy". |
| 21:40 | shachaf | I didn't investigate it further. |
| 21:41 | somnium | hiredman: is there a function in core or contrib to return the first item in a seq via pred? |
| 21:43 | hiredman | (comp first filter) |
| 21:44 | hiredman | there was a thrad on the google group about adding a function to contrib somewhere, but I forget if it ever was |
| 21:44 | somnium | ah |
| 21:45 | somnium | some things like that would increase the "user-friendliness" fact imho, but its easy now that I see it |
| 21:45 | somnium | and I guess thats much more flexible to specify (nth ...) or whatever |
| 21:46 | somnium | ... I think I had a semi-"lisp enlightenment" moment the other day |
| 21:47 | somnium | was writing a gtk-wrapper in ruby, and couldn't get a really pleasing syntax without some form of xml |
| 21:47 | somnium | and it clicked |
| 21:59 | somnium | (comp first filter) |
| 23:10 | manic12 | I watched clojure for lisp programmers and my brain hurt afterward |
| 23:12 | technomancy | that pain is weakness leaving the body |
| 23:12 | manic12 | I don't know how to use the language yet, but i noticed it seems to work on JamVM running on ARM9 |
| 23:13 | technomancy | mmm... Jam. |
| 23:14 | manic12 | my brain is so wired for common lisp, that I feel actually like I'm at a disadvantage |
| 23:15 | technomancy | could be a lot worse |
| 23:21 | duck1123 | manic12: just remind yourself that clojure is absolutely nothing like common lisp in any way whatsoever. That way you'll never be surprised. |
| 23:22 | dthomas | How should I find the index of the first occurrence of a given item in a vector? Or should I be using some other data type, like sorted-set or a map? |
| 23:22 | dthomas | (I see there's an (index) in docs but it's not clear if it does what I want and it doesn't seem to be in Clojure 1.0 anyway.) |
| 23:24 | manic12 | I have a large c++ library swigged into CL and I am thinking of reworking the interface files to be for java, and i am contemplating how well it might work in a clojure world |
| 23:28 | manic12 | i hope java has finalizations |
| 23:43 | dthomas | Getting the index of something in a vector really seems like it should be obvious and brief... |
| 23:44 | technomancy | sweet; jochu merged the fuzzy-find patch. =) |
| 23:46 | _mst | ,(.indexOf [1 2 3 "hello" 4 5 6] "hello") |
| 23:46 | clojurebot | 3 |
| 23:47 | technomancy | wow, it's quite the patch |
| 23:47 | dthomas | _mst: [expletive deleted] |
| 23:48 | _mst | I'm hoping I'm not relying on implementation-dependent behaviour in doing that :) |
| 23:52 | dthomas | _mst: I guess that's because a PersistentVector is a java.util.List. Thanks for that. |
| 23:53 | _mst | yep, I think so. I couldn't see anywhere in the docs that said vectors were guaranteed to be Lists, but oh well :) |
| 23:58 | dthomas | Holy crap, repl-utils/show is awesome. |