#clojure logs

2010-11-23

00:00Licensercompojure is the closest to that I think but I'm not sure
00:01LicenserI use rack there but it does not make much just translates the requests into a hashmap and retranslates a result hashmap to a html response
00:02trybeingarunactually the way things work in my company is weird. If i get a few devs interested in clojure and we showcase some decent project then it becomes management's responsibility to bring new projects in that technology to the devs
00:02dnolenamalloy: I agree w/ the great way it present the basics.
00:03Licenserheh that is cool
00:03LicenserI'm kind of lucky that I'm not a dev so I have realtively much freedome what to use if I have the chance to code once in a while
00:04trybeingarunyep. The downside is that each dev will have his own preference and it would be difficult to convince people :)
00:04dnolentrybeingarun: I've heard only good things to HTDP. But it's not nearly as broad in scope as SICP from the looks of it, much more "obviously" practical
00:04Licenserheh
00:05Licenserwell talking about work, I got to run, time to work :) take care people and don't get eaten by the flying spagetti monster!
00:05trybeingarundnolen: at least the book doesn't seem threatening from its looks (unlike SCIP)
00:05trybeingarunc ya l8r!
00:06dnolentrybeingarun: good point. Can't say much bad about a book authored by Felleisen and Krishnamurthi either.
00:08dnolentrybeingarun: still that's introductory text to programming in general as well - seems like a lack of things in the middle ... Land of Lisp ? :)
00:08trybeingarunbut there are not many reviews in Amazon
00:10trybeingarunam new to lisp/clojure. I have that book (Land of Lisp). Have to read it some time
00:10trybeingarunFrom the looks of it LoL seems to be a very funny/entertaining book
00:11trybeingarunI'll find out some time whether it really packs the punch
00:11tomojthe music video was hilarious but also terrible
00:12trybeingaruntomoj: which video?
00:14tomojI'll find it
00:14dnolentrybeingarun: did you already look at Joy of Clojure ?
00:14tomojhttp://www.youtube.com/watch?v=HM1Zb3xmvMc
00:14trybeingarunnope. So far I have gone through only 2 texts on clojure, programming clojure and practical clojure
00:15trybeingarunProgramming clojure is my favorite among these two
00:15trybeingarunI also went through "The little schemer" which is very good imho
00:16dnolentrybeingarun: Little Schemer rocks
00:16dnolenthe ultimate first programming book IMO. You don't even need a computer.
00:25trybeingaruntomoj: too good. Really funny :)
00:34LauJensenMorning!
00:35joshua__In case anyone was wondering putting (setq default-frame-alist `((width . 80) (height . 30))) into my .emacs fixed the problem. Good morning LauJensen, thanks for the advice on Enlive.
00:35LauJensennp :)
00:36joshua__Such a clever approach to templating, it might actually be getting me a job too. I was talking to someone about it and they might be having me do some scraping for them. They're not really technical so they don't know how to do it themselves.
00:51ossarehjoshua__: snatch that money, homie! (/me goes back to proper english)
00:53LauJensenjoshua__: Yea, I remember telling Christophe (the author) that if he didn't make a load of money on Enlive, that I would :)
03:16samxWith multimethods, what happens if you define instances of the method in multiple different source files / namespaces.. And then, when using them in two other namespaces, in one usage you only require one of the namespaces defining the instances, while in the other you require both the namespace.. Will the two namespaces I'm using them from have different sets of instance methods, or the same set of instance methods ? Is defining the instance
03:16samxmethods in more than one file just a really "bad thing" to do?
03:19raekyou can have implementations in multiple namespaces
03:20raekhowever, make sure that you don't redefine the method for a certain dispatch value
03:22raekyou have to make sure that the namespaces with the implementations use the same namespace with the defmulti
03:24samxright.. not quite what I was asking though.. that is, lets say namespace NS1 defines the multimethod MM, and instances MMA and MMB.. NS2 defines instance MMC.. In NS3, I require NS1, but not NS2.. I'm assuming I'd only see instances MMA and MMB then.. In NS4, I require NS1 and NS2. I'd assume the method would then have MMA, MMB and MMC.. But would me doing thing in NS4 also affect the multimethod usages in NS3 to contain MMC ?
03:25raekyes
03:27samxcool.. thanks
03:28raek(assuming that NS2 calls (defmethod MM ...) where MM is the var that NS1 defines)
03:28raeki.e. (ns NS2 (:use [NS1 :only (MM)])) (defmethod MM MMC ...)
03:28samxyeah, that's what i meant with the 'instances'
05:32jonaskoelkerHi all. I have an object I want to thread through a bunch of function calls; I can best describe the sequence of function calls by some nested loops of [apply f to object, i, j, ...]. I try to write this in terms of reduce but my code is a mess...
05:32jonaskoelkerWhat's a poor lisp/clojure newbie to do?
05:46trybeingarunjonaskoelker: I dont get what you are trying to do.. what are i, j ...?
05:46trybeingarunbtw I too am a newbie. Can't guarantee I will be able to answer your question
05:48jonaskoelkerI'm basically trying to translate some python (with braces indicating indentation/nesting): foo = some_object(); for i in ...: { massage(foo, i); for j in ...: massage(foo, i, j) } return foo
05:49shachafjonaskoelker: For a nested loop like that (a cartesian product) a list comprehension of some sort might make more sense.
05:49shachafI only saw a reference to it somewhere once. Ignore that.
05:49jonaskoelkershachaf: I'm trying to compute the final version of foo, not the list of (i, j) pairs...
05:50shachafjonaskoelker: Can you give a little more context?
05:51mrBlissmaybe this is what you look for: http://clojuredocs.org/clojure_core/clojure.core/for
06:04jonaskoelkermrBliss: no, not exactly: I don't want a bunch of lists; I want the result of composing f length-of-the-lists times with itself, applied to my object foo
06:05jonaskoelkermrBliss: `for' would be what I wanted if I could make an assigment to a global variable inside the loop
06:06jonaskoelkersomething like this: http://pastebin.com/YdxyyDZX
06:34vedangI'm seeing some weird behavior in slime-who-calls..
06:34vedangit works in some cases and throws an error in other cases..
06:36vedangthis error to be precise:
06:36vedangDebugger entered--Lisp error: (wrong-type-argument char-or-string-p nil)
06:38vedangCould someone please shed some light on this, is this behavior expected/documented? Am I missing anything? I'm using the latest versions of technomancy's clojure-mode and swank-clojure from github..
07:00isloncan I easily serialize a record (read-string (pr-str myrecord))?
07:06AWizzArdislon: no
07:06AWizzArdWhat happened when you tried this?
07:07islonjava.lang.Exception: No dispatch macro for: :
07:07islonany sugestions?
07:14raekjonaskoelker: maybe something like (nth (iterate f foo) n)
07:14jonaskoelkerraek: not exactly (I think); the parameters to f vary from call to call
07:14raeki see.
07:14jonaskoelkeranyways, I have my problem solved with a macro defining a new kind of loop
07:15raekjonaskoelker: also, ` ("syntax-quote") has a gensym feature built into it. just write seq# and ret#
07:15raek`(let [x# 1] (inc x))
07:16raek,`(let [x# 1] (inc x))
07:16clojurebot(clojure.core/let [x__394__auto__ 1] (clojure.core/inc sandbox/x))
07:16raek(the last one should be a x# too, of course...)
07:16jonaskoelkerneat :)
07:17raek,((resolve (symbol "eval")) '(ns-unmap 'sandbox 'x))
07:17clojurebotnil
07:17raekmaybe you could use reduce in some way
07:19jonaskoelker:) // yeah, reduce seems obvious but it makes a mess in my code and makes my head explode
07:19raekcan you give an example of some input data you have and the desured output data?
07:20raekor what you are trying to accomplish in a wider sense
07:35AWizzArd~seen rhickey
07:35clojurebotrhickey was last seen joining #clojure, 1450 minutes ago
08:14raek,(read-string "010")
08:14clojurebot8
08:19jweiss_is there an easier way to get the name of a var, #'user/myfn to "myfn", other than using str and then chopping up the string?
08:20MayDaniel,(str (name (:meta (var reduce))))
08:20clojurebotjava.lang.NullPointerException
08:20MayDanieljwiss_: ^
08:22jweiss_that didn't work for me :)
08:23jweiss_,(str (:name (:meta (var reduce))))
08:23clojurebot""
08:23jweiss_,(str (:name (meta (var reduce))))
08:23clojurebot"reduce"
08:23jweiss_there we go :)
08:33jweiss_if my macro is going to generate a defn with metadata, can it just spit out the reader macro ^ ? or do i have to use with-meta somehow
08:34jweiss_actually my macro is creating a gen-class call and pulling the metadata from the fn and adding it as annotations on the method in the gen-class
08:34jweiss_but same concept
09:37neotykGood afternoon!
09:38InnarHello hello
09:38jaleyhi guys. am I right in thinking that conj'ing vectors won't reorder them?
09:39chouserconj'ing an item onto a vector "adds" it to the right-hand end, disturbing nothing else.
09:39neotykwhat would reorder vector?
09:39jaleychouser: cool. but that's not true of a list, right?
09:39chouserconj'ing on a list "adds" to the left-hand end, disturbing nothing else
09:40jaleychouser: ahhh makes sense. so, I'd like to add to the right using butlast, which seems to return a list when you pass it a vector, thus i'm getting the opposite of what i want :s is there an alternative?
09:41chouseruse 'pop' to take things off the right end of a vector
09:41chouser,(pop [1 2 3 4 5])
09:41clojurebot[1 2 3 4]
09:41jaleychouser: perfect. thanks!
09:41chouser,(-> [1 2 3 4 5] pop (conj 42))
09:41clojurebot[1 2 3 4 42]
09:41jaleychouser: cheers, that's exactly what i wanted
09:43neotykare you guys able to work with clj-sys packages?
10:08trybeingarunhello guys!
10:13islondoes anyone know how can I serialize and deserialize records?
10:16trybeingarunto write it to a file: (spit filename (pr-str object)))
10:16trybeingarunRead from file: (read-string (slurp filename)))
10:16islonit doesn't work with records
10:16trybeingarunThis is where I got it from. http://thinkrelevance.com/blog/2008/09/16/pcl-clojure-chapter-3.html
10:17AWizzArdislon: you can do this by overwriting the print method for your specific record.
10:18Chousukeprint/read is not a very good method of serialisation.
10:18islonspecialy with records
10:18Chousukewith anything, really
10:18Chousukeit only works if you have reasonably simple data.
10:18islonindeed
10:19isloni think i'll have to use basic java object serialization
10:21AWizzArdWhen you have (defrecord Foo [x y]) then you could (defmethod print-dup Foo [f, ^java.io.Writer w] (.write w (format "(Foo. %d %d)" (:x f) (:y f))))
10:21AWizzArdNow (binding [*print-dup* true] (print (Foo. 10 20 ))) prints it in a way in which it can be read back.
10:21jweiss_in a syntax quote form, can i avoid a symbol being namespace qualified (just output the symbol without ns) ?
10:21islonthis is a kind of externalization
10:22MayDanieljweiss_: ~'foo
10:22chouserjweiss_: yes, but usually the desire to do so is misplaced.
10:23AWizzArd,`(~'x)
10:23clojurebot(x)
10:23AWizzArdIt can be useful if you expand into a defn for example and want to offer the caller a sane preview in Emacs.
10:24jweiss_chouser: my overall goal for this macro is to let me put java annotations in metadata on my defn, not in the gen-class call. so the macro will put them there for me. :methods [[mymethod [] void]] <- mymethod shouldn't have a namespace, right?
10:24AWizzArdHe wants to see that the function takes [x y] so you can expand into [~'x ~'y]
10:25chouserjweiss_: did you know that you can replace the body of a gen-class method at run time?
10:26chouserthis is part of why the the entire spec of the class is given in the gen-class form, rather than picking up type hints etc. from the functions or vars and applying them to the class
10:27jweiss_chouser: hm, i see usefulness there, but also still want to be able to specify java annotations in the defn :)
10:28chouserheh, ok.
10:29jweiss_chouser: is there an example somewhere of replacing the body of a gen-class method at runtime?
10:29chouseryou can just re-run the (defn foo- ...), or change the .clj file that has those and re-load it
10:29jweiss_ah i see
10:30chouserand then all your existing instances of gen-class classes will behave the new way
10:31jweiss_chouser: ok, so my macro is not going to prevent me from doing that, it'll just make the java annotations fixed, which is ok with me
10:31jweiss_they're fixed anyway, right?
10:31chouserright
10:33islonhow can I force clojure to evaluate a ratio? (/ 30 4) => 15/2
10:34jarpiain&(quot 30 4)
10:34sexpbot⟹ 7
10:34islonthanks
10:34jarpiain&(double (/ 30 4))
10:34sexpbot⟹ 7.5
10:34trybeingarunI was doing it like (int (/ 30 4))
10:34islonthat's what I want
10:35trybeingarun*double* whatever :P
10:42hugodanyone else having issues with maven 3 trying to resolve clojure, and picking up org.clojure:clojure:jar:1.3.0-testbuild1-SNAPSHOT?
10:48hugodseems to happen with any dependency that transitively depends on an old snaphot, like autodoc or a version range, like moustache
10:53stuartsierraIf you have Sonatype OSS snapshots as a repo it gets pulled in.
10:55hugodthe failure I get is Failed to read artifact descriptor for org.clojure:clojure:jar:1.3.0-testbuild1-SNAPSHOT: Failure to find org.clojure:pom.baseline:pom:0.0.1 in http://oss.sonatype.org/content/repositories/snapshots
10:56stuartsierrahugod: I don't think this is specific to Maven 3
10:58hugodstuartsierra: I haven't tested with maven 2
10:59stuartsierraSolution for now is excluding those transitive dependencies.
10:59stuartsierratestbuild1 isn't for general use
11:00hugodI realise that - just annoying that it keeps getting picked up
11:00stuartsierraI'll ask Chas if we can delete it from Sonatype's repo
11:01hugodstuartsierra: thanks - though I don't want to get in the way of you testing new builds
11:04stuartsierraYeah, we needed to do that, just regret that it ended up affecting actual builds.
11:07hugodthe vagaries of maven...
11:24alpheusI'm using clojure.contrib.shell-out/sh to create PNG using dot. If I have dot write to a file everything's fine. But if I store the output of shell-out/sh in a var the data seems to be corrupted. Any ideas?
11:38dnolendoes it seem weird to anybody that satisfies? returns true even though the entire Protocol has not been implemented?
11:39islonclojure is easily satisfiable ;)
11:40KirinDavednolen: I must have missed the first part?
11:41dnolenKirinDave: no that's the whole shebang there. If you extend a Protocol or reify you get a record/object that returns true for (satisfies? Protocol x), regardless of how much of the Protocol you actually implemented.
11:42KirinDaveAhh, I misread.
11:47chouseroh no, naked :use!
12:02amalloychouser: (use 'misfeatures)
12:17jweiss_hm. i'm making a macro that expands into a call to gen-class, with the annotations for the methods put in place by the macro. I can't figure out whether i should have the macro produce a symbol with the metadata already on it, or just return a literal form (with-meta mysym {:annotx :valx}) ?
12:17jweiss_i tried the former but it doesn't seem to work. (and if anyone knows how to inspect class files for annotations, that'd help me a bunch. javap apparently doesn't do it)
12:19raekjweiss_: do you have a paste of you code?
12:19jweiss_raek: let me make a gist
12:20rata_hi
12:21jweiss_raek: https://gist.github.com/712134
12:21djpowellalpheus: if the output of the command is binary, then you probably want to call it as (sh :outenc :bytes "command")
12:21jweiss_raek: the macro is the important part, the fn's above are just for building the annotation metadata i want to add
12:22djpowellalpheus: otherwise you are going to get your PNG mushed into a string using some random character encoding. If you are storing binaries in strings in Java, then you are probably doing something wrong
12:22djpowells/outenc/out-enc
12:23raekjweiss_: btw, when writing map + anon fn, consider 'for'
12:23jweiss_raek: ok
12:24rata_is this a good construct to send a fn several times to an agent? (reduce #(send % f) agent (range n))
12:25raekrata_: (dotimes [_ n] (send agent f))
12:25djpowellalpheus: hmm, actually (sh "command" :out-enc :bytes)
12:26raekjweiss_: I can't see anything suspicious with it yet
12:26jweiss_raek: the issue is that it generates the classes ok, with the right methods, etc. but they don't appear to have any annotations
12:27jweiss_so i'm wondering if it's better to remove the unquote from (with-meta ... )
12:27rata_raek: so what send returns is just the same as the original agent?
12:28raekrata_: yes
12:28rata_thanks =)
12:32jweiss_raek: removing the unquote (and unquoting the forms inside with-meta instead) seems to generate ok looking code, but gen-class doesn't produce anything with it
12:33jweiss_maybe because it insists on actual symbols for a method, not a form that evaluates to one
12:33raekjweiss_: is an annotation attached by putting {AnnotationClass some-value} metadata on the mehtod name symbol?
12:33jweiss_raek: yup
12:34raekjweiss_: which one of the unquotes?
12:34jweiss_raek: line 15, right before with-meta
12:34jweiss_let me update the gist with the variation i just tried
12:35jweiss_done
12:36jweiss_it produces this: (clojure.core/gen-class :name test_clj.sample_tests :methods [[(clojure.core/with-meta config5 {org.testng.annotations.BeforeMethod {:groups []}}) [] void] etc
12:37raekwhat is config5 here?
12:38jweiss_raek: one of the fn's in the namespace i pass in. ie, (defn config5 [] etc etc)
12:38raekthe nested `s is confusing me... :)
12:38jweiss_there's a nested `?
12:38raekthat will take the value of config5, and attach the metadata to that
12:38raekyou first generate code in the let
12:39raekand then insert it into another `-form
12:39jweiss_oh right
12:39raekwell, maybe not nested...
12:39jweiss_yeah i see what you mean
12:39raekyou could generate a quote around config5
12:40jweiss_ok, let me try that
12:41jweiss_raek: (clojure.core/gen-class :name test_clj.sample_tests :methods [[(clojure.core/with-meta (quote config5) {org.testng.annotations.BeforeMethod {:groups []}}) [] void] etc
12:41jweiss_that doesn't produce any classes either
12:44rata_what does it mean in the documentation of await that it "Will block on failed agents"? if there's a failed agent it will never return?
12:45raekjweiss_: what did the original version you gisted produce?
12:45jweiss_raek: (clojure.core/gen-class :name test_clj.sample_tests :methods [[config5 [] test-clj.meta/void] etc
12:46jweiss_i'm wondering whether config5 still has metadata on it
12:46jweiss_in that case
12:46raekdo you have *print-meta* on?
12:46jweiss_raek: er, no, didn't know about that
12:48raekalso, I think the void return type is handled incorrectly
12:48raekit should be void instead of test-clj.meta/void
12:49raekhrm, but you're already doing ~'void...
12:49raekanyway, I have to go now. good luck!
12:49jweiss_raek: thanks for your help!
13:11dnoleninteresting reify is one of the cases where you not care that much about "this". *also* a pretty amazing way to make some datatype become something else ...
13:12chouserright, reify almost always has everything you need in lexical context, so rarely need 'this'
13:22raekjweiss_: just realized something. check the class of the generated org.testng.annotations.BeforeMethod. is it a symbol or is it a _class_?
13:23jweiss_raek: i'm doing (.getAnnotations (.getMethod test_clj.sample_tests "config5" nil)) and it actually has the annotations
13:24jweiss_so either the version picked up by the repl is not the same as the class files on disk... or something i don't know what :)
13:24jweiss_i don't know how to check the files on disk
13:25jweiss_oh i think i know what's going on
13:27dnolenwow, 1.2.0 protocols+reify has some serious awesomeness consequences that I had not yet considered.
13:28jweiss_raek: yeah i think i got it, so far the expansion of the macro call works (if i paste the expansion in place of the call). so i think it works
13:29jweiss_or sorta, the macro itself still doesn't work :)
13:29jweiss_but i must be 99% of the way there
13:56jweiss_there's something weird going on - my macro takes a namespace as an argument. when i call (macroexpand-1'(mymac my.namespace)) it expands correctly. executing the expansion works. but (mymac my.namespace) doesn't work. is there some kind of quoting gotcha here?
14:07dnolenchouser: any thoughts about the nature of satisfies? that I brought up earlier?
14:09chouserdnolen: "meh" ...how's that for a thought?
14:10dnolenw/ current behavior it means that consumers must always provide all methods, as library designers can't check via satisfies?. I suppose consumers merge provided default impl fn map for things they don't intend to customize ?
14:10dnolenchouser: as in you don't see it being much of an issue?
14:10chouserI haven't found a situation where using 'satisfies?' felt right.
14:11dnolenchouser: I agree, but then why is it there?
14:11jweiss_can i not refer to the current namespace with *ns* inside a macro?
14:12jweiss_i want to call a macro to do things with the ns-publics of the namespace i make the call from
14:14kotarakdnolen: why is map? there? or seq?? or integer?? or instance?? Because people want it.
14:15dnolenkotarak: have you looked at the Rx Observable protocol at all?
14:15dnolenObserver I mean
14:15kotarakdnolen: no. :) Just saw your question why satifsfies? is there.
14:16kotarakI missed the previous discussion. (if any)
14:16dnolenhere's the gist of the problem, people want to observer something. They reify the Observer protocol to do so.
14:16dnolenObserver protocol is (on-next [this v] ...) (on-error [this exc]) (on-complete [this ...])
14:17chouserdnolen: I think it may not be "correct" to extend a protocol without extending all methods.
14:17stuartsierradnolen: I did a version of that in Clojure
14:17dnolenproblem is, an Observer may only care about errors
14:17dnolenstuartsierra: I know I was there at your talk.
14:17stuartsierraah. :)
14:17stuartsierranames, nicknames, faces, … all a big blur to me
14:18dnolenbecause of the nature of Protocols, reified instances of Observer must always provide everything, regardless of whether they only care about some specific methods of the Protocol.
14:18kotarakdnolen: then the observer should probably only have on-event and the actual observer filter out stuff, they don't want. Or the tell the Observee, that they only want certain events.
14:20kotarakI had the case that I had instances which implemented only part of the protocol, other instance only other parts. And suddenly ... CLABANGO. I should have actually two different protocols because they were actually different things. And I was conflating stuff.
14:22kotarakOeh. btw. Can I put metadata on a Protocol? In particular {:added "<some-version>"}.
14:22mduerksenjweiss: i'm quite new to clojure, so i may be wrong, but AFAIK, you have to capture the ns at the time the macro is defined. like this: (defmacro some-macro [] (let [current-ns (ns-name *ns*)] ...
14:23mduerksenjweiss: and then, inside the macro, you can do (create-ns '~current-ns). but it could be that i made this too complicated
14:23stuartsierrakotarak: yes, protocols are Vars
14:24jweiss_mduerksen: maybe that's what i'm confused about. what is the purpose of ns-name, what are you supposed to pass to it?
14:24jweiss_seems like it takes a symbol and returns the same symbol.
14:25stuartsierrajweiss_: it takes a Namespace object
14:25mduerksenjweiss: ns-name takes a *real* namespace and return its name
14:25mduerksenas symbol
14:25kotarakhmmm... "Deprecating the Observer Pattern"
14:25jweiss_so, what does ns-publics take? seems to take symbols as well
14:26stuartsierraMost of the ns functions accept symbols and will call "the-ns" on them
14:26dnolenkotarak: exactly!
14:26jweiss_stuartsierra: mduerksen: thanks, that helps clear things up a bit
14:26dnolenhe's critiquing complexing Observer/Observable interface points.
14:27dnolenit should be absolutely minimal
14:27dnolenthat what Reactive Extensions are about
14:27mduerksenstuartsierra: thx for the-ns, everytime i'm here, i learn new useful functions :)
14:27dnolena minimal Protocol means you can convert reliably convert all kinds of streams in to all kinds of events and all kinds of events into all kinds of streams
14:27kotarakdnolen: ah. Ok. I'm not up to date with this new stuff. I only know Clojure.
14:28dnolensubscribe, unsubscribe, on-event, on-error, on-complete is it basically.
14:29stuartsierraunsubscribe might be redundant
14:29dnolenObservers don't tell Observables to filter. an Observer *can* be a filter, for yet another Observer
14:30kotarakdnolen: seqs are everywhere
14:31dnolenkotarak: :)
14:32kotarakdnolen: well, that's it basically. A seq. Maybe in a different form than usual, so what?
14:33dnolenkotarak: converting side effects into streams, right? (map-events + side-effect-src1 side-effect-src2 side-effect-src3 ...)
14:34dnolenkotarak: stuartsierra gave a great preso, are the slides somewhere? also https://github.com/stuartsierra/cljque
14:35stuartsierraslides at http://stuartsierra.com/download/2010-11-17-clojure-async.pdf
14:37jweiss_gen-class is killing me. it only does stuff at compile time, so i can't see what's going on. is there a way to at least get the macro expansion when the compiler hits it?
14:41chousergen-class is pain
14:41chouseryou could try faking it out by setting *compile-files* yourself
14:41chouserI've never done that though -- not sure what happens.
14:42jweiss_chouser: sneaky, what's the worst that could happen
14:42rlbIt'd be nice if http://clojure.org/libraries had links to the docs (or code) for things like clojure.contrib.command-line.
14:46mduerksenjweiss_: I just prn'ted all parameters of the macro before the actual macro code started. Not elegant, but helped me figure out the *ns* issue.
14:56fogus`Is there a technical or philosophical reason why a macro that "returns" a function can't be apply'd?
14:56amalloyfogus`: because the list of parameters isn't known at compile time?
14:56kotarakrlb: http://clojure.github.com/clojure-contrib
14:57kotarakmember:rlb: http://clojure.github.com/clojure-contrib
14:57amalloy&(apply (or nil +) [1 2 3]) ; should work, if that's what you mean, fogus`
14:57sexpbot⟹ 6
14:58fogus`amalloy: Why would that matter?
14:58amalloyfogus`: i must not understand what you're asking. can you give an example form that you wish would work but doesn't?
14:59kotarakfogus`: I'm not sure I understand „"returns"“
14:59fogus`let me put together an example
14:59rlbkotarak: thanks -- perhaps http://clojure.org/libraries should just have links there.
15:00technomancythe libraries page needs to be deprecated IMO
15:00pjstadigoinc
15:00kotaraktechnomancy: +1
15:00Thornhello
15:01technomancythe idea that one manually-curated page could list all interesting Clojure libraries implies Clojure being a very immature ecosystem.
15:01kotaraktechnomancy: it was back then
15:01technomancykotarak: oh, certainly.
15:04fogus`ammaloy, kotarak: Hmmm, nevermind. I was looking at the problem from the wrong perspective. What I wanted (I think) would/will be solved by letmacro
15:07Thornif I do (map print some-seq) is memory wasted on a list of nils?
15:08kotarakThorn: you want (doseq [x some-seq] (print x))
15:09amalloyThorn: no, but because map is lazy you might not see your prints
15:09kotarakThorn: map is not supposed to be used like this.
15:09amalloykotarak: or (dorun (map print some-seq))
15:09kotarakamalloy: dorun is sooooooo ugly.
15:12rlbtechnomancy: the libraries page is also what google seems to finds first, i.e. for "clojure command-line"
15:12rlbs/finds/find
15:12sexpbot<rlb> technomancy: the libraries page is also what google seems to find first, i.e. for "clojure command-line"
15:13Thornwhat if I want to apply a function to each element in a collection and don't care agbout return values, like .forEach() in javascript? is there an appropriate builtin for that?
15:13kotarakThorn: doseq
15:14kotarakThorn: replace print in above example with your function
15:15ThornI want syntax like (foreach fun seq)
15:15Thornshould I do that myself?
15:17chouser(def foreach (comp dorun map))
15:17chouserif you must
15:17Thornthat's cool thanks
15:17chouseryeah
15:19dnolenThorn: doseq would probably be more idiomatic (doseq [x coll] (f x)) and going through a lazy seq.
15:19dnolenand not involve going through a lazy seq I mean.
15:34Thornwhy is '() not nil? ?
15:35ChousukeThorn: because it's the empty list, and nil is null
15:35Chousukenil is supposed to represent "nothing", and an empty list is not nothing :)
15:37Thornwell given that there are no cons cells that's probably a good idea
15:38hiredman() is also the empty seq, and making the distinction has ramifications for lazy seqs
15:40raekThorn: well, there's still 'cons'. apart from that it can only have an ISeq object in its cdr slot, it's like whate you're used to in other lisps
15:40javeI'm trying to make a hello world portlet with clojure, but I'm getting file not found errors for clojure/core.clj on init
15:43Thornclojure probably wins the "language with the largest amount of finer points" award
15:44hiredmanunless you consider all the other languages
15:45raekjave: maybe it could be related to this: http://groups.google.com/group/clojure/browse_thread/thread/bb450997c5edf4ba/bb6ed7185c80c13a
15:46Thornthose will compete for the "unnecessary complicated" award (except scheme)
15:47dnolenanybody ever played with Quartz Scheduler?
15:48javeraek: hmm yes
15:49raekI found out that cron4j did what I needed (run a task at a specific time every weekday), so I never looked into Quartz
15:51mduerksendnolen: quartz.net for work, but I did not do very sophisticated things with it
15:55puredangeranyone out there a guru on the implementation of clojure.zipper ? I have some questions around the signaling of enumeration end and how that doesn't play well with the loc state
15:59hiredmanpuredanger: there is a zipper/end?
16:00puredangerhiredman: yes
16:02hiredmanpuredanger: perhaps if you cared to share the problem you are having
16:02puredangerhiredman: well it requires some intimate knowledge of clojure.zipper but I'm happy to share my question
16:03hiredmanin #java their bot has a factoid about "just ask your question, it is more efficent then all known implementations of the ask to ask protocol"
16:03puredangerzippers wrap nodes in "locs" which is a vector of the form [node { /loc-data /}]
16:04puredangerhiredman: point taken
16:04hiredmanand if you zip/next off the end you get a nil loc
16:04puredangerhiredman: actually no
16:04puredangerif you zip to the end, you get a loc = [node :end]
16:04hiredmanoff the end
16:05hiredmannot "to the end"
16:05hiredmanbut I could be wrong, it's something like 6 or 8 months since I have done anything with zippers
16:05puredangerthe point being that the :end loc actually destroys the other data that was in the map in (loc 1)
16:06puredangerand at that point, any operations on that last loc will mostly not work as you expect them to
16:06puredangerfor instance, if your tree is actually a single node, and you call next on it, you get back this state
16:07hiredmanthe various zip ops don't work on it?
16:08puredangerI'm not sure how to then get back to a state where that loc is the original loc, ready to next again without actually calling node, then recreating the zipper (which seems antithetical to the notion of zippers as (conceptually) a mutable tree)
16:08puredangerhiredman: they do, but they work differently
16:09hiredmanI see
16:09puredangerhiredman: I'm actually running into differences in code over the top of zipper so I'm trying to come up with a cogent example
16:09hiredmanzip/prev doesn't work?
16:10hiredmananyway, I don't have an answer, and unfortunately I need to pay attention to something else at the moment :(
16:11puredangerhiredman: thx
16:22puredangerbecause the end node is also the last node in a DFS through the tree, it must be the root and thus has no left or right siblings - this actually covers many of the potentially broken paths. down is a function that will fail in this scenario though:
16:22puredanger; (def v (vector-zip [1 2]))
16:22puredanger; (-> v next next next down node) --> throws NPE
16:23puredanger(the node call at the end is immaterial - the down is the point where the function expects a map at (loc 1) but finds only :end
16:23puredangerhere next next next will traverse from 1 to 2 to [1 2], then down should go back to 1.
16:24puredangerwhat I'm wondering is if that is just outside the realm of what the zipper is supposed to do
16:24hiredmanerm
16:24hiredmanright, hmmm
16:28puredanger; (-> v next next next prev) --> returns nil, which is also somewhat confusing to me
16:29hiredmanmay also be a result of the :end thing
16:33puredangerhiredman: oh, it definitely is
16:34puredangeranything that relies on destructuring the map passed in the loc will fail as that map is destroyed
16:34hiredmanare you on clojure-dev?
16:34puredangerhiredman: y
16:35puredangerhiredman: good thought
16:37puredangermy thinking now as I read more of the Huet paper is that getting to the end of the zipper should not return you to the same place as the beginning - you are "down the zipper" and the changes you've made are embodied in the zipper behind you. but you should be able to get back to the start by unzipping and other operations should understand when you get into this state.
17:06phaerHow can i make a function parameter optional? eg. (defn connect-to-database [database user password host?] (...)). With host optional?
17:07chouser(defn foo [database user password & [host]] ...) is one way
17:08raekthat will make the function take any number of arguments, right?
17:08chouseryep
17:08Raynes(defn foo ([database user password] ...some code that will call foo with a sane default for host...) ([database user password host] ..))
17:08RaynesThat's another option using arities.
17:09raekphaer: (defn connect-to-database ([database user password] (connect-to-database database user password nil)) ([database user password host] ...))
17:09raekthe longer variant
17:09Raynesraek: I beat you too it.
17:09Raynesto*
17:09raek...as Raynes already demonstated
17:09Raynes:p
17:09raekRaynes: and now again...
17:09kotarak(defn foo [database user password & {:keys [host]}] ...) (foo db u p :host host)
17:10kotarakJust for the case files
17:10phaerI'd like to make port optional too, so i guess your first variant will do the job. thanks.
17:11Raynesphaer: kotarak's version might be better for this.
17:11Raynes(defn foo [database user password & {:keys [port host]}]) ... (foo db u :port 8080 :host localhost))
17:11RaynesMinus the last paren.
17:18alpheusPlease help me adjust my expectations about binding: http://alpheus.me/binding-question.clj
17:20chouseralpheus: because map returns a lazy seq, so f is not called until the REPL is trying to print the seq, well after the thread has left the scope of 'binding'
17:21dnolenanybody here messing with fogus's unifier?
17:21alpheusAh, got it.
17:22raekalpheus: you can use bound-fn to make f remember the bindings
17:23raekor maybe bound-fn* would be a better fit in this case
17:23kotarakor rolling something similar for seq: bound-seq http://bit.ly/anYaZq
17:23raekhow does things look for a reactive framework for clojure?
17:25raekI've seen ztellman's work on channels, and overheard that dnolen and stuartsierra were discussing something related
17:26stuartsierraDon't hold your breath.
17:26alpheusI've got a with-config macro that establishes some bindings then evaluates body. The body could be inside a bound-fn, but I'm wondering if this sounds like bad style?
17:26raekI'm reading "Deprecating the Observer Pattern" now, and I would like to hear about what similar things people are hacking on now
17:27dnolenraek: I would look at stuartsierra's work on cljque on github to get some ideas, stuff to play w/. Microsofts Rx definitely is working off the ideas presented in that paper.
17:49alpheusBack to my question about binding: would I still need to use bound-fn in 1.3?
17:51mabesalpheus: IIRC, with 1.3 dynamic vars must be explicit.. one key benefit of this is that bound-fn and variants are no longer needed
18:16KirinDaveHa
18:16KirinDaveI clicked the "run in console mode" on fogus's homepage.
18:16KirinDaveForever will that mistake dominate my destiny.
18:18bhenryKirinDave: wow that is really cool.
18:19mabesKirinDave: hah, yeah, I did that once too.. I had to reset my cookies for the site.. once the novelty runs out it is somewhat annoying IMO...
18:19RaynesOh wow, that is fantastic.
18:19stain_xkcd did something like that as well
18:19mabesit is a wordpress theme I believe
18:22KirinDaveYes, it is.
18:23KirinDaveAnd it's very cool for about 35 seconds
18:23KirinDaveThen you start trying to figure out how to undo it
18:26KirinDaveDoes anyone have a link offhand to how to tell lein to pull from a local maven repo?
18:29amalloyKirinDave: it should do that first by default, no?
18:29KirinDaveamalloy: I mean a new one of my own architecting.
18:38mabesKirinDave: you just need to specify the repo in the project.clj like so: :repositories {"leadtune-repo" "http://c0026236.cdn1.cloudfiles.rackspacecloud.com/repo&quot;}
18:38technomancyKirinDave: there was a thread about this last week on the lein list; puredanger had a good example.
18:38KirinDaveAhh, cool. Thanks, mabes
18:39KirinDavetechnomancy: I'm trying to get sbt and lein to nicely put banksimple stuff in private repos, etc.
18:39KirinDavetechnomancy: So it's becoming relevant to my interests.
18:39technomancyyou sir are on an edge which is cutting. unexplored territory there. =)
18:40KirinDaveThe sharp end of the stick
18:40KirinDavetechnomancy: I've got some serious razorburn out here as it is.
18:40KirinDaveI think I'm going to have to make a lein command to fool maven into doing the deploy properly.
18:40mabesa simple approach would be to "lein install" and then sync over the appropriate dir from the ~/.m2 folder
18:45javeI'm trying to inherit a java class from clojure, using genclass
18:46javeaparently the class I get cannot be cast to an interface of the class I'm inheriting
18:51KirinDavejave: A gist demonstrating the problem is the fastest way to get an answer
18:51KirinDavejave: A lot can go wrong with gen-class, I feel your pain. Maybe I can help.
18:51javeThanks.
18:51javeive just noticed I havent rtfm:ed properly. so ill do that and come back
18:57javertfm didnt help
18:57javehttps://gist.github.com/712809
18:58javeI get: java.lang.ClassCastException: cljportlet.portlet cannot be cast to javax.portlet.Portlet
18:58javeI suppose theres something wrong with the signature
18:59javeI dont actually need the typehints, right?
19:01KirinDaveYou don't.
19:01Deranderwhen I try to use clojure.xml/parse on a file with a "?" in its filename, everything from the ? to the end of the filename is thrown away and I get a filenotfound exception from java.io
19:01Deranderis there something I need to do?
19:01Derander(slurp file-with-?-in-name) works fine
19:02KirinDavejave: So what's the specific error you get?
19:02javeCaused by: java.lang.ClassCastException: cljportlet.portlet cannot be cast to javax.portlet.Portlet
19:02javewhen deploying the portlet
19:04joshua__Question about enlive. Lets say I have a class like "book" that appears like ten times on a page and I want to go through each of these book classes and fill them in with book details. Sometimes there will be more books, sometimes there will be less, depending on how many books need to be filled in. How would I do that?
19:04Derander(clojure.xml/parse (File. file-with-?-in-name)) works, fixed.
19:05_atoDerander: I think SAXParser (which clojure.xml wraps) treats a passed in string as a url, not a file path, so a ? in it will be treated as the query string separator, I guess
19:05KirinDave_jave: When you do lein compile it says that as the reason the compile fails?
19:06Derander_ato: yeah, I have a feeling something like that was going on.
19:06Derander_ato: like I said, (xml/parse (File. <filename>)) fixed the issue
19:07javeKirinDave_: oh, I dont get a compile time error. I build the uberwar fine. the error happens uppon deployment to liferay
19:07KirinDaveInstantiate one on the repl and say (supers (class (cljportlet.portlet.)))
19:07joshua__Anyone know?
19:09javeKirinDave: javax.portlet.Portlet is on the list of supers
19:18Deranderhttps://gist.github.com/712835 <-- any idea why this does not seem to act multithreaded? When it finds a file to process it runs the process function, and when that returns it continues writing "Firing."
19:19DeranderI would expect it to keep writing "Firing." while processing the file
19:19Deranderthe java processes' thread count does increase by 1 while it's processing and then decrease by 1 after it's done, though
19:24javeyay, my hello world portlet now works!
19:25_atoDerander: hit Ctrl+\ (or do kill -QUIT $pid) while it's processing the file and "Firing" is blocked. It'll give you a stack trace telling you what each thread is doing and also if they're holding or waiting on any locks
19:26Derander_ato: in the repl?
19:26Derander(I'm doing this in emacs w/ slime)
19:27_mstdon't you also want (Thread. #(process file)) or something?
19:27_atoaah
19:27Derander_mst: probably
19:27_atothere we go
19:27_mstif you're not passing in a fn it'll get evaluated in the main thread
19:27Deranderoh, thank you
19:27DeranderI wasn't aware of that
19:28_mstno worries. I'm often doing the same thing so the symptoms were familiar :)
19:28Derander:P
19:29amalloyDerander: (future (process file) works as well as (.start (Thread. (fn [] (process file))))
19:29Deranderalright
19:29amalloysince future is a macro, it can delay evaluation of its arguments; java.lang.Thread knows nothing about that, so the arguments have to be evaluated before being shipped off
19:29Deranderthat's cool.
19:30DeranderI see the use case for futures now
19:30amalloyDerander: well, the main use case is that futures return a value
19:30Deranderright
19:30DeranderI just read the docs and finally got what they di
19:30Deranderdo
19:30joshua__I had a flash of insihgt.
19:31joshua__My question is answered, I had a misguided understanding of how to use the templating system.
19:31Deranderjoshua__: join the club :-)
19:32Deranderalright, seems like it works now.
19:32Deranderbeautiful
19:32joshua__Congrats.
20:22DeranderShould lein compile tell me "All namespaces already :aot compiled" no matter what I do?
20:22DeranderTrying to run this app standalone outside of the repl, failing miserable
20:22DeranderI've put (:gen-class) in my main ns, defined a -main function there, and put :main in project.clj
20:27Deranderoh, I'm a moron.
20:32defnwhat does one need to start working on a ring middleware?
20:35defnnvm -- figured it out :D
20:35defnworking on ring-modernizr
20:36defnhttps://github.com/marshally/rack-modernizr
20:36defnlike that
21:00islonhow can i do a record implement an interface?
21:08puredangerislon: you can specify an arbitrary number of interface or protocol extensions at the end of defrecord
21:12islonpuredanger: thanks!
21:13puredangerislon: like: (defrecord Foo [a b] Iterable (iterator [] nil))
21:13puredangerwill implement the java.lang.Iterable interface which has one method iterator()
21:14puredangerislon: actually, I always forget the interface takes the instance as the first arg: (defrecord Foo [a b] Iterable (iterator [this] nil))
21:14islon(defrecord bla [a b] Serializable) -> Duplicate interface name in class file compile__stub/user/bla
21:14puredangerislon: all records should automatically be serializable
21:14islonthat's what I thought
21:14islonthanks anyway =)
21:30alpheus`Where's a good place for information about switching from 1.2 to 1.3?
21:55ossarehsince moving to 1.3.0 I'm noticing these, I assume generated by included libraries (certainly see that some libs cause more than others), what are they? "Var *classpath* not marked :dynamic true, setting to :dynamic. You should fix this before next release!"
21:57Raynesossareh: In 1.3, vars have to be explicitly dynamic. Meaning, for a var to be able to be rebound using binding, it has to have :dynamic true in it's metadata map.
21:57alpheus`(def ^:dynamic a) ;; for example
21:58ossarehthat is such a good idea.
21:59ossarehalpheus: so just the presence of the key is enough? Raynes' msg suggests it would be (def ^{:dynamic true} a) ?
21:59Raynes^:dynamic = ^{:dynamic true}
21:59alpheus`I just cribbed that from the test src
21:59ossarehRaynes: ahh - I didn't know that.
21:59RaynesIt's shorthand.
21:59ossarehthanks guys =
21:59ossareh=)
22:09Lajla&(-> (+ 1 2) "I worship his shadow"))
22:09sexpbotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
22:10LajlaHmm
22:10LajlaSo strings do not work as functions like vectors?
22:10Lajla&("I worship your shadow" 0)
22:10sexpbotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
22:10Lajla=(
22:15alpheus`&((vec "abc") 0)
22:15sexpbot⟹ \a
22:37Lajla&('(1 2 3 4) 0)
22:37sexpbotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
22:37LajlaHmm
22:37Lajlaoh well
22:38Raynes&([1 2 3 4] 0)
22:38sexpbot⟹ 1
22:38LajlaI know
22:38LajlaI am just dissapointed that strings and lists don't. =(
22:38LajlaI guess.
22:39LajlaBecause this is probably the part I like most about clojure.
22:39LajlaThat vectors are basically functions with their indices as domain
22:48EdwAnyone home?
22:49Edwclojurebot: help
22:49clojurebothttp://www.khanacademy.org/
22:52AdamantKHANNNNNNNNNNN
22:52Edw,(reduce #(assoc %1 %2 %3) {} '(a b c d e) (range))
22:52clojurebotjava.lang.IllegalArgumentException: Wrong number of args (4) passed to: core$r
22:54ossarehI just had to roll back all of my 1.3 work - was fine working in isolation but the moment I started using other libraries that haven't been ported it started to fall apart
22:54ossarehseems all to do with the equality changes
22:55ossarehedw: what are you trying to do?
22:56edwossareh: take a list and create a hash whose keys are the elements and values the indices. While typing into web chat.freebies.net on my iPad.
22:57edwWebchat.freenode.net, that is.
22:58Raynes&(into {} (clojure.contrib.seq/indexed '('a 'b 'c 'd)))
22:58sexpbotjava.lang.ClassNotFoundException: clojure.contrib.seq
22:58RaynesNonetheless.
22:59edwThanks. Wish I'd brought my laptop home.
23:00Raynes(let [l '(a b c d)] (zipmap (range (count l)) l)) ; also works
23:00Raynes&(let [l '(a b c d)] (zipmap (range (count l)) l))
23:00sexpbot⟹ {3 d, 2 c, 1 b, 0 a}
23:01edw,(reduce (fn [c [k v]] assoc c k v) {} (map #(list %1 %2) '(a b c d e) (range)))
23:01clojurebot4
23:02edwD'oh, forgot patens...
23:03edw,(reduce (fn [c [k v]] (assoc c k v)) {} (map #(list %1 %2) '(a b c d e) (range)))
23:04clojurebot{e 4, d 3, c 2, b 1, a 0}
23:04edwThere we go...
23:13edw.(doc zipmap)
23:13edw, (doc zipmap)
23:13edw,(doc zipmap)
23:13clojurebot"([keys vals]); Returns a map with the keys mapped to the corresponding vals."
23:13clojurebot"([keys vals]); Returns a map with the keys mapped to the corresponding vals."