#clojure log - Jul 10 2010

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

0:12 bhenry: with ring, how might i serve up static files from a dynamically decided path (based on a "get" variable from the query string)?

0:13 eg localhost:8080/?dir=/Users/myname/Pictures

0:13 http://...

0:15 i'm able to get all the file objects, but the browser won't let me use file:///path coming from http://

0:47 ysph: is it possible to instantiate a defrecord class using a map of the fields?

0:53 nm, i think my case is better suited for a dictionary anyway

1:55 how do you guys go about referencing random utilities that you primarily just use at the repl? do you just put a file somewhere, open it, and then evaluate it?

1:56 hiredman: the repl loads user.clj from the classpath

1:56 ysph: ah, good to know

1:58 does leiningen set up the classpath in that way, or would i need to link user.clj into the src/ folder?

1:58 hiredman: you might

2:13 scottj: I don't think lein includes user.clj

2:14 hiredman: I think lein doesn't get a say in the matter

2:15 Bahman: Hi all!

2:25 jkkramer: ysph: i use this in my .emacs: (setq swank-clojure-init-files (list "/Users/tin/src/clj/user.clj"))

2:27 ysph: jkkramer: thanks, i'll try that

4:29 Licenser: good morning my lispy friends

4:32 hiredman: you're around?

4:35 hiredman: I supose

4:36 whats up

4:38 Licenser: yay

4:38 you've had found a problem in cj-sandbox/sexpbot right?

4:38 hiredman: strictly speaking no

4:38 I wouldn't worry about it

4:39 Licenser: I know from the log I think it is more a clojure thing but it should be cought :P

4:39 I always do clj-sandbox is suposed to be as secure as possible

4:39 hiredman: it is a clojure issue

4:40 Licenser: *nods* I just saw the line you executed and the expection, when I understand it right, the gen'ed keyword isn't freed after the exit of the function right?

4:49 hiredman: thanks for the info :) makes tracking the thing way easyer or rather a non-problem

5:03 A question why writing (. clojure.lang.RT (first coll)) and not (. clojure.lang.RT first coll) ?

5:03 is there a difference or are they actually the same?

5:10 Chousuke: Licenser: only the former works?

5:11 Licenser: hmm I am kind of confused

5:11 isn't it (. obj (method args)) ?

5:11 just as much as (. obj method args)

5:15 Chousuke: actually they both work

5:15 ,(. clojure.lang.RT (first [1 2 3]))

5:15 clojurebot: 1

5:15 Licenser: ,(. clojure.lang.RT first [1 2 3])

5:15 clojurebot: 1

5:31 vvsh: hi, i'm new to clojure and really want to get REPL with jline working, but i always t the error "Exception in thread "main" java.lang.ClassNotFoundException: clojure.main" , can give me a hand?

5:31 Licenser: vvsh: do yo have the clojure.jar in your classpath?

5:32 vvsh: yes, but the error is not about clojure, is actually about jline - "at jline.ConsoleRunner.main(Unknown Source)"

5:33 i downloaded jline-0.9.94.jar at the current directory( with clojure.jar)

5:34 and executed with this command - java -cp jline-0.9.94.jar:clojure.jar jline.ConsoleRunner clojure.main

5:36 Licenser: ah I see, sadly I never used the jiinline thing :(

5:36 vvsh: is there something wrong with the jline jar

5:36 Licenser: well the exception says it does not find clojure.main

5:36 it is just in the jinline jar

5:36 is the clojure.jar in the same directory?

5:37 vvsh: jline and clojure jar are in the same directory

5:38 Licenser: hmmm

5:38 windows or linux?

5:38 *unix

5:38 vvsh: mac

5:38 Licenser: so unix no issue there either

5:38 try java -cp clojure.jar clojure.main

5:38 hmm is it the latest clojure?

5:39 vvsh: java -cp clojure.jar clojure.main is working - 1.1.0

5:40 Licenser: oky so that should be fine

5:40 hmm hmm

5:40 while not a solution to your question there was a project on github let me dig it out to you

5:40 *for

5:42 it was a set of scripts to run clojure and things

5:42 vvsh: cool thanks,

5:43 is it lein, the build tool

5:45 Licenser: http://github.com/liebke/cljr

5:45 no not lein

5:46 vvsh: thanks, i will look at it

5:46 Licenser: I hope it helps

5:47 vvsh: i will try it, if not working, might give dejour or labrepl a try as well

5:51 Licenser: oh grrr

5:51 noidi: vvsh, you can use rlwrap instead of jline

5:51 Licenser: rlwrap isn't default on OS X afaik

5:52 vvsh: Licenser: it still have to same problem when trying with - cljr repl

5:52 Licenser: hmm odd

5:52 very odd

5:52 vvsh: i don't understand why it can't find clojure.main

5:52 i mean i already add clojure.jar to classpath

5:54 i found this guy got the same problem as me, but don't really understand how he solve it

5:54 http://forums.pragprog.com/forums/91/topics/3466

5:55 sorry, that's the error about jline

5:57 Licenser: okay the solution of 1.2 with the namespace overload is a nice idea but it isn't working

5:57 you can't reaload stuff since when you do it crashes with 'already pointing to'

5:57 meaning you've one bug in your code and you#ve to restart your repl ...

5:57 bah

6:00 vvsh: is there a way to explicitly tell the path to clojure.main in - java -cp jline-0.9.94.jar:clojure.jar jline.ConsoleRunner clojure.main

6:10 Licenser: I'm new to clojure, just wondering in clojure how do i load somethine from classpath?

6:12 Licenser: vvsh: well a clojure namespace or a java clasS?

6:12 namespaces can be load with use or require, classes via import

6:13 vvsh: java class i guess, what i want to do is add jline to the class path, then run a normal clojure repl, then import jline - ( java -cp jline-0.9.94.jar:clojure.jar clojure.main, then import )

6:15 Licenser: well (import java.ns.path.to.Jinline)

6:18 vvsh: thanks, but still can't get the repl working, it really annoying now

6:32 Licenser: vvsh: I can imagine, but I'm not sure what the problem is :(

6:33 vvsh: yeah, it seems pretty odd, do you know where else can i ask for help?

6:36 Licenser: vvsh: what editor do you use

6:36 a good idea would be emacs since you get a repl for free there

6:36 o

6:36 r

6:36 tr

6:36 y

6:36 yuck

6:36 or try cljr repl

6:36 vvsh: vi

6:36 Licenser: ah there is also a vim clojure package that should be helpful

6:37 vvsh: i tried cljr repl, but still get the same problem - can't find clojure.main

6:37 i thinking to learn some emacs, so will stay with emacs on this one

6:37 does the repl on emacs using jline or something else?

6:39 Licenser: nope it uses swank and slime

6:39 no jinline since it is EMAC's controlled (history and stuff)

6:39 also emacs makes a pretty good development env

6:39 at least for clojure :P

6:39 in my eyes currently the best

6:40 vvsh: yeah, its pretty power

6:40 its more easier for lisp like languages

6:42 another point is i can't use lein repl,(jline cause the same problem :(

6:43 Licenser: yuck

6:44 vvsh: that means i can't build any projects, which is a hugh thing

6:45 hiredman: vvsh: where did you get your clojure jar?

6:45 is it 1.1 or a 1.2 snapshot or …

6:45 vvsh: from github

6:46 its 1.1

6:46 hiredman: how do you know?

6:46 vvsh: when i run - java -cp clojure.jar clojure.main, it print out version 1.1.

6:47 hiredman: and what is the exception you get?

6:49 vvsh: when i running with - java -cp jline-0.9.94.jar:clojure.jar jline.ConsoleRunner clojure.main

6:49 i got " Exception in thread "main" java.lang.ClassNotFoundException: clojure.main"

6:50 hiredman: pastebin the whole thing somewhere

6:51 Licenser: good god :(

6:51 vvsh: http://pastebin.com/vhzGDp6d

6:52 hiredman: and does the clojure jar contain clojure/main.class

6:54 vvsh: i don't know much about java, so i don't know if it contain clojure/main.class or not. but when i run - java -cp clojure.jar clojure.main, i get a standard clojure repl

6:55 Licenser: week a new version clj-sandbox is finally out :)

7:49 bhenry: with ring, how might i serve up static files from a dynamically decided path (based on a "get" variable from the query string)?

7:50 eg localhost:8080/?dir=/Users/myname/Pictures

7:50 i'm able to get all the file objects, but the browser won't let me use file:///path coming from http://

9:18 Raynes: I just added support for defing stuff to sexpbot.

9:21 mmarczyk: Raynes: cool! any limits?

9:21 Raynes: mmarczyk: 5 defs.

9:22 mmarczyk: per person?

9:22 per form?

9:22 Raynes: 5 defs at any given time.

9:22 mmarczyk: oh.

9:22 Raynes: It's not allocated per-person.

9:22 mmarczyk: what then? the old ones get dropped?

9:22 Raynes: Yeah.

9:22 mmarczyk: cool :-)

9:23 Raynes: Licenser added stuff for this earlier in clj-sandbox.

9:23 I just took advantage of it.

9:23 Going to see how it works out.

9:26 * Raynes notes before anyone tries it, defn isn't working right this second, but def is. Will be in a little while.

9:26 mmarczyk: $(defn fooey [] (reify clojure.lang.IKeywordLookup (getLookupThunk [this k] (reify clojure.lang.ILookupThunk (get [thunk target] (if (identical? (class this) (class target)) :foo))))))

9:26 sexpbot: java.lang.NullPointerException

9:26 mmarczyk: oh.

9:26 $(def fooey (fn [] (reify clojure.lang.IKeywordLookup (getLookupThunk [this k] (reify clojure.lang.ILookupThunk (get [thunk target] (if (identical? (class this) (class target)) :foo)))))))

9:26 sexpbot: java.lang.NullPointerException

9:31 Licenser: $(def <3 (fn [love & loves] (loop [l (str "I love " love) loves loves](let [[love & loves] loves] (if (nil? love) (str l ".") (if (empty? loves) (str l " and " love ".") (recur (str l ", " love) loves)))))))

9:31 sexpbot: => #'net.licenser.sandbox.box3471/<3

9:31 Licenser: $(<3 "Raynes" "sexpbot" "clj-sandbox" "clojure")

9:31 sexpbot: => "I love Raynes, sexpbot, clj-sandbox and clojure."

9:32 Licenser: mmarczyk: classes are often not allowed

9:32 save for raynes allowing . for some reason in sexpbot, which is rather silly :P

9:32 mmarczyk: $(def ->--- (atom (<3 "Raynes" "sexpbot" "clj-sandbox" "Clojure")))

9:32 sexpbot: => #'net.licenser.sandbox.box3471/->---

9:32 mmarczyk: $(do @->---)

9:32 sexpbot: => "I love Raynes, sexpbot, clj-sandbox and Clojure."

9:33 Licenser: mmarczyk: @->-... is my macro :P

9:33 mmarczyk: :-P

9:33 Licenser: thief!

9:33 but the defs are pretty cool I think

9:33 mmarczyk: yup :-)

9:33 Licenser: Raynes: satisfied with the solution? :)

9:33 mmarczyk: pity about reify, though

9:34 you could do (def ->--- (reify clojure.lang.IDeref (deref [this] ...)))

9:34 Licenser: hmm well it could be allowed but I must say I grew hazzatant about adding 1.2 features to the whitelist since they tend to change so often

9:34 mmarczyk: do they?

9:35 I mean, on master?

9:35 Licenser: well their inner workings might do yes so the border between save and unsafe is very scratchy

9:36 I can't with a good concience whitelist something that might not stay save

9:36 mmarczyk: ah well

9:36 I take this to mean that you'll have no problem whitelisting that stuff after 1.2 comes out

9:36 Licenser: not at all

9:37 mmarczyk: I mostly meant "no technical problem" by that :-)

9:37 Licenser: I hope not :P

9:37 mmarczyk: cool

9:37 :-)

9:37 Licenser: clj-sandbox does some pretty complicated things with the code, as in compleatly not using the . special form

9:37 mmarczyk: ?

9:39 Licenser: you can't use . in the code

9:40 it will be removed, or rather replaced, that is why we can allow you to write . without risking you breaking the sandbox

9:41 mmarczyk: well, yes, I'd expect that

9:41 Licenser: I'm not entirely sure how reify and protocolls will play into this but I hope it will go smoothly

9:42 mmarczyk: right.

9:45 "You silly wabbit have 'Object' in a class matcher." :-)

9:48 Licenser: That is a good Exception isn't it? I'm particular proud of that one!

9:49 mmarczyk: as well you should be :-)

9:50 * Licenser bows

9:52 Licenser: I wonder about defn

9:52 (def blah (.withMeta (clojure.core/fn blah ([x] x)) (.meta (var blah))))

9:52 is what defn does, but when bla does not exist, before the def why would it try to get the meta?

9:53 mmarczyk: Licenser: the way in which you jump at the opportunity to mock Raynes *in an exception message* is a particularly nice touch, I find :-P

9:53 Licenser: That is because I love raynes

9:53 mmarczyk: of course :-)

9:53 Licenser: after all Raynes is the only one using clj-sandbox

9:54 I soley develop it for him :P

9:55 mmarczyk: :-)

9:55 Licenser: about defn

9:55 Licenser: yes

9:55 mmarczyk: (.withMeta ...)

9:55 gets rewritten as

9:55 (. (fn blah ...) withMeta ...)

9:56 no problem with that

9:56 Licenser: I know

9:56 mmarczyk: $(. (ArrayList.) toArray)

9:56 sexpbot: java.lang.IllegalArgumentException: Unable to resolve classname: ArrayList

9:56 Licenser: well no what I mean is it says this fn (object) has the meta of the var, but the ar does not exist

9:56 mmarczyk: $(. (java.util.ArrayList.) toArray)

9:56 sexpbot: java.lang.SecurityException: Code did not pass sandbox guidelines: ()

9:56 mmarczyk: ah, but it does

9:56 Raynes: I love those useful error messages.

9:56 mmarczyk: $(def foo (meta #'foo))

9:56 sexpbot: => #'net.licenser.sandbox.box3471/foo

9:57 mmarczyk: $(println foo)

9:57 sexpbot: => {:ns #<Namespace net.licenser.sandbox.box3471>, :name foo} nil

9:57 mmarczyk: def creates the Var first, then does a .bindRoot, I think

9:57 Licenser: hmm I see

9:57 sneaky

9:57 okay then it makes sense, but you've to understand the interna there

9:57 mmarczyk: you're not meant to care how defn works, you know :-P

9:58 unless you feel compelled to write a sandboxing lib for some reason ;-)

9:58 Licenser: Yea silly me

9:59 Raynes: I'm happy he did.

9:59 Licenser: did not kow how defn works? :P

9:59 Raynes: That way when people whine and complain because sexpbot does something weird, I can say "hey, it's not my fault"

9:59 :D

10:00 mmarczyk: ah, the perfect relationship

10:00 * Raynes goes hotpocket hunting.

10:01 Licenser: have fun!

10:01 mmarczyk: (just googled hotpockets)

10:01 Licenser: yea sad thing is just that in most plces it actually is sexpbot doing something wird

10:02 mmarczyk: which is just as well, because this way when people whine and complain because clj-sandbox does something weird, you can say "hey, it's acutally sexpbot's fault"

10:02 Licenser: *nods* If you could read german I would give you a link to an old article of mine :P

10:03 mmarczyk: oh, please do

10:03 I can, somewhat

10:03 Licenser: oh then I

10:03 v

10:03 've to dig it out

10:03 mmarczyk: waiting patiently. :-)

10:04 Licenser: http://cycnus.de/index.php?frame=/fun/schuldspirale/funschuldspirale.htm

10:05 mmarczyk: ok, it'll take me a while though, I'm a slow reader when dealing with German text

10:07 Licenser: *nods* take your time

10:07 mmarczyk: :-D

10:07 love this

10:08 I might translate this into Polish; I think I've already got an idea of whom to substitute for Simon, Sven &c. :-P

10:19 stuarthalloway: hugod: you around? I am getting started with pallet and am stymied at square one

10:25 Licenser: mmarczyk: cool

10:43 djpowell: what's the deal with github.com/clojure?

10:47 stuarthalloway: djpowell: what do you mean?

10:47 djpowell: has clojure moved?

10:48 stuarthalloway: yes

10:48 now that github has organization support

10:49 If there are busted links somewhere let me know

10:49 I updated http://clojure.org/downloads

10:49 djpowell: ah k. has this been well publicised, I'd never heard about it

10:49 stuarthalloway: couple of posts to the mailing list, plus fixing pointers

10:49 hope to move the build box this weekend

10:50 djpowell: ok

11:00 clojay: I have a .clj file that I'd like to load automatically before every Repl session. How can I modify the standard clj script to ensure this file is loaded? The file itself contains plain functions.

11:07 djpowell: did you know that if you put a user.clj on the class path it gets loaded automatically?

11:08 also, if you run "java -jar clojure.jar --help" there are some startup flatgs for loading scripts

11:13 stuarthalloway: hmm - clojure.java.shell is still broke

11:13 stuarthalloway: broke how?

11:13 djpowell: in http://github.com/clojure/clojure/commit/31b6fb557a3c524c447d312f5c51b6262ffb9b0f you removed the pmap stuff

11:15 stuarthalloway: I see your point

11:16 the pmap didn't work either, because it forced the same encoding on both streams, which is not how the API now works

11:16 so we need to get back the parallelism, but not with pmap

11:16 clojay: thank djpowell. Let me try that

11:17 stuarthalloway: djpowell: hmm, put the two calls in futures?

11:18 djpowell: i didn't realise that stderr was going to use platform default encoding

11:18 clojay: djpowell: I get the following error Don't know how to create ISeq from: clojure.lang.Symbol (user.clj:1

11:18 stuarthalloway: djpowell: me neither, til recently

11:18 djpowell: stuarthalloway: but you could just put pmap back and sort the encodings

11:19 or use pvalues or one of those functions

11:19 hugod: stuarthalloway: I am now, how are you getting on?

11:20 stuarthalloway: djpowell: will add issue and do it before 1.2 goes final

11:20 hugod: it is quite strange

11:21 when I do the defnode from demo.clj, the VM exits, without warning or explanation

11:21 djpowell: oh and thanks for sorting the bug out in it, it must have creeped in when i added in-enc

11:22 stuarthalloway: tested defnode at the REPL, both plain and in emacs

11:22 does that make any sense at all?

11:22 clojay: My ~/.init.clj file contains a single function my-pretty-print. I load it as follows java -cp "$CP" clojure.main --repl -i "$HOME"/.init.clj. The error I get when I try to call the function from repl is "java.lang.Exception: Unable to resolve symbol: exit in this context".

11:23 hugod: stuarthalloway: that's strange - are you using a checkout or jar?

11:23 stuarthalloway: checkout

11:23 let me try the jar

11:23 clojay: (sorry the error should be java.lang.Exception: Unable to resolve symbol: my-pretty-print in this context)

11:24 hugod: stuarthalloway: the checkout should be fine - with lein or mvn?

11:24 stuarthalloway: I was using lein

11:25 hugod: I'm doing a fresh checkout to try and replicate....

11:28 Licenser: hmm lein refuses to download 1.2.0-SNAPSHOT for some reason o.O

11:28 stuarthalloway: hugod: found it!

11:28 hugod: stuarthalloway: ok - anything I need to fix?

11:28 Licenser: anyone had this happening to them yet?

11:28 stuarthalloway: no, it's a bug in the repl, or clojure itself!

11:28 ,\"[^J]+9.10[^32]+\"

11:28 clojurebot: \"

11:29 stuarthalloway: I had copied from the clj file (with the slash escaping), and that constant crashes the replp

11:29 ,(+ 1 2)

11:29 clojurebot: 3

11:29 stuarthalloway: but didn't seem to kill the clojurebut

11:30 I have such a gift for stumbling into weird bugs

11:30 hugod: $\"[^J]+9.10[^32]+\"

11:30 sexpbot: Command not found. No entiendo lo que estás diciendo.

11:33 djpowell: stuarthalloway: (let [out err] (pvalues (stream-to-enc stdout out-enc) (stream-to-string stderr)) ...) seems to work

11:33 stuarthalloway: djpowell: throw it into https://www.assembla.com/spaces/clojure/tickets/399-make-sure-shell-out-and-err-handled-in-parallel if you want

11:34 Licenser: $eval \"[^J]+9.10[^32]+\"

11:34 sexpbot: => \"

11:34 Licenser: $eval 3

11:34 sexpbot: => 3

11:34 stuarthalloway: or I will, after I solve the repl bug

11:34 Licenser: $eval (def x \"[^J]+9.10[^32]+\")

11:34 sexpbot: java.lang.Exception: Unmatched delimiter: ]

11:34 Licenser: $eval 3

11:34 sexpbot: => 3

11:34 Licenser: +c still working

11:38 mmarczyk: Licenser: 1.2.0-SNAPSHOT of what? it's 1.2.0-master-SNAPSHOT for Clojure

11:39 Licenser: mmarczyk: my problem was oddly enough the horrible error mesage of mvn not the jar names

11:39 I had a wrong jar for something else, which then told me clojure is wrong - no clue why

11:39 mmarczyk: ah

11:39 the error message imps played a game of dice to determine which jar would get blamed

11:41 stuarthalloway: hugod: weirder still: the bad constant is an error in clojure repl, but bombs the lein repl

11:41 looks like a lein bug

11:41 mmarczyk: stuarthalloway: \"[^J]+9.10[^32]+\" is not a valid constant anyway

11:41 with the "s escaped

11:42 stuarthalloway: mmarczyk: agreed!

11:42 but it kills the lein repl with no message

11:42 mmarczyk: oh?

11:42 which Clojure version in project.clj?

11:43 stuarthalloway: 1.2 master branch is what I have tested so far

11:43 mmarczyk: just checked with 1.1, same thing

11:43 wow :-)

11:43 stuarthalloway: my best guess, looking at lein code, is that repl catches only Exception, not Throwable

11:44 but just throwing throwable is ok... hmm...

11:44 mmarczyk: I guess that the problem is that

11:44 at [^J

11:44 the reader expects something to attach {:tag J} to

11:44 but finds end-of-vector

11:45 should be an exception rather than an error, no?

11:45 stuarthalloway: dunno

11:48 mmarczyk: any reader exception kills the lein repl, just try the two characters (]

11:48 mmarczyk: ouch, indeed

11:48 stuarthalloway: will post a comment to technomancy

11:49 clojay: ,(System/Exit 0)

11:49 clojurebot: java.lang.IllegalArgumentException: No matching method: Exit

11:49 clojay: hehe

11:49 stuarthalloway: clojay: are you from C#-land?

11:49 mmarczyk: clojay: it's exit, but won't work with the bots

11:50 serp_: ,(reduce + '(1 2 3))

11:50 clojurebot: 6

11:50 clojay: stuarthalloway: yes

11:50 stuarthalloway: your capital methods are showing :-)

11:54 clojay: stuarthalloway: :) Do you know how can I force the repl to load a file at startup? I tried the -i option and it doesn't seem to work

11:54 mmarczyk: add-break-thread! doesn't seem to work with lein repl... same issue I guess

11:54 stuarthalloway: clojay -e "any clojure here"

11:55 including, of course, (load "stuff")

11:55 remember your command line escaping tho

12:01 mmarczyk: clojay: you can use -i, but then you'll need to add an explicit -r to get the REPL to start

12:01 clojay: mmarczyk: stuart's method with -e worked, however I have a different problem now

12:02 mmarczyk: ?

12:02 clojay: mmarczyk: what's wrong with this? (defn exit (do (System/exit 0)))

12:03 mmarczyk: clojay: you're missing an argument vector

12:03 anonymouse89: what would be an idiomatic way to block until a boolean changes?

12:03 mmarczyk: (defn exit [] (System/exit 0))

12:03 note the do is superfluous

12:03 clojay: (defn exit [] (System/exit 0))

12:04 oh good

12:04 mmarczyk: function bodies are implicitly wrapped in do

12:04 clojay: same as yours

12:04 mmarczyk: great, thanks

12:04 mmarczyk: np

12:06 clojay: sometimes I get confused when a () is needed and when it's not. Is there some general rule to immediately realize if it's needed or not?

12:07 mmarczyk: anonymouse89: if the Boolean is stored in a Ref / Atom / whatever, you could use add-watch and have the watcher deliver to a promise on which you can block with deref wherever it is that you need to block

12:07 anonymouse89: More specifically, I want to block until (every? true? (vector-of-things :complete)) is true

12:07 like the equivalent of await but I'm not using agents

12:08 oh, or I could wrap every element of the vector with an agent?

12:08 mmarczyk: (vector-of-things :complete) ?

12:08 that you could

12:09 anonymouse89: I mean the things in vec-of-things have a keyword :complete that should be true before continuing

12:09 mmarczyk: clojay: well, if you need parens but skip them, your code will break

12:09 clojay: mmarczyk: with trial and error I will learn I guess :)

12:10 mmarczyk: clojay: basically they denote literal lists, which, unless quoted, are treated as function calls / macro calls... so whenever you're calling a function, you'll need to use ()

12:10 true enough :-)

12:10 anonymouse89: so it's more like (every? (comp true? :complete) vector-of-things)? what are the things?

12:11 I mean, if they can actually *change*, they're something mutable -- what exactly?

12:11 anonymouse89: they are dispatched computations. so an item is returned immediately, but (item :value) is nil until actually complete

12:11 and (item :complete) is false until complete

12:12 clojay: that's a very easy way to think about it. I was wrongly thinking about "evaluation" so when I was returning a value trhough a symbol like x, I would pause to think if I need the parenthesis or not. Which I don't of course. So in short, the solution is to think "Is this is a function call?" if not, no parenthesis apply.

12:12 anonymouse89: so I'm just trying to wait for all those to become complete before continuing

12:12 mmarczyk: dispatched to what and how?

12:12 I mean, say, for futures

12:12 you can just use @ in place of await

12:12 same for promises

12:13 anonymouse89: deref's block?

12:13 mmarczyk: for other kinds of "dispatched / delayed / etc." stuff, there might be other methods

12:13 anonymouse89: depends what you deref

12:13 anonymouse89: on Atoms, Refs, Agents, Vars they don't block

12:13 anonymouse89: on Futures they do

12:13 anonymouse89: mmarczyk: good to know

12:14 mmarczyk: anonymouse89: on Promises they do in the sense they'll block 'til sth gets delivered

12:14 clojay: right :-)

12:15 anonymouse89: mmarczyk: okay, so I think I've reformulated my question. Is there an idiomatic way to try sth every (insert unit of time here) until ...

12:15 or just loop and sleep?

12:15 mmarczyk: anonymouse89: sure, you can use a (while ...) block

12:16 loop/recur is fine, but you'd have no loop bindings, so while is cleaner

12:16 anonymouse89: so like: (while not every? true? (vec-of-bools))

12:16 mmarczyk: ((while ~@body) = (loop [] ~@body (recur)))

12:16 (while (not (every? true? (vec-of-bools))) (Thread/sleep 100))

12:17 anonymouse89: right, I think that's what I'm looking for

12:17 mmarczyk: thanks

12:17 mmarczyk: presumably you'd use this as the first form in a do (possibly implicit)

12:17 anonymouse89: mmarczyk: I'm not sure what implicit means there

12:17 mmarczyk: anonymouse89: cool, though for special cases where something like a blocking deref is available, the special way to do it might be better / cleaner

12:18 anonymouse89: I meant "possibly an implicit do"

12:18 as in let, fn etc.

12:18 ah, that definition of while above is wrong of course

12:19 misses the condition... nvm

12:19 the example with (not (every? ...)) will work, though

13:03 fyuryu: mmarczyk: just looked at your default-map gist and I'm wondering if there's any reason for putting (reify ..) inside getLookupThunk. Unless I

13:04 mmarczyk:* Unless I'm missing something

13:24 mmarczyk: fyuryu: getLookupThunk needs to return an ILookupThunk

13:30 fyuryu: mmarczyk: doh!

13:30 mmarczyk: :-)

13:30 fyuryu: mmarczyk: it must be because of the heat

13:32 mmarczyk: oh, the heat... it's been thirty-ish (on the Celsius scale) here today and it seriously interferes with my present coding effort :-(

13:33 qbg: No AC?

13:33 fyuryu: same over here...

13:34 mmarczyk: no ac.

13:35 I'd be perfectly happy with a fan, but alas, I can't see going to get one now *sigh*

13:50 AWizzArd: mmarczyk: I had 57,5°C in front of my window today, in the direct sun. Now it is 31°C in my apartment, argh!

13:50 For people who don’t know what these Celsius numbers mean, use Clojure: http://clojure.org/jvm_hosted :-)

13:51 mmarczyk: 57.5!? totally crazy

13:51 AWizzArd: Yes, in the direct sun.

13:52 And my thermometer is very accurate. Now just 42 :-)

13:52 Raynes: Or use sexpbot. $#tc C57#$

13:52 mmarczyk: much better ;-)

13:52 sexpbot: Raynes: 134.60000000000002

13:52 mmarczyk: whoa, that's one comprehensive plugin collection :-)

13:52 Raynes: :p

13:52 qbg: Pics or it didn't happen

13:53 AWizzArd: qbg: okay, next time

13:53 qbg: :)

13:53 mmarczyk: the worst thing here is that the sun is shining straight into this room's window

13:54 and I'm missing some essential equipment now, like a working wi-fi router

13:54 or an ethernet cable

13:54 either would suffice for me to be able to go to the next room where it's perfectly cool :-P

13:55 AWizzArd: mmarczyk: buy some aluminium foil, that is the same stuff mirrors are made with, and put them from the outside on your window.

13:55 mmarczyk: whenever I go shopping for the aforementioned equipment (tomorrow?), I guess I'll also by something reflective to put over...

13:55 AWizzArd: right, exactly :-)

13:55 AWizzArd: I wished Oracle would bring out a weather API, so I could use Clojure to solve such heat challenges.

13:56 mmarczyk: I was thinking about buying some bricks and getting rid of the window once and for all :-P

13:56 but I think that might be problematic in some ways, so I'll make do with the foil.

13:57 Window.attach(new AluminiumFoil(2.0, 0.75, Units/METER)) ?

13:59 LauJensen: We had 43.5 in the sun today, just after noon

14:00 32 in the shade

14:00 AWizzArd: Well, it really helps, because Aluminium reflects nearly the full spectrum of electromagnetic waves, and if you have over a m² window, then this means that you can keep out a significant bit of watts from your room.

14:01 Hodapp: AWizzArd: wait, so I should have my tinfoil hat actually be an aluminum foil hat?

14:02 AWizzArd: Hodapp: you are learning fast!

14:04 Btw, is there an ETA when build.clojure.org will spit out new jars? (:

14:06 mmarczyk: Stu H. mentioned a plan to let the build box know about github.com/clojure this weekend

14:06 $(def fibs (concat [0 1] (map + fibs (rest fibs))))

14:06 sexpbot: java.lang.IllegalStateException: Var net.licenser.sandbox.box3471/fibs is unbound.

14:07 mmarczyk: $(def fibs (lazy-cat [0 1] (map + fibs (rest fibs))))

14:07 sexpbot: => #'net.licenser.sandbox.box3471/fibs

14:07 mmarczyk: $(nth fibs 10000000000)

14:07 sexpbot: java.lang.Exception: EvalReader not allowed when *read-eval* is false.

14:07 mmarczyk: huh...?

14:07 $(first fibs)

14:07 sexpbot: => 0

14:07 AWizzArd: Raynes: about the sexpbot's knowledge about Celsius2Fahrenheit... did it had that functionality before I mentioned the numbers above, or did you do some fast magic? ;)

14:08 mmarczyk: $(nth fibs 1000000)

14:08 Raynes: I added that ages ago.

14:08 AWizzArd: k

14:08 Raynes: I'm not that fast. :p

14:08 sexpbot: Execution Timed Out!

14:09 AWizzArd: mmarczyk: killing bots huhm?

14:09 mmarczyk: :-)

14:10 hm, incidentally

14:10 $(make-array Double/TYPE 100)

14:10 sexpbot: => #<double[] [D@460a87a8>

14:11 mmarczyk: I wonder if I could get in trouble by asking for a particularly large array

14:12 perhaps just short of OutOfMemoryError... followed by an allocation-intensive op

14:13 AWizzArd: mmarczyk: try locally (in your Clojure) to ask for a 10 Terabyte Array

14:14 mmarczyk: I have, got OOME

14:14 and a new prompt :-)

14:17 presumably asking the bot to create -- and keep around -- an array which would *just* fit on the heap

14:17 would result in OOMEs for subsequent regular ops

14:18 how does one check the size of an object in Java?

14:18 AWizzArd: mmarczyk: what do you mean by that?

14:20 mmarczyk: well, there's (-> (Runtime/getRuntime) .totalMemory) for total memory available

14:20 as well as .freeMemory for free memory

14:20 AWizzArd: Yes, you can work with the three Runtime methods.

14:20 mmarczyk: I'm wondering about something similar to ask about a given objects size on the heap.

14:20 ^object's

14:20 AWizzArd: But also have a look at http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/api/java/lang/management/package-summary.html

14:20 chouser: it's difficult, but close estimates can be found

14:21 AWizzArd: They offer a MemoryUsage class

14:21 mmarczyk: hm, interesting, thanks

14:21 I found this: http://www.javapractices.com/topic/TopicAction.do?Id=83

14:22 AWizzArd: http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/api/java/lang/management/MemoryUsage.html

14:22 mmarczyk: estimates heap space taken up by objects of a given class by creating a bunch of them while keeping track of the Runtime/foo output

14:23 which is not at all what I want, but still fun

14:23 Bahman: mmarczyk: AFAIK you have to measure memory before and after creating the object and the usage it's their difference.

14:24 And don't forget to call GC before measuring.

14:25 AWizzArd: (dotimes [i 5] (System/gc))

14:27 mmarczyk: look into your priv pls

14:34 arohner: while we're on the subject, is there a way to get the size of a single object?

14:39 stuartsierra: aorhner: define "size"

14:40 AWizzArd: arohner: most of the time it is just 8-byte pointers on 64-bit systems

14:40 should one follow the pointers?

14:40 arohner: I want the total memory usage for a tree of clojure maps

14:40 AWizzArd: How big are circular objects?

14:40 stuartsierra: arohner: you need a Java profiler or debugger

14:41 arohner: let me put it another way. If the only reference to this clojure map went away, how much memory would be GC'd

14:41 stuartsierra: yeah, visualVM is incredibly slow on this datastructure (~1.5GB)

14:41 and cumbersome to use

14:42 stuartsierra: arohner: you can get a rough approximation by creating a bunch of objects, removing references, and calling System.gc while you watch your OS memory usage

14:42 arohner: sigh

14:43 I wrote a little fn that uses clojure.walk to call (class) on every object, and returns a summary of instance counts

14:43 that takes ~3 seconds to walk 1.5GB. I just want to convert that into bytes per object

14:44 AWizzArd: arohner: it is not really clear what this means, there are multiple ways to look at it.

14:45 stuartsierra: well, figure out how many bytes the instance fields take up, add X bytes for every Java pointer (look that up)

14:45 AWizzArd: You can surely find out how much memory all objects take. Just scroll up, this was discussed a few minutes ago, see the MemoryUsage class.

14:45 arohner: AWizzArd: I know. I'm just annoyed that the tools suck. This should be a trivial thing to report

14:47 stuartsierra: The JVM goes to great lengths to abstract away memory usage.

14:48 arohner: stuartsierra: which is broken, IMO. Until it can abstract away physical memory usage, you need to know that sometimes

14:48 stuartsierra: agreed

14:48 AWizzArd: arohner: in principle you are right, but it really is not such a trivial thing

14:49 arohner: AWizzArd: sure it is. there are two main operations I care about.

14:49 1) how much memory does it take to malloc an instance of this class? That counts the size of each field in the class, plus the pointers built into the JVM object

14:50 2) how much memory would be free'd if the object were GC'd

14:50 obviously 1) is O(1), and 2) requires walking the object graph. I'm ok with #2 taking significantly more time

14:51 but visualvm appears to have an algorithmic complexity class bug, in that it can't walk 250MB of memory in a reasonable amount of time

14:52 and actually, I'm ok with #2 being done destructively

14:52 i.e. actually GC the object, and return the number of bytes GC'd

15:00 roblally: As I understand it, on modern VMs individual objects are rarely GC'd. The process of GC is handled by higher level algorithms based on root node retention. Not to mention Schroedinger objects with various types of weak references which have indeterminate size.

15:01 I say rarely because I'm not sure, but I suspect 'never' to be the case.

15:02 stuarthalloway: hugod (or other palleters): how do I configure an SshModule?

15:04 hugod: stuarthalloway: how have you connected to the provider? (org.jclouds.compute/compute-service ... ?)

15:05 stuarthalloway: using basically the same settings cemerick's blog post

15:05 passed :ssh flag at end of call to compute-service

15:05 do I also need to pass (ssh) under :configure?

15:06 hugod: the :ssh in compute-service should suffice

15:07 stuarthalloway: I am running from my own project -- could I be missing a jar?

15:07 I notice that pallet itself has various jars as dev dependencies

15:07 so I made the ones I thought I needed into regular dependencies in my own project

15:07 mmarczyk: arohner: that's what I'd like to do too... to learn the size of a single object on the heap

15:08 stuarthalloway: e.g. I added org.jclouds/jclouds-aws

15:08 hugod: stuarthalloway: the ssh jar is a direct dependency of pallet - so should be picked up

15:08 mmarczyk: it would be absolutely fantastic if, given a class, I could tell how much memory I'd need to instantiate it...

15:09 hugod: you'll need the jar for the provider you are using , so adding jclouds-aws is correct for ec2

15:09 stuarthalloway: hugod, yes, I see clj-ssh-0.1.0.jar. I will try running the same code from pallet's own repl to see if things go any different

15:10 hugod: stuarthalloway: if you are using 0.1, please switch to 0.1.1

15:10 stuarthalloway: hugod: back atcha! pallet seems to be using 0.1 :-)

15:14 hugod: stuarthalloway: sorry, if you are using pallet-0.1, please switch to pallet-0.1.1 - I messed up with the project.clj file in 0.1 (the pom.xml is fine though)

15:14 stuarthalloway: ah, I am on edge anyway

15:21 hugod: stuarthalloway: so what are you trying? I assume you have an exception asking you to configure an SshModule?

15:21 stuarthalloway: yes

15:21 I am about to create a gist so you can see it exactly

15:23 ah cool, now that I am running at the pallet repl I get tons of stdout info that I wasn't seeing before

15:23 wonder what sucks that stuff up when using it from another project...

15:24 hugod: you'll need a logging configuration file

15:24 stuarthalloway: ah, that's it, I already have one

15:24 now I am getting a mix of the error I saw before, plus com.jcraft.jsch.JSchException: Auth fail

15:25 hugod: by default, it authorises you id_rsa key - if you are not on OSX, you'll need to make sure it doesn't have a passphrase

15:26 stuarthalloway: I am on OSX

15:26 http://gist.github.com/470955

15:28 is part of my problem that a new key pair keeps getting generated each time?

15:29 I now have a slew of keypairs with names like jclouds#praxis-NN

15:29 which would make me think that converge would fail on existing instances that use the keypair from the previous round

15:30 and you are right, it is wanting a passphrase -- I can see it in the log

15:33 hugod: it should ask for access to your keychain - assuming you use the osx keychain

15:34 stuarthalloway: hugod -- thanks -- the issue is definitely now local to me :-/

15:34 should I expect to see a new keypair in EC2 every time I run the code?

15:40 hugod: stuarthalloway: which keypair are you refering to?

15:40 stuarthalloway: every time I run the pallet script, it seems to create a new keypair on ec2

15:41 with a name like jclouds#praxis-NN

15:41 or maybe it is just every time I have changed the definition of the server, since I was playing around with that

15:42 hugod: I found the missing jar

15:42 hugod: stuarthalloway: I'll ask adriancole_ over on #jclouds - I don't use ec2 myself...

15:43 stuarthalloway: for some reason lein deps isn't picking up the jsch jar file, even though I am depending on pallet

15:43 hugod: that's strange - it's a dependency for clj-ssh

15:44 stuarthalloway: strange indeed, wonder if that's my second lein bug of the day, or maven, or just me

15:44 hugod: mvn dependency:tree should list jsch unless there is a maven issur

15:46 * stuarthalloway downloading internet

15:48 rmarianski: p /go evilhackerdude

15:48 err, sorry

15:50 stuarthalloway: hugod: org.jclouds/jclouds-jsch is listed as optional in the pallet pom.xml

15:51 ... which makes the dependency non-transitive. Consumers of pallet as a library will thus need to redeclare a dependency. By design?

15:55 hugod: stuarthalloway: oversight. thanks for catching this, ditto jclouds-log4j and jclouds-enterprise

15:55 stuarthalloway: hugod: no problem, sorry I am so dumb that it took so much of your time

15:58 hugod: stuarthalloway: and apologies that it so much of yours to track it down - jar soup is enough to confuse any of us

15:58 stuarthalloway: any particular plans for pallet?

15:59 stuarthalloway: hugod: we are (at present) big into chef

15:59 I would like to see more parens in my cloud admin

16:00 currently just messing around, using it as a stable reference platform for testing different libraries we might use on client projects

16:01 hugod: ok, I would appreciate your feedback once you have spent some time with pallet

16:01 stuarthalloway: hugod: you bet!

16:54 technomancy: oh sweet, the CLI launcher ticket has been scheduled for the release after 1.2

16:54 better late than never

16:58 stuarthalloway: technomancy: did you see the bug I filed on lein

16:58 I would fix it if I knew the right thing to do

16:58 technomancy: stuarthalloway: yeah, actually looking into it right now

16:58 stuarthalloway: awesome, thanks!

16:58 technomancy: stuarthalloway: it's because the reader doesn't know how to distinguish between ^D characters and malformed input

16:59 stuarthalloway: the regular clojure repl does the right thing somehow

16:59 mudge: what does "No matching ctor found" mean?

16:59 what the heck is a "ctor" ?

16:59 qbg: Constructor

17:00 Raynes: Couldn't have that cljr project theoretically have been a Leiningen plugin? If there were global plugins, that is.

17:00 mudge: qbg: ohhh

17:00 thanks

17:00 i thought it was short for some type of dinosaur, boy was I way off

17:01 technomancy: Raynes: yeah, I was planning on implenting cljr-like functionality once I had global plugins working

17:01 stuarthalloway: yeah, probably just means I can't use a bare (read) call

17:01 Raynes: I have a couple of ideas for plugins myself once global plugins work.

17:02 technomancy: stuarthalloway: I can't use the regular repl because ant's subprocess launcher is totally busted for anything that uses stdin

17:02 * technomancy makes a stabby face

17:02 stuarthalloway: doh!

17:02 technomancy: stuarthalloway: it's very convoluted as a result =\

17:02 mudge: stuarthalloway: I'm reading your book. Learning a lot.

17:03 stuarthalloway: mudge: cool. I had a question yesterday and somebody pointed my to the book :-)

17:03 mudge: haha

17:07 arohner: what's a global plugin?

17:08 technomancy: arohner: "user-level" is what I was calling it. basically for tasks like "lein new" that need to be run outside the scope of a project.

17:08 planned for lein 1.3

17:09 arohner: technomancy: cool

17:30 pietia: does clojure is good to writting crawlers/scrapers? are there any good tools for clojure to parse html?

17:31 stuarthalloway: enlive

17:33 pietia: how about the performance ?

17:34 in comparison to jruby + mechanize / nokogiri

17:46 hiredman: htmlunit is pretty nice for scraping/crawling

17:46 walking through forms and pushing buttons and walking through the response

17:47 it's a java library, but very arrowy if I recall

17:48 technomancy: MenTaLguY: hey, how's it going?

17:49 MenTaLguY: goes okay

17:49 finally doing some clojure hacking again

17:49 technomancy: cools

17:49 MenTaLguY: wish 'lein test' didn't take so long to start/warm up, but that's not your fault

17:50 technomancy: MenTaLguY: are you able to use a client JVM?

17:50 MenTaLguY: yes -- isn't that the default? versus -server?

17:50 technomancy: MenTaLguY: well... sort of. it's not always available.

17:50 bulters: g'day all

17:50 technomancy: "lein version" will tell you what it's using

17:51 MenTaLguY: on 64-bit machines you have to get a special JDK to get the client JVM

17:51 on ubuntu it's ia32-sun-java6-bin

17:51 MenTaLguY: Leiningen 1.1.0 on Java 1.6.0_18 OpenJDK Client VM

17:52 technomancy: cool

17:52 you can also avoid the startup penalties by re-running the tests in an already-running repl or swank session

17:52 course it's easy to get in a bad state (aka "getting slimed"), but you can avoid that by doing a fresh "lein test" once before committing

17:53 * MenTaLguY nods

17:53 MenTaLguY: I guess what I really want is something like nailgun

17:53 well, no

17:53 what I really want is a JVM that starts instantly

17:53 technomancy: are you a vim guy?

17:53 MenTaLguY: and a pony

17:53 yes

17:53 technomancy: it integrates with nailgun

17:53 heh

17:54 you can do worse than calling run-tests at the repl though, especially if you're not in the mood for an environment yak-shave

18:08 AWizzArd: Fast Leiningen question: when one does “lein swank” in the shell, does it then run a repl inside the shell, or will it start a background process that manually needs to be stopped?

18:10 technomancy: AWizzArd: it just launches a swank server

18:10 it's not really a classic repl

18:10 but it's foregrounded

18:10 btw, any Japanese speakers care to translate this? もうLeiningen使えば無理にIDE使わなくても良いよなぁ。っということでNetbeans周りのToDoは優先度下げた

18:12 AWizzArd: technomancy: so, is it comparable with an Ant <java> task with fork="true" and spawn="false"?

18:12 technomancy: I'm not sure what spawn means, but it is a java task that forks

18:14 AWizzArd: technomancy: when spawn="true" then the forked jvm will outlive ant, so I guess it is supposed to run in the background. Though this does not work for me, while fork true and spawn false does. Thanks for the info.

18:14 MenTaLguY: hm, so is there a library function similar to (fn [m k f] (assoc m k (f (m k)))) ?

18:15 technomancy: ,(doc update-in)

18:15 clojurebot: "([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created."

18:15 technomancy: I think that's what you want.

18:17 AWizzArd: technomancy: is there a way to make Emacs (using Emacs Starter Kit) using a default folder of my choice, when a fresh Emacs is started and I do “M-x f”

18:18 i.e. the first M-x f will default me to ~/ for example

18:18 technomancy: AWizzArd: I think just (setq default-directory "~") in your dotfiles

18:19 not sure what M-x f means though

18:19 AWizzArd: uh, C-x f

18:19 Or, C-x C-f

18:20 okay fine, thanks

18:20 And the ESK auto suggests files to me, and when I type in a file name that does not exist yet (for example “awizzard.el”) it will open whatever the suggestion says

18:21 Is there a way to have it open a buffer with my file, not using the suggestion?

18:24 technomancy: AWizzArd: yeah, C-f will disable ido-mode temporarily if you hit it while you're choosing a file or buffer

18:25 AWizzArd: great, thx

18:25 again :)

18:25 technomancy: I should put that in the readme; it's quite a faq

18:26 * AWizzArd needs a cheat sheet for all those goodies in the ESK

18:27 technomancy: not all that much is specific to ESK

18:27 it just brings together a bunch of previously-disparate usefulness

18:27 even package.el is now included in Emacs

18:28 AWizzArd: In my version too? “GNU Emacs 23.2.1 (i386-mingw-nt6.0.6002) of 2010-05-08”

18:30 technomancy: no, it's only in trunk right now.

18:30 and it's kind of a busted version.

18:30 working on fixing that right now, actually.

18:31 man... lein's uberjar function really is a mess.

18:32 AWizzArd: why?

18:32 clojurebot: why not?

18:33 technomancy: why's package.el busted, or why is uberjar a mess?

18:34 AWizzArd: überjar

18:34 Doesn’t it create überjars? ;)

18:34 technomancy: I can't figure it out, but most of the messiness centers around a file called META-INF/plexus/components.xml

18:34 which smells like working around maven funkiness

18:35 unfortunately this was all written by _ato, who has disapperaed. =P

18:36 AWizzArd: oh

19:26 thunk: Does anyone tell me the idiomatic way to serve static files in compojure?

19:26 s/Does/Can/

19:26 sexpbot: Can anyone tell me the idiomatic way to serve static files in compojure?

19:27 AWizzArd: thunk: your Handler can just return the file

19:27 i.e. (File. "/the/file/you/want/to/serve.txt")

19:28 thunk: AWizzArd: Hrm. What's a project's default root directory?

19:28 e.g. I'm striking out with (GET "/foo.css" [] (route/files "foo.css"))

19:28 with foo.css in ./public

19:29 AWizzArd: Ahh, gotcha.

19:34 AWizzArd: Thanks, that did the trick.

19:36 AWizzArd: thunk: you can also add a GET handler accepting *

19:36 and then you do security checks in the handler, if it is okay to serve that file, and that way you can serve any file, in principle

19:37 just be aware that a user could move around on the server, if your handler is not careful.

19:37 Anyone here with a recent clojure.jar? Please test if (do (set! *warn-on-reflection* true) (defrecord Foo [])) throws a Reflection warning for you too.

19:43 robink: This may be a Java question, but calling ".split" on a string returns a Java string, not a vector of strings.

19:44 I'm not sure if there's a Clojure analogue to .split. The book I'm reading intimated that it was preferable to call the Java method.

19:44 AWizzArd: ,(doc clojure.contrib.string.split)

19:44 clojurebot: java.lang.ClassNotFoundException: clojure.contrib.string.split

19:44 AWizzArd: ,(doc clojure.contrib.string/split)

19:44 clojurebot: "([re s] [re limit s]); Splits string on a regular expression. Optional argument limit is the maximum number of splits."

19:44 robink: Thanks

19:45 AWizzArd: robink: but btw, String’s .split method does not return a String.

19:45 robink: AWizzArd: The REPL suggests that it does

19:45 AWizzArd: It returns an array of Strings and you should have no problems using it.

19:45 robink: Hm

19:46 AWizzArd: The String class does not have a .split method returning a String. Only returning String[]

19:46 robink: Oh, OK

19:46 AWizzArd: robink: can you please paste the .split expression that you used, and the string it returned?

19:47 robink: AWizzArd: The actual string?

19:47 AWizzArd: I get a reference to a String[]

19:47 AWizzArd: I mean your usecase: (.split "a b c" " ") ==> "a"

19:47 Something like that is what you got

19:48 robink: I didn't get "a"

19:48 I just got the reference

19:48 AWizzArd: well, you got a string

19:48 robink: Yeah

19:48 OK

19:48 AWizzArd: can you show that example please?

19:48 I would like to try it myself

19:48 robink: (.split "test.string" ".")

19:48 returns #<String[] [Ljava.lang.String;@177ba38f>

19:48 AWizzArd: so, now it works correctly?

19:49 robink: Not sure how to deal with a string array but that's what I initially got.

19:49 AWizzArd: aah, ok

19:49 robink: I'm sure it's correct behavior, but I was assuming Clojure would wrap the type.

19:49 AWizzArd: well, you can use map/reduce/filter/doseq on String arrays

19:49 robink: Oh, OK

19:50 AWizzArd: ,(map count (.split "a b c d e" " "))

19:50 clojurebot: (1 1 1 1 1)

19:51 robink: OK, but what I'd like is ("a" "b" "c" "d" "e") or ["a" "b" "c" "d" "e"]

19:52 AWizzArd: why?

19:52 clojurebot: why not?

19:52 gregh: ,(map identity (.split "a b c d e" " "))

19:52 clojurebot: ("a" "b" "c" "d" "e")

19:52 robink: Oh, OK

19:53 AWizzArd: or (vec (.split s1 s2))

19:53 But still, why do you want that?

19:53 robink: AWizzArd: because I'm getting back a Clojure data type.

19:55 AWizzArd: I don’t understand why that is needed. Typically the result will be used in a form that iterates over the returned values anyway.

20:54 hugod: AWizzArd: C-j will use whatever you have typed in ido-mode

21:43 AWizzArd: hugod: thx

22:22 defn: http://aperiodic.net/phil/scala/s-99/ cool way to learn clojure...

Logging service provided by n01se.net