#clojure logs

2010-07-10

00:12bhenrywith ring, how might i serve up static files from a dynamically decided path (based on a "get" variable from the query string)?
00:13bhenryeg localhost:8080/?dir=/Users/myname/Pictures
00:13bhenryhttp://...
00:15bhenryi'm able to get all the file objects, but the browser won't let me use file:///path coming from http://
00:47ysphis it possible to instantiate a defrecord class using a map of the fields?
00:53ysphnm, i think my case is better suited for a dictionary anyway
01:55ysphhow 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?
01:56hiredmanthe repl loads user.clj from the classpath
01:56ysphah, good to know
01:58ysphdoes leiningen set up the classpath in that way, or would i need to link user.clj into the src/ folder?
01:58hiredmanyou might
02:13scottjI don't think lein includes user.clj
02:14hiredmanI think lein doesn't get a say in the matter
02:15BahmanHi all!
02:25jkkramerysph: i use this in my .emacs: (setq swank-clojure-init-files (list "/Users/tin/src/clj/user.clj"))
02:27ysphjkkramer: thanks, i'll try that
04:29Licensergood morning my lispy friends
04:32Licenserhiredman: you're around?
04:35hiredmanI supose
04:36hiredmanwhats up
04:38Licenseryay
04:38Licenseryou've had found a problem in cj-sandbox/sexpbot right?
04:38hiredmanstrictly speaking no
04:38hiredmanI wouldn't worry about it
04:39LicenserI know from the log I think it is more a clojure thing but it should be cought :P
04:39LicenserI always do clj-sandbox is suposed to be as secure as possible
04:39hiredmanit is a clojure issue
04:40Licenser*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?
04:49Licenserhiredman: thanks for the info :) makes tracking the thing way easyer or rather a non-problem
05:03LicenserA question why writing (. clojure.lang.RT (first coll)) and not (. clojure.lang.RT first coll) ?
05:03Licenseris there a difference or are they actually the same?
05:10ChousukeLicenser: only the former works?
05:11Licenserhmm I am kind of confused
05:11Licenserisn't it (. obj (method args)) ?
05:11Licenserjust as much as (. obj method args)
05:15LicenserChousuke: actually they both work
05:15Licenser,(. clojure.lang.RT (first [1 2 3]))
05:15clojurebot1
05:15Licenser,(. clojure.lang.RT first [1 2 3])
05:15clojurebot1
05:31vvshhi, 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?
05:31Licenservvsh: do yo have the clojure.jar in your classpath?
05:32vvshyes, but the error is not about clojure, is actually about jline - "at jline.ConsoleRunner.main(Unknown Source)"
05:33vvshi downloaded jline-0.9.94.jar at the current directory( with clojure.jar)
05:34vvshand executed with this command - java -cp jline-0.9.94.jar:clojure.jar jline.ConsoleRunner clojure.main
05:36Licenserah I see, sadly I never used the jiinline thing :(
05:36vvshis there something wrong with the jline jar
05:36Licenserwell the exception says it does not find clojure.main
05:36Licenserit is just in the jinline jar
05:36Licenseris the clojure.jar in the same directory?
05:37vvshjline and clojure jar are in the same directory
05:38Licenserhmmm
05:38Licenserwindows or linux?
05:38Licenser*unix
05:38vvshmac
05:38Licenserso unix no issue there either
05:38Licensertry java -cp clojure.jar clojure.main
05:38Licenserhmm is it the latest clojure?
05:39vvshjava -cp clojure.jar clojure.main is working - 1.1.0
05:40Licenseroky so that should be fine
05:40Licenserhmm hmm
05:40Licenserwhile not a solution to your question there was a project on github let me dig it out to you
05:40Licenser*for
05:42Licenserit was a set of scripts to run clojure and things
05:42vvshcool thanks,
05:43vvshis it lein, the build tool
05:45Licenserhttp://github.com/liebke/cljr
05:45Licenserno not lein
05:46vvshthanks, i will look at it
05:46LicenserI hope it helps
05:47vvshi will try it, if not working, might give dejour or labrepl a try as well
05:51Licenseroh grrr
05:51noidivvsh, you can use rlwrap instead of jline
05:51Licenserrlwrap isn't default on OS X afaik
05:52vvshLicenser: it still have to same problem when trying with - cljr repl
05:52Licenserhmm odd
05:52Licenservery odd
05:52vvshi don't understand why it can't find clojure.main
05:52vvshi mean i already add clojure.jar to classpath
05:54vvshi found this guy got the same problem as me, but don't really understand how he solve it
05:54vvshhttp://forums.pragprog.com/forums/91/topics/3466
05:55vvshsorry, that's the error about jline
05:57Licenserokay the solution of 1.2 with the namespace overload is a nice idea but it isn't working
05:57Licenseryou can't reaload stuff since when you do it crashes with 'already pointing to'
05:57Licensermeaning you've one bug in your code and you#ve to restart your repl ...
05:57Licenserbah
06:00vvshis 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
06:10vvshLicenser: I'm new to clojure, just wondering in clojure how do i load somethine from classpath?
06:12Licenservvsh: well a clojure namespace or a java clasS?
06:12Licensernamespaces can be load with use or require, classes via import
06:13vvshjava 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 )
06:15Licenserwell (import java.ns.path.to.Jinline)
06:18vvshthanks, but still can't get the repl working, it really annoying now
06:32Licenservvsh: I can imagine, but I'm not sure what the problem is :(
06:33vvshyeah, it seems pretty odd, do you know where else can i ask for help?
06:36Licenservvsh: what editor do you use
06:36Licensera good idea would be emacs since you get a repl for free there
06:36Licensero
06:36Licenserr
06:36Licensertr
06:36Licensery
06:36Licenseryuck
06:36Licenseror try cljr repl
06:36vvshvi
06:36Licenserah there is also a vim clojure package that should be helpful
06:37vvshi tried cljr repl, but still get the same problem - can't find clojure.main
06:37vvshi thinking to learn some emacs, so will stay with emacs on this one
06:37vvshdoes the repl on emacs using jline or something else?
06:39Licensernope it uses swank and slime
06:39Licenserno jinline since it is EMAC's controlled (history and stuff)
06:39Licenseralso emacs makes a pretty good development env
06:39Licenserat least for clojure :P
06:39Licenserin my eyes currently the best
06:40vvshyeah, its pretty power
06:40vvshits more easier for lisp like languages
06:42vvshanother point is i can't use lein repl,(jline cause the same problem :(
06:43Licenseryuck
06:44vvshthat means i can't build any projects, which is a hugh thing
06:45hiredmanvvsh: where did you get your clojure jar?
06:45hiredmanis it 1.1 or a 1.2 snapshot or …
06:45vvshfrom github
06:46vvshits 1.1
06:46hiredmanhow do you know?
06:46vvshwhen i run - java -cp clojure.jar clojure.main, it print out version 1.1.
06:47hiredmanand what is the exception you get?
06:49vvshwhen i running with - java -cp jline-0.9.94.jar:clojure.jar jline.ConsoleRunner clojure.main
06:49vvshi got " Exception in thread "main" java.lang.ClassNotFoundException: clojure.main"
06:50hiredmanpastebin the whole thing somewhere
06:51Licensergood god :(
06:51vvshhttp://pastebin.com/vhzGDp6d
06:52hiredmanand does the clojure jar contain clojure/main.class
06:54vvshi 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
06:55Licenserweek a new version clj-sandbox is finally out :)
07:49bhenrywith ring, how might i serve up static files from a dynamically decided path (based on a "get" variable from the query string)?
07:50bhenryeg localhost:8080/?dir=/Users/myname/Pictures
07:50bhenryi'm able to get all the file objects, but the browser won't let me use file:///path coming from http://
09:18RaynesI just added support for defing stuff to sexpbot.
09:21mmarczykRaynes: cool! any limits?
09:21Raynesmmarczyk: 5 defs.
09:22mmarczykper person?
09:22mmarczykper form?
09:22Raynes5 defs at any given time.
09:22mmarczykoh.
09:22RaynesIt's not allocated per-person.
09:22mmarczykwhat then? the old ones get dropped?
09:22RaynesYeah.
09:22mmarczykcool :-)
09:23RaynesLicenser added stuff for this earlier in clj-sandbox.
09:23RaynesI just took advantage of it.
09:23RaynesGoing to see how it works out.
09:26mmarczyk$(defn fooey [] (reify clojure.lang.IKeywordLookup (getLookupThunk [this k] (reify clojure.lang.ILookupThunk (get [thunk target] (if (identical? (class this) (class target)) :foo))))))
09:26sexpbotjava.lang.NullPointerException
09:26mmarczykoh.
09:26mmarczyk$(def fooey (fn [] (reify clojure.lang.IKeywordLookup (getLookupThunk [this k] (reify clojure.lang.ILookupThunk (get [thunk target] (if (identical? (class this) (class target)) :foo)))))))
09:26sexpbotjava.lang.NullPointerException
09:31Licenser$(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)))))))
09:31sexpbot=> #'net.licenser.sandbox.box3471/<3
09:31Licenser$(<3 "Raynes" "sexpbot" "clj-sandbox" "clojure")
09:31sexpbot=> "I love Raynes, sexpbot, clj-sandbox and clojure."
09:32Licensermmarczyk: classes are often not allowed
09:32Licensersave for raynes allowing . for some reason in sexpbot, which is rather silly :P
09:32mmarczyk$(def ->--- (atom (<3 "Raynes" "sexpbot" "clj-sandbox" "Clojure")))
09:32sexpbot=> #'net.licenser.sandbox.box3471/->---
09:32mmarczyk$(do @->---)
09:32sexpbot=> "I love Raynes, sexpbot, clj-sandbox and Clojure."
09:33Licensermmarczyk: @->-... is my macro :P
09:33mmarczyk:-P
09:33Licenserthief!
09:33Licenserbut the defs are pretty cool I think
09:33mmarczykyup :-)
09:33LicenserRaynes: satisfied with the solution? :)
09:33mmarczykpity about reify, though
09:34mmarczykyou could do (def ->--- (reify clojure.lang.IDeref (deref [this] ...)))
09:34Licenserhmm 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
09:34mmarczykdo they?
09:35mmarczykI mean, on master?
09:35Licenserwell their inner workings might do yes so the border between save and unsafe is very scratchy
09:36LicenserI can't with a good concience whitelist something that might not stay save
09:36mmarczykah well
09:36mmarczykI take this to mean that you'll have no problem whitelisting that stuff after 1.2 comes out
09:36Licensernot at all
09:37mmarczykI mostly meant "no technical problem" by that :-)
09:37LicenserI hope not :P
09:37mmarczykcool
09:37mmarczyk:-)
09:37Licenserclj-sandbox does some pretty complicated things with the code, as in compleatly not using the . special form
09:37mmarczyk?
09:39Licenseryou can't use . in the code
09:40Licenserit will be removed, or rather replaced, that is why we can allow you to write . without risking you breaking the sandbox
09:41mmarczykwell, yes, I'd expect that
09:41LicenserI'm not entirely sure how reify and protocolls will play into this but I hope it will go smoothly
09:42mmarczykright.
09:45mmarczyk"You silly wabbit have 'Object' in a class matcher." :-)
09:48LicenserThat is a good Exception isn't it? I'm particular proud of that one!
09:49mmarczykas well you should be :-)
09:52LicenserI wonder about defn
09:52Licenser(def blah (.withMeta (clojure.core/fn blah ([x] x)) (.meta (var blah))))
09:52Licenser is what defn does, but when bla does not exist, before the def why would it try to get the meta?
09:53mmarczykLicenser: the way in which you jump at the opportunity to mock Raynes *in an exception message* is a particularly nice touch, I find :-P
09:53LicenserThat is because I love raynes
09:53mmarczykof course :-)
09:53Licenserafter all Raynes is the only one using clj-sandbox
09:54LicenserI soley develop it for him :P
09:55mmarczyk:-)
09:55mmarczykLicenser: about defn
09:55Licenseryes
09:55mmarczyk(.withMeta ...)
09:55mmarczykgets rewritten as
09:55mmarczyk(. (fn blah ...) withMeta ...)
09:56mmarczykno problem with that
09:56LicenserI know
09:56mmarczyk$(. (ArrayList.) toArray)
09:56sexpbotjava.lang.IllegalArgumentException: Unable to resolve classname: ArrayList
09:56Licenserwell no what I mean is it says this fn (object) has the meta of the var, but the ar does not exist
09:56mmarczyk$(. (java.util.ArrayList.) toArray)
09:56sexpbotjava.lang.SecurityException: Code did not pass sandbox guidelines: ()
09:56mmarczykah, but it does
09:56RaynesI love those useful error messages.
09:56mmarczyk$(def foo (meta #'foo))
09:56sexpbot=> #'net.licenser.sandbox.box3471/foo
09:57mmarczyk$(println foo)
09:57sexpbot=> {:ns #<Namespace net.licenser.sandbox.box3471>, :name foo} nil
09:57mmarczykdef creates the Var first, then does a .bindRoot, I think
09:57Licenserhmm I see
09:57Licensersneaky
09:57Licenserokay then it makes sense, but you've to understand the interna there
09:57mmarczykyou're not meant to care how defn works, you know :-P
09:58mmarczykunless you feel compelled to write a sandboxing lib for some reason ;-)
09:58LicenserYea silly me
09:59RaynesI'm happy he did.
09:59Licenserdid not kow how defn works? :P
09:59RaynesThat way when people whine and complain because sexpbot does something weird, I can say "hey, it's not my fault"
09:59Raynes:D
10:00mmarczykah, the perfect relationship
10:01Licenserhave fun!
10:01mmarczyk(just googled hotpockets)
10:01Licenseryea sad thing is just that in most plces it actually is sexpbot doing something wird
10:02mmarczykwhich 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:02Licenser*nods* If you could read german I would give you a link to an old article of mine :P
10:03mmarczykoh, please do
10:03mmarczykI can, somewhat
10:03Licenseroh then I
10:03Licenserv
10:03Licenser've to dig it out
10:03mmarczykwaiting patiently. :-)
10:04Licenserhttp://cycnus.de/index.php?frame=/fun/schuldspirale/funschuldspirale.htm
10:05mmarczykok, it'll take me a while though, I'm a slow reader when dealing with German text
10:07Licenser*nods* take your time
10:07mmarczyk:-D
10:07mmarczyklove this
10:08mmarczykI might translate this into Polish; I think I've already got an idea of whom to substitute for Simon, Sven &c. :-P
10:19stuarthallowayhugod: you around? I am getting started with pallet and am stymied at square one
10:25Licensermmarczyk: cool
10:43djpowellwhat's the deal with github.com/clojure?
10:47stuarthallowaydjpowell: what do you mean?
10:47djpowellhas clojure moved?
10:48stuarthallowayyes
10:48stuarthallowaynow that github has organization support
10:49stuarthallowayIf there are busted links somewhere let me know
10:49stuarthallowayI updated http://clojure.org/downloads
10:49djpowellah k. has this been well publicised, I'd never heard about it
10:49stuarthallowaycouple of posts to the mailing list, plus fixing pointers
10:49stuarthallowayhope to move the build box this weekend
10:50djpowellok
11:00clojayI 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:07djpowelldid you know that if you put a user.clj on the class path it gets loaded automatically?
11:08djpowellalso, if you run "java -jar clojure.jar --help" there are some startup flatgs for loading scripts
11:13djpowellstuarthalloway: hmm - clojure.java.shell is still broke
11:13stuarthallowaybroke how?
11:13djpowellin http://github.com/clojure/clojure/commit/31b6fb557a3c524c447d312f5c51b6262ffb9b0f you removed the pmap stuff
11:15stuarthallowayI see your point
11:16stuarthallowaythe pmap didn't work either, because it forced the same encoding on both streams, which is not how the API now works
11:16stuarthallowayso we need to get back the parallelism, but not with pmap
11:16clojaythank djpowell. Let me try that
11:17stuarthallowaydjpowell: hmm, put the two calls in futures?
11:18djpowelli didn't realise that stderr was going to use platform default encoding
11:18clojaydjpowell: I get the following error Don't know how to create ISeq from: clojure.lang.Symbol (user.clj:1
11:18stuarthallowaydjpowell: me neither, til recently
11:18djpowellstuarthalloway: but you could just put pmap back and sort the encodings
11:19djpowellor use pvalues or one of those functions
11:19hugodstuarthalloway: I am now, how are you getting on?
11:20stuarthallowaydjpowell: will add issue and do it before 1.2 goes final
11:20stuarthallowayhugod: it is quite strange
11:21stuarthallowaywhen I do the defnode from demo.clj, the VM exits, without warning or explanation
11:21djpowelloh and thanks for sorting the bug out in it, it must have creeped in when i added in-enc
11:22stuarthallowaytested defnode at the REPL, both plain and in emacs
11:22stuarthallowaydoes that make any sense at all?
11:22clojayMy ~/.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:23hugodstuarthalloway: that's strange - are you using a checkout or jar?
11:23stuarthallowaycheckout
11:23stuarthallowaylet me try the jar
11:23clojay(sorry the error should be java.lang.Exception: Unable to resolve symbol: my-pretty-print in this context)
11:24hugodstuarthalloway: the checkout should be fine - with lein or mvn?
11:24stuarthallowayI was using lein
11:25hugodI'm doing a fresh checkout to try and replicate....
11:28Licenserhmm lein refuses to download 1.2.0-SNAPSHOT for some reason o.O
11:28stuarthallowayhugod: found it!
11:28hugodstuarthalloway: ok - anything I need to fix?
11:28Licenseranyone had this happening to them yet?
11:28stuarthallowayno, it's a bug in the repl, or clojure itself!
11:28stuarthalloway,\"[^J]+9.10[^32]+\"
11:28clojurebot\"
11:29stuarthallowayI had copied from the clj file (with the slash escaping), and that constant crashes the replp
11:29stuarthalloway,(+ 1 2)
11:29clojurebot3
11:29stuarthallowaybut didn't seem to kill the clojurebut
11:30stuarthallowayI have such a gift for stumbling into weird bugs
11:30hugod$\"[^J]+9.10[^32]+\"
11:30sexpbotCommand not found. No entiendo lo que estás diciendo.
11:33djpowellstuarthalloway: (let [out err] (pvalues (stream-to-enc stdout out-enc) (stream-to-string stderr)) ...) seems to work
11:33stuarthallowaydjpowell: throw it into https://www.assembla.com/spaces/clojure/tickets/399-make-sure-shell-out-and-err-handled-in-parallel if you want
11:34Licenser$eval \"[^J]+9.10[^32]+\"
11:34sexpbot=> \"
11:34Licenser$eval 3
11:34sexpbot=> 3
11:34stuarthallowayor I will, after I solve the repl bug
11:34Licenser$eval (def x \"[^J]+9.10[^32]+\")
11:34sexpbotjava.lang.Exception: Unmatched delimiter: ]
11:34Licenser$eval 3
11:34sexpbot=> 3
11:34Licenser+c still working
11:38mmarczykLicenser: 1.2.0-SNAPSHOT of what? it's 1.2.0-master-SNAPSHOT for Clojure
11:39Licensermmarczyk: my problem was oddly enough the horrible error mesage of mvn not the jar names
11:39LicenserI had a wrong jar for something else, which then told me clojure is wrong - no clue why
11:39mmarczykah
11:39mmarczykthe error message imps played a game of dice to determine which jar would get blamed
11:41stuarthallowayhugod: weirder still: the bad constant is an error in clojure repl, but bombs the lein repl
11:41stuarthallowaylooks like a lein bug
11:41mmarczykstuarthalloway: \"[^J]+9.10[^32]+\" is not a valid constant anyway
11:41mmarczykwith the "s escaped
11:42stuarthallowaymmarczyk: agreed!
11:42stuarthallowaybut it kills the lein repl with no message
11:42mmarczykoh?
11:42mmarczykwhich Clojure version in project.clj?
11:43stuarthalloway1.2 master branch is what I have tested so far
11:43mmarczykjust checked with 1.1, same thing
11:43mmarczykwow :-)
11:43stuarthallowaymy best guess, looking at lein code, is that repl catches only Exception, not Throwable
11:44stuarthallowaybut just throwing throwable is ok... hmm...
11:44mmarczykI guess that the problem is that
11:44mmarczykat [^J
11:44mmarczykthe reader expects something to attach {:tag J} to
11:44mmarczykbut finds end-of-vector
11:45mmarczykshould be an exception rather than an error, no?
11:45stuarthallowaydunno
11:48stuarthallowaymmarczyk: any reader exception kills the lein repl, just try the two characters (]
11:48mmarczykouch, indeed
11:48stuarthallowaywill post a comment to technomancy
11:49clojay,(System/Exit 0)
11:49clojurebotjava.lang.IllegalArgumentException: No matching method: Exit
11:49clojayhehe
11:49stuarthallowayclojay: are you from C#-land?
11:49mmarczykclojay: it's exit, but won't work with the bots
11:50serp_,(reduce + '(1 2 3))
11:50clojurebot6
11:50clojaystuarthalloway: yes
11:50stuarthallowayyour capital methods are showing :-)
11:54clojaystuarthalloway: :) 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:54mmarczykadd-break-thread! doesn't seem to work with lein repl... same issue I guess
11:54stuarthallowayclojay -e "any clojure here"
11:55stuarthallowayincluding, of course, (load "stuff")
11:55stuarthallowayremember your command line escaping tho
12:01mmarczykclojay: you can use -i, but then you'll need to add an explicit -r to get the REPL to start
12:01clojaymmarczyk: stuart's method with -e worked, however I have a different problem now
12:02mmarczyk?
12:02clojaymmarczyk: what's wrong with this? (defn exit (do (System/exit 0)))
12:03mmarczykclojay: you're missing an argument vector
12:03anonymouse89what would be an idiomatic way to block until a boolean changes?
12:03mmarczyk(defn exit [] (System/exit 0))
12:03mmarczyknote the do is superfluous
12:03clojay(defn exit [] (System/exit 0))
12:04clojayoh good
12:04mmarczykfunction bodies are implicitly wrapped in do
12:04clojaysame as yours
12:04clojaymmarczyk: great, thanks
12:04mmarczyknp
12:06clojaysometimes 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:07mmarczykanonymouse89: 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:07anonymouse89More specifically, I want to block until (every? true? (vector-of-things :complete)) is true
12:07anonymouse89like the equivalent of await but I'm not using agents
12:08anonymouse89oh, or I could wrap every element of the vector with an agent?
12:08mmarczyk(vector-of-things :complete) ?
12:08mmarczykthat you could
12:09anonymouse89I mean the things in vec-of-things have a keyword :complete that should be true before continuing
12:09mmarczykclojay: well, if you need parens but skip them, your code will break
12:09clojaymmarczyk: with trial and error I will learn I guess :)
12:10mmarczykclojay: 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:10mmarczyktrue enough :-)
12:10mmarczykanonymouse89: so it's more like (every? (comp true? :complete) vector-of-things)? what are the things?
12:11mmarczykI mean, if they can actually *change*, they're something mutable -- what exactly?
12:11anonymouse89they are dispatched computations. so an item is returned immediately, but (item :value) is nil until actually complete
12:11anonymouse89and (item :complete) is false until complete
12:12clojaythat'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:12anonymouse89so I'm just trying to wait for all those to become complete before continuing
12:12mmarczykdispatched to what and how?
12:12mmarczykI mean, say, for futures
12:12mmarczykyou can just use @ in place of await
12:12mmarczyksame for promises
12:13anonymouse89deref's block?
12:13mmarczykfor other kinds of "dispatched / delayed / etc." stuff, there might be other methods
12:13mmarczykanonymouse89: depends what you deref
12:13mmarczykanonymouse89: on Atoms, Refs, Agents, Vars they don't block
12:13mmarczykanonymouse89: on Futures they do
12:13anonymouse89mmarczyk: good to know
12:14mmarczykanonymouse89: on Promises they do in the sense they'll block 'til sth gets delivered
12:14mmarczykclojay: right :-)
12:15anonymouse89mmarczyk: 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:15anonymouse89or just loop and sleep?
12:15mmarczykanonymouse89: sure, you can use a (while ...) block
12:16mmarczykloop/recur is fine, but you'd have no loop bindings, so while is cleaner
12:16anonymouse89so like: (while not every? true? (vec-of-bools))
12:16mmarczyk((while ~@body) = (loop [] ~@body (recur)))
12:16mmarczyk(while (not (every? true? (vec-of-bools))) (Thread/sleep 100))
12:17anonymouse89right, I think that's what I'm looking for
12:17anonymouse89mmarczyk: thanks
12:17mmarczykpresumably you'd use this as the first form in a do (possibly implicit)
12:17anonymouse89mmarczyk: I'm not sure what implicit means there
12:17mmarczykanonymouse89: cool, though for special cases where something like a blocking deref is available, the special way to do it might be better / cleaner
12:18mmarczykanonymouse89: I meant "possibly an implicit do"
12:18mmarczykas in let, fn etc.
12:18mmarczykah, that definition of while above is wrong of course
12:19mmarczykmisses the condition... nvm
12:19mmarczykthe example with (not (every? ...)) will work, though
13:03fyuryummarczyk: just looked at your default-map gist and I'm wondering if there's any reason for putting (reify ..) inside getLookupThunk. Unless I
13:04fyuryummarczyk:* Unless I'm missing something
13:24mmarczykfyuryu: getLookupThunk needs to return an ILookupThunk
13:30fyuryummarczyk: doh!
13:30mmarczyk:-)
13:30fyuryummarczyk: it must be because of the heat
13:32mmarczykoh, the heat... it's been thirty-ish (on the Celsius scale) here today and it seriously interferes with my present coding effort :-(
13:33qbgNo AC?
13:33fyuryusame over here...
13:34mmarczykno ac.
13:35mmarczykI'd be perfectly happy with a fan, but alas, I can't see going to get one now *sigh*
13:50AWizzArdmmarczyk: 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:50AWizzArdFor people who don’t know what these Celsius numbers mean, use Clojure: http://clojure.org/jvm_hosted :-)
13:51mmarczyk57.5!? totally crazy
13:51AWizzArdYes, in the direct sun.
13:52AWizzArdAnd my thermometer is very accurate. Now just 42 :-)
13:52RaynesOr use sexpbot. $#tc C57#$
13:52mmarczykmuch better ;-)
13:52sexpbotRaynes: 134.60000000000002
13:52mmarczykwhoa, that's one comprehensive plugin collection :-)
13:52Raynes:p
13:52qbgPics or it didn't happen
13:53AWizzArdqbg: okay, next time
13:53qbg:)
13:53mmarczykthe worst thing here is that the sun is shining straight into this room's window
13:54mmarczykand I'm missing some essential equipment now, like a working wi-fi router
13:54mmarczykor an ethernet cable
13:54mmarczykeither would suffice for me to be able to go to the next room where it's perfectly cool :-P
13:55AWizzArdmmarczyk: buy some aluminium foil, that is the same stuff mirrors are made with, and put them from the outside on your window.
13:55mmarczykwhenever I go shopping for the aforementioned equipment (tomorrow?), I guess I'll also by something reflective to put over...
13:55mmarczykAWizzArd: right, exactly :-)
13:55AWizzArdI wished Oracle would bring out a weather API, so I could use Clojure to solve such heat challenges.
13:56mmarczykI was thinking about buying some bricks and getting rid of the window once and for all :-P
13:56mmarczykbut I think that might be problematic in some ways, so I'll make do with the foil.
13:57mmarczykWindow.attach(new AluminiumFoil(2.0, 0.75, Units/METER)) ?
13:59LauJensenWe had 43.5 in the sun today, just after noon
14:00LauJensen32 in the shade
14:00AWizzArdWell, 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:01HodappAWizzArd: wait, so I should have my tinfoil hat actually be an aluminum foil hat?
14:02AWizzArd Hodapp: you are learning fast!
14:04AWizzArdBtw, is there an ETA when build.clojure.org will spit out new jars? (:
14:06mmarczykStu H. mentioned a plan to let the build box know about github.com/clojure this weekend
14:06mmarczyk$(def fibs (concat [0 1] (map + fibs (rest fibs))))
14:06sexpbotjava.lang.IllegalStateException: Var net.licenser.sandbox.box3471/fibs is unbound.
14:07mmarczyk$(def fibs (lazy-cat [0 1] (map + fibs (rest fibs))))
14:07sexpbot=> #'net.licenser.sandbox.box3471/fibs
14:07mmarczyk$(nth fibs 10000000000)
14:07sexpbotjava.lang.Exception: EvalReader not allowed when *read-eval* is false.
14:07mmarczykhuh...?
14:07mmarczyk$(first fibs)
14:07sexpbot=> 0
14:07AWizzArdRaynes: 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:08mmarczyk$(nth fibs 1000000)
14:08RaynesI added that ages ago.
14:08AWizzArdk
14:08RaynesI'm not that fast. :p
14:08sexpbotExecution Timed Out!
14:09AWizzArdmmarczyk: killing bots huhm?
14:09mmarczyk:-)
14:10mmarczykhm, incidentally
14:10mmarczyk$(make-array Double/TYPE 100)
14:10sexpbot=> #<double[] [D@460a87a8>
14:11mmarczykI wonder if I could get in trouble by asking for a particularly large array
14:12mmarczykperhaps just short of OutOfMemoryError... followed by an allocation-intensive op
14:13AWizzArdmmarczyk: try locally (in your Clojure) to ask for a 10 Terabyte Array
14:14mmarczykI have, got OOME
14:14mmarczykand a new prompt :-)
14:17mmarczykpresumably asking the bot to create -- and keep around -- an array which would *just* fit on the heap
14:17mmarczykwould result in OOMEs for subsequent regular ops
14:18mmarczykhow does one check the size of an object in Java?
14:18AWizzArdmmarczyk: what do you mean by that?
14:20mmarczykwell, there's (-> (Runtime/getRuntime) .totalMemory) for total memory available
14:20mmarczykas well as .freeMemory for free memory
14:20AWizzArdYes, you can work with the three Runtime methods.
14:20mmarczykI'm wondering about something similar to ask about a given objects size on the heap.
14:20mmarczyk^object's
14:20AWizzArdBut also have a look at http://download.oracle.com/docs/cd/E17409_01/javase/6/docs/api/java/lang/management/package-summary.html
14:20chouserit's difficult, but close estimates can be found
14:21AWizzArdThey offer a MemoryUsage class
14:21mmarczykhm, interesting, thanks
14:21mmarczykI found this: http://www.javapractices.com/topic/TopicAction.do?Id=83
14:22AWizzArdhttp://download.oracle.com/docs/cd/E17409_01/javase/6/docs/api/java/lang/management/MemoryUsage.html
14:22mmarczykestimates 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:23mmarczykwhich is not at all what I want, but still fun
14:23Bahmanmmarczyk: AFAIK you have to measure memory before and after creating the object and the usage it's their difference.
14:24BahmanAnd don't forget to call GC before measuring.
14:25AWizzArd(dotimes [i 5] (System/gc))
14:27AWizzArdmmarczyk: look into your priv pls
14:34arohnerwhile we're on the subject, is there a way to get the size of a single object?
14:39stuartsierraaorhner: define "size"
14:40AWizzArdarohner: most of the time it is just 8-byte pointers on 64-bit systems
14:40AWizzArdshould one follow the pointers?
14:40arohnerI want the total memory usage for a tree of clojure maps
14:40AWizzArdHow big are circular objects?
14:40stuartsierraarohner: you need a Java profiler or debugger
14:41arohnerlet me put it another way. If the only reference to this clojure map went away, how much memory would be GC'd
14:41arohnerstuartsierra: yeah, visualVM is incredibly slow on this datastructure (~1.5GB)
14:41arohnerand cumbersome to use
14:42stuartsierraarohner: 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:42arohnersigh
14:43arohnerI wrote a little fn that uses clojure.walk to call (class) on every object, and returns a summary of instance counts
14:43arohnerthat takes ~3 seconds to walk 1.5GB. I just want to convert that into bytes per object
14:44AWizzArdarohner: it is not really clear what this means, there are multiple ways to look at it.
14:45stuartsierrawell, figure out how many bytes the instance fields take up, add X bytes for every Java pointer (look that up)
14:45AWizzArdYou 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:45arohnerAWizzArd: I know. I'm just annoyed that the tools suck. This should be a trivial thing to report
14:47stuartsierraThe JVM goes to great lengths to abstract away memory usage.
14:48arohnerstuartsierra: which is broken, IMO. Until it can abstract away physical memory usage, you need to know that sometimes
14:48stuartsierraagreed
14:48AWizzArdarohner: in principle you are right, but it really is not such a trivial thing
14:49arohnerAWizzArd: sure it is. there are two main operations I care about.
14:49arohner1) 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:50arohner2) how much memory would be free'd if the object were GC'd
14:50arohnerobviously 1) is O(1), and 2) requires walking the object graph. I'm ok with #2 taking significantly more time
14:51arohnerbut 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:52arohnerand actually, I'm ok with #2 being done destructively
14:52arohneri.e. actually GC the object, and return the number of bytes GC'd
15:00roblallyAs 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:01roblallyI say rarely because I'm not sure, but I suspect 'never' to be the case.
15:02stuarthallowayhugod (or other palleters): how do I configure an SshModule?
15:04hugodstuarthalloway: how have you connected to the provider? (org.jclouds.compute/compute-service ... ?)
15:05stuarthallowayusing basically the same settings cemerick's blog post
15:05stuarthallowaypassed :ssh flag at end of call to compute-service
15:05stuarthallowaydo I also need to pass (ssh) under :configure?
15:06hugodthe :ssh in compute-service should suffice
15:07stuarthallowayI am running from my own project -- could I be missing a jar?
15:07stuarthallowayI notice that pallet itself has various jars as dev dependencies
15:07stuarthallowayso I made the ones I thought I needed into regular dependencies in my own project
15:07mmarczykarohner: that's what I'd like to do too... to learn the size of a single object on the heap
15:08stuarthallowaye.g. I added org.jclouds/jclouds-aws
15:08hugodstuarthalloway: the ssh jar is a direct dependency of pallet - so should be picked up
15:08mmarczykit would be absolutely fantastic if, given a class, I could tell how much memory I'd need to instantiate it...
15:09hugodyou'll need the jar for the provider you are using , so adding jclouds-aws is correct for ec2
15:09stuarthallowayhugod, 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:10hugodstuarthalloway: if you are using 0.1, please switch to 0.1.1
15:10stuarthallowayhugod: back atcha! pallet seems to be using 0.1 :-)
15:14hugodstuarthalloway: 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:14stuarthallowayah, I am on edge anyway
15:21hugodstuarthalloway: so what are you trying? I assume you have an exception asking you to configure an SshModule?
15:21stuarthallowayyes
15:21stuarthallowayI am about to create a gist so you can see it exactly
15:23stuarthallowayah cool, now that I am running at the pallet repl I get tons of stdout info that I wasn't seeing before
15:23stuarthallowaywonder what sucks that stuff up when using it from another project...
15:24hugodyou'll need a logging configuration file
15:24stuarthallowayah, that's it, I already have one
15:24stuarthallowaynow I am getting a mix of the error I saw before, plus com.jcraft.jsch.JSchException: Auth fail
15:25hugodby 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:26stuarthallowayI am on OSX
15:26stuarthallowayhttp://gist.github.com/470955
15:28stuarthallowayis part of my problem that a new key pair keeps getting generated each time?
15:29stuarthallowayI now have a slew of keypairs with names like jclouds#praxis-NN
15:29stuarthallowaywhich would make me think that converge would fail on existing instances that use the keypair from the previous round
15:30stuarthallowayand you are right, it is wanting a passphrase -- I can see it in the log
15:33hugodit should ask for access to your keychain - assuming you use the osx keychain
15:34stuarthallowayhugod -- thanks -- the issue is definitely now local to me :-/
15:34stuarthallowayshould I expect to see a new keypair in EC2 every time I run the code?
15:40hugodstuarthalloway: which keypair are you refering to?
15:40stuarthallowayevery time I run the pallet script, it seems to create a new keypair on ec2
15:41stuarthallowaywith a name like jclouds#praxis-NN
15:41stuarthallowayor maybe it is just every time I have changed the definition of the server, since I was playing around with that
15:42stuarthallowayhugod: I found the missing jar
15:42hugodstuarthalloway: I'll ask adriancole_ over on #jclouds - I don't use ec2 myself...
15:43stuarthallowayfor some reason lein deps isn't picking up the jsch jar file, even though I am depending on pallet
15:43hugodthat's strange - it's a dependency for clj-ssh
15:44stuarthallowaystrange indeed, wonder if that's my second lein bug of the day, or maven, or just me
15:44hugodmvn dependency:tree should list jsch unless there is a maven issur
15:48rmarianskip /go evilhackerdude
15:48rmarianskierr, sorry
15:50stuarthallowayhugod: org.jclouds/jclouds-jsch is listed as optional in the pallet pom.xml
15:51stuarthalloway... which makes the dependency non-transitive. Consumers of pallet as a library will thus need to redeclare a dependency. By design?
15:55hugodstuarthalloway: oversight. thanks for catching this, ditto jclouds-log4j and jclouds-enterprise
15:55stuarthallowayhugod: no problem, sorry I am so dumb that it took so much of your time
15:58hugodstuarthalloway: and apologies that it so much of yours to track it down - jar soup is enough to confuse any of us
15:58hugodstuarthalloway: any particular plans for pallet?
15:59stuarthallowayhugod: we are (at present) big into chef
15:59stuarthallowayI would like to see more parens in my cloud admin
16:00stuarthallowaycurrently just messing around, using it as a stable reference platform for testing different libraries we might use on client projects
16:01hugodok, I would appreciate your feedback once you have spent some time with pallet
16:01stuarthallowayhugod: you bet!
16:54technomancyoh sweet, the CLI launcher ticket has been scheduled for the release after 1.2
16:54technomancybetter late than never
16:58stuarthallowaytechnomancy: did you see the bug I filed on lein
16:58stuarthallowayI would fix it if I knew the right thing to do
16:58technomancystuarthalloway: yeah, actually looking into it right now
16:58stuarthallowayawesome, thanks!
16:58technomancystuarthalloway: it's because the reader doesn't know how to distinguish between ^D characters and malformed input
16:59stuarthallowaythe regular clojure repl does the right thing somehow
16:59mudgewhat does "No matching ctor found" mean?
16:59mudgewhat the heck is a "ctor" ?
16:59qbgConstructor
17:00RaynesCouldn't have that cljr project theoretically have been a Leiningen plugin? If there were global plugins, that is.
17:00mudgeqbg: ohhh
17:00mudgethanks
17:00mudgei thought it was short for some type of dinosaur, boy was I way off
17:01technomancyRaynes: yeah, I was planning on implenting cljr-like functionality once I had global plugins working
17:01technomancystuarthalloway: yeah, probably just means I can't use a bare (read) call
17:01RaynesI have a couple of ideas for plugins myself once global plugins work.
17:02technomancystuarthalloway: I can't use the regular repl because ant's subprocess launcher is totally busted for anything that uses stdin
17:02stuarthallowaydoh!
17:02technomancystuarthalloway: it's very convoluted as a result =\
17:02mudgestuarthalloway: I'm reading your book. Learning a lot.
17:03stuarthallowaymudge: cool. I had a question yesterday and somebody pointed my to the book :-)
17:03mudgehaha
17:07arohnerwhat's a global plugin?
17:08technomancyarohner: "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:08technomancyplanned for lein 1.3
17:09arohnertechnomancy: cool
17:30pietiadoes clojure is good to writting crawlers/scrapers? are there any good tools for clojure to parse html?
17:31stuarthallowayenlive
17:33pietiahow about the performance ?
17:34pietiain comparison to jruby + mechanize / nokogiri
17:46hiredmanhtmlunit is pretty nice for scraping/crawling
17:46hiredmanwalking through forms and pushing buttons and walking through the response
17:47hiredmanit's a java library, but very arrowy if I recall
17:48technomancyMenTaLguY: hey, how's it going?
17:49MenTaLguYgoes okay
17:49MenTaLguYfinally doing some clojure hacking again
17:49technomancycools
17:49MenTaLguYwish 'lein test' didn't take so long to start/warm up, but that's not your fault
17:50technomancyMenTaLguY: are you able to use a client JVM?
17:50MenTaLguYyes -- isn't that the default? versus -server?
17:50technomancyMenTaLguY: well... sort of. it's not always available.
17:50bultersg'day all
17:50technomancy"lein version" will tell you what it's using
17:51technomancyMenTaLguY: on 64-bit machines you have to get a special JDK to get the client JVM
17:51technomancyon ubuntu it's ia32-sun-java6-bin
17:51MenTaLguYLeiningen 1.1.0 on Java 1.6.0_18 OpenJDK Client VM
17:52technomancycool
17:52technomancyyou can also avoid the startup penalties by re-running the tests in an already-running repl or swank session
17:52technomancycourse 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:53MenTaLguYI guess what I really want is something like nailgun
17:53MenTaLguYwell, no
17:53MenTaLguYwhat I really want is a JVM that starts instantly
17:53technomancyare you a vim guy?
17:53MenTaLguYand a pony
17:53MenTaLguYyes
17:53technomancyit integrates with nailgun
17:53technomancyheh
17:54technomancyyou 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:08AWizzArdFast 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:10technomancyAWizzArd: it just launches a swank server
18:10technomancyit's not really a classic repl
18:10technomancybut it's foregrounded
18:10technomancybtw, any Japanese speakers care to translate this? もうLeiningen使えば無理にIDE使わなくても良いよなぁ。っということでNetbeans周りのToDoは優先度下げた
18:12AWizzArdtechnomancy: so, is it comparable with an Ant <java> task with fork="true" and spawn="false"?
18:12technomancyI'm not sure what spawn means, but it is a java task that forks
18:14AWizzArdtechnomancy: 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:14MenTaLguYhm, so is there a library function similar to (fn [m k f] (assoc m k (f (m k)))) ?
18:15technomancy,(doc update-in)
18:15clojurebot"([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:15technomancyI think that's what you want.
18:17AWizzArdtechnomancy: 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:18AWizzArdi.e. the first M-x f will default me to ~/ for example
18:18technomancyAWizzArd: I think just (setq default-directory "~") in your dotfiles
18:19technomancynot sure what M-x f means though
18:19AWizzArduh, C-x f
18:19AWizzArdOr, C-x C-f
18:20AWizzArdokay fine, thanks
18:20AWizzArdAnd 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:21AWizzArdIs there a way to have it open a buffer with my file, not using the suggestion?
18:24technomancyAWizzArd: yeah, C-f will disable ido-mode temporarily if you hit it while you're choosing a file or buffer
18:25AWizzArdgreat, thx
18:25AWizzArdagain :)
18:25technomancyI should put that in the readme; it's quite a faq
18:27technomancynot all that much is specific to ESK
18:27technomancyit just brings together a bunch of previously-disparate usefulness
18:27technomancyeven package.el is now included in Emacs
18:28AWizzArdIn my version too? “GNU Emacs 23.2.1 (i386-mingw-nt6.0.6002) of 2010-05-08”
18:30technomancyno, it's only in trunk right now.
18:30technomancyand it's kind of a busted version.
18:30technomancyworking on fixing that right now, actually.
18:31technomancyman... lein's uberjar function really is a mess.
18:32AWizzArdwhy?
18:32clojurebotwhy not?
18:33technomancywhy's package.el busted, or why is uberjar a mess?
18:34AWizzArdüberjar
18:34AWizzArdDoesn’t it create überjars? ;)
18:34technomancyI can't figure it out, but most of the messiness centers around a file called META-INF/plexus/components.xml
18:34technomancywhich smells like working around maven funkiness
18:35technomancyunfortunately this was all written by _ato, who has disapperaed. =P
18:36AWizzArdoh
19:26thunkDoes anyone tell me the idiomatic way to serve static files in compojure?
19:26thunks/Does/Can/
19:26sexpbotCan anyone tell me the idiomatic way to serve static files in compojure?
19:27AWizzArdthunk: your Handler can just return the file
19:27AWizzArdi.e. (File. "/the/file/you/want/to/serve.txt")
19:28thunkAWizzArd: Hrm. What's a project's default root directory?
19:28thunke.g. I'm striking out with (GET "/foo.css" [] (route/files "foo.css"))
19:28thunkwith foo.css in ./public
19:29thunkAWizzArd: Ahh, gotcha.
19:34thunkAWizzArd: Thanks, that did the trick.
19:36AWizzArdthunk: you can also add a GET handler accepting *
19:36AWizzArdand 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:37AWizzArdjust be aware that a user could move around on the server, if your handler is not careful.
19:37AWizzArdAnyone 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:43robinkThis may be a Java question, but calling ".split" on a string returns a Java string, not a vector of strings.
19:44robinkI'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:44AWizzArd,(doc clojure.contrib.string.split)
19:44clojurebotjava.lang.ClassNotFoundException: clojure.contrib.string.split
19:44AWizzArd,(doc clojure.contrib.string/split)
19:44clojurebot"([re s] [re limit s]); Splits string on a regular expression. Optional argument limit is the maximum number of splits."
19:44robinkThanks
19:45AWizzArdrobink: but btw, String’s .split method does not return a String.
19:45robinkAWizzArd: The REPL suggests that it does
19:45AWizzArdIt returns an array of Strings and you should have no problems using it.
19:45robinkHm
19:46AWizzArdThe String class does not have a .split method returning a String. Only returning String[]
19:46robinkOh, OK
19:46AWizzArdrobink: can you please paste the .split expression that you used, and the string it returned?
19:47robinkAWizzArd: The actual string?
19:47robinkAWizzArd: I get a reference to a String[]
19:47AWizzArdI mean your usecase: (.split "a b c" " ") ==> "a"
19:47AWizzArdSomething like that is what you got
19:48robinkI didn't get "a"
19:48robinkI just got the reference
19:48AWizzArdwell, you got a string
19:48robinkYeah
19:48robinkOK
19:48AWizzArdcan you show that example please?
19:48AWizzArdI would like to try it myself
19:48robink(.split "test.string" ".")
19:48robinkreturns #<String[] [Ljava.lang.String;@177ba38f>
19:48AWizzArdso, now it works correctly?
19:49robinkNot sure how to deal with a string array but that's what I initially got.
19:49AWizzArdaah, ok
19:49robinkI'm sure it's correct behavior, but I was assuming Clojure would wrap the type.
19:49AWizzArdwell, you can use map/reduce/filter/doseq on String arrays
19:49robinkOh, OK
19:50AWizzArd,(map count (.split "a b c d e" " "))
19:50clojurebot(1 1 1 1 1)
19:51robinkOK, but what I'd like is ("a" "b" "c" "d" "e") or ["a" "b" "c" "d" "e"]
19:52AWizzArdwhy?
19:52clojurebotwhy not?
19:52gregh,(map identity (.split "a b c d e" " "))
19:52clojurebot("a" "b" "c" "d" "e")
19:52robinkOh, OK
19:53AWizzArdor (vec (.split s1 s2))
19:53AWizzArdBut still, why do you want that?
19:53robinkAWizzArd: because I'm getting back a Clojure data type.
19:55AWizzArdI don’t understand why that is needed. Typically the result will be used in a form that iterates over the returned values anyway.
20:54hugodAWizzArd: C-j will use whatever you have typed in ido-mode
21:43AWizzArdhugod: thx
22:22defnhttp://aperiodic.net/phil/scala/s-99/ cool way to learn clojure...