#clojure logs

2009-02-21

00:06slashus2,#=()
00:07slashus2That gives me a NullPointerException
00:07slashus2Is that a normal behavior?
00:12blbrownjava approach to getting a file extension from a filename, (. a substring (- (count a) 4)) anyone have a more clojure oriented approach
00:12blbrownwhere a = "MyFile.clj")
00:17slashus2blbrown: (seq (.split "myfile.clj" ".")) <-- I wonder why this doesn't work?
00:20blbrownslashus2, I normally don't include the '.' with split as I have files that have multiple '.'
00:20slashus2blbrown: It returns nil and I don't know why.
00:22slashus2blbrown: Maybe I am not seeing something obvious.
00:23blbrownhmm, split returns a java array. yet seq on that array returns nil
00:23slashus2vec does the same thing
00:23slashus2[]
00:23slashus2Not nil, but still it doesn't return the split
00:24slashus2blbrown: No one responded when I said that #=() threw a NullPointerException, but I am not sure why it does that.
00:25blbrownwrong person, I have only been getting into clojure this last month
00:26slashus2Java does the same thing when I run System.out.println("hello.clj".split(".").length); the length is zero.
00:26slashus2curious
00:26blbrownslashus2, oh yea, regex, escape the .
00:26blbrownmaybe
00:26slashus2why?
00:26slashus2It isn't a regex
00:26slashus2it is a string
00:27blbrownslashus2, the dot is a regex operator
00:27blbrowntry this. (seq (.split "myfile.clj" "\\."))
00:27slashus2That works ..
00:27slashus2OHHH split takes a regex
00:27slashus2*feels dumb*
00:27blbrownhehe
00:28slashus2Chouser: Sorry to bother you, but is #=() suppose to throw a NullPointerException?
00:28blbrown (last (seq (.split "myfile.clj" "\\."))) ... so I guess this would get the file extension
00:28slashus2yeah
00:29slashus2(last (.split "myfile.clj" "\\."))
00:29slashus2I don't think you need seq
00:29hiredmanslashus2: why wouldn't throw an PNE?
00:29hiredmanit
00:29hiredmanNPE
00:30hiredmanugh
00:30slashus2I was just playing around with different reader expressions, and it surprised me.
00:30hiredman#=() executes whatever is inthe parens
00:30hiredmannothing in the parens, it tries to execute nothing, NPE
00:31slashus2Fair enough.
00:33blbrownslashus2, curious, what are you trying to do, I don't know the operators
00:33hiredman,(.invoke inc 1)
00:33clojurebot2
00:33hiredman,(.invoke nil 1)
00:33clojurebotjava.lang.NullPointerException
00:33blbrownis that like apply, hmm
00:33blbrownfunccall I mean
00:34blbrown,#=(+ 1)
00:34clojurebot1
00:34slashus2hiredman: Okay, that is pretty consistent.
00:34blbrown,#=(+ 1 1)
00:34clojurebot2
00:34blbrown,#=()
00:34Chouser,(re-find #"\.[^.]*$" "foo.bar.baz.jar")
00:34clojurebot".jar"
00:34blbrownChouser, you like that one better
00:34Chouserpretty scary regex, I guess
00:35blbrownnot really
00:35Chouserno, last on the one you had is good.
00:35Chouser,(re-find #"[^.]*$" "foo.bar.baz.jar")
00:35Chouser(re-find #"[^.]*$" "foo.bar.baz.jar")
00:35clojurebot"jar"
00:35blbrown,(re-find #"[^.]*$" "foo.bar.baz.jar")
00:35clojurebot"jar"
00:36ChouserI like to use the #"" literal regex when I can, but .split is fine too.
00:36Chouseryou've solved it, move on. :-)
00:38Chouser? goal? have a question?
00:39blbrownno... I was saying put my hands in the air because we are OK with the solution "Fine ...lets move on"
00:44hiredman,#=()
00:44clojurebotnil
00:44hiredmanhmmm
00:44slashus2hmm?
00:44slashus2What?!?
00:45hiredmantuning eval-in-box
01:10nullman`how do i do something like mapcar in clojure? ex: (mapcar #'(lambda (x) (* x 999)) '(1 2 3))
01:11hiredmanwhat does mapcar do?
01:13hiredman,(prn 1)
01:13clojurebot1
01:13hiredmanhmm
01:13slashus2If it existed, it may apply to the first item of every sequence given to it?
01:14nullman`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)
01:14hiredman,#=()
01:15hiredman,(map #(* % 999) '(1 2 3))
01:15clojurebot(999 1998 2997)
01:15nullman`cool, i was using map differently and it was not working; thanks again
01:21pjb3I'm trying to create a Java object in clojure at runtime that has a method, and then call that method
01:21pjb3(.foo (proxy [Object] [] (foo [] "foo")))
01:22pjb3java.lang.IllegalArgumentException: No matching field found: foo for class clojure.proxy.java.lang.Object
01:22pjb3Why doesn't that work?
01:27hiredman,#=()
01:27hiredmanhmmm
01:27hiredman,#=()
01:29slashus2hiredman: What are you experimenting with?
01:39hiredmanslashus2: clojurebot's sandbox
01:39hiredmanI would like it if ,#=() returned the NPE exception
01:40slashus2okay
01:42hiredmancannot seem to catch reader exceptions
01:42hiredman:/
02:33Chouserhttp://clojure.googlegroups.com/web/issues-graph.png
02:35slashus2I think that is good?
02:38Chousermany more closed than open is good
02:38Chouserbut really it's a demo of code I'm working on -- scrape the issues page, process the data, draw a graph
02:38slashus2yep
02:39Chouserjust under 95 lines, though I think I can tighten that up a bit
02:39Chouserbut not tonight
02:40slashus2You just writing a BufferedImage?
02:40ChouserJFreeChart
02:40Chouservia Dejcartes
02:41slashus2okay, neat
02:41Chouserusing tagsoup + zip-filter for the html scraping
08:02Lau_of_DKJava 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:01Lau_of_DKHow do I use getClassLoader with Clojure-genclassed-classes ?
12:28Lau_of_DKpackage com.jme.image;
12:28Lau_of_DKpublic abstract class Texture implements Savable {
12:29Lau_of_DKThis 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:30Chousercom.jme.image.Texture$MinificationFilter/Trilinear
12:39Lau_of_DKLove you Chouser :)
12:44blbrownif 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:45ayrnieublbrown - why use Repl instead of Script?
12:46blbrownayrnieu, clojure.lang.Repl didn't know about Script
12:47blbrownis there a big difference
12:47ayrnieublbrown - 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:47ayrnieufi
12:48ayrnieuwell, *command-line-args* works as you'd lke.
12:48danlarkinLau_of_DK: I'm very close to being able to having something to show you, but I still need a name...
12:49Lau_of_DKdanlarkin: Stop teasing me! :)
12:50Lau_of_DKI've almost built a 3D game in the time you took deciding on a name :)
12:50danlarkinhaha yeah yeah yeah
12:57blbrownayrnieu, 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:58Chouseryou need a -- after Script and before $1
12:58blbrowncr@p
13:00blbrownChouser, you sure it isn't after the $1
13:33blbrown[#^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:33ayrnieublbrown - for efficiency, for type checking, for documentation.
13:34blbrownnice
13:34blbrownclojure = best language ever
13:36ayrnieuwell, efficiency and documentation anyway. I can't get #^java.io.File to complain. It's a reasonable addition to the language, though.
13:39Lau_of_DKdanlarkin: I just got a 3d-landscape generated by a fractal to render quite nicely - got a name yet? :)
13:41Chouserright, not for type checking
13:41ayrnieudanlarkin, 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:42Lau_of_DKyea!
13:55rhickeyayrnieu: You don't like "Clojure" eh?
13:55Lau_of_DKuh oh
13:56ayrnieurhickey - it's hard to say, I have to pretend that I don't associate it with Clojure.
13:56Lau_of_DKrhickey: Since youre finally awake - Did you consider my request for float short-hand syntax ?
13:56rhickeyIt's worked out well, searchability alone has been great
13:57rhickeyLau_of_DK: what request?
13:57danlarkinayrnieu: that's good advice I guess
13:58Lau_of_DKrhickey: My request for (class 5.0f) => float
14:00ayrnieudanlarkin - 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:02rhickeyLau_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:03danlarkinayrnieu: heh, yeah
14:03Chouseruse the last letter instead of the first. Then instead of i,l,f,d you have r,g,t,e
14:03Lau_of_DKOf course youre right, bad example
14:03rhickeyChouser: intuitive :)
14:04Lau_of_DKChouser: No good :)
14:04Lau_of_DKrhickey: 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:05danlarkinoh 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:05ayrnieuChouser - you forgot ratio. 1.5O
14:05rhickeydanlarkin: ick
14:06danlarkinthe humor didn't come across there as I'd hoped it would
14:06ayrnieu(declare (type float x))
14:07rhickeyIt ends up it might be possible to always make (let [x 5.0] ...) a primitive *double*
14:07rhickeydue to contagion
14:08rhickeythere's not a lot of advantage to using float vs double anymore
14:08Lau_of_DKexcept when Java requires it...
14:10rhickeyLau_of_DK: that conversion is a separate issue
14:10Lau_of_DKhow so?
14:14Lau_of_DKrhickey: Here, 5.0 is always a double, but I really need floats, is there any drawbacks to providing 5.0F ?
14:21ayrnieujust (macrolet [f (fn [x] `(float ~x))] ... (f 5.0)) -- some assembly required.
14:22ayrnieu(let-type float [g 5.0 x 2.0] ...)
14:24ayrnieu(with-numeric-context float (blah blah blah 2.0) (blah blah 5.0))
14:35rhickeyLau_of_DK: as I said, I'm not opposed, but what about l and I?
14:36Lau_of_DKl and I?
14:36rhickeythere you go
14:36rhickeyel and eye
14:36Lau_of_DKFor long/int ?
14:36rhickeyright
14:37Lau_of_DK5 = int, 5.0 = double, 5.0F = float, 5.0L = long, any problems with that?
14:38rhickeyLau_of_DK: 5.0L is not going to be ok, 5L is, but you can't have the 5 = int default either
14:39Lau_of_DKYoure right about 5.0L = no go of course, but why would that compromise the int being default?
14:40rhickeysince default operations on ints can become bigints, the int cast is required to tell me you think that's not going to happen
14:41Lau_of_DKHm - Thats a little unfortunate
14:41rhickey(loop [x 5] ... (recur (something-that-promotes-to-bigint x))) normally works
14:43Lau_of_DKBut 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:44Chouserrhickey: 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:44Chouseris this the kind of vortex you're trying to avoid? :-)
14:46rhickeyChouser: reflection has caches already. There are well-known call-site optimizations for that stuff, the invokedynamic enhancements also support that kind of work
14:46pilkarnhmm 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:47Lau_of_DKpilkarn: android game?
14:47pilkarnsorry game for the Android-phones. an shott-em-up sidecscrolelr 2d
14:47pilkarnshoot
14:48pilkarnLau_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:48Lau_of_DKpilkarn: I think if you never try, you'll never know :)
14:48Lau_of_DKpilkarn: 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:49rhickeyChouser: http://groups.google.com/group/clojure/browse_frm/thread/2590ee3c75c04e91/c5c9377644096c49#c5c9377644096c49
14:51Chouserso, compile time fastpath rather than runtime like I just described.
14:57rhickeyright, I think in a lot of cases the best guess will be right - this all falling out of lack of import blah.*
15:01Chouserbecause you have small set of specific classes to check
15:01rhickeyshould be in most cases
15:02rhickeyjust those with method matching name + arity
15:04Chouserso are you doint this, or avoiding doing it? :-)
15:04Chouserdoing
15:05rhickeyI'm not doing it at this moment, but I think reflection should go this way, Slava's points were more about numerics
15:06rhickeyThere, 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:12Chouserah, sure.
15:31pilkarnis there an xbox-dev channel?
15:34alinphi
15:35alinpis there a default way to create a list with a default number of elements ?
15:35alinpnil elements for instance
15:35alinpthere is ... range
15:35alinpbut it's not the one that I want
15:35alinpI made something like: defn create [i] (if (zero? i) () (lazy-cons nil (create (dec i)))))
15:36Chouserwhat are you going to do with that once you've made it?
15:36alinpis there a more elegant way for doing this ?
15:36jochualinp (replicate nil 10) ?
15:36Chouser,(replicate 5 nil)
15:36clojurebot(nil nil nil nil nil)
15:36Chouserjochu: close :-)
15:36jochuright :P dyslexic
15:36jochuthanks
15:36alinpjochu: NPE
15:36alinp:)
15:37alinpok, thanks jochu
15:37alinpChouser: it's one fix that I have :)
15:37alinpI want to add/remove data from/to it
15:37alinpdepending on nil values that I have there
15:38Chouseryou can only add or remove data from one end
15:38alinpdidn't know about replicate, nice
15:38Chouserof a seq or list
15:38alinpno, I want to already have the coll
15:38alinpfor a fixed size
15:39Chouserdo 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:39alinphmmm, ...
15:39alinpreally ? :)
15:40alinpok, if so, I'll use vectors
15:40alinpnow I have one small strange q
15:40alinp,(doc replicate)
15:40clojurebot"([n x]); Returns a lazy seq of n xs."
15:40alinpxs = ?
15:40alinpwhat means xs ?
15:41alinpcoll = collection
15:41hiredmanChouser: technically you cannot remove items from any clojure data structure
15:41alinphiredman: I don't want to modify structures
15:42alinpbut to have some default structure that I'll "modify" and return
15:42alinpI'm not mutating them
15:43Chouserhiredman: indeed. imagine air quotes around all such verbs.
15:43Chouser,(assoc (into [] (replicate 5 nil)) 2 42)
15:43clojurebot[nil nil 42 nil nil]
15:44alinp,(doc into)
15:44clojurebot"([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."
15:44hiredmanChouser: but it that cases lists are just as amendable to "modification" as vectors hashes
15:44hiredmanjust not indexed
15:49Chouserwell, you'd use 'into' to build the vector, and then pass that around.
15:49Chousercreating 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:50alinpyes, fair enough Chouser
15:50alinpthanks
15:50drewrSo how's the lazy migration? I'm scared to start without knowing how long the investment will take.
15:50rhickeydrewr: all done here
15:50rhickey:)
15:51drewrrhickey: Good, cuz I was worried about you. :-)
15:52drewrDangit, don't make me resubscribe to that.
15:52ChouserI think the hardest part is test coverage to flush out all the nil puns, unless you already had unit test coverage of course.
15:53ChouserThe 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:54Lau_of_DKAnybody know if Swank-clojure/SLIME are up to speed with Clojure yet?
15:54drewrLau_of_DK: I know he's been working on it.
15:54drewrHaven't tried yet.
15:55danlarkinjochu has graced us with his presence, he could probably tell you
15:55rhickeyhttp://groups.google.com/group/comp.lang.lisp/browse_frm/thread/0d05837df1efe075/36204b1134ccd1c9?hl=en#36204b1134ccd1c9
15:55Chouseror: http://groups.google.com/group/comp.lang.lisp/search?group=comp.lang.lisp&amp;q=richhickey
15:55Chouser:-)
15:56Lau_of_DKHow do I use Proxy for overriding 2 or 3 methods ?
16:00slashus2Lau_of_DK: (name [params*] body) or (name ([params*] body) ([params+] body) ...)
16:00ChouserLau_of_DK: example here: http://groups.google.com/group/clojure/msg/1aca89d1a53dbd1c
16:01hiredman~def future
16:03hiredmanfuture-call has an example as well
16:03Lau_of_DKThanks guys
16:07jochuLau, yeah - it should be working with lazy-seqs now.
16:12jgracin_rhickey, any estimates on when 1.0 will be released? Is "lazier" the last major breaking change before 1.0?
16:13jgracin_We have pushed our Clojure code into production, so any info helps...
16:14rhickeyjgracin_: 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:15jgracin_rhickey: nice to hear that. thanks!
16:28technomancyjochu: thanks!
16:28technomancyso glad to hear that
16:29hiredmanugh, I really shouldn't read c.l.l, but it is like rubber-necking at train wreck
16:30technomancyhiredman: it's such a black hole
16:32technomancyjochu: 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:32technomancywould have been a lot more useful if it had been implemented right before the lazy merge, but still. =)
16:36jochutechnomancy: 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:37technomancyjochu: 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:40technomancyhrm; my app is failing pretty hard after pulling, but it could be vestigal lazy-conses in contrib
16:42technomancyshoover: on mono or the MS one?
16:43shooverI'm on C# 2008 Express at the moment
16:43shoover(MS)
16:45fandahello!
16:45fandajust a quick note: 'last' is missing in sequences/data-structures
16:45fanda(on clojure.org)
16:45Chouserfanda: thanks
16:45fandaChouser: np
16:46technomancywould be really nice if the source to clojure.org were available so those kinds of fixes could be submitted as patches
16:46technomancyjust a thought
16:48drewrIt's a third-party wiki site.
16:48technomancyoh, it's not kept in version control?
16:48technomancyhow quaint. =)
16:49drewrIt's versioned, just not in a traditional VCS. :-)
16:50Chouserhttp://clojure.org/space/changes
16:50technomancygotcha
17:08slashus2In 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:08slashus2I guess rest could be preferred for certain situations.
17:09hiredmanrest is completely lazy
17:09hiredmanso when you need that...
17:10slashus2So next isn't lazy?
17:11hiredmanI am not sure, but I think it behaves like 'rest' did in the past wiht regard to laziness
17:11hiredman~def next
17:12slashus2(time (take 5 (next (range 1000000000000000000)))) and (time (take 5 (rest (range 1000000000000000000)))) have slightly different times. rest is a little more efficient?
17:12fandaslashus2: read http://clojure.org/lazy
17:12hiredmanat the very least next needs to do the work to decide to return a seq or nil
17:12Chouserslashus2: the differece in work there is far too small be measured by 'time'
17:13slashus2It isn't significant.
17:19Chouser,(time (let [x (next (cons 1 (lazy-seq (do (Thread/sleep 2000) nil))))]))
17:19clojurebot"Elapsed time: 2001.322 msecs"
17:19Chouser,(time (let [x (rest (cons 1 (lazy-seq (do (Thread/sleep 2000) nil))))]))
17:19clojurebot"Elapsed time: 0.556 msecs"
17:19cp2woah
17:20cp2oh, nevermind
17:23slashus2,(time (let [x (rest (cons 1 (lazy-seq (do (Thread/sleep 2000) nil))))] x))
17:23clojurebot()
17:23clojurebot"Elapsed time: 0.596 msecs"
17:24slashus2When I ran that on my computer, it printed the time, waited about 2 seconds and then did ()
17:26clojurebotsvn rev 1299; improved Maven integration [issue 70], patch from hlship
17:27slashus2Why does it behave that way?
17:28hiredmanbecause, when printint a lazy seq you hvae to realize it
17:28slashus2So time doesn't really work correctly in that situation?
17:28hiredmanno
17:29hiredmanthe step of the repl printing the result is not included in time
17:30technomancyslashus2: you're timing the creation of the lazy sequence, not the realization of it.
17:31slashus2Looking at it at first, I would think that it would time everything inside of time.
17:31hiredmanit does
17:31technomancyright; the only thing inside time in the construction of the lazy sequence
17:32technomancythe whole point of lazy-seq is that it's cheap to create
17:32Chouser,(let [x (time #(Thread/sleep 2000))] (x))
17:32technomancyit's only when it's *used* that the slowdown occurs
17:32clojurebot"Elapsed time: 0.425 msecs"
17:32hiredmanthe realization of the lazy seq doesn't happen until the repl prints it out
17:32technomancyslashus2: put it in a def and it won't take any time at all
17:32technomancyuntil you try to print the def'd var
17:46robnik (let [syms (map symbol (seq (.split "a,b,c,d" ",")))]
17:46robnik (printf "syms: %s\n" syms))
17:46robnikThat prints... syms: clojure.core$map__3719$fn__3721@9a965e88
17:47hiredmanand?
17:47robnikHow does one make it print: (a b c d).
17:47robnikI know I can call (apply list syms) or something...
17:47hiredman,(print '(a b c d))
17:48clojurebot(a b c d)
17:48robnik... but I'm wondering if there is a standard way to convert that lazy map thing to a something printable.
17:48hiredman,(doc printf)
17:48clojurebot"([fmt & args]); Prints formatted output, as per format"
17:48hiredman,(doc format)
17:48clojurebot"([fmt & args]); Formats a string using java.lang.String.format, see java.util.Formatter for format string syntax"
17:49hiredman,(str '(a b c d))
17:49clojurebot"(a b c d)"
17:49hiredmanthe problem is you are telling printf that syms is a string
17:49hiredmanbut it isn't
17:50hiredmanwrap syms with (str ...)
17:50hiredmanor don't use printf
17:51hiredman,(println "syms: " '(a b c d))
17:51clojurebotsyms: (a b c d)
17:51robnik%s tells Formatter to call .toString. Same with (str syms) I think.
17:52robnikYeah, println works.
17:53hiredman~def str
17:53cp2hiredman, i like this new ~def command
17:53cp2nice addition
17:53hiredmanyes
17:53hiredmanvery useful
17:53hiredmanmaybe it was AWizzArd who suggested it?
17:53hiredmanI forget
17:55hiredmanrobnik: str is not the same thing as calling .toString
17:56robnikIn my original code snippet changing syms to (seq syms) also makes it print (a b c d).
17:57robnikOkay, I see the str definition. Thank you.
17:57hiredmanthat is because map returns a lazy-seq
17:58robnikokay
17:58hiredmanand lazy-seqs are secretly functions
17:58hiredmanso println was just calling .toString on a function
17:59hiredman,(map inc (range 2))
17:59clojurebot(1 2)
17:59hiredmangrrr
17:59hiredman,(ref (map inc (range 2)))
17:59clojurebot#<Ref@bb9f5b: (1 2)>
17:59hiredmanbah
18:00Chouser,(let [syms (map symbol (seq (.split "a,b,c,d" ",")))] (printf "syms: %s\n" (seq syms)))
18:00clojurebotsyms: (a b c d)
18:02robnik,(let [syms (map symbol (seq (.split "a,b,c,d" ",")))] (printf "syms: %s\n" syms))
18:02clojurebotsyms: clojure.core$map__3719$fn__3721@9a965e88
18:02Chouser,(str (lazy-seq '(a b c d)))
18:02clojurebot"sandbox$eval__2873$fn__2875@9a965e88"
18:02Chouser,(str (seq (lazy-seq '(a b c d))))
18:02clojurebot"(a b c d)"
18:03robnikSo... does (seq x) when x is lazy make x non-lazy?
18:06technomancy,(def a-lazy-seq (map identity [1 2 3]))
18:06clojurebotDENIED
18:06technomancy,(let [a-lazy-seq (map identity [1 2 3])] (identical? a-lazy-seq (seq a-lazy-seq)))
18:06clojurebotfalse
18:07technomancyoh snap!
18:07technomancyrobnik: anyway, the answer is no.
18:07robnikthanks.
18:10slashus2,(class (seq (map identity [1 2 3])))
18:10clojurebotclojure.lang.Cons
18:11technomancywhy isn't that LazyCons?
18:12slashus2I don't understand why it doesn't have $Seq at the end.
18:12hiredmanmost likely map's lazy-seq yields a value cons'ed onto another lazy-seq
18:13hiredman~def map
18:13robnikThanks for the help, but I'm losing my connection. Doh.
18:14robnikHopefully I can find a chat log somewhere later.
18:14hiredmanclojurebot: logs?
18:14clojurebotlogs is http://clojure-log.n01se.net/
18:15hiredmantechnomancy: I think LazyCons maybe gone
18:16ChouserLazyCons is gone
18:17technomancyso regular conses can be lazy now?
18:17Chouserand lazy-seqs a weird thing compared to the classes and objects Clojure's had before
18:17hiredmansvn rev 1295
18:17Chousercalling seq on a lazy-seq only forces one step -- the rest can still be lazy
18:18technomancyChouser: ah, of course
18:18Chouser,(class (lazy-seq [1 2]))
18:18clojurebotsandbox$eval__2891$fn__2893
18:19Chouserlazy-seq returns a fn, as you can see there
18:19Chouserbut it's a fn that implements ISeq
18:19Chouser,(instance? clojure.lang.ISeq (lazy-seq [1 2]))
18:19clojurebottrue
18:20Chouser,(parents (class (lazy-seq [1 2])))
18:20clojurebot#{clojure.lang.LazySeq}
18:22technomancythanks for the explanation.
18:57gnuvince_Hello
18:57rhickeyhey
18:59gnuvince_I'm definitely gonna apply there
19:01gnuvince_Raynes: work out?
19:01RaynesProgrammers should /never/ under any circumstances do hard work.
19:01Raynesgnuvince_: No, cleaning out ratchewed mess that has been gathering in the garage since 1991.
19:02RaynesLot's of shoveling of gravel.
19:03gnuvince_Raynes: no automatic garbage collection for that, eh?
19:03Raynesgnuvince_: No, :|
19:04gnuvince_Raynes: do you do regular exercise?
19:04Raynesgnuvince_: 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:06gnuvince_ok
19:07gnuvince_To save me the morning traffic, I go swim 3 times a week and work out in a gym 2 times a week
19:08Raynesgnuvince_: I don't have those options. The closest Gym is around 22 or 60 miles from here. Gas money isn't cheap.
19:08gnuvince_Raynes: you live in a rural area?
19:09Raynesgnuvince_: Alabama. About as rural as it gets.
19:10gnuvince_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:10gnuvince_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:27gnuvince_How do you only see the changes in HEAD with git log?
19:30Chousergit show
19:30Chouseror is that not what you mean?
19:31gnuvince_Looks like it
19:54schoppenhauerIs it possible to make a (proxy [x] [] ...) where x is a Class-Object rather than a Symbol?
19:55hiredman,(class string)
19:55clojurebotjava.lang.Exception: Unable to resolve symbol: string in this context
19:55hiredman,(class String)
19:55clojurebotjava.lang.Class
19:56schoppenhauerHm... Strange
19:57schoppenhauerhiredman: whats then wrong with (proxy [(. Class forName "java.lang.String")] [] (bla []))
19:57schoppenhauer,(bla)
19:57clojurebotjava.lang.Exception: Unable to resolve symbol: bla in this context
19:58schoppenhauer,(. Class forName "java.lang.String")
19:58clojurebotjava.lang.String
19:58rhickeyschoppenhauer: proxy is a macro and operates on names, not values
19:58schoppenhauerah.
19:58schoppenhauerrhickey: so will quoting do the job?
19:59rhickeyschoppenhauer: nope - proxy is not a runtime-reflective API, same as all of the interop.
20:00eyerisIs there a std function that is the opposite of slurp?
20:00schoppenhauerrhickey: wah.
20:00schoppenhauerrhickey: why?
20:00rhickeyschoppenhauer: what are you trying to do?
20:01rhickeyschoppenhauer: why in general is that Clojure is supposed to be a fast, compiled language
20:01schoppenhauerrhickey: 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:01rhickeyon Runtime?
20:01schoppenhauerrhickey: yes
20:02schoppenhauerrhickey: at least in /theory/ it should be possible. With the javax.util.JavaCompiler- and ClassLoader-API, for example
20:02rhickeyschoppenhauer: you can just use the reflection API
20:02schoppenhauerrhickey: i can create interfaces, but unfortunately, i cannot proxify them :(
20:03schoppenhauerrhickey: no. i cannot define new interfaces with the reflection API as far as I know
20:04rhickeyschoppenhauer: still not sure what you want - Runtime exists and is accessible, what would an interface add?
20:05rhickeyproxy is about instantiating interfaces, not creating them
20:05schoppenhauerrhickey: 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:06rhickeyschoppenhauer: well, you can with genclass, but you don't want to?
20:06schoppenhauerrhickey: yes. ok. I can create interfaces... But I get them in Class-Objects... And therefore I cannot pass them to proxy
20:06schoppenhauerrhickey: genclass works only when I use (compile '...) as far as I have read
20:08rhickeyschoppenhauer: 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:08rhickeyinterfaces with names
20:08schoppenhauerhm... i dont know. there are things like ClassLoader, etc.
20:08schoppenhauer(i use them - though i dont really understand them yet ^^)
20:09schoppenhauerthat is you can load new absract classes ("interfaces")
20:09schoppenhauerrhickey: 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:10hiredmanha ha
20:10hiredmanschoppenhauer: all clojure functions are Runnable
20:10rhickeyschoppenhauer: all fns are Runnable and Callable
20:10hiredmanand Callable
20:10schoppenhauerAh, so I can pass them to a java-method expecting a Runnable?
20:10rhickeyyup
20:10schoppenhauerah wonderful
20:11schoppenhauerThank you.
20:11rhickeysure
20:12schoppenhauerdont misunderstand me: clojure is fine as it is. it is just... not "beautiful" to explicitly have to compile files...
20:12schoppenhauerat least to me it is not
20:14rhickeyschoppenhauer: 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:15schoppenhauerrhickey: ok. but it is fun to implement something like this anyway ;-)
20:16schoppenhauerrhickey: as a library for people who dont care about speed ^^
20:16zakwilsonJava isn't very dynamic? The horror! Someone should write a Lisp dialect for the JVM.
20:17schoppenhauerrhickey: 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:18rhickeyschoppenhauer: are you not interoperating with code that takes Callable/Runnable? Or do you just need to call a Clojure fn from Java?
20:21schoppenhauerrhickey: 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:23rhickeyClojure fns implement clojure.lang.IFn, which has invoke() with various arities
20:26schoppenhauerah thank you
20:27schoppenhauerwah. its ... late ... good nigth
20:32digash`(add-remote-javadoc "" "http://www.google.com/search?btnI=I%27m%20Feeling%20Lucky&amp;q=allinurl:&quot;)
20:32digash`(javadoc String)
20:33digash`works pretty good with any java class.
20:44Chousercure
20:44Chouserer, cute
20:46digash`Chouser: yea, i got tired of listing all of the links.
20:46ayrnieuwho's http://sardakcode.blogspot.com/2009/02/my-first-clojure-macro-inspired-by.html ? Does he come here?
20:49hiredman~seen sardak
20:49clojurebotno, I have not seen sardak
21:21Chrononautis tab-completion in the slime repl supposed to work?
21:22gnuvince_Chrononaut: yes.
21:23Chrononauthm, i get this error each time i hit tab: "funcall: Synchronous Lisp Evaluation aborted"
21:24Chrononautmy tab key is bound to slime-indent-and-complete-symbol btw
21:25gnuvince_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:26Chrononautah, now it works. i had to comment out some stuff from my common lisp-catered slime config
21:26Chrononautrelated to fuzzy completion
21:27gnuvince_Chrononaut: are you a CLer?
21:28Chrononautwell not really, i've just played around a bit in cl before. mostly related to university coursework
21:29Chrononauti love lisp though
21:32gnuvince_How do you like Clojure so far?
21:35Chrononauti've only watched the 'clojure for lisp programmers'-talk and written hello-world kind of stuff, but I'm enjoying it so far
21:36Chrononauti especially like the first-class reader support for maps and vectors
21:36gnuvince_cool :)
22:17rryandoes swank-clojure work with the lazy-seq updates now?
22:17gnuvince_rryan: it does here
22:19rryancool -- ill update then
23:45digash`hmm, just found a bug in my code that was hard to find due to the string and multiargs
23:45digash`,(String/format "%s" (into-array "abc"))
23:45clojurebot"a"
23:45digash`but meant this
23:45digash`,(String/format "%s" (into-array ["abc"]))
23:45clojurebot"abc"
23:52Chouser,(format "%s" "abc")
23:52clojurebot"abc"
23:52ChouserBut I don't know if that makes the whole thing less or more confusing.
23:53digash`i was trying to distil the example of much more convoluted code that i had
23:53Chouser:-)
23:53Chouserok
23:54ChouserI don't know what could have helped you though -- what would you want?
23:55digash`I had something more like (map #(Grid. (into-array %)) args)
23:55digash`args were just a string instead of list of strings
23:59digash`i am not sure what would've helped me here, but it was hard to find since it worked but returned some weird results.