#clojure logs

2008-10-28

00:00pjb3It would be a nice macro to make that pattern clear
00:00pjb3so you write (defk foo {a "a" b "b" c "c"} (prn :a a) ... )
00:01pjb3Seems like this does that: http://www.turbojugend-cossebaude.de/clojure/defk.clj
00:01pjb3but it seems like a lot of code to make that happen
00:09Chouserwow. yeah, well he's also doing non-keyword args and rest args. my snippet does strictly keyword args.
01:28Jedi_Stanniswriting a little calculator app to learn clojure, can anyone explain the following behavior?
01:28Jedi_Stannisuser=> (= (symbol "+") '+)
01:28Jedi_Stannistrue
01:28Jedi_Stannisuser=> (= (symbol "/") '/)
01:28Jedi_Stannisfalse
01:35Chouseris used as the separator between the namespace and the name of the symbol.
01:35Chouser"/" is used ...
01:36ChouserCompare (name (symbol "/")) with (name (symbol "+"))
01:36Chouser(name (symbol "my-ns/my-name"))
01:37Jedi_StannisI see
01:38ChouserThat's described here under "Symbols" http://clojure.org/reader
01:38Jedi_Stannisso if I want user input and want to convert the string "/" to a symbol, is there some way to escape it?
01:40ChouserI 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:41Chouseryou 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:42Jedi_Stannisok
01:42Chouseror better, why not just keep the / in a string? Is there something special about having it in a symbol that you need?
01:43Jedi_Stannisyeah I think that would work better
05:59Lau_of_DKI 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:02jdzLau_of_DK: (format nil "~R" 100)
06:03jdzand 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:04Lau_of_DKok, thanks
06:04tWipanyone doing project euler puzzles will have written one ;)
06:05Lau_of_DKtWip, nope, because I just used SBCLs
06:05tWipwell I did
06:06Lau_of_DKSo you have something that works in java/clojure?
06:06tWipI have clojure code for it, but only upto one thousand as the task didn't require more
06:06tWipand I don't have the code here at my work machine
06:07Lau_of_DKI should probably invent "my online code vault"
08:53DrakesonI 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:54rhickeyDrakeson: you'll have to look in the JavaDoc for the library. Java packages are not reified/enumerable
08:55rhickeyyou can use reflection to see things in a specific class
08:58slevenim trying to install clojure on ubuntu
08:59sleveni have downloaded and unzipped but I find no explanation of where i should put the folder etc
09:00rhickeysleven: some tips here: http://riddell.us/clojure/
09:00Drakesonis there a way to lookup documentation from within slime?
09:00Drakesonrhickey: actually, do you use slime?
09:00slevenwhat is maven?
09:00rhickeyDrakeson: not yet
09:00Drakesonsleven: you can skip that
09:01Drakesonmaven2 - Java software project management and comprehension tool
09:02duck1123sleven: all you really need is ant
09:02Drakesonrhickey: just FYI, I haven't been able to make slime do a proper debugging ...
09:05Drakesonthis is kind of embarrassing, how do you use javadoc to lookup documentation for, say, java.sql ?
09:05rhickeyDrakeson: http://java.sun.com/j2se/1.5.0/docs/api/index.html
09:06Drakesonrhickey: thanks.
09:06rhickeyAlso 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:07tWipalso jdocs.com and quickref.org
09:07lisppaste8blackdog pasted "introspection" at http://paste.lisp.org/display/69337
09:07rhickeyalso: http://clj-me.blogspot.com/2008/05/jumping-to-javadocs-from-repl.html
09:07tWipYou have new mail.
09:07blackdogDrakeson: those are some functions courtesy of Chouser
09:08tWipsorry about that... my terminal mispasted
09:08rhickeyMaybe someone could gather these and make an entry on the Wiki?
09:08Drakesonactually, is there a command line tool for that?
09:09Drakesonthere is javadoc, which apparently generates the documentation.
09:10Drakesonmy problem is that I have installed a few other java packages that are most likely not in java.sun.com
09:11slevenCould not find the main class: clojure.lang.Repl. Program will exit.
09:11tWipDrakeson: try if they are in jdocs.com
09:11tWipit has javadocs for many libs
09:11Drakesonthey come with -doc packages (debian packages). So, what is the "canonical" way of looking up documentation that is installed on ones machine?
09:11sleven^ get that when trying to run the interpreter
09:22sleveni did exactly as it says on the lnk rich posted
09:44achim_p_sleven: did you skip the maven step?
09:49slevenachim_p: no i needed it to install
09:59slevenhttp://hpaste.org/11544
10:01achim_p_where is clojure.jar in your file system?
10:02slevennot in op/clojure
10:02slevenwhere should it be?
10:03achim_p_sleven: i don't know what maven does, i'm using ant for building clojure
10:04achim_p_if you have ant, try this: in step 5, instead of "mvn install", do "ant"
10:04achim_p_and then: java -cp clojure.jar clojure.lang.Repl
10:05slevenhow do i get ant(what is it)?
10:05sleveni have ant
10:06achim_p_ant is a build tool for java
10:07sleveni see im running it now
10:07achim_p_there should be a clojure.jar after running ant
10:11sleventhere is
10:11slevenbut java -cp clojure .jar isnt enough
10:11slevenjava -cp target/clojure-lang-1.0-SNAPSHOT.jar clojure.lang.Repl
10:11achim_p_java -cp clojure.jar clojure.lang.Repl
10:11slevenstill doesnt work(maybe ti shouldt with ant)?
10:12slevenit works thanks
10:13achim_p_good
10:24Drakesonhow 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:24Drakesonis (. java.lang.Class forName) the way to call it?
10:27slevenwget http://jline.sourceforge.net
10:27slevenwhere odes that put jline?
10:27slevencuz i cant see it
10:27Drakesonheh
10:28ChouserDrakeson: (Class/forName "java.lang.String")
10:29Chousersleven: that probably just downloaded the index.html web page.
10:29Chousersleven: what instructions are you following?
10:30Drakesonget here and download the zip file --> http://downloads.sourceforge.net/jline/jline-0.9.94.zip?modtime=1203704122&big_mirror=0
10:33DrakesonChouser: thanks
10:33Drakesonso, if I have a class, I can access its field using "/", right?
10:34Drakeson*fields
10:36Chouserstatic field or method, yes.
11:00Drakesonis there a fast UI toolkit with java bindings (awt is too sluggish)?
11:00Drakeson(hopefully on Linux)
11:03wwmorganDrakeson: a few people have been talking about Qt/Jambi
11:03wwmorganHere's supposedly a demo in clojure. I haven't had the chance to run it http://paste.lisp.org/display/66213
11:09waltersDrakeson: I've been hacking on http://live.gnome.org/JGIR recently, if you are interested in the GNOME stack
11:24Drakesonwalters: 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:25waltersDrakeson: i mainly ran up against the fact that its public layer is hand coded and the coverage is terrible
11:27Drakesonwalters: 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:29waltersDrakeson: 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:29waltersDrakeson: you might read this thread; http://groups.google.com/group/clojure/browse_thread/thread/22e4696550b6c4fa/686eb076bc89ec33?lnk=gst&q=GUI+#
11:34Drakesonwalters: thanks, that was very useful. I will lurk in that news group...
11:50Drakesonwhat is nil_?
11:51wwmorganDrakeson: my guess is that it's a typo and should be nil)
11:53Drakesonbut what is the meaning of (def x nil (defn [] 1) (defn [] 2)) then?
11:54Drakesonis this how one defines a class?
11:55wwmorgan(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:55Drakesonactually, is there any documentation on "classes" ?
11:56wwmorganDrakeson: http://clojure.org/java_interop
11:56jdzdef only accepts two arguments
11:56jdzand it is not used to define classes
11:57jdzhttp://clojure.org/special_forms#toc1
11:57Drakesonoh, 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:58wwmorganDrakeson: yes. The indentation is the giveaway
12:00Drakesonyet, 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:01H4nsDrakeson: that is because clojure does not really support object oriented programming.
12:01jdzDrakeson: as far as i know there is no such thing
12:01danlarkinDrakeson: you can use the gen-class family of functions if that's what you *really* need
12:02wwmorganDrakeson: look up "Implementing Interfaces and Extending Classes" on the java interop page
12:02slevenor roll your own
12:03danlarkinDrakeson: 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:03Drakesonactually, I am not interested in writing any java code in the "java language". Can I still use clojure "effectively"?
12:04jdzDrakeson: i write function oriented code ;)
12:04ChousukeDrakeson: I'd say yes you can
12:06ChousukeSome java libraries of course might not be the best fit for clojure though
12:06Drakesonok, 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:07Chousukewell, you'll have to work with objects
12:08Chousukejust... clojure manages to make writing java remarkably unlike writing java.
12:09Chousukeand 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:10DrakesonChousuke: 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:14Drakeson[not-so-productive-mode] btw, how about making :(a 1 b 2) mean {:a 1 :b 2} ?
12:14Drakeson(in the reader)
12:17Chousukehmmh
12:17Drakeson(to get more "real" parens)
12:17Chousukethat would be mixing list syntax with map syntax :/
12:18jdzDrakeson: what's the gain?
12:20Drakesonmaybe aesthetic reasons?
12:21jdzwell, aeshetically what's the gain?
12:21jdzaesthetically even
12:21jdzimho it would just be harder to spot that there is a map right there..
12:21Chousukeand with that syntax it looks like a {a 1 b 2}
12:22Chousukewhich is not {:a 1 :b 2} :/
12:22danlarkin-1 for :(a 1 b 2)
12:24Drakesonwell, 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:25jdzDrakeson: there already is a single type of parens
12:25jdzwhatever that means
12:26sohaildoes it matter if they are all sequences anyway?
12:26DrakesonI guess I might prefer (m :a 1 :b 2) over {:a 1 :b 1}
12:27sohailfor what purpose
12:27Chousukeyou can already do that though.
12:28DrakesonChousuke: I know. (defmacro m ...)
12:28Chousuke(hash-map :a 1 :b 1) :P
12:28jdzyou don't need a macro
12:29Drakesondo we have defalias?
12:29danlarkinalias
12:29wwmorganDrakeson: def
12:29Chousukeheh
12:30wwmorganclojure is a lisp-1 so (def m hash-map) and then (m :a 1 :b 2) will do what you want
12:30jdzDrakeson: just don't expect the readers of your code be happy of your renames.
12:33DrakesonI'll see if it looks horrible ...
12:33danlarkin(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:33Drakesonwhat is the benefit of the {} syntax?
12:34Chousukeit's succinct, and doesn't look like a list or a vector
12:35Drakesonso you mean I should not rely on the highlighting/colorizing in the text-editor?
12:35Chousukeno, those help
12:35Chousukebut the {} syntax is instantly recognisable
12:35jdzand it is read as a literal object, not as a function call at runtime
12:35Chousukeyou see a {} it
12:35Chousukeit's a map.
12:36Drakesonso, I can make (m :a 1 :b) to be very distinguishable (totally different colors, etc.)
12:36jdzDrakeson: so how will your map print then?
12:36Drakesonjdz: right. that's why I prefer something directly in the reader.
12:36Chousukeyeah, but that will be read in as a list. {} will be read in as a map
12:37jdzbut {} already is in the reader...
12:37adakkakdoes anyone know if clojure supports parallel programming across machines?
12:37Chousukecl and scheme discriminate against non-list data structures. clojure brings two others up to the same level ;)
12:38gnuvince_three: vectors, hash-maps and sets
12:38DrakesonChousuke: I like that clojure has distinguishable builtin support for vectors and hash-tables, I just want that to even look more like lists.
12:38gnuvince_Don't forget sets
12:38Chousukegnuvince_: ah, right, forgot sets
12:39ChousukeDrakeson: but that'd just be confusing :/
12:39ChousukeDrakeson: if it isn't a list, why does it need to look like a list?
12:40Drakesonso I can quickly switch between lists and other types when I find the other data-type is better.
12:41jdzDrakeson: it's not the data structure that makes it possible to switch them, but the functions that operate on them
12:42jdzDrakeson: it's called abstract data types
12:43Drakesonjdz: 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:43jdzthey both are wrong
12:44jdzthey should be something like (make-my-something :a 1 :b 2)
12:44jdzwhich would internally call either list or hash-map
12:47danlarkinI 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:47Chousukenah
12:48Chousukejust write your logic using sequences
12:48Chousukespecify only that my-something is a sequence, and you can return any sequence depending on how the stars are aligned or whatever :)
12:49jdzthe 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:51Drakesonjdz: 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:51Drakesonso, I prefer meta over ^, etc.
12:51jdzDrakeson: if you use abstract data types, you won't see {}
12:52jdzexcept when printing out values
12:52tWipbut why propose new syntax for maps if you want to avoid more syntax
12:53DrakesontWip: I consider "(m :a 1) instead of {:a 1}" less syntax.
12:54tWipdidn't someone just propos :(a 1 b 2) or something
12:54ChousukeDrakeson: how would you print a map though, if {} didn't exist?
12:54DrakesontWip: I dropped that.
12:54jdzDrakeson: you already have (hash-map :a 1)
12:54jdzDrakeson: i don't see your point, sorry.
12:54ChousukeDrakeson: if you print (m :a 1 :b 1) it would not be a map, it would be a list :/
12:55Chousuke(one that evaluates to a map though)
12:55jdzwhen given to eval
12:55jdzwhich is evil
12:57Drakesonok, 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:57Drakesonthere may or may not be solution to satisfy both.
12:58danlarkinI 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:58Chousukeone thing I *really* like about clojure is that it uses the vector syntax in places like defn/defmacro argument lists and let forms.
12:58Chousukeit
12:58Chousukeit's so much clearer :P
12:59DrakesonChousuke: why it is clearer?
12:59wwmorganalso 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:59Chousukewell it clearly separates the naming, the arguments, and the code
12:59DrakesonChousuke: I don't consider that a real benefit.
13:00Chousukemaybe you don
13:00Chousukedon't*
13:00Chousukedamn I keep hitting the enter too much :/
13:00Drakesonheh
13:01H4nsDrakeson: don't use clojure then - really, it does not make sense to discuss syntax. write code instead :)
13:01Chousukeevil ' is right next to it.
13:03DrakesonH4ns: 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:03Chousukebut 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:05H4nsDrakeson: 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:05H4nsDrakeson: i'd rather see more idiomatic clojure code appear and be discussed than the syntax be changed.
13:06Chousukewhat's the idiomatic clojure alternative to keyword arguments? just take a map parameter?
13:06danlarkinChousuke: 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:08rhickey_I would recommend anyone who thinks Clojure should be different use it for a while, then reconsider
13:10gnuvince_Hear hear
13:12DrakesonH4ns: 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:13Drakesonbut I have no clue whether this can be achieved.
13:15ChousukeI 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:16sohailI thought Norvig believes in Python now
13:19gnuvince_We could send him a free copy of Stuart's book when it is released
13:19Drakesongnuvince_: what is it about?
13:19Drakesonclojure?
13:20gnuvince_Drakeson: yes.
13:20gnuvince_http://www.pragprog.com/titles/shcloj/programming-clojure
13:21sohail"a modernized Lisp dialect"
13:21sohailtake that out, you'll alienate 80% of potential users :-)
13:22Drakesonsohail: 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:23DrakesonMarch 15 is too late ;)
13:23sohailya march 15 is so far
13:23sohailwe need a beta
13:23Drakesonsure we do
13:24Drakesonor I have to litter #clojure with newb questions ...
13:24ChousukeAnyway, 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:25duck1123we can't even pre-order the beta yet, can we?
13:26danlarkinChousuke: I also love python's *args, **kwargs idiom
13:26sohailclojure doesn't have keyword arguments eh..
13:27Chousukewhen 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:27rhickey_you can get them with macros, just not a part of fn syntax, since it's not a primitive notion
13:27sohailrhickey_, I was just about to say that I've used them in macros mostly
13:28Chousukethat's just a toggle, not a real keyword arg though.
13:28Chouserhttp://paste.lisp.org/display/69329 -- keyword args with defaults
13:29sohailnice, now write a (defn*
13:31Chousukethat doesn't allow mixing positional/&rest with keyword args though. I wonder if that's even possible
13:31Chouseryeah, someone wrote a macro. hang on...
13:31Chouserhttp://www.turbojugend-cossebaude.de/clojure/defk.clj
13:34Chousukehmm.
13:34Chousukelooks nice.
13:36sohaillooks like a winner
13:36sohailCPL is like BSD?
13:37Drakesondoesn't it look more permissive?
13:38sohailsomeone needs to execute M-x fill-paragraph on CPL.txt
13:39sohailmore permissive than BSD?
13:40Drakesonthat was my first impression
13:40lisppaste8rhickey pasted "defnk" at http://paste.lisp.org/display/69347
13:43sohailrhickey_, that's awesome
13:50Drakesonhave you guys managed to make slime working well with clojure? I don't get completion, debugging, etc.
13:51Drakeson*work
14:03sohailDrakeson, 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:04sohailoh that's a lie, apparently completion works now
14:05Drakesoncan I see the relevant slime-setup parts of your .emacs ?
14:05DrakesonI have (slime-setup '(slime-fancy slime-asdf slime-tramp slime-fuzzy)) for sbcl
14:07Drakesonit doesn't even complete def<TAB> here
14:09sohailin a bit, debugging some err... concurrent C++ code...
14:09sohailironically enough
14:10Drakesonthanks
14:11duck1123I turn on pabbrev-mode for my completion
14:11duck1123I got used to using it with Ruby, so I just carried that behavior over
14:12Drakesonduck1123: so you only get M-/ ?
14:14sohailDrakeson, seems I misunderstood what you said... I was thinking hints not completion
14:17duck1123pabbrev uses [tab]. Not sure if M-/ also works for it, but I'm pretty sure M-/ was already working for me.
14:50Drakeson(resolve 'init)
14:51Drakesonheh. sorry.
14:55gnuvince_Hey guys, how would you find the most frequent letter in a string?
14:55gnuvince_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:02wwmorgangnuvince: here's how I would do it http://paste.lisp.org/display/69348
15:05gnuvince_wwmorgan: essentially the same thing, but with a nicer separation.
15:10rhickey_another way to do freqs http://paste.lisp.org/display/69348#1
15:21tomppaShouldn't (try (/ 1 0) () (print 'foo)) always print foo?
15:24tomppafor some reason it seems like the finally expressions are no longer evaluated
15:25kotaraktomppa, the syntax is (try (/ 1 0) (finally (print 'foo)))
15:25tomppaoh great. thanks
15:27tomppait is just funny that I think it worked the other just a while ago... oh well
15:52tomppais anybody here familiar with the internals of the clojure slime mode?
15:53Drakesontomppa: I am only familiar with parts of it that do not work :D
15:53tomppaI'm trying to send sexps from emacs to clojure with (slime-eval '(+ 1 1)) but I just get "Synchronous Lisp Evaluation aborted" error
15:53tomppahow does the clojure mode send sexps to be evaluated
15:54Drakesondid you follow http://en.wikibooks.org/wiki/Clojure_Programming#Emacs_.2F_Slime_Integration ?
15:55Drakesontomppa: it works for me (TM)
15:55tomppayes, I think I got everything set up just about right. AFAIK the parts that should work work.
15:55tomppaI'd just like to send expressions to be evaluated in clojure from the emacs lisp side
15:56tomppaWith CLs the slime-eval works for that
15:56Drakesontomppa: it works the same way for me. I C-x C-e in a "Clojure"-mode buffer, and it does the right thing
15:56Drakesoncan you check the error messages?
16:01tomppahmm, 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:02tomppathere are no errors in the Clojure side
16:03tomppaI'll have to dig around the swank-clojure.el etc. to see how it's supposed to work
16:03jgracintomppa: 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:04jgracintomppa: there's some other function that takes a string
16:04Drakesonjgracin: slime-eval-last-expression works
16:06jgracinDrakeson: 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:07jgracinIsn't that what (slime-eval '{:a 1}) would mean?
16:07tomppabut elisp can't read all CL expressions either. Esp. when you throw in custom read macros
16:08jgracintomppa: and does slime-eval work in that case?
16:10tomppaI don't think it does
16:12jgracintomppa: try looking at *slime-events* buffer to see the difference between messages when you use slime-eval explicitly and the normal events.
16:13tomppaok. It seems that slime-interactive-eval takes strings, so that is probably what I would need
16:13tomppawoo, it works :) An I was sure I already tried all the options.
16:15jgracintomppa: oh, yeah, I just remembered... that was the function that I'd found as well. :-)
16:16tomppais there a way to get a list of all active threads in Java? I'd like to have slime-list-threads working
16:19jgracintomppa: http://www.java-forums.org/java-lang/7345-listing-all-threads-threadgroups-vm.html
16:20tomppathanks, I just found it myself too :)
16:25robewaldhello, how do I subscribe to the mailing list without having a google account?
16:29tomppaI don't have much Java experience but exploring the API and runtime with Clojure is actually quite fun
16:33jgracintomppa: I totally agree. Clojure is what Java needs to stay alive.
16:34ChouserJava isn't thriving pretty well on its own?
16:34tomppawell, I don't care much about Java but the JVM could be handy
16:36abrooksChouser: There's a difference between lumbering and thriving, right? :)
16:37Chouserabrooks: are you saying lumber doesn't thrive?
16:37abrooksWhat wood you say?
16:37abrooks;-D
16:37Chouser..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:39abrooksChouser: 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:45tomppais there anything like FROM-ARRAY function for converting Java arrays to Clojure vectors?
16:46Chouser(seq ...) works on java arrays, so you may not need to copy it at all.
16:46wwmorgan(vec (to-array (range 10)))
16:46tomppagreat
16:47leafwChouser: (seq ...) is lazy ?
16:47Chouserhm... I guess it doesn't destroy any laziness that may exist in the underlying collection.
16:50leafwChouser: I mean when wrapping native java arrays. I thought (seq ..) may duplicate the sequence, by creating a new, clojure-side sequence.
16:50leafwso perhaps not lazy, but shallow.
16:51Chouserah, 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:52leafwgreat. Thanks.
16:55lisppaste8Chouser pasted "demo of ArraySeq" at http://paste.lisp.org/display/69357
16:56leafwthanks, that proves it.
16:56leafwa bit unsafe actually, sometimes one would want to make an explicit duplicate.
16:57ChouserIt'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:58ChouserThere are other seqs with similar dangers -- seqs made from Iterators, result sets (which can close), etc.
16:58Chouserit's easy to copy them to a vector, though, if needed. As wwmorgan demonstrated.
17:03leafw(vec (to-array (range 10))) I guess.
17:04Chouseryep
17:05lisppaste8tomppa pasted "List all Java threads/groups" at http://paste.lisp.org/display/69360
17:05tomppaat least I think that does what I wanted
17:15danlarkinI'm hard up for clojure-isms in python right now
17:40tomppaokay, I got slime-list-threads working, now I just need to define the thread actions
17:58duck1123is it possible to discard a value when doing a destructuring bind, or do I have to assign it and just not use it?
18:00wwmorganduck1123: one convention is to use the symbol _ for values you don't use
18:01wwmorganexample here http://clj-me.blogspot.com/2008/07/lazy-butlast.html
18:02rhickey(let [[_ _ _ d e] [1 2 3 4 5]] [d e])
18:03hoeckwwmorgan: but it does bind _ to (nth x whatever) - would be nice if _ gets ignored while destructuring vectors
18:03wwmorganhoeck: I don't see the difference?
18:05hoeckwwmorgan: it expands to (let [... _ (nth foo n) ...] so "_" is not really ignored
18:07wwmorganbut 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:09hoeckyeah, ignoring the _ in destructuring would just avoid the (small) side effect of accessing the vector unnecessary
18:10wwmorganoh haha yeah
19:02FibtooWhere does load-file look for files?
19:04FibtooI 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:05wwmorganFibtoo: relative to the classpath.
19:18FibtooHmm, guess I am not setting up the classpath correctly for the enclojure REPL then
19:19rhickeyload-file is not classpath related, no path uses current directory
20:06sohailso when is someone implementing cl:format for clojure
20:10rhickeysohail: 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:11sohailrhickey, good news!
20:12sohailso are you guys finding you can write whole non-trivial applications in clojure or do you have to write java code sometimes too?
20:12sohailI'm ok so far but most java apis are so non-functional it's not even funny
20:13ChouserI don't think anyone has to do more than the smallest of stubs in Java, if anything at all.
20:14sohailChouser, that's good news!
20:14ChouserI think so. :-)
20:15rhickeyanyone here have thoughts on fcase/condp?
20:17ChouserI 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:17rhickeyWhat about always throw on no match?
20:18rhickeywhen no default supplied
20:19Chouserthat 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:21sohaildoesn't ecase throw an error
20:21sohailfrom cl, that is
20:22Chousersohail: I think so, but I've never really used CL.
20:23sohailI like ecase when I've used it, fwiw
22:05ChouserHa! http://twitter.com/fogus/statuses/977626788
22:09arohnernice
22:09arohnerI have a function that takes #^java.sql.Connection
22:10arohnerI'm trying to pass in an instance of org.apache.commons.dbcp.PoolableConnection
22:10arohnerand I get incompatible class change error. dbcp.PoolableConnection says it implements java.sql.Connection. That should work, right?
22:11Chouseryeah, I'd think so.
22:11Chouser"says" in the docs, or via introspection?
22:11arohnerdocs. How do I figure out via introspection?
22:11Chouser(supers org.apache.commons.dbcp.PoolableConnection)
22:12arohneruser> (supers org.apache.commons.dbcp.PoolableConnection)
22:12arohner#{#=java.sql.Connection #=org.apache.commons.dbcp.DelegatingConnection #=org.apache.commons.dbcp.AbandonedTrace #=java.lang.Object}
22:12arohnerthat's a pretty awesome function
22:12Chouserit sure is.
22:13Chouserthat's what isa? uses.
22:13Chouserand it looks like you've got a java.sql.Connection. Hm...
22:15Chouserwhat function are you trying to call?
22:16arohnerlisppaste8: url
22:16lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
22:16lisppaste8arohner pasted "query" at http://paste.lisp.org/display/69383
22:17arohnerthe exception is on the (.prepareStatement con sql)
22:17arohnerthat is, if there is no type hint
22:17arohnerif there is a type hint, I get the incompatibleClassChange
22:20Chousersql is a string?
22:21arohneryeah
22:21ChouserI'm pretty stumped. What's the exception without the type hint?
22:22arohnerhrm. this is weird.
22:24arohnernow it's working
22:24Chouserheh.
22:24ChouserHeisenbug.
22:45sleveni 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:43lisppaste8bradbev pasted "fwrap" at http://paste.lisp.org/display/69388
23:44bradbevIt'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:45bradbevsorry, I mean "I get the metadata _wrong_ for :arglists"
23:47bradbevis 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:50Chouserbradbev: I think that came up on the group recently.
23:51bradbevI think I can directly call the Java code to do it ...
23:55ChouserWell, this is what I was thinking of: http://groups.google.com/group/clojure/browse_thread/thread/3f685b8ef6a4ee1c/366ef758830e11da
23:55ChouserNot sure it applies to symbols.
23:55bradbevthanks Chouser