#clojure logs

2010-11-27

00:00clojurebotCool story bro.
00:00_mstbeauty :)
01:23notsonerdysunnyis there a way to get the name of the struct which was used to create it from the instance
01:23notsonerdysunnyusing the class function just says it is a struct-map
01:24leifwjust a guess, but what does the meta-map have?
01:25leifwor, if it doesn't help, can you change the way you create the struct, to add the name to the metadata for your struct?
01:25leifwI am picturing you want to print out the name for debugging, or something like that
01:41hippiehunterdoes anyone have any blog posts/tutorials that discuss how named parameters work(I don't think they're called that in clojure but I hope you get the idea).
01:42Rayneshippiehunter: Do you want a detailed explanation about how they're implemented, or do you just want to know how to use them?
01:42hippiehunterIf by implemented you mean how i would go about making functions that take named parameters, then i mean implemented
01:43RaynesThe latter, then. http://stackoverflow.com/questions/3337888/clojure-named-arguments/3337967#3337967 I wrote this answer to a similar question. It should be helpful.
01:44RaynesThere is a blog post 'round here somewhere.
01:44hippiehunterawsome, thanks
01:45Raynes&(let [{:keys [a b]} {:a 1 :b 1}] (+ a b)) ; It's just map destructuring.
01:45sexpbot⟹ 2
01:46Raynes&(let [{n :a n2 :b} {:a 1 :b 2}] (+ n n2)) ; This is another, longer form of the above. It's useful if you need to destructure deeply nested structures.
01:46sexpbot⟹ 3
01:47Raynes&(let [{{a :a b :b} :numbers} {:numbers {:a 1 :b 1}}] (+ a b)) ; like so
01:47sexpbot⟹ 2
01:47hippiehunterwhats the deal with :or
01:48RaynesIt's a way to provide defaults for keys that aren't provided.
01:48Raynes&(let [{:keys [a b] :or {a 1}} {:b 1}] (+ a b))
01:48sexpbot⟹ 2
01:49hippiehunterdid you mean {a 1} or {:a 1} ?
01:49Raynes{a 1}
01:50RaynesIt's saying "... or, if a is not present, it should be bound to the number 1"
01:50hippiehunterI think the simplicity of it all is blowing my mind
01:51Raynes:)
01:53hippiehunterwhats the & doing in front of the (let ?
01:53RaynesThat just tells sexpbot to evaluate the code.
01:53Raynes& (println "blah")
01:53sexpbot⟹ blah nil
02:11mroesslerI'm trying to call a nested joda class: DateTime lastDayOfMonth = dt.dayOfMonth().withMaximumValue(); I'm using (.dayofMonth$withMaximumValue mydatetime) and getting "no matching field found". Direct calls such as .getMaximumValue do work.
02:13replacamroessler: you're just calling a method on a result. Do this (.withMaximumValue (.dayOfMonth dt)).
02:14mroesslerreplaca: Many thanks!
02:15replacamroessler: Or you can get fancy and say (-> dt .dayOfMonth .withMaxumumValue)
02:15replacamroessler: np
04:34trybeingarun2/c
10:50kaiserhi, guys
10:50kaiseris there any way to get the returning value of the time function?
10:51Guest43529i mean, the time elapsed...it's returning nil
10:51Guest43529when i try to get the returning value
10:52LauJensen&(with-out-str (time (Thread/sleep 200)))
10:52sexpbot⟹ "\"Elapsed time: 203.868 msecs\"\n"
10:54LauJensenGuest43529:
10:54Guest43529well, this way i'll have to parse the string...isn't there any nicier way?
10:54LauJensen&(first (re-find #"(\d+\.\d+)" (with-out-str (time (Thread/sleep 200)))))
10:54sexpbot⟹ "202.716"
10:54LauJensen~source time
10:54LauJensenGuest43529: its quite easy to implement yourself
10:56Guest43529thanks, LauJensen, anyway
10:56Guest43529http://tinyurl.com/2dywtf7
10:56Guest43529sorry, wrong pasting..
13:02Guest28709,(pr "huh")
13:02clojurebot"huh"
13:05serp__,(do (pr "hurr") (pr "durr"))
13:05clojurebot"hurr""durr"
13:06serp__,(do (pr "hurr") (pr "durr") :herp)
13:06clojurebot"hurr""durr"
13:06clojurebot:herp
13:17Guest28709has anybody used aleph?
13:43Raynes$seen LauJensen
13:43sexpbotLauJensen was last seen quitting 4 minutes and 28 seconds ago.
14:57Guest28709anybody know why using content-type of "application/json" fails in aleph?
14:57Guest28709I'm confused as to why it's even processing the headers
15:08headlessClownIs there a central source for any recorded presentations from the con?
15:10stuartsierraeventually there will be
15:10stuartsierraAt http://clojure.blip.tv/
15:10replacaheadlessClown: last I heard, those were still being prepared. I'm sure there will be an announcement in the group when they're ready
15:10Rayness_s
15:11RaynesI'm going to be on one of those.
15:11RaynesDamn you, Aaron Bedra.
15:11stuartsierradon't sweat it
15:11replacaRaynes: time for your 15seconds of fame!
15:11Raynes:p
15:27danlarkinclojurebot!!!111111
15:32replacadanlarkin: it's checkins that are making it do that. Rich just checked something into clojure master
15:32danlarkinwhere's hiredman when you need him
15:32replacahe hasn't been around this weekend
15:33replacathe nerve! :)
15:33danlarkininconceivable!!!
15:51danlarkinsuperburn
15:54RaynesGithub's post-receive hooks are lovely.
16:13replacaRaynes: where did it report?
16:14Raynesreplaca: sexpbot? It doesn't report Clojure commits. It uses the post-receive hooks from Github, so if somebody wanted sexpbot commit reporting, they'd have to add my URL to their hooks in the admin section of their repository's page.
16:14RaynesNever bothered offering since clojurebot already seems to have that covered. Or, will, in any case.
16:16Raynes$max
16:16sexpbotThe most users ever in #clojure is 317
16:18kumarshantanuwhy can't I write something like this? (is it reader associated?) -- (let [x ['a 10]] (let x (println a)))
16:18replacaRaynes: ah, ok
16:19replacaRaynes: clojurebot does it by polling, so it lags
16:21Raynesreplaca: https://gist.github.com/718283 Is an example.
16:21Raynesninjudd and friends uses it in #cake.clj
16:24neotykkumarshantanu: what are you trying to do?
16:24RaynesIt looks better when pieces of it are in bold, but bold from IRC doesn't copy to gist. :p
16:24kumarshantanuneotyk: trying to bind multiple vars to some values
16:25kumarshantanuneotyk: but the number can be variable, depending on the call
16:26neotykkumarshantanu: I don't get second let, why?
16:26kumarshantanuneotyk: I want the inner let to be expanded like this -- (let [a 10] (println a))
16:26RaynesYou can't do that without a macro.
16:27kumarshantanuRaynes: how can I do this inside a macro?
16:27RaynesActually, I'm not sure you can even do that in a macro. Why do you want to do this?
16:28kumarshantanuRaynes: I am trying to bind either or both of *out* and *err* to some values depending on the call
16:31Rayneshttps://gist.github.com/718293 Here is an example.
16:32RaynesThat'll only work if you pass a vector literal.
16:32RaynesI highly doubt this is really what you want to do. It seems odd.
16:36kumarshantanuRaynes: got it...in fact I am trying to refactor this function -- http://pastebin.com/N6GZjnUJ
16:37kumarshantanus/function/macro/
16:37sexpbot<kumarshantanu> Raynes: got it...in fact I am trying to refactor this macro -- http://pastebin.com/N6GZjnUJ
16:43Rayneskumarshantanu: You can use str rather than .toString, and the (do ..) around ~@body shouldn't be necessary.
16:44kumarshantanuRaynes: right
17:18jjidohow do I (use) a Java class that was not compiled part of a package?
17:20replacaRaynes: looks nice
17:23replacajjido: I don't understand your question. In general for a class, you use (ns (:import classname)) and make sure that it's on your classpath
17:24technomancyjjido: in some circumtances, java classes that are not part of any package simply can't be used.
17:24technomancynot sure of the details, but it's probably a sign you're trying to do something you shouldn't.
17:25jjido,(doc ns)
17:25clojurebot"([name docstring? attr-map? references*]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use...
17:26replacajjido: http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/ns
17:26dnolenhmm how do you get deftype/record to convert properly when str is called on them ?
17:27replacadnolen: define toString?
17:35kumarshantanubye all
17:35LauJensendnolen: I actually showed that in one my recent tumblr posts, so thats what you get for not keeping up :)
17:35dnolenheh
17:37dnolenLauJensen: link?
17:37LauJensendnolen: http://offtopic.bestinclass.dk
17:37dnolenLauJensen: thx
17:37LauJensennp
17:38RaynesLauJensen: Did you consider posterous?
17:38LauJensenRaynes: no
17:43jjidoSo, I recompiled with a package name.
17:43mheldhey y'all
17:44LauJensenmheld: hey all ya'll
17:45mhelddoes the .net version of clojure use TCO?
17:46jjidodo I need some prefix if the package is not 'java....'?
17:48woobymheld: no
17:48mheldbummer
17:48bsteubermheld: so use recur
17:48mheldI'll check it out
17:49mheldare there any cloqure web frameworks?
17:49clojurebotwebjure is http://code.google.com/p/webjure/
17:49mheldoh neat
17:52Raynesmheld: Compojure, Moustache, Webjure, Conjure, and probably others I'm not thinking of.
17:52RaynesThe first too are the most popular.
17:52Raynestwo*
17:52KirinDaveFor those who are into REST apis, Clothesline is in clojars now http://clojars.org/clothesline
17:53mheldRaynes: gracias
17:53mheldemacs or eclipse?
17:54jjidostill can't import it
17:55RaynesMost people use Emacs, but I've heard some exciting things about Eclipse lately. counterclockwise is under heavy development.
17:55RaynesIf you're already familiar with Eclipse, but not Emacs, it's worth giving it ago.
17:55Raynesa go*
17:56jjido(ns foo (:import (java.util Vector))) works fine
17:57jjido(ns foo (:import (mypackage MyClass))) gives class not found
17:58jjidothe directory named after mypackage is in the class path
17:58jjidoand it contains the .class file
18:00wjlroeWhen you run `lein swank` - how can you configure the classpath? It's not finding a .clj file in the same dir as the file I'm compiling - if that makes any sense
18:01wjlroeFYI, this is an appengine project
18:03technomancywjlroe: you can see the classpath using "lein classpath"
18:04jjidoThought I already tried this... (ns foo (:import MyClass)) did work. Good.
18:07wjlroehmmm, so I guess this classpath is from the build.xml file?
18:09jjidohow do I pass a int[] to a Java class? Do I need a Java wrapper?
18:10technomancywjlroe: no, lein swank only looks at project.clj. I don't know how the app engine stuff works into it though. where's the file that it can't find?
18:10wjlroeactually no. how is the classpath put together? I guess you can configure that in the project.clj
18:10wjlroetechnomancy: yeah - so it's got src/ in the CP, but not the package - so I think I need to add stuff to the classpath
18:11technomancywhat's "the package"?
18:11wjlroeI mean src/packagename/
18:11jjidonice there is (ints)
18:11wjlroelike src/woot/blah.clj
18:12technomancywjlroe: so you're saying (require 'woot.blah) fails?
18:12wjlroeyeah so in blah.clj I say (:use something.clj) <- in the same dir... it doesn't find it
18:13wjlroeso
18:13wjlroeI need the full NS
18:13technomancyyeah, without the .clj
18:13wjlroemmm, ok
18:14technomancyit might help to read through some more examples if you're running into problems with the ns form
18:14jjido,(ints [3 2 5])
18:14clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to [I
18:14wjlroeyeah, the PragProg book doesn't go into details
18:14technomancywjlroe: I mean projects on github, etc.
18:15wjlroeanyway, I'm getting a completely different error now so that's wonderful
18:15jjido,(ints (to-array [3 2 5]))
18:15clojurebotjava.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [I
18:15wjlroetechnomancy: yeah sure, I was looking through Composure, Ring, clj-gae-datastore mainly
18:16wjlroeDoes anyone know what happened to compojure.control ?
18:17jjido,(into-array Integer/TYPE [3 2 5])
18:17clojurebot#<int[] [I@ed09f6>
18:17jjidoaaahh
18:20RaynesThe majority of compojure ended up as ring middleware and other, related projects like hiccup.
18:20wjlroeyeah, can't find it in ring or compojure
18:21wjlroebut then again I don't know what it does - this is error driven development
18:22raekwjlroe: you can use the older version of compojure, if you just want to follow a tutorial
18:22wjlroeI like the challenge
18:22wjlroeand new stuff
18:23RaynesError driven development. :>
18:23raekMoustache and Enlive are worth to check out too
18:23Raynes$learn edd Error Driven Development
18:23sexpbotMy memory is more powerful than M-x butterfly. I wont forget it.
18:23wjlroeAt work we have a really good system - it's called Complaint Driven Development
18:24wjlroeit's really relaxing
18:24raek(Moustache does routing and Enlive does html templating and scraping)
18:25RaynesI think I'm the only person who still uses Hiccup rather than enlive these days for html templating.
18:26wjlroeI like hiccup
18:26wjlroethe smartrevolution peeps are using it also it appears
18:47replacawjlroe: what's smartrevolution?
18:48wjlroereplaca: https://github.com/smartrevolution/clj-gae-datastore <- actually I think they're caled something else - it's Steven Richter's company
18:48replacawjlroe: oh, yeah, I see now. I read about that before. Cool stuff.
18:48wjlroepeople who wrote TheDeadline
18:49bsteuberfreiheit
19:07dnolenhas anyone tried doing a REPL w/in the REPL ?
20:36samxWhat does '&' mean in when attached to a formal parameter in 'fn' arglist, e.g... (fn [&foo bar] ...)
20:37jjidosamx: isn't that (fn [& foo bar] ...)?
20:38samxno
20:39samxfor example, from the definition of 'defn' in core.clj: (fn defn [&form &env name & fdecl] ...
20:40jjidojust a var name
20:42jjido,(letfn [(foo [&blue &red] &blue)] (foo 3 4))
20:42jjido&(letfn [(foo [&blue &red] &blue)] (foo 3 4))
20:42sexpbot⟹ 3
20:44wjlroethere used to be a function compojure.http/static-file and I can't find where it's gone to... anyone know?
20:44samxi guess.. just seemed weird to use & as part of a parameter name, so figured it might have some kind of a side effect
21:26Raynessamx: Those are implicit parameters. I imagine that's Riches own little convention. It's nothing special.
21:28Rayneshttps://gist.github.com/718515
23:22Intertricity_Woo, I just saw clojure-clr binaries, does that mean it's now in beta?
23:22Intertricity_Or at least relatively useable?
23:33tensorpuddingis there a way to convert a String[] to a list of strings?
23:34tensorpuddingor maybe, in general, converting java arrays to clojure lists
23:37tensorpuddingeh, nevermind, clojure-contrib has what i want
23:41Raynestensorpudding: You should just be able to call seq on it.
23:43Raynes&(type (seq (into-array String ["one" "two" "three"])))
23:43sexpbot⟹ clojure.lang.ArraySeq