2008-10-28
| 00:00 | pjb3 | It would be a nice macro to make that pattern clear |
| 00:00 | pjb3 | so you write (defk foo {a "a" b "b" c "c"} (prn :a a) ... ) |
| 00:01 | pjb3 | Seems like this does that: http://www.turbojugend-cossebaude.de/clojure/defk.clj |
| 00:01 | pjb3 | but it seems like a lot of code to make that happen |
| 00:09 | Chouser | wow. yeah, well he's also doing non-keyword args and rest args. my snippet does strictly keyword args. |
| 01:28 | Jedi_Stannis | writing a little calculator app to learn clojure, can anyone explain the following behavior? |
| 01:28 | Jedi_Stannis | user=> (= (symbol "+") '+) |
| 01:28 | Jedi_Stannis | true |
| 01:28 | Jedi_Stannis | user=> (= (symbol "/") '/) |
| 01:28 | Jedi_Stannis | false |
| 01:35 | Chouser | is used as the separator between the namespace and the name of the symbol. |
| 01:35 | Chouser | "/" is used ... |
| 01:36 | Chouser | Compare (name (symbol "/")) with (name (symbol "+")) |
| 01:36 | Chouser | (name (symbol "my-ns/my-name")) |
| 01:37 | Jedi_Stannis | I see |
| 01:38 | Chouser | That's described here under "Symbols" http://clojure.org/reader |
| 01:38 | Jedi_Stannis | so if I want user input and want to convert the string "/" to a symbol, is there some way to escape it? |
| 01:40 | Chouser | I don't think there's any way to get clojure to print a symbol with a / in it that means anything other than the separator. |
| 01:41 | Chouser | you could have your own convention of using _SLASH_ in place of / Clojure does this internally, creating Java classes named, for example, class_QMARK_ since Java doesn't allow "class?" |
| 01:42 | Jedi_Stannis | ok |
| 01:42 | Chouser | or better, why not just keep the / in a string? Is there something special about having it in a symbol that you need? |
| 01:43 | Jedi_Stannis | yeah I think that would work better |
| 05:59 | Lau_of_DK | I remember something vaguely from SBCL where you could (format -R 100) and it would output "one hundred" - Is there a similar func. in Java/Clojure ? |
| 06:02 | jdz | Lau_of_DK: (format nil "~R" 100) |
| 06:03 | jdz | and no, i don't think it is a part of standard library or somesuch. but somebody must have written it, so google should have it. |
| 06:04 | Lau_of_DK | ok, thanks |
| 06:04 | tWip | anyone doing project euler puzzles will have written one ;) |
| 06:05 | Lau_of_DK | tWip, nope, because I just used SBCLs |
| 06:05 | tWip | well I did |
| 06:06 | Lau_of_DK | So you have something that works in java/clojure? |
| 06:06 | tWip | I have clojure code for it, but only upto one thousand as the task didn't require more |
| 06:06 | tWip | and I don't have the code here at my work machine |
| 06:07 | Lau_of_DK | I should probably invent "my online code vault" |
| 08:53 | Drakeson | I am pretty much a total newbie in Java. Assume I import something like (import '(some.thing)), how can I know what symbols are in there? |
| 08:54 | rhickey | Drakeson: you'll have to look in the JavaDoc for the library. Java packages are not reified/enumerable |
| 08:55 | rhickey | you can use reflection to see things in a specific class |
| 08:58 | sleven | im trying to install clojure on ubuntu |
| 08:59 | sleven | i have downloaded and unzipped but I find no explanation of where i should put the folder etc |
| 09:00 | rhickey | sleven: some tips here: http://riddell.us/clojure/ |
| 09:00 | Drakeson | is there a way to lookup documentation from within slime? |
| 09:00 | Drakeson | rhickey: actually, do you use slime? |
| 09:00 | sleven | what is maven? |
| 09:00 | rhickey | Drakeson: not yet |
| 09:00 | Drakeson | sleven: you can skip that |
| 09:01 | Drakeson | maven2 - Java software project management and comprehension tool |
| 09:02 | duck1123 | sleven: all you really need is ant |
| 09:02 | Drakeson | rhickey: just FYI, I haven't been able to make slime do a proper debugging ... |
| 09:05 | Drakeson | this is kind of embarrassing, how do you use javadoc to lookup documentation for, say, java.sql ? |
| 09:05 | rhickey | Drakeson: http://java.sun.com/j2se/1.5.0/docs/api/index.html |
| 09:06 | Drakeson | rhickey: thanks. |
| 09:06 | rhickey | Also you can leverage the structure of this url to find things directly: http://java.sun.com/j2se/1.5.0/docs/api/java/sql/package-summary.html |
| 09:07 | tWip | also jdocs.com and quickref.org |
| 09:07 | lisppaste8 | blackdog pasted "introspection" at http://paste.lisp.org/display/69337 |
| 09:07 | rhickey | also: http://clj-me.blogspot.com/2008/05/jumping-to-javadocs-from-repl.html |
| 09:07 | tWip | You have new mail. |
| 09:07 | blackdog | Drakeson: those are some functions courtesy of Chouser |
| 09:08 | tWip | sorry about that... my terminal mispasted |
| 09:08 | rhickey | Maybe someone could gather these and make an entry on the Wiki? |
| 09:08 | Drakeson | actually, is there a command line tool for that? |
| 09:09 | Drakeson | there is javadoc, which apparently generates the documentation. |
| 09:10 | Drakeson | my problem is that I have installed a few other java packages that are most likely not in java.sun.com |
| 09:11 | sleven | Could not find the main class: clojure.lang.Repl. Program will exit. |
| 09:11 | tWip | Drakeson: try if they are in jdocs.com |
| 09:11 | tWip | it has javadocs for many libs |
| 09:11 | Drakeson | they come with -doc packages (debian packages). So, what is the "canonical" way of looking up documentation that is installed on ones machine? |
| 09:11 | sleven | ^ get that when trying to run the interpreter |
| 09:22 | sleven | i did exactly as it says on the lnk rich posted |
| 09:44 | achim_p_ | sleven: did you skip the maven step? |
| 09:49 | sleven | achim_p: no i needed it to install |
| 09:59 | sleven | http://hpaste.org/11544 |
| 10:01 | achim_p_ | where is clojure.jar in your file system? |
| 10:02 | sleven | not in op/clojure |
| 10:02 | sleven | where should it be? |
| 10:03 | achim_p_ | sleven: i don't know what maven does, i'm using ant for building clojure |
| 10:04 | achim_p_ | if you have ant, try this: in step 5, instead of "mvn install", do "ant" |
| 10:04 | achim_p_ | and then: java -cp clojure.jar clojure.lang.Repl |
| 10:05 | sleven | how do i get ant(what is it)? |
| 10:05 | sleven | i have ant |
| 10:06 | achim_p_ | ant is a build tool for java |
| 10:07 | sleven | i see im running it now |
| 10:07 | achim_p_ | there should be a clojure.jar after running ant |
| 10:11 | sleven | there is |
| 10:11 | sleven | but java -cp clojure .jar isnt enough |
| 10:11 | sleven | java -cp target/clojure-lang-1.0-SNAPSHOT.jar clojure.lang.Repl |
| 10:11 | achim_p_ | java -cp clojure.jar clojure.lang.Repl |
| 10:11 | sleven | still doesnt work(maybe ti shouldt with ant)? |
| 10:12 | sleven | it works thanks |
| 10:13 | achim_p_ | good |
| 10:24 | Drakeson | how do I access a class's method? for instance, javadoc tells me that java.lang.Class has a method "forName". How can I call that? |
| 10:24 | Drakeson | is (. java.lang.Class forName) the way to call it? |
| 10:27 | sleven | wget http://jline.sourceforge.net |
| 10:27 | sleven | where odes that put jline? |
| 10:27 | sleven | cuz i cant see it |
| 10:27 | Drakeson | heh |
| 10:28 | Chouser | Drakeson: (Class/forName "java.lang.String") |
| 10:29 | Chouser | sleven: that probably just downloaded the index.html web page. |
| 10:29 | Chouser | sleven: what instructions are you following? |
| 10:30 | Drakeson | get here and download the zip file --> http://downloads.sourceforge.net/jline/jline-0.9.94.zip?modtime=1203704122&big_mirror=0 |
| 10:33 | Drakeson | Chouser: thanks |
| 10:33 | Drakeson | so, if I have a class, I can access its field using "/", right? |
| 10:34 | Drakeson | *fields |
| 10:36 | Chouser | static field or method, yes. |
| 11:00 | Drakeson | is there a fast UI toolkit with java bindings (awt is too sluggish)? |
| 11:00 | Drakeson | (hopefully on Linux) |
| 11:03 | wwmorgan | Drakeson: a few people have been talking about Qt/Jambi |
| 11:03 | wwmorgan | Here's supposedly a demo in clojure. I haven't had the chance to run it http://paste.lisp.org/display/66213 |
| 11:09 | walters | Drakeson: I've been hacking on http://live.gnome.org/JGIR recently, if you are interested in the GNOME stack |
| 11:24 | Drakeson | walters: interesting. I am having some problems with java-gnome. java-gnome 2.x is deprecated, java-gnome 4.0.x is not well documented. |
| 11:25 | walters | Drakeson: i mainly ran up against the fact that its public layer is hand coded and the coverage is terrible |
| 11:27 | Drakeson | walters: do you happen to have some examples of clojure codes using gnome toolkits? (no matter how simple they are, since I am absolutely newb in java, and prefer to avoid java itself as much as I can) |
| 11:29 | walters | Drakeson: the code would look pretty similar in feel to that Qt/Jambi example; to be honest though I don't really know Clojure, I hang out here to learn indirectly =) |
| 11:29 | walters | Drakeson: you might read this thread; http://groups.google.com/group/clojure/browse_thread/thread/22e4696550b6c4fa/686eb076bc89ec33?lnk=gst&q=GUI+# |
| 11:34 | Drakeson | walters: thanks, that was very useful. I will lurk in that news group... |
| 11:50 | Drakeson | what is nil_? |
| 11:51 | wwmorgan | Drakeson: my guess is that it's a typo and should be nil) |
| 11:53 | Drakeson | but what is the meaning of (def x nil (defn [] 1) (defn [] 2)) then? |
| 11:54 | Drakeson | is this how one defines a class? |
| 11:55 | wwmorgan | (def x nil) defines a var whose value is nil. (defn foo [] 1) is shorthand for (def foo (fn [] 1)). It defines a function |
| 11:55 | Drakeson | actually, is there any documentation on "classes" ? |
| 11:56 | wwmorgan | Drakeson: http://clojure.org/java_interop |
| 11:56 | jdz | def only accepts two arguments |
| 11:56 | jdz | and it is not used to define classes |
| 11:57 | jdz | http://clojure.org/special_forms#toc1 |
| 11:57 | Drakeson | oh, I see. http://paste.lisp.org/display/66213 had a typo puttin a "_" instead of ")" (they are close to each other, at least on my keyboard). That made me confused. |
| 11:58 | wwmorgan | Drakeson: yes. The indentation is the giveaway |
| 12:00 | Drakeson | yet, I don't seem to be able to find any documentation on how you could achieve "defclass" (a la common-lisp) or "class" (a la python) in clojure. |
| 12:01 | H4ns | Drakeson: that is because clojure does not really support object oriented programming. |
| 12:01 | jdz | Drakeson: as far as i know there is no such thing |
| 12:01 | danlarkin | Drakeson: you can use the gen-class family of functions if that's what you *really* need |
| 12:02 | wwmorgan | Drakeson: look up "Implementing Interfaces and Extending Classes" on the java interop page |
| 12:02 | sleven | or roll your own |
| 12:03 | danlarkin | Drakeson: but chances are you can either get away with using #'clojure/proxy or rethinking your problem to use more generic datastructures (lists etc) and functions to operate on them |
| 12:03 | Drakeson | actually, I am not interested in writing any java code in the "java language". Can I still use clojure "effectively"? |
| 12:04 | jdz | Drakeson: i write function oriented code ;) |
| 12:04 | Chousuke | Drakeson: I'd say yes you can |
| 12:06 | Chousuke | Some java libraries of course might not be the best fit for clojure though |
| 12:06 | Drakeson | ok, good. (object oriented is not what I really want. Somehow I had the impression that you could not survive without writing OO when you are targetting JVM) |
| 12:07 | Chousuke | well, you'll have to work with objects |
| 12:08 | Chousuke | just... clojure manages to make writing java remarkably unlike writing java. |
| 12:09 | Chousuke | and if you find yourself writing a lot of java-like code, maybe you can write macros to hide some of it under a more lispy interface :) |
| 12:10 | Drakeson | Chousuke: I won't write java-like code unless I am really forced to do so. I like CL. It just doesn't have enough libraries at the moment. |
| 12:14 | Drakeson | [not-so-productive-mode] btw, how about making :(a 1 b 2) mean {:a 1 :b 2} ? |
| 12:14 | Drakeson | (in the reader) |
| 12:17 | Chousuke | hmmh |
| 12:17 | Drakeson | (to get more "real" parens) |
| 12:17 | Chousuke | that would be mixing list syntax with map syntax :/ |
| 12:18 | jdz | Drakeson: what's the gain? |
| 12:20 | Drakeson | maybe aesthetic reasons? |
| 12:21 | jdz | well, aeshetically what's the gain? |
| 12:21 | jdz | aesthetically even |
| 12:21 | jdz | imho it would just be harder to spot that there is a map right there.. |
| 12:21 | Chousuke | and with that syntax it looks like a {a 1 b 2} |
| 12:22 | Chousuke | which is not {:a 1 :b 2} :/ |
| 12:22 | danlarkin | -1 for :(a 1 b 2) |
| 12:24 | Drakeson | well, I guess that cannot be helped easily. The benefit of having a single type of parens, is that XML <--> s-exp will be very straight forward. There are (and will be more) applications of this. |
| 12:25 | jdz | Drakeson: there already is a single type of parens |
| 12:25 | jdz | whatever that means |
| 12:26 | sohail | does it matter if they are all sequences anyway? |
| 12:26 | Drakeson | I guess I might prefer (m :a 1 :b 2) over {:a 1 :b 1} |
| 12:27 | sohail | for what purpose |
| 12:27 | Chousuke | you can already do that though. |
| 12:28 | Drakeson | Chousuke: I know. (defmacro m ...) |
| 12:28 | Chousuke | (hash-map :a 1 :b 1) :P |
| 12:28 | jdz | you don't need a macro |
| 12:29 | Drakeson | do we have defalias? |
| 12:29 | danlarkin | alias |
| 12:29 | wwmorgan | Drakeson: def |
| 12:29 | Chousuke | heh |
| 12:30 | wwmorgan | clojure is a lisp-1 so (def m hash-map) and then (m :a 1 :b 2) will do what you want |
| 12:30 | jdz | Drakeson: just don't expect the readers of your code be happy of your renames. |
| 12:33 | Drakeson | I'll see if it looks horrible ... |
| 12:33 | danlarkin | (m :a 1 :b 2) gains you nothing over {:a 1 :b 2}, it's the same datastructure, both implement ISeq, it's just giving up the benefit of builtin hash syntax :/ |
| 12:33 | Drakeson | what is the benefit of the {} syntax? |
| 12:34 | Chousuke | it's succinct, and doesn't look like a list or a vector |
| 12:35 | Drakeson | so you mean I should not rely on the highlighting/colorizing in the text-editor? |
| 12:35 | Chousuke | no, those help |
| 12:35 | Chousuke | but the {} syntax is instantly recognisable |
| 12:35 | jdz | and it is read as a literal object, not as a function call at runtime |
| 12:35 | Chousuke | you see a {} it |
| 12:35 | Chousuke | it's a map. |
| 12:36 | Drakeson | so, I can make (m :a 1 :b) to be very distinguishable (totally different colors, etc.) |
| 12:36 | jdz | Drakeson: so how will your map print then? |
| 12:36 | Drakeson | jdz: right. that's why I prefer something directly in the reader. |
| 12:36 | Chousuke | yeah, but that will be read in as a list. {} will be read in as a map |
| 12:37 | jdz | but {} already is in the reader... |
| 12:37 | adakkak | does anyone know if clojure supports parallel programming across machines? |
| 12:37 | Chousuke | cl and scheme discriminate against non-list data structures. clojure brings two others up to the same level ;) |
| 12:38 | gnuvince_ | three: vectors, hash-maps and sets |
| 12:38 | Drakeson | Chousuke: I like that clojure has distinguishable builtin support for vectors and hash-tables, I just want that to even look more like lists. |
| 12:38 | gnuvince_ | Don't forget sets |
| 12:38 | Chousuke | gnuvince_: ah, right, forgot sets |
| 12:39 | Chousuke | Drakeson: but that'd just be confusing :/ |
| 12:39 | Chousuke | Drakeson: if it isn't a list, why does it need to look like a list? |
| 12:40 | Drakeson | so I can quickly switch between lists and other types when I find the other data-type is better. |
| 12:41 | jdz | Drakeson: it's not the data structure that makes it possible to switch them, but the functions that operate on them |
| 12:42 | jdz | Drakeson: it's called abstract data types |
| 12:43 | Drakeson | jdz: still, if I can change (list :a 1 :b 2) to (m :a 1 :b 2) in the "source-code", I might feel a bit happier. |
| 12:43 | jdz | they both are wrong |
| 12:44 | jdz | they should be something like (make-my-something :a 1 :b 2) |
| 12:44 | jdz | which would internally call either list or hash-map |
| 12:47 | danlarkin | I think changing from a list to a hash will happen so infrequently as to make this a mute point. Lists and Hashes serve totally different purposes, when would it be the case that you have been using a list and then want to switch to a hash and expect to only change your constructor code? You'd have to change all of your logic... |
| 12:47 | Chousuke | nah |
| 12:48 | Chousuke | just write your logic using sequences |
| 12:48 | Chousuke | specify only that my-something is a sequence, and you can return any sequence depending on how the stars are aligned or whatever :) |
| 12:49 | jdz | the point is that besides the constructor all other operations are also defined... and one case where it would be reasonable to switch between lists and maps would be if the lists are property lists. |
| 12:51 | Drakeson | jdz: if that is good, (using make-something instead of both list and hash-map), why should I still see {}'s in the code? seeing more "syntax" is what I actually want to avoid. |
| 12:51 | Drakeson | so, I prefer meta over ^, etc. |
| 12:51 | jdz | Drakeson: if you use abstract data types, you won't see {} |
| 12:52 | jdz | except when printing out values |
| 12:52 | tWip | but why propose new syntax for maps if you want to avoid more syntax |
| 12:53 | Drakeson | tWip: I consider "(m :a 1) instead of {:a 1}" less syntax. |
| 12:54 | tWip | didn't someone just propos :(a 1 b 2) or something |
| 12:54 | Chousuke | Drakeson: how would you print a map though, if {} didn't exist? |
| 12:54 | Drakeson | tWip: I dropped that. |
| 12:54 | jdz | Drakeson: you already have (hash-map :a 1) |
| 12:54 | jdz | Drakeson: i don't see your point, sorry. |
| 12:54 | Chousuke | Drakeson: if you print (m :a 1 :b 1) it would not be a map, it would be a list :/ |
| 12:55 | Chousuke | (one that evaluates to a map though) |
| 12:55 | jdz | when given to eval |
| 12:55 | jdz | which is evil |
| 12:57 | Drakeson | ok, so I guess I am confused. On one hand I need more data types than just lists. On the other hand I like to have everything look like lists as much the same as possible. |
| 12:57 | Drakeson | there may or may not be solution to satisfy both. |
| 12:58 | danlarkin | I think it just comes down to this being the syntax, if you don't like it you can use (hash-map :a 1) or not use the language if it bothers you too much that there's literal support for more than just lists |
| 12:58 | Chousuke | one thing I *really* like about clojure is that it uses the vector syntax in places like defn/defmacro argument lists and let forms. |
| 12:58 | Chousuke | it |
| 12:58 | Chousuke | it's so much clearer :P |
| 12:59 | Drakeson | Chousuke: why it is clearer? |
| 12:59 | wwmorgan | also you could do (def m hash-map) and that'll give you (m :a :b :c :d) at the possible price of alienating your readers |
| 12:59 | Chousuke | well it clearly separates the naming, the arguments, and the code |
| 12:59 | Drakeson | Chousuke: I don't consider that a real benefit. |
| 13:00 | Chousuke | maybe you don |
| 13:00 | Chousuke | don't* |
| 13:00 | Chousuke | damn I keep hitting the enter too much :/ |
| 13:00 | Drakeson | heh |
| 13:01 | H4ns | Drakeson: don't use clojure then - really, it does not make sense to discuss syntax. write code instead :) |
| 13:01 | Chousuke | evil ' is right next to it. |
| 13:03 | Drakeson | H4ns: It is the best thing I can get now, so I cannot afford to give up on that. Yet, I am curious to know if it is possible to unify things even more? |
| 13:03 | Chousuke | but seriously, the [] is a strong visual separator: (defn foo [args] (codestartshere)) compared to (defun foo (args) (codestartshere)) or (let [binding (someforms) morebinding 123] (code)) |
| 13:05 | H4ns | Drakeson: i would suggest that you try discussing this with rhickey and i'm confident that he'll give you a definite answer with respect to whether he wants to change the syntax or not. i happen to not like the [] and {} myself, too, but i don't dislike them enough to consider them a problem i would discuss or lobby for. |
| 13:05 | H4ns | Drakeson: i'd rather see more idiomatic clojure code appear and be discussed than the syntax be changed. |
| 13:06 | Chousuke | what's the idiomatic clojure alternative to keyword arguments? just take a map parameter? |
| 13:06 | danlarkin | Chousuke: I agree, I really like the user of vectors in places like arglists, it's not only a good visual separator but a reminder that that form isn't going to be evaled |
| 13:08 | rhickey_ | I would recommend anyone who thinks Clojure should be different use it for a while, then reconsider |
| 13:10 | gnuvince_ | Hear hear |
| 13:12 | Drakeson | H4ns: In Norvig I have read that common lisp is in the middle of an evolution. As symptoms he mentions the fact that there is support for vectors and sequences, yet they are treated differently than lists. Clojure has got this (and many other things) right, yet I feel I would prefer "a bit less distinction between lists and other data types". |
| 13:13 | Drakeson | but I have no clue whether this can be achieved. |
| 13:15 | Chousuke | I think it's wrong to think of it as "lists and others". Clojure does just "sequences", and lists are a kind of sequence that are represented (with characters) using parens. |
| 13:16 | sohail | I thought Norvig believes in Python now |
| 13:19 | gnuvince_ | We could send him a free copy of Stuart's book when it is released |
| 13:19 | Drakeson | gnuvince_: what is it about? |
| 13:19 | Drakeson | clojure? |
| 13:20 | gnuvince_ | Drakeson: yes. |
| 13:20 | gnuvince_ | http://www.pragprog.com/titles/shcloj/programming-clojure |
| 13:21 | sohail | "a modernized Lisp dialect" |
| 13:21 | sohail | take that out, you'll alienate 80% of potential users :-) |
| 13:22 | Drakeson | sohail: I guess most people don't even know what lisp is. I have encountered very few people who actually had some bias against lisp. |
| 13:23 | Drakeson | March 15 is too late ;) |
| 13:23 | sohail | ya march 15 is so far |
| 13:23 | sohail | we need a beta |
| 13:23 | Drakeson | sure we do |
| 13:24 | Drakeson | or I have to litter #clojure with newb questions ... |
| 13:24 | Chousuke | Anyway, about keyword args: I really think they could be useful. If there's a function that needs to alter its behaviour slightly based on a parameter I don't think there's anything better than kw args, since even just having to pass a map feels a bit unwieldy. |
| 13:25 | duck1123 | we can't even pre-order the beta yet, can we? |
| 13:26 | danlarkin | Chousuke: I also love python's *args, **kwargs idiom |
| 13:26 | sohail | clojure doesn't have keyword arguments eh.. |
| 13:27 | Chousuke | when I was playing with clojure/swing I made a macro that allowed me to execute clojure in the swing thread simply by doing (in-swing (code)); it defaulted to synchronous execution, but I also added a check to make it possible to call (in-swing :async (code)) |
| 13:27 | rhickey_ | you can get them with macros, just not a part of fn syntax, since it's not a primitive notion |
| 13:27 | sohail | rhickey_, I was just about to say that I've used them in macros mostly |
| 13:28 | Chousuke | that's just a toggle, not a real keyword arg though. |
| 13:28 | Chouser | http://paste.lisp.org/display/69329 -- keyword args with defaults |
| 13:29 | sohail | nice, now write a (defn* |
| 13:31 | Chousuke | that doesn't allow mixing positional/&rest with keyword args though. I wonder if that's even possible |
| 13:31 | Chouser | yeah, someone wrote a macro. hang on... |
| 13:31 | Chouser | http://www.turbojugend-cossebaude.de/clojure/defk.clj |
| 13:34 | Chousuke | hmm. |
| 13:34 | Chousuke | looks nice. |
| 13:36 | sohail | looks like a winner |
| 13:36 | sohail | CPL is like BSD? |
| 13:37 | Drakeson | doesn't it look more permissive? |
| 13:38 | sohail | someone needs to execute M-x fill-paragraph on CPL.txt |
| 13:39 | sohail | more permissive than BSD? |
| 13:40 | Drakeson | that was my first impression |
| 13:40 | lisppaste8 | rhickey pasted "defnk" at http://paste.lisp.org/display/69347 |
| 13:43 | sohail | rhickey_, that's awesome |
| 13:50 | Drakeson | have you guys managed to make slime working well with clojure? I don't get completion, debugging, etc. |
| 13:51 | Drakeson | *work |
| 14:03 | sohail | Drakeson, I get completion for primitives but not for functions I define myself... last I checked anyway. I've also given up on debugging with slime after using sbcl! |
| 14:04 | sohail | oh that's a lie, apparently completion works now |
| 14:05 | Drakeson | can I see the relevant slime-setup parts of your .emacs ? |
| 14:05 | Drakeson | I have (slime-setup '(slime-fancy slime-asdf slime-tramp slime-fuzzy)) for sbcl |
| 14:07 | Drakeson | it doesn't even complete def<TAB> here |
| 14:09 | sohail | in a bit, debugging some err... concurrent C++ code... |
| 14:09 | sohail | ironically enough |
| 14:10 | Drakeson | thanks |
| 14:11 | duck1123 | I turn on pabbrev-mode for my completion |
| 14:11 | duck1123 | I got used to using it with Ruby, so I just carried that behavior over |
| 14:12 | Drakeson | duck1123: so you only get M-/ ? |
| 14:14 | sohail | Drakeson, seems I misunderstood what you said... I was thinking hints not completion |
| 14:17 | duck1123 | pabbrev uses [tab]. Not sure if M-/ also works for it, but I'm pretty sure M-/ was already working for me. |
| 14:50 | Drakeson | (resolve 'init) |
| 14:51 | Drakeson | heh. sorry. |
| 14:55 | gnuvince_ | Hey guys, how would you find the most frequent letter in a string? |
| 14:55 | gnuvince_ | I got this, but it's pretty ugly IMO: (first (reduce #(max-key second %1 %2) (into [] (reduce #(merge-with + %1 %2) (for [c s :when (Character/isLetter c)] {c 1}))))) |
| 15:02 | wwmorgan | gnuvince: here's how I would do it http://paste.lisp.org/display/69348 |
| 15:05 | gnuvince_ | wwmorgan: essentially the same thing, but with a nicer separation. |
| 15:10 | rhickey_ | another way to do freqs http://paste.lisp.org/display/69348#1 |
| 15:21 | tomppa | Shouldn't (try (/ 1 0) () (print 'foo)) always print foo? |
| 15:24 | tomppa | for some reason it seems like the finally expressions are no longer evaluated |
| 15:25 | kotarak | tomppa, the syntax is (try (/ 1 0) (finally (print 'foo))) |
| 15:25 | tomppa | oh great. thanks |
| 15:27 | tomppa | it is just funny that I think it worked the other just a while ago... oh well |
| 15:52 | tomppa | is anybody here familiar with the internals of the clojure slime mode? |
| 15:53 | Drakeson | tomppa: I am only familiar with parts of it that do not work :D |
| 15:53 | tomppa | I'm trying to send sexps from emacs to clojure with (slime-eval '(+ 1 1)) but I just get "Synchronous Lisp Evaluation aborted" error |
| 15:53 | tomppa | how does the clojure mode send sexps to be evaluated |
| 15:54 | Drakeson | did you follow http://en.wikibooks.org/wiki/Clojure_Programming#Emacs_.2F_Slime_Integration ? |
| 15:55 | Drakeson | tomppa: it works for me (TM) |
| 15:55 | tomppa | yes, I think I got everything set up just about right. AFAIK the parts that should work work. |
| 15:55 | tomppa | I'd just like to send expressions to be evaluated in clojure from the emacs lisp side |
| 15:56 | tomppa | With CLs the slime-eval works for that |
| 15:56 | Drakeson | tomppa: it works the same way for me. I C-x C-e in a "Clojure"-mode buffer, and it does the right thing |
| 15:56 | Drakeson | can you check the error messages? |
| 16:01 | tomppa | hmm, I'm not that familiar with the elisp debugger, so that "Synch. Lisp eval." error is pretty much the most informative part of the stacktrace |
| 16:02 | tomppa | there are no errors in the Clojure side |
| 16:03 | tomppa | I'll have to dig around the swank-clojure.el etc. to see how it's supposed to work |
| 16:03 | jgracin | tomppa: I was trying to do the same thing some time ago, and I came to the conclusion that slime-eval is not the right function to do what you want. |
| 16:04 | jgracin | tomppa: there's some other function that takes a string |
| 16:04 | Drakeson | jgracin: slime-eval-last-expression works |
| 16:06 | jgracin | Drakeson: I don't know, really. It just made sense to me that I cannot expect Emacs reader to be able to read Clojure expressions. |
| 16:07 | jgracin | Isn't that what (slime-eval '{:a 1}) would mean? |
| 16:07 | tomppa | but elisp can't read all CL expressions either. Esp. when you throw in custom read macros |
| 16:08 | jgracin | tomppa: and does slime-eval work in that case? |
| 16:10 | tomppa | I don't think it does |
| 16:12 | jgracin | tomppa: try looking at *slime-events* buffer to see the difference between messages when you use slime-eval explicitly and the normal events. |
| 16:13 | tomppa | ok. It seems that slime-interactive-eval takes strings, so that is probably what I would need |
| 16:13 | tomppa | woo, it works :) An I was sure I already tried all the options. |
| 16:15 | jgracin | tomppa: oh, yeah, I just remembered... that was the function that I'd found as well. :-) |
| 16:16 | tomppa | is there a way to get a list of all active threads in Java? I'd like to have slime-list-threads working |
| 16:19 | jgracin | tomppa: http://www.java-forums.org/java-lang/7345-listing-all-threads-threadgroups-vm.html |
| 16:20 | tomppa | thanks, I just found it myself too :) |
| 16:25 | robewald | hello, how do I subscribe to the mailing list without having a google account? |
| 16:29 | tomppa | I don't have much Java experience but exploring the API and runtime with Clojure is actually quite fun |
| 16:33 | jgracin | tomppa: I totally agree. Clojure is what Java needs to stay alive. |
| 16:34 | Chouser | Java isn't thriving pretty well on its own? |
| 16:34 | tomppa | well, I don't care much about Java but the JVM could be handy |
| 16:36 | abrooks | Chouser: There's a difference between lumbering and thriving, right? :) |
| 16:37 | Chouser | abrooks: are you saying lumber doesn't thrive? |
| 16:37 | abrooks | What wood you say? |
| 16:37 | abrooks | ;-D |
| 16:37 | Chouser | ..and I'm not commenting on whether it *deserves* to thrive or not, just that I don't see it disappearing any faster than C++ or Cobol. |
| 16:39 | abrooks | Chouser: I think the real notion here is Java and the JVM's assurance of longevity vs Java (the language's) loss of market share. While other JVM languages assure that the JVM and libraries survive, they are likely doing so by eating part of Java's market share. |
| 16:45 | tomppa | is there anything like FROM-ARRAY function for converting Java arrays to Clojure vectors? |
| 16:46 | Chouser | (seq ...) works on java arrays, so you may not need to copy it at all. |
| 16:46 | wwmorgan | (vec (to-array (range 10))) |
| 16:46 | tomppa | great |
| 16:47 | leafw | Chouser: (seq ...) is lazy ? |
| 16:47 | Chouser | hm... I guess it doesn't destroy any laziness that may exist in the underlying collection. |
| 16:50 | leafw | Chouser: I mean when wrapping native java arrays. I thought (seq ..) may duplicate the sequence, by creating a new, clojure-side sequence. |
| 16:50 | leafw | so perhaps not lazy, but shallow. |
| 16:51 | Chouser | ah, yes, shallow. You do get a new object, specifically an ArraySeq, but it only points to the existing array, it doesn't copy it. |
| 16:52 | leafw | great. Thanks. |
| 16:55 | lisppaste8 | Chouser pasted "demo of ArraySeq" at http://paste.lisp.org/display/69357 |
| 16:56 | leafw | thanks, that proves it. |
| 16:56 | leafw | a bit unsafe actually, sometimes one would want to make an explicit duplicate. |
| 16:57 | Chouser | It's also interesting because I was under the impression that seqs cached the values you actually examined, causing the parts you look at to become immutable. Clearly that's not always the case. |
| 16:58 | Chouser | There are other seqs with similar dangers -- seqs made from Iterators, result sets (which can close), etc. |
| 16:58 | Chouser | it's easy to copy them to a vector, though, if needed. As wwmorgan demonstrated. |
| 17:03 | leafw | (vec (to-array (range 10))) I guess. |
| 17:04 | Chouser | yep |
| 17:05 | lisppaste8 | tomppa pasted "List all Java threads/groups" at http://paste.lisp.org/display/69360 |
| 17:05 | tomppa | at least I think that does what I wanted |
| 17:15 | danlarkin | I'm hard up for clojure-isms in python right now |
| 17:40 | tomppa | okay, I got slime-list-threads working, now I just need to define the thread actions |
| 17:58 | duck1123 | is it possible to discard a value when doing a destructuring bind, or do I have to assign it and just not use it? |
| 18:00 | wwmorgan | duck1123: one convention is to use the symbol _ for values you don't use |
| 18:01 | wwmorgan | example here http://clj-me.blogspot.com/2008/07/lazy-butlast.html |
| 18:02 | rhickey | (let [[_ _ _ d e] [1 2 3 4 5]] [d e]) |
| 18:03 | hoeck | wwmorgan: but it does bind _ to (nth x whatever) - would be nice if _ gets ignored while destructuring vectors |
| 18:03 | wwmorgan | hoeck: I don't see the difference? |
| 18:05 | hoeck | wwmorgan: it expands to (let [... _ (nth foo n) ...] so "_" is not really ignored |
| 18:07 | wwmorgan | but when would that ever come up? You wouldn't try to get the value of _ inside the let unless you expected something to be there right? |
| 18:09 | hoeck | yeah, ignoring the _ in destructuring would just avoid the (small) side effect of accessing the vector unnecessary |
| 18:10 | wwmorgan | oh haha yeah |
| 19:02 | Fibtoo | Where does load-file look for files? |
| 19:04 | Fibtoo | I can load a file using a full path, but all the examples I see just use (load-file "foo.clj"); if I try that, I get a FileNotFoundException |
| 19:05 | wwmorgan | Fibtoo: relative to the classpath. |
| 19:18 | Fibtoo | Hmm, guess I am not setting up the classpath correctly for the enclojure REPL then |
| 19:19 | rhickey | load-file is not classpath related, no path uses current directory |
| 20:06 | sohail | so when is someone implementing cl:format for clojure |
| 20:10 | rhickey | sohail: Dan Weinreb's been pretty enthusiastic about Clojure since I met him in Boston and again at OOPSLA. Maybe he'll come on board and do format for Clojure as he did for CL :) |
| 20:11 | sohail | rhickey, good news! |
| 20:12 | sohail | so are you guys finding you can write whole non-trivial applications in clojure or do you have to write java code sometimes too? |
| 20:12 | sohail | I'm ok so far but most java apis are so non-functional it's not even funny |
| 20:13 | Chouser | I don't think anyone has to do more than the smallest of stubs in Java, if anything at all. |
| 20:14 | sohail | Chouser, that's good news! |
| 20:14 | Chouser | I think so. :-) |
| 20:15 | rhickey | anyone here have thoughts on fcase/condp? |
| 20:17 | Chouser | I agree with Mike Hinchey's general preference for extra options on one function than multiple functions, if it can be made to work well. |
| 20:17 | rhickey | What about always throw on no match? |
| 20:18 | rhickey | when no default supplied |
| 20:19 | Chouser | that seems sensible -- I've never used a language that does that, but if it's easy to say :default nil or whatever, then a exception otherwise seems nice. |
| 20:21 | sohail | doesn't ecase throw an error |
| 20:21 | sohail | from cl, that is |
| 20:22 | Chouser | sohail: I think so, but I've never really used CL. |
| 20:23 | sohail | I like ecase when I've used it, fwiw |
| 22:05 | Chouser | Ha! http://twitter.com/fogus/statuses/977626788 |
| 22:09 | arohner | nice |
| 22:09 | arohner | I have a function that takes #^java.sql.Connection |
| 22:10 | arohner | I'm trying to pass in an instance of org.apache.commons.dbcp.PoolableConnection |
| 22:10 | arohner | and I get incompatible class change error. dbcp.PoolableConnection says it implements java.sql.Connection. That should work, right? |
| 22:11 | Chouser | yeah, I'd think so. |
| 22:11 | Chouser | "says" in the docs, or via introspection? |
| 22:11 | arohner | docs. How do I figure out via introspection? |
| 22:11 | Chouser | (supers org.apache.commons.dbcp.PoolableConnection) |
| 22:12 | arohner | user> (supers org.apache.commons.dbcp.PoolableConnection) |
| 22:12 | arohner | #{#=java.sql.Connection #=org.apache.commons.dbcp.DelegatingConnection #=org.apache.commons.dbcp.AbandonedTrace #=java.lang.Object} |
| 22:12 | arohner | that's a pretty awesome function |
| 22:12 | Chouser | it sure is. |
| 22:13 | Chouser | that's what isa? uses. |
| 22:13 | Chouser | and it looks like you've got a java.sql.Connection. Hm... |
| 22:15 | Chouser | what function are you trying to call? |
| 22:16 | arohner | lisppaste8: url |
| 22:16 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 22:16 | lisppaste8 | arohner pasted "query" at http://paste.lisp.org/display/69383 |
| 22:17 | arohner | the exception is on the (.prepareStatement con sql) |
| 22:17 | arohner | that is, if there is no type hint |
| 22:17 | arohner | if there is a type hint, I get the incompatibleClassChange |
| 22:20 | Chouser | sql is a string? |
| 22:21 | arohner | yeah |
| 22:21 | Chouser | I'm pretty stumped. What's the exception without the type hint? |
| 22:22 | arohner | hrm. this is weird. |
| 22:24 | arohner | now it's working |
| 22:24 | Chouser | heh. |
| 22:24 | Chouser | Heisenbug. |
| 22:45 | sleven | i really like that clojure, like python, have such nice syntactic sugar for Maps and other datastructures. a bit different from Hashmap stirng int mymap = new hashmap string int |
| 23:43 | lisppaste8 | bradbev pasted "fwrap" at http://paste.lisp.org/display/69388 |
| 23:44 | bradbev | It's a way to wrap functions. But I get the meta data for :arglists wrong in wrapped functions. Any suggestions on how I can modify :arglists metadata when using (def...) ? |
| 23:45 | bradbev | sorry, I mean "I get the metadata _wrong_ for :arglists" |
| 23:47 | bradbev | is there a big "make this mutable" hammer that I can use to mutate metadata on a symbol? Kinda how def is a mutable hammer for symbols. |
| 23:50 | Chouser | bradbev: I think that came up on the group recently. |
| 23:51 | bradbev | I think I can directly call the Java code to do it ... |
| 23:55 | Chouser | Well, this is what I was thinking of: http://groups.google.com/group/clojure/browse_thread/thread/3f685b8ef6a4ee1c/366ef758830e11da |
| 23:55 | Chouser | Not sure it applies to symbols. |
| 23:55 | bradbev | thanks Chouser |