#clojure log - Feb 21 2009

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:06 slashus2: ,#=()

0:07 That gives me a NullPointerException

0:07 Is that a normal behavior?

0:12 blbrown: java approach to getting a file extension from a filename, (. a substring (- (count a) 4)) anyone have a more clojure oriented approach

0:12 where a = "MyFile.clj")

0:17 slashus2: blbrown: (seq (.split "myfile.clj" ".")) <-- I wonder why this doesn't work?

0:20 blbrown: slashus2, I normally don't include the '.' with split as I have files that have multiple '.'

0:20 slashus2: blbrown: It returns nil and I don't know why.

0:22 blbrown: Maybe I am not seeing something obvious.

0:23 blbrown: hmm, split returns a java array. yet seq on that array returns nil

0:23 slashus2: vec does the same thing

0:23 []

0:23 Not nil, but still it doesn't return the split

0:24 blbrown: No one responded when I said that #=() threw a NullPointerException, but I am not sure why it does that.

0:25 blbrown: wrong person, I have only been getting into clojure this last month

0:26 slashus2: Java does the same thing when I run System.out.println("hello.clj".split(".").length); the length is zero.

0:26 curious

0:26 blbrown: slashus2, oh yea, regex, escape the .

0:26 maybe

0:26 slashus2: why?

0:26 It isn't a regex

0:26 it is a string

0:27 blbrown: slashus2, the dot is a regex operator

0:27 try this. (seq (.split "myfile.clj" "\\."))

0:27 slashus2: That works ..

0:27 OHHH split takes a regex

0:27 *feels dumb*

0:27 blbrown: hehe

0:28 slashus2: Chouser: Sorry to bother you, but is #=() suppose to throw a NullPointerException?

0:28 blbrown: (last (seq (.split "myfile.clj" "\\."))) ... so I guess this would get the file extension

0:28 slashus2: yeah

0:29 (last (.split "myfile.clj" "\\."))

0:29 I don't think you need seq

0:29 hiredman: slashus2: why wouldn't throw an PNE?

0:29 it

0:29 NPE

0:30 ugh

0:30 slashus2: I was just playing around with different reader expressions, and it surprised me.

0:30 hiredman: #=() executes whatever is inthe parens

0:30 nothing in the parens, it tries to execute nothing, NPE

0:31 slashus2: Fair enough.

0:33 blbrown: slashus2, curious, what are you trying to do, I don't know the operators

0:33 hiredman: ,(.invoke inc 1)

0:33 clojurebot: 2

0:33 hiredman: ,(.invoke nil 1)

0:33 clojurebot: java.lang.NullPointerException

0:33 blbrown: is that like apply, hmm

0:33 funccall I mean

0:34 ,#=(+ 1)

0:34 clojurebot: 1

0:34 slashus2: hiredman: Okay, that is pretty consistent.

0:34 blbrown: ,#=(+ 1 1)

0:34 clojurebot: 2

0:34 blbrown: ,#=()

0:34 Chouser: ,(re-find #"\.[^.]*$" "foo.bar.baz.jar")

0:34 clojurebot: ".jar"

0:34 blbrown: Chouser, you like that one better

0:34 * Chouser shrugs

0:34 Chouser: pretty scary regex, I guess

0:35 blbrown: not really

0:35 Chouser: no, last on the one you had is good.

0:35 ,(re-find #"[^.]*$" "foo.bar.baz.jar")

0:35 (re-find #"[^.]*$" "foo.bar.baz.jar")

0:35 clojurebot: "jar"

0:35 blbrown: ,(re-find #"[^.]*$" "foo.bar.baz.jar")

0:35 clojurebot: "jar"

0:36 Chouser: I like to use the #"" literal regex when I can, but .split is fine too.

0:36 you've solved it, move on. :-)

0:37 * blbrown puts his hands in the air

0:38 Chouser: ? goal? have a question?

0:39 blbrown: no... I was saying put my hands in the air because we are OK with the solution "Fine ...lets move on"

0:44 hiredman: ,#=()

0:44 clojurebot: nil

0:44 hiredman: hmmm

0:44 slashus2: hmm?

0:44 What?!?

0:45 hiredman: tuning eval-in-box

1:10 nullman`: how do i do something like mapcar in clojure? ex: (mapcar #'(lambda (x) (* x 999)) '(1 2 3))

1:11 hiredman: what does mapcar do?

1:13 ,(prn 1)

1:13 clojurebot: 1

1:13 hiredman: hmm

1:13 slashus2: If it existed, it may apply to the first item of every sequence given to it?

1:14 nullman`: takes the car of each element in the '(1 2 3) list and applies the lambda function to it and returns a list, result is: '(999 1998 2997)

1:14 hiredman: ,#=()

1:15 ,(map #(* % 999) '(1 2 3))

1:15 clojurebot: (999 1998 2997)

1:15 nullman`: cool, i was using map differently and it was not working; thanks again

1:21 pjb3: I'm trying to create a Java object in clojure at runtime that has a method, and then call that method

1:21 (.foo (proxy [Object] [] (foo [] "foo")))

1:22 java.lang.IllegalArgumentException: No matching field found: foo for class clojure.proxy.java.lang.Object

1:22 Why doesn't that work?

1:27 hiredman: ,#=()

1:27 hmmm

1:27 ,#=()

1:29 slashus2: hiredman: What are you experimenting with?

1:39 hiredman: slashus2: clojurebot's sandbox

1:39 I would like it if ,#=() returned the NPE exception

1:40 slashus2: okay

1:42 hiredman: cannot seem to catch reader exceptions

1:42 :/

2:33 Chouser: http://clojure.googlegroups.com/web/issues-graph.png

2:35 slashus2: I think that is good?

2:38 Chouser: many more closed than open is good

2:38 but really it's a demo of code I'm working on -- scrape the issues page, process the data, draw a graph

2:38 slashus2: yep

2:39 Chouser: just under 95 lines, though I think I can tighten that up a bit

2:39 but not tonight

2:40 slashus2: You just writing a BufferedImage?

2:40 Chouser: JFreeChart

2:40 via Dejcartes

2:41 slashus2: okay, neat

2:41 Chouser: using tagsoup + zip-filter for the html scraping

8:02 Lau_of_DK: Java CP question. I have my entire program running in the namespace foo.bar.baz, and my directory structure is /project/src/foo/bar/baz.clj. Now I want to add a res / resources directory, and I want to load files from it, without having to supply absolutely paths. Where do I put it, how do I link?

10:01 How do I use getClassLoader with Clojure-genclassed-classes ?

12:28 package com.jme.image;

12:28 public abstract class Texture implements Savable {

12:29 This class com.jme.image.Texture has a public enum called MinificationFilter - How do I acces it from my Class which extends an another class ?

12:30 Chouser: com.jme.image.Texture$MinificationFilter/Trilinear

12:39 Lau_of_DK: Love you Chouser :)

12:44 blbrown: if I am running clojure as a script through the Repl main class. How do I pass args. E.g. I tried using this. *command-line-args* but I get nil returned

12:45 ayrnieu: blbrown - why use Repl instead of Script?

12:46 blbrown: ayrnieu, clojure.lang.Repl didn't know about Script

12:47 is there a big difference

12:47 ayrnieu: blbrown - look at GettingStarted or somesuch on the wiki. It has a 'clj' shell script with if [ $# -eq 0 ] then; rlwrap ...; else java ... clojure.lang.Script $1 -- $@

12:47 fi

12:48 well, *command-line-args* works as you'd lke.

12:48 danlarkin: Lau_of_DK: I'm very close to being able to having something to show you, but I still need a name...

12:49 Lau_of_DK: danlarkin: Stop teasing me! :)

12:50 I've almost built a 3D game in the time you took deciding on a name :)

12:50 danlarkin: haha yeah yeah yeah

12:57 blbrown: ayrnieu, still not getting my args for some reason. Here is some more code http://paste.lisp.org/display/75910 (waits for obligatory lisp code improvements)

12:58 Chouser: you need a -- after Script and before $1

12:58 blbrown: cr@p

13:00 Chouser, you sure it isn't after the $1

13:33 [#^java.io.File d] hmm, this is interesting. Is this a way to force type safety on args passed to a function. Just saw this in the clojure code

13:33 ayrnieu: blbrown - for efficiency, for type checking, for documentation.

13:34 blbrown: nice

13:34 clojure = best language ever

13:36 ayrnieu: well, efficiency and documentation anyway. I can't get #^java.io.File to complain. It's a reasonable addition to the language, though.

13:39 Lau_of_DK: danlarkin: I just got a 3d-landscape generated by a fractal to render quite nicely - got a name yet? :)

13:41 Chouser: right, not for type checking

13:41 ayrnieu: danlarkin, names don't bless projects so much as projects bless names. So if you make an excellent project, you can pretty much call it something absurd like 'Hutchentoot' or 'Clojure'.

13:42 Lau_of_DK: yea!

13:55 rhickey: ayrnieu: You don't like "Clojure" eh?

13:55 Lau_of_DK: uh oh

13:56 ayrnieu: rhickey - it's hard to say, I have to pretend that I don't associate it with Clojure.

13:56 Lau_of_DK: rhickey: Since youre finally awake - Did you consider my request for float short-hand syntax ?

13:56 rhickey: It's worked out well, searchability alone has been great

13:57 Lau_of_DK: what request?

13:57 danlarkin: ayrnieu: that's good advice I guess

13:58 Lau_of_DK: rhickey: My request for (class 5.0f) => float

14:00 ayrnieu: danlarkin - well, the one pitfall with names is that names can also be a form of advertisement, and advertisements tend to put blinders on people that they get really annoyed because of. So if you write the world's most perfect webserver but call it 'SDL-asteroids', people are going to tend to complain that it wasn't fun, that the graphics were bad, etc.

14:02 rhickey: Lau_of_DK: you'll never quite get that, as (class x) is a function that takes an Object, like all other functions. But (let [x 5.0f] ...) could yield a local x of primitive float type. I think the only issue is consistency - i,l,f,d - I,L,F,D? the lower case L and upper case i both have problems next to numbers IMO

14:03 danlarkin: ayrnieu: heh, yeah

14:03 Chouser: use the last letter instead of the first. Then instead of i,l,f,d you have r,g,t,e

14:03 Lau_of_DK: Of course youre right, bad example

14:03 rhickey: Chouser: intuitive :)

14:04 Lau_of_DK: Chouser: No good :)

14:04 rhickey: If you could add it with the Caps, I'll be very happy. Im doing bindings for a 3D engine, and using almost nothing but floats :)

14:04 * Chouser enjoys his own jokes.

14:05 danlarkin: oh I have an original idea, what about adding a "type declaration" before the variable name the first time it's used, so (let [float x 5.0] ...) :)

14:05 ayrnieu: Chouser - you forgot ratio. 1.5O

14:05 rhickey: danlarkin: ick

14:06 danlarkin: the humor didn't come across there as I'd hoped it would

14:06 ayrnieu: (declare (type float x))

14:07 rhickey: It ends up it might be possible to always make (let [x 5.0] ...) a primitive *double*

14:07 due to contagion

14:08 there's not a lot of advantage to using float vs double anymore

14:08 Lau_of_DK: except when Java requires it...

14:09 * rhickey is trying not to get sucked into Slava's optimization vortex

14:10 rhickey: Lau_of_DK: that conversion is a separate issue

14:10 Lau_of_DK: how so?

14:14 rhickey: Here, 5.0 is always a double, but I really need floats, is there any drawbacks to providing 5.0F ?

14:21 ayrnieu: just (macrolet [f (fn [x] `(float ~x))] ... (f 5.0)) -- some assembly required.

14:22 (let-type float [g 5.0 x 2.0] ...)

14:24 (with-numeric-context float (blah blah blah 2.0) (blah blah 5.0))

14:35 rhickey: Lau_of_DK: as I said, I'm not opposed, but what about l and I?

14:36 Lau_of_DK: l and I?

14:36 rhickey: there you go

14:36 el and eye

14:36 Lau_of_DK: For long/int ?

14:36 rhickey: right

14:37 Lau_of_DK: 5 = int, 5.0 = double, 5.0F = float, 5.0L = long, any problems with that?

14:38 rhickey: Lau_of_DK: 5.0L is not going to be ok, 5L is, but you can't have the 5 = int default either

14:39 Lau_of_DK: Youre right about 5.0L = no go of course, but why would that compromise the int being default?

14:40 rhickey: since default operations on ints can become bigints, the int cast is required to tell me you think that's not going to happen

14:41 Lau_of_DK: Hm - Thats a little unfortunate

14:41 rhickey: (loop [x 5] ... (recur (something-that-promotes-to-bigint x))) normally works

14:43 Lau_of_DK: But does this really have to be a part of the bigger discussion? The concret situation is just, that when working with 3D, massive series of (float 255.5) become a little lengthy, so cant we start by having the F suffix only?

14:44 Chouser: rhickey: slava's most recent prodding caused me to consider if it would be a net win to cache the most recent reflection result at each call site, to try a set of 'instance?' calls first before falling back to full reflection.

14:44 is this the kind of vortex you're trying to avoid? :-)

14:46 rhickey: Chouser: reflection has caches already. There are well-known call-site optimizations for that stuff, the invokedynamic enhancements also support that kind of work

14:46 pilkarn: hmm is it worth tryong to write an android-game in clojure? or is it gonna be too much wrapping of Java-calls only and some potential difficulties with compiling and speed?

14:47 Lau_of_DK: pilkarn: android game?

14:47 pilkarn: sorry game for the Android-phones. an shott-em-up sidecscrolelr 2d

14:47 shoot

14:48 Lau_of_DK: how is the Monkey engine stuff? is it to Java-ish to be worth ding in Clojure? or can you do a lot of stuff on top of it in Clojure?

14:48 Lau_of_DK: pilkarn: I think if you never try, you'll never know :)

14:48 pilkarn: That initial building of the stage and generating classes is too much Javaish for my taste, but Im hoping for clear skies after that

14:49 rhickey: Chouser: http://groups.google.com/group/clojure/browse_frm/thread/2590ee3c75c04e91/c5c9377644096c49#c5c9377644096c49

14:51 Chouser: so, compile time fastpath rather than runtime like I just described.

14:57 rhickey: right, I think in a lot of cases the best guess will be right - this all falling out of lack of import blah.*

15:01 Chouser: because you have small set of specific classes to check

15:01 rhickey: should be in most cases

15:02 just those with method matching name + arity

15:04 Chouser: so are you doint this, or avoiding doing it? :-)

15:04 doing

15:05 rhickey: I'm not doing it at this moment, but I think reflection should go this way, Slava's points were more about numerics

15:06 There, the issues have to do with local vars needin a fixed representation, as I just was saying, if an int might convert to a bigint it must be a local of Object type

15:12 Chouser: ah, sure.

15:31 pilkarn: is there an xbox-dev channel?

15:34 alinp: hi

15:35 is there a default way to create a list with a default number of elements ?

15:35 nil elements for instance

15:35 there is ... range

15:35 but it's not the one that I want

15:35 I made something like: defn create [i] (if (zero? i) () (lazy-cons nil (create (dec i)))))

15:36 Chouser: what are you going to do with that once you've made it?

15:36 alinp: is there a more elegant way for doing this ?

15:36 jochu: alinp (replicate nil 10) ?

15:36 Chouser: ,(replicate 5 nil)

15:36 clojurebot: (nil nil nil nil nil)

15:36 Chouser: jochu: close :-)

15:36 jochu: right :P dyslexic

15:36 thanks

15:36 alinp: jochu: NPE

15:36 :)

15:37 ok, thanks jochu

15:37 Chouser: it's one fix that I have :)

15:37 I want to add/remove data from/to it

15:37 depending on nil values that I have there

15:38 Chouser: you can only add or remove data from one end

15:38 alinp: didn't know about replicate, nice

15:38 Chouser: of a seq or list

15:38 alinp: no, I want to already have the coll

15:38 for a fixed size

15:39 Chouser: do you want a vector? seqs and lists can only have items added or removed on one end, you can't change, add, or removed values from the middle

15:39 alinp: hmmm, ...

15:39 really ? :)

15:40 ok, if so, I'll use vectors

15:40 now I have one small strange q

15:40 ,(doc replicate)

15:40 clojurebot: "([n x]); Returns a lazy seq of n xs."

15:40 alinp: xs = ?

15:40 what means xs ?

15:41 coll = collection

15:41 hiredman: Chouser: technically you cannot remove items from any clojure data structure

15:41 alinp: hiredman: I don't want to modify structures

15:42 but to have some default structure that I'll "modify" and return

15:42 I'm not mutating them

15:43 Chouser: hiredman: indeed. imagine air quotes around all such verbs.

15:43 ,(assoc (into [] (replicate 5 nil)) 2 42)

15:43 clojurebot: [nil nil 42 nil nil]

15:44 alinp: ,(doc into)

15:44 clojurebot: "([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."

15:44 hiredman: Chouser: but it that cases lists are just as amendable to "modification" as vectors hashes

15:44 just not indexed

15:49 Chouser: well, you'd use 'into' to build the vector, and then pass that around.

15:49 creating a new vector with the nth item changed to a new value is both faster and much more convenient api-wise than changing the nth item in a seq.

15:50 alinp: yes, fair enough Chouser

15:50 thanks

15:50 drewr: So how's the lazy migration? I'm scared to start without knowing how long the investment will take.

15:50 rhickey: drewr: all done here

15:50 :)

15:51 drewr: rhickey: Good, cuz I was worried about you. :-)

15:51 * rhickey just argues on c.l.l. all day now

15:52 drewr: Dangit, don't make me resubscribe to that.

15:52 Chouser: I think the hardest part is test coverage to flush out all the nil puns, unless you already had unit test coverage of course.

15:53 The second hardest is if you have complex lazy-cons usage -- I have to think a bit to correctly convert to lazy-seq. Fortunately those are pretty rare.

15:54 Lau_of_DK: Anybody know if Swank-clojure/SLIME are up to speed with Clojure yet?

15:54 drewr: Lau_of_DK: I know he's been working on it.

15:54 Haven't tried yet.

15:55 danlarkin: jochu has graced us with his presence, he could probably tell you

15:55 rhickey: http://groups.google.com/group/comp.lang.lisp/browse_frm/thread/0d05837df1efe075/36204b1134ccd1c9?hl=en#36204b1134ccd1c9

15:55 Chouser: or: http://groups.google.com/group/comp.lang.lisp/search?group=comp.lang.lisp&q=richhickey

15:55 :-)

15:56 Lau_of_DK: How do I use Proxy for overriding 2 or 3 methods ?

16:00 slashus2: Lau_of_DK: (name [params*] body) or (name ([params*] body) ([params+] body) ...)

16:00 Chouser: Lau_of_DK: example here: http://groups.google.com/group/clojure/msg/1aca89d1a53dbd1c

16:01 hiredman: ~def future

16:03 future-call has an example as well

16:03 Lau_of_DK: Thanks guys

16:07 jochu: Lau, yeah - it should be working with lazy-seqs now.

16:12 jgracin_: rhickey, any estimates on when 1.0 will be released? Is "lazier" the last major breaking change before 1.0?

16:13 We have pushed our Clojure code into production, so any info helps...

16:14 rhickey: jgracin_: I want to change watchers back to synchronous, but you'll be able to emulate current behavior easily, other than that, I don't think so - that's why I was working on lazier

16:15 jgracin_: rhickey: nice to hear that. thanks!

16:28 technomancy: jochu: thanks!

16:28 so glad to hear that

16:29 hiredman: ugh, I really shouldn't read c.l.l, but it is like rubber-necking at train wreck

16:30 technomancy: hiredman: it's such a black hole

16:32 jochu: what did you think of the idea of distributing clojure-mode with a list of "last-known-good sha1s" for each of the dependent projects?

16:32 would have been a lot more useful if it had been implemented right before the lazy merge, but still. =)

16:33 * technomancy crosses his fingers and hits M-x clojure-update

16:36 jochu: technomancy: well, with slime also being a moving target, it still bight be a good idea. though it does mean we'd have to keep those up to date which could be a bit painful.

16:37 technomancy: jochu: if it's only slime that you're worried about, why don't you keep a github clone of slime and only push out updates once they've been tested?

16:40 hrm; my app is failing pretty hard after pulling, but it could be vestigal lazy-conses in contrib

16:41 * shoover compiles ClojureCLR! hopes there is hope for startup speeds closer to Clojure

16:42 technomancy: shoover: on mono or the MS one?

16:43 shoover: I'm on C# 2008 Express at the moment

16:43 (MS)

16:45 fanda: hello!

16:45 just a quick note: 'last' is missing in sequences/data-structures

16:45 (on clojure.org)

16:45 Chouser: fanda: thanks

16:45 fanda: Chouser: np

16:46 technomancy: would be really nice if the source to clojure.org were available so those kinds of fixes could be submitted as patches

16:46 just a thought

16:48 drewr: It's a third-party wiki site.

16:48 technomancy: oh, it's not kept in version control?

16:48 how quaint. =)

16:49 drewr: It's versioned, just not in a traditional VCS. :-)

16:50 Chouser: http://clojure.org/space/changes

16:50 technomancy: gotcha

17:08 slashus2: In the current svn branch, "next" should be preferred over "rest"? If you do (rest []) it will return (), which is sort of strange, but (next []) returns nil.

17:08 I guess rest could be preferred for certain situations.

17:09 hiredman: rest is completely lazy

17:09 so when you need that...

17:10 slashus2: So next isn't lazy?

17:11 hiredman: I am not sure, but I think it behaves like 'rest' did in the past wiht regard to laziness

17:11 ~def next

17:12 slashus2: (time (take 5 (next (range 1000000000000000000)))) and (time (take 5 (rest (range 1000000000000000000)))) have slightly different times. rest is a little more efficient?

17:12 fanda: slashus2: read http://clojure.org/lazy

17:12 hiredman: at the very least next needs to do the work to decide to return a seq or nil

17:12 Chouser: slashus2: the differece in work there is far too small be measured by 'time'

17:13 slashus2: It isn't significant.

17:19 Chouser: ,(time (let [x (next (cons 1 (lazy-seq (do (Thread/sleep 2000) nil))))]))

17:19 clojurebot: "Elapsed time: 2001.322 msecs"

17:19 Chouser: ,(time (let [x (rest (cons 1 (lazy-seq (do (Thread/sleep 2000) nil))))]))

17:19 clojurebot: "Elapsed time: 0.556 msecs"

17:19 cp2: woah

17:20 oh, nevermind

17:23 slashus2: ,(time (let [x (rest (cons 1 (lazy-seq (do (Thread/sleep 2000) nil))))] x))

17:23 clojurebot: ()

17:23 "Elapsed time: 0.596 msecs"

17:24 slashus2: When I ran that on my computer, it printed the time, waited about 2 seconds and then did ()

17:26 clojurebot: svn rev 1299; improved Maven integration [issue 70], patch from hlship

17:27 slashus2: Why does it behave that way?

17:28 hiredman: because, when printint a lazy seq you hvae to realize it

17:28 slashus2: So time doesn't really work correctly in that situation?

17:28 hiredman: no

17:29 the step of the repl printing the result is not included in time

17:30 technomancy: slashus2: you're timing the creation of the lazy sequence, not the realization of it.

17:31 slashus2: Looking at it at first, I would think that it would time everything inside of time.

17:31 hiredman: it does

17:31 technomancy: right; the only thing inside time in the construction of the lazy sequence

17:32 the whole point of lazy-seq is that it's cheap to create

17:32 Chouser: ,(let [x (time #(Thread/sleep 2000))] (x))

17:32 technomancy: it's only when it's *used* that the slowdown occurs

17:32 clojurebot: "Elapsed time: 0.425 msecs"

17:32 hiredman: the realization of the lazy seq doesn't happen until the repl prints it out

17:32 technomancy: slashus2: put it in a def and it won't take any time at all

17:32 until you try to print the def'd var

17:46 robnik: (let [syms (map symbol (seq (.split "a,b,c,d" ",")))]

17:46 (printf "syms: %s\n" syms))

17:46 That prints... syms: clojure.core$map__3719$fn__3721@9a965e88

17:47 hiredman: and?

17:47 robnik: How does one make it print: (a b c d).

17:47 I know I can call (apply list syms) or something...

17:47 hiredman: ,(print '(a b c d))

17:48 clojurebot: (a b c d)

17:48 robnik: ... but I'm wondering if there is a standard way to convert that lazy map thing to a something printable.

17:48 hiredman: ,(doc printf)

17:48 clojurebot: "([fmt & args]); Prints formatted output, as per format"

17:48 hiredman: ,(doc format)

17:48 clojurebot: "([fmt & args]); Formats a string using java.lang.String.format, see java.util.Formatter for format string syntax"

17:49 hiredman: ,(str '(a b c d))

17:49 clojurebot: "(a b c d)"

17:49 hiredman: the problem is you are telling printf that syms is a string

17:49 but it isn't

17:50 wrap syms with (str ...)

17:50 or don't use printf

17:51 ,(println "syms: " '(a b c d))

17:51 clojurebot: syms: (a b c d)

17:51 robnik: %s tells Formatter to call .toString. Same with (str syms) I think.

17:52 Yeah, println works.

17:53 hiredman: ~def str

17:53 cp2: hiredman, i like this new ~def command

17:53 nice addition

17:53 hiredman: yes

17:53 very useful

17:53 maybe it was AWizzArd who suggested it?

17:53 I forget

17:55 robnik: str is not the same thing as calling .toString

17:56 robnik: In my original code snippet changing syms to (seq syms) also makes it print (a b c d).

17:57 Okay, I see the str definition. Thank you.

17:57 hiredman: that is because map returns a lazy-seq

17:58 robnik: okay

17:58 hiredman: and lazy-seqs are secretly functions

17:58 so println was just calling .toString on a function

17:59 ,(map inc (range 2))

17:59 clojurebot: (1 2)

17:59 hiredman: grrr

17:59 ,(ref (map inc (range 2)))

17:59 clojurebot: #<Ref@bb9f5b: (1 2)>

17:59 hiredman: bah

18:00 Chouser: ,(let [syms (map symbol (seq (.split "a,b,c,d" ",")))] (printf "syms: %s\n" (seq syms)))

18:00 clojurebot: syms: (a b c d)

18:02 robnik: ,(let [syms (map symbol (seq (.split "a,b,c,d" ",")))] (printf "syms: %s\n" syms))

18:02 clojurebot: syms: clojure.core$map__3719$fn__3721@9a965e88

18:02 Chouser: ,(str (lazy-seq '(a b c d)))

18:02 clojurebot: "sandbox$eval__2873$fn__2875@9a965e88"

18:02 Chouser: ,(str (seq (lazy-seq '(a b c d))))

18:02 clojurebot: "(a b c d)"

18:03 robnik: So... does (seq x) when x is lazy make x non-lazy?

18:06 technomancy: ,(def a-lazy-seq (map identity [1 2 3]))

18:06 clojurebot: DENIED

18:06 technomancy: ,(let [a-lazy-seq (map identity [1 2 3])] (identical? a-lazy-seq (seq a-lazy-seq)))

18:06 clojurebot: false

18:07 technomancy: oh snap!

18:07 robnik: anyway, the answer is no.

18:07 robnik: thanks.

18:10 slashus2: ,(class (seq (map identity [1 2 3])))

18:10 clojurebot: clojure.lang.Cons

18:11 technomancy: why isn't that LazyCons?

18:12 slashus2: I don't understand why it doesn't have $Seq at the end.

18:12 hiredman: most likely map's lazy-seq yields a value cons'ed onto another lazy-seq

18:13 ~def map

18:13 robnik: Thanks for the help, but I'm losing my connection. Doh.

18:14 Hopefully I can find a chat log somewhere later.

18:14 hiredman: clojurebot: logs?

18:14 clojurebot: logs is http://clojure-log.n01se.net/

18:15 hiredman: technomancy: I think LazyCons maybe gone

18:16 Chouser: LazyCons is gone

18:17 technomancy: so regular conses can be lazy now?

18:17 Chouser: and lazy-seqs a weird thing compared to the classes and objects Clojure's had before

18:17 * technomancy loves how the Emacs spellchecker knows that conses is a word

18:17 hiredman: svn rev 1295

18:17 Chouser: calling seq on a lazy-seq only forces one step -- the rest can still be lazy

18:18 technomancy: Chouser: ah, of course

18:18 Chouser: ,(class (lazy-seq [1 2]))

18:18 clojurebot: sandbox$eval__2891$fn__2893

18:19 Chouser: lazy-seq returns a fn, as you can see there

18:19 but it's a fn that implements ISeq

18:19 ,(instance? clojure.lang.ISeq (lazy-seq [1 2]))

18:19 clojurebot: true

18:20 Chouser: ,(parents (class (lazy-seq [1 2])))

18:20 clojurebot: #{clojure.lang.LazySeq}

18:22 technomancy: thanks for the explanation.

18:22 * technomancy has got to head off

18:57 gnuvince_: Hello

18:57 rhickey: hey

18:59 * gnuvince_ went to visit a university today

18:59 gnuvince_: I'm definitely gonna apply there

19:00 * Raynes worked his ass off so hard that he can't move his neck more than 10 degrees to each side.

19:01 gnuvince_: Raynes: work out?

19:01 Raynes: Programmers should /never/ under any circumstances do hard work.

19:01 gnuvince_: No, cleaning out ratchewed mess that has been gathering in the garage since 1991.

19:02 Lot's of shoveling of gravel.

19:03 gnuvince_: Raynes: no automatic garbage collection for that, eh?

19:03 Raynes: gnuvince_: No, :|

19:04 gnuvince_: Raynes: do you do regular exercise?

19:04 Raynes: gnuvince_: No, but that changes now, I'm already in so much pain from the last 2 days that I might as well work it out. I'll be helping my uncle pull a motor out of a car tomorrow.

19:06 gnuvince_: ok

19:07 To save me the morning traffic, I go swim 3 times a week and work out in a gym 2 times a week

19:08 Raynes: gnuvince_: I don't have those options. The closest Gym is around 22 or 60 miles from here. Gas money isn't cheap.

19:08 gnuvince_: Raynes: you live in a rural area?

19:09 Raynes: gnuvince_: Alabama. About as rural as it gets.

19:10 gnuvince_: Raynes: I'm in a pretty rural region too, but I work in the big town of the area, so that's why I have this possibility.

19:10 Not having access to a bunch of services is sometimes a hassle, but I generally think the peace of the place is worth more.

19:27 How do you only see the changes in HEAD with git log?

19:30 Chouser: git show

19:30 or is that not what you mean?

19:31 gnuvince_: Looks like it

19:54 schoppenhauer: Is it possible to make a (proxy [x] [] ...) where x is a Class-Object rather than a Symbol?

19:55 hiredman: ,(class string)

19:55 clojurebot: java.lang.Exception: Unable to resolve symbol: string in this context

19:55 hiredman: ,(class String)

19:55 clojurebot: java.lang.Class

19:56 schoppenhauer: Hm... Strange

19:57 hiredman: whats then wrong with (proxy [(. Class forName "java.lang.String")] [] (bla []))

19:57 ,(bla)

19:57 clojurebot: java.lang.Exception: Unable to resolve symbol: bla in this context

19:58 schoppenhauer: ,(. Class forName "java.lang.String")

19:58 clojurebot: java.lang.String

19:58 rhickey: schoppenhauer: proxy is a macro and operates on names, not values

19:58 schoppenhauer: ah.

19:58 rhickey: so will quoting do the job?

19:59 rhickey: schoppenhauer: nope - proxy is not a runtime-reflective API, same as all of the interop.

20:00 eyeris: Is there a std function that is the opposite of slurp?

20:00 schoppenhauer: rhickey: wah.

20:00 rhickey: why?

20:00 rhickey: schoppenhauer: what are you trying to do?

20:01 schoppenhauer: why in general is that Clojure is supposed to be a fast, compiled language

20:01 schoppenhauer: rhickey: actually, I didnt like the fact that it is not possible to create a bean (or interface or whatever) on runtime. so at the moment i am trying to write something to do this.

20:01 rhickey: on Runtime?

20:01 schoppenhauer: rhickey: yes

20:02 rhickey: at least in /theory/ it should be possible. With the javax.util.JavaCompiler- and ClassLoader-API, for example

20:02 rhickey: schoppenhauer: you can just use the reflection API

20:02 schoppenhauer: rhickey: i can create interfaces, but unfortunately, i cannot proxify them :(

20:03 rhickey: no. i cannot define new interfaces with the reflection API as far as I know

20:04 rhickey: schoppenhauer: still not sure what you want - Runtime exists and is accessible, what would an interface add?

20:05 proxy is about instantiating interfaces, not creating them

20:05 schoppenhauer: rhickey: i think we are talking about different things ;-) - yesterday I had the problem that StringTemplate wants a Bean for some stuff, and I couldnt create one with clojure without compiling a whole source... So ok, meanwhile I have a workaround for this, but its in general not good not to be able to do something.

20:06 rhickey: schoppenhauer: well, you can with genclass, but you don't want to?

20:06 schoppenhauer: rhickey: yes. ok. I can create interfaces... But I get them in Class-Objects... And therefore I cannot pass them to proxy

20:06 rhickey: genclass works only when I use (compile '...) as far as I have read

20:08 rhickey: schoppenhauer: there's a reason for that - all this Java class stuff is static. You create instances with names and can use the names to instantiate/proxy, no?

20:08 interfaces with names

20:08 schoppenhauer: hm... i dont know. there are things like ClassLoader, etc.

20:08 (i use them - though i dont really understand them yet ^^)

20:09 that is you can load new absract classes ("interfaces")

20:09 rhickey: ah... is it somehow possible to pass something like lambda-form (like a Runnable or whatever) to a Java-Method from Clojure? This would solve all my problems I think.

20:10 hiredman: ha ha

20:10 schoppenhauer: all clojure functions are Runnable

20:10 rhickey: schoppenhauer: all fns are Runnable and Callable

20:10 hiredman: and Callable

20:10 schoppenhauer: Ah, so I can pass them to a java-method expecting a Runnable?

20:10 rhickey: yup

20:10 schoppenhauer: ah wonderful

20:11 Thank you.

20:11 rhickey: sure

20:12 schoppenhauer: dont misunderstand me: clojure is fine as it is. it is just... not "beautiful" to explicitly have to compile files...

20:12 at least to me it is not

20:14 rhickey: schoppenhauer: agreed - that's a Java thing, classes are not dynamic insofar as you get one shot to load them per classloader, also they need to be in classpath for other Java stuff to see them, so best not to pretend here and accept that Java is less dynamic than Lisp/Clojure

20:15 schoppenhauer: rhickey: ok. but it is fun to implement something like this anyway ;-)

20:16 rhickey: as a library for people who dont care about speed ^^

20:16 zakwilson: Java isn't very dynamic? The horror! Someone should write a Lisp dialect for the JVM.

20:17 schoppenhauer: rhickey: hm... i cant find it in the java-interop-documentation: can I pass arguments from java to the lambda-forms passed to Java? Callable and Runnable doesnt have this.

20:18 rhickey: schoppenhauer: are you not interoperating with code that takes Callable/Runnable? Or do you just need to call a Clojure fn from Java?

20:21 schoppenhauer: rhickey: I can define a Proxy for an instantly-generated Interface using the reflection-api. I can generate it to get runnables which are called by the methods (runnables from clojure i.e.). But when a method of that interface is called, it maybe gets additional Arguments. How can I pass them to the given functions (yes, I think I want to call Clojure from Jav)

20:23 rhickey: Clojure fns implement clojure.lang.IFn, which has invoke() with various arities

20:26 schoppenhauer: ah thank you

20:27 wah. its ... late ... good nigth

20:32 digash`: (add-remote-javadoc "" "http://www.google.com/search?btnI=I%27m%20Feeling%20Lucky&q=allinurl:")

20:32 (javadoc String)

20:33 works pretty good with any java class.

20:44 Chouser: cure

20:44 er, cute

20:46 digash`: Chouser: yea, i got tired of listing all of the links.

20:46 ayrnieu: who's http://sardakcode.blogspot.com/2009/02/my-first-clojure-macro-inspired-by.html ? Does he come here?

20:49 hiredman: ~seen sardak

20:49 clojurebot: no, I have not seen sardak

21:21 Chrononaut: is tab-completion in the slime repl supposed to work?

21:22 gnuvince_: Chrononaut: yes.

21:23 Chrononaut: hm, i get this error each time i hit tab: "funcall: Synchronous Lisp Evaluation aborted"

21:24 my tab key is bound to slime-indent-and-complete-symbol btw

21:25 gnuvince_: Chrononaut: there were some changes in swank-clojure recently to deal with the new lazy seqs in Clojure itself. Make sure that Clojure, clojure-mode and swank-clojure are up to date.

21:26 Chrononaut: ah, now it works. i had to comment out some stuff from my common lisp-catered slime config

21:26 related to fuzzy completion

21:27 gnuvince_: Chrononaut: are you a CLer?

21:28 Chrononaut: well not really, i've just played around a bit in cl before. mostly related to university coursework

21:29 i love lisp though

21:32 gnuvince_: How do you like Clojure so far?

21:35 Chrononaut: i've only watched the 'clojure for lisp programmers'-talk and written hello-world kind of stuff, but I'm enjoying it so far

21:36 i especially like the first-class reader support for maps and vectors

21:36 gnuvince_: cool :)

22:17 rryan: does swank-clojure work with the lazy-seq updates now?

22:17 gnuvince_: rryan: it does here

22:19 rryan: cool -- ill update then

23:45 digash`: hmm, just found a bug in my code that was hard to find due to the string and multiargs

23:45 ,(String/format "%s" (into-array "abc"))

23:45 clojurebot: "a"

23:45 digash`: but meant this

23:45 ,(String/format "%s" (into-array ["abc"]))

23:45 clojurebot: "abc"

23:52 Chouser: ,(format "%s" "abc")

23:52 clojurebot: "abc"

23:52 Chouser: But I don't know if that makes the whole thing less or more confusing.

23:53 digash`: i was trying to distil the example of much more convoluted code that i had

23:53 Chouser: :-)

23:53 ok

23:54 I don't know what could have helped you though -- what would you want?

23:55 digash`: I had something more like (map #(Grid. (into-array %)) args)

23:55 args were just a string instead of list of strings

23:59 i am not sure what would've helped me here, but it was hard to find since it worked but returned some weird results.

Logging service provided by n01se.net