#clojure log - Jan 25 2009

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

0:00 Cark: actually you should do your requires in the ns form

0:00 so you could have something like this :

0:00 hiredman: eee: did you pass -server to java?

0:01 eee: um, I don't run things like that. whatever netbeans does

0:01 hiredman: java has two different vms

0:01 Cark: (ns org.mysite.my-lib (:use [clojure.contrib.math :exclude [mod]])

0:01 eee: which is dead working on this again

0:01 hiredman: -server and -client

0:02 -server does all the cool jitstuff

0:02 -client does not

0:02 eee: well can someone whose setup is working convert my filtrem to use lists and time again

0:03 against separate from contrib

0:03 ayrnieu: ,(defn eenie-meenie-mynie-moe [list] (nth list (mod 15 (count list)))) (eenie-meenie-mynie-moe '(pizza pork pb-and-j))

0:03 clojurebot: DENIED

0:03 eee: my environment is clearly hosed

0:03 Cark: eee : why don't you try with the basic repl ?

0:05 gnuvince_: Chouser: Sorry to bother, did you get a chance to look at my greatest-least package?

0:05 hiredman: clojurebot: does not allow defns

0:05 clojurebot: I don't understand.

0:05 ayrnieu: ,(let [e-m-m-m (fn [list] (nth list (mod 15 (count list))))] (e-m-m-m '(pizza pork pb-and-j)))

0:05 clojurebot: pizza

0:05 hiredman: er

0:06 eee: i don't think time works right

0:06 hiredman: time is very simple

0:06 Chouser: 'mod' is removed from 'math' now

0:06 ayrnieu: it may not provide wallclock time, eee.

0:06 eee: lazy things continue to process after the timer comes back

0:07 you could run someting that hangs for an hor

0:07 hour

0:07 hiredman: eee: wrap in doall

0:07 eee: and then it prints .123

0:07 Cark: benchmarking is hard =)

0:07 eee: oh

0:07 ok

0:07 hiredman: eee: that is host laziness works

0:07 it defers execution

0:07 how

0:07 eee: laziness dumb

0:07 :)

0:08 i can just imagine the fun I'll have trying to get coworkers to use the language

0:08 there's aren't fewer gotcha's . .. just different ones

0:09 Chouser: gnuvince_: very briefly. were you going to integrate Jason Wolfe's maximal-elements or whatever that's called?

0:14 eee: what does this mean? #(< % x)

0:14 percent

0:14 ayrnieu: ,(let [x 5] (#(< % x) 2))

0:14 clojurebot: true

0:14 hiredman: is #() is a kind of function literal

0:14 ayrnieu: ,(let [x 5] (#(< % x) 7))

0:14 clojurebot: false

0:14 eee: but the percent?

0:15 hiredman: % is the first argument

0:15 % or %1

0:15 %2 is the second

0:15 eee: oh

0:15 hiredman: etc

0:15 ayrnieu: ,(let [x 5] ((fn [percent] (< percent x)) 2))

0:15 clojurebot: true

0:15 eee: 1st areg of let

0:16 arg

0:16 hiredman: no

0:16 the first arg of the function

0:16 Chouser: #(+ % %2) is the same as (fn [a b] (+ a b))

0:23 eee: oh

0:24 i like that

0:24 gnuvince_: Chouser: I did, but I changed the name and the code.

0:24 Chouser: There are 8 functions now: greatest, greatest-by, all-greatest, all-greatest-by and the same thing for least.

0:25 eee: do I automatically have contrib available?

0:25 i just use enclojure

0:27 Chouser: Does greatest-by always return the same thing as (first (all-greatest-by ...)) ?

0:27 eee: wow!

0:27 now I know lazy was messing up the timing

0:27 mine is faster than filter

0:27 so anything that uses two passes with filter is way slower

0:28 Chouser: gnuvince_: If so, and if the all-* functions produces lazy seqs, then you'd could have half as many functions.

0:31 gnuvince_: I don't see how they could produce a lazy sequence: they need to go until the end of the sequence to find the greatest element

0:32 eee: anyone have access to the contrib 'separate' implementation?

0:32 Chouser: gnuvince_: heh. good point.

0:32 sorry, I'm apparently not thinking very clearly

0:33 gnuvince_: Chouser: don't worry about it :)

0:33 Chouser: eee: "access"?

0:34 gnuvince_: I'm just trying to think of ways to reduce the number of new functions needed to express the range of related functionality.

0:34 hiredman: clojurebot: contrib?

0:34 clojurebot: contrib is http://code.google.com/p/clojure-contrib/

0:34 eee: what is the implementation for separate. someone listed it before but it is off my screen

0:34 Chouser: eee: http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/seq_utils.clj#37

0:34 ayrnieu: http://www.catholic.com/audio/2008/MP3/ca081212a.mp3

0:35 huh, that's wrong.

0:35 http://code.google.com/p/clojure-contrib/source/browse/trunk/src/clojure/contrib/seq_utils.clj

0:35 eee: thanks

0:36 hiredman: ugh

0:36 my internet is so slow

0:37 ayrnieu: yow, I really hate this style. (defn name "long comment" [args] ...)

0:37 eee: wow. it really is way faster

0:37 i guess the lack of branching and more efficient looping?

0:38 Chouser: gnuvince_: ok, let me try again. even 'greatest' has to consume all its args. is boundary any more efficient than boundary-all?

0:38 eee: i dunno, it calls filter twice, but calling filter once is slow

0:38 hiredman: is doall recursive? does it realize lazy-seqs recursively?

0:39 Chouser: hiredman: no

0:39 hiredman: ah

0:39 Chouser: ,(second (doall [(iterate inc 0) [1 2]]))

0:39 clojurebot: [1 2]

0:40 Chouser: ,(seconde (iterate inc 0)) ; lazy

0:40 clojurebot: java.lang.Exception: Unable to resolve symbol: seconde in this context

0:40 Chouser: ,(second (iterate inc 0)) ; lazy

0:40 clojurebot: 1

0:41 Chouser: (second (doall (iterate inc 0))) ; hangs

0:41 hiredman: ,(second (doall (iterate inc 0)))

0:41 clojurebot: Execution Timed Out

0:42 hiredman: sure, "hangs"

0:42 ayrnieu: ,(second (first (doall [(iterate inc 0) [1 2]])))

0:42 clojurebot: 1

0:43 Chouser: gnuvince_: I gotta go. I'm not stopping any other contrib member from putting your code in, but personally I'd like to see if there's any sane way to pack the functionality of those 8 fns into 1 or 2 fns.

0:47 gnuvince_: Chouser: I'll look into it

1:01 * technomancy gives up... how do you call (read) on a java.io.File?

1:02 gnuvince_: You can't

1:02 You call it on a Reader or a Stream

1:02 hiredman: ,(doc read)

1:02 clojurebot: "([] [stream] [stream eof-error? eof-value] [stream eof-error? eof-value recursive?]); Reads the next object from stream, which must be an instance of java.io.PushbackReader or some derivee. stream defaults to the current value of *in* ."

1:03 technomancy: so I need to instantiate some kind of stream?

1:04 hiredman: you nead a java.io.PushbackReader

1:05 technomancy: right... but I can't make one by passing a File in

1:06 I guess I need a reader?

1:06 to make a reader?

1:06 hiredman: FileReader

1:06 Cark: (-> file FileReader. PushbackReader.)

1:06 something like that i guess

1:07 technomancy: yay hoops

1:07 * technomancy leaps through them to land safely on the other side

1:07 technomancy: thanks though

1:08 is this considered reasonable, or is it just one of those, "yeah, the language is still young, so it's got some rough edges" moments?

1:25 If I want to look up a docstring for a function given a symbol, (:doc ^#'my-func) works... but what if I want to make it dynamic?

1:26 gnuvince_: technomancy: (:doc (meta (var my-func)))

1:27 technomancy: gnuvince_: that's what I tried

1:27 this doesn't work: (let [x filter] (:doc (meta (var x))))

1:27 maybe I'm misunderstanding var

1:27 * technomancy looks it up

1:28 technomancy: docstrings that point to web sites? hrm.

1:28 that may be taking "Don't Repeat Yourself" a bit too literally. =)

1:28 gnuvince_: That's because x is not a var

1:29 technomancy: special forms can't have meta data, so they can't have doc.

1:29 technomancy: right, I need to look up the docstring for the function that x is bound to... ah. but the function doesn't have the docstring, the var does?

1:30 that's ... problematic.

1:30 I guess I'll have to write this as a macro then.

1:31 gnuvince_: Look at how it's done for doc

1:31 ayrnieu: ,(let [x filter] (doc x))

1:31 clojurebot: java.lang.Exception: Unable to resolve var: x in this context

1:32 ayrnieu: ,(macroexpand '(doc x))

1:32 clojurebot: (let* [m__63__auto__ (clojure.core/meta (var x)) al__64__auto__ (:arglists m__63__auto__) docstring__65__auto__ (:doc m__63__auto__)] (.replaceAll (.replaceAll (clojure.core/str al__64__auto__ "; " docstring__65__auto__) "\n" "") (clojure.core/str \\ \s) " "))

1:32 durka42: ,(macroexpand-1 '(doc x))

1:32 clojurebot: (clojure.core/let [m__63__auto__ (clojure.core/meta (var x)) al__64__auto__ (:arglists m__63__auto__) docstring__65__auto__ (:doc m__63__auto__)] (.replaceAll (.replaceAll (clojure.core/str al__64__auto__ "; " docstring__65__auto__) "\n" "") (clojure.core/str \\ \s) " "))

1:32 ayrnieu: ,(macroexpand-1 '(doc x))

1:32 clojurebot: (clojure.core/let [m__63__auto__ (clojure.core/meta (var x)) al__64__auto__ (:arglists m__63__auto__) docstring__65__auto__ (:doc m__63__auto__)] (.replaceAll (.replaceAll (clojure.core/str al__64__auto__ "; " docstring__65__auto__) "\n" "") (clojure.core/str \\ \s) " "))

1:32 ayrnieu: hm.

1:32 interactively, it macroexpands to (clojure.core/print-doc (var x))

1:33 durka42: ,(= doc clojure.core/doc)

1:33 clojurebot: java.lang.Exception: Can't take value of a macro: #'clojure.core/doc

1:33 durka42: ,(= (var doc) (var clojure.core/doc))

1:33 clojurebot: true

1:35 technomancy: can't map a macro over a list, of course.

1:36 I guess this is where I use Emacs rectangle commands for "code generation"

1:37 ayrnieu: what are you trying to do?

1:38 technomancy: I've got a list of symbols that refer to functions, and I want to get a list of the corresponding docstrings

1:38 durka42: hmm, you can do something dumb like (map #(eval `(doc ~%)) '[filter print-doc])

1:39 technomancy: durka42: was about to do that, actually.

1:39 much to my shame.

1:39 durka42: it feels like a goto or something

1:39 or using a void*

1:40 technomancy: (my version was going to use read-string, which is far worse)

1:40 durka42: that would add an extra step

1:40 (+ 2 3)

1:40 clojurebot: *suffusion of yellow*

1:42 Cark: technomency : i have some code to search the metadata of symbols in namespaces

1:42 what to get it ?

1:42 err i mean: want to get it

1:42 ayrnieu: "want in on it?"

1:43 technomancy: Cark: sure

1:43 Cark: clojurebot: paste?

1:43 clojurebot: paste is http://paste.lisp.org/new/clojure if it's working

1:43 durka42: lisppaste8: is it working?

1:44 lisppaste8: cark pasted "doc search stuff" at http://paste.lisp.org/display/74206

1:44 technomancy: thanks

1:44 Cark: you're welcome

1:48 technomancy: ok, I need to set the namespace before this will work

1:49 at runtime it tries to look it up in clojure.core

1:50 (let [*ns* mire.commands] ...) blows up though; what's the right way to do that?

1:50 Cark: (doc binding)

1:50 clojurebot: binding => var-symbol init-expr Creates new bindings for the (already-existing) vars, with the supplied initial values, executes the exprs in an implicit do, then re-establishes the bindings that existed before.; arglists ([bindings & body])

1:50 technomancy: in-ns?

1:50 binding blows up the same way

1:51 Cark: what are you trying to achieve ?

1:51 ayrnieu: (defn- all-symbols [] "Don't really get all symbols." (meta (vals (list (ns-publics mire.commands)))))

1:51 technomancy: ayrnieu: that looks perfect

1:52 ayrnieu: well, that's wrong because it calls meta on a list.

1:52 technomancy: right, but I get the idea

1:52 Cark: ,(find-ns 'user)

1:52 clojurebot: #<Namespace user>

1:52 Cark: (ns-publics (find-ns 'user))

1:53 durka42: ,(ns-publics 'user)

1:53 clojurebot: {}

1:54 ayrnieu: ,(ns-publics 'clojure.core)

1:54 clojurebot: {sorted-map #'clojure.core/sorted-map, read-line #'clojure.core/read-line, re-pattern #'clojure.core/re-pattern, keyword? #'clojure.core/keyword?, val #'clojure.core/val, *compile-path* #'clojure.core/*compile-path*, max-key #'clojure.core/max-key, list* #'clojure.core/list*, ns-aliases #'clojure.core/ns-aliases, the-ns #'clojure.core/the-ns, == #'clojure.core/==, longs #'clojure.core/longs, special-form-anchor #'clojure.

1:54 technomancy: ayrnieu: thanks a bunch

1:54 I need to head off though; getting late here

1:54 durka42: ,(keys (ns-publics 'clojure.core)) ; human-readable

1:54 clojurebot: (sorted-map read-line re-pattern keyword? val *compile-path* max-key list* ns-aliases the-ns == longs special-form-anchor instance? syntax-symbol-anchor format sequential? fn? empty dorun time remove-method gensym not= *3 unchecked-multiply doseq bit-or aset-byte if-not hash-set unchecked-dec some nil? string? second keys for *2 long-array cond bit-set fn sorted? ns-unalias ns-publics dosync all-ns long with-open init-pro

1:54 * technomancy breathes a sigh of relief at not having to use eval

1:55 durka42: (doc longs)

1:55 clojurebot: It's greek to me.

1:55 durka42: me too, that's why i asked

2:09 hiredman: http://gist.github.com/51721 <-- I took a stab at (scope ...)

2:16 Cark: shouldn't you be running the functions backward ?

2:16 hiredman: ah

2:17 or I could just change the vectors to lists

2:17 Cark: true

2:18 hiredman: so fixed

2:19 clojurebot: horizons?

2:19 clojurebot: Titim gan �ir� ort.

2:19 hiredman: clojurebot: horizons is http://gist.github.com/51721

2:19 clojurebot: Ok.

2:21 hiredman: ~ seen oudeis?

2:21 clojurebot: oudeis was last seen joining #clojure, 1 minutes ago

2:22 hiredman: huh

2:22 I could have sworn I saw him part

2:29 Cark: ~ seen oudeis?

2:29 ~ seen oudeis?

2:29 clojurebot: oudeis was last seen joining #clojure, 9 minutes ago

2:46 hiredman: ~ seen mrsolo

2:46 clojurebot: mrsolo was last seen joining #clojure, 82 minutes ago

2:47 hiredman: hmmmm

2:57 yoeljacobsen: Q: I'm trying to use enclojure and when I try to run the automatically generated project I get the following error: <No main class found>

2:57 Main class is of course configured..

2:57 Any idea?

2:58 lisppaste8: ayrnieu pasted "RFC: apropos.clj" at http://paste.lisp.org/display/74207

3:00 hiredman: yoeljacobsen: what is the exact exception?

3:00 show us some code

3:01 lisppaste8: url?

3:01 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

3:01 yoeljacobsen: No exception - Netbeans complains for no main class

3:01 hiredman: oh, well netbeans I know nothing about

5:00 Lau_of_DK: There's a Clojure to-do list on some Backpack(?) site somehwere, anyone got link ?

5:03 clojurebot: todo?

5:03 clojurebot: todo is http://richhickey.backpackit.com/pub/1597914

5:03 Lau_of_DK: broken link

5:12 clojurebot: todo is not what you think it is

5:12 clojurebot: Roger.

5:12 Lau_of_DK: clojurebot: todo?

5:12 clojurebot: todo is not what you think it is

5:12 Lau_of_DK: Hmm

6:47 drhz: There's a small typo in API decrtiption for (empty? coll). IS ..(seq x) rather than (not (empty? x)), SHOULD BE: ..(seq? x) rather than (not (empty? x))

7:52 leafw: "things supporting seq and stream" --> why not "Flow"? Or Iterable (although this one exists in java, but it *is*)

7:53 Chouser: drhz: nope. (seq x) is right

7:53 Lau_of_DK: Chouser: He quit

7:53 Chouser: oh. so he did.

7:54 Youhou: Hmm... I think there is a function missing from the zipper API. I need zip/root-loc and it isn't there. I would expect it to behave just like zip/root, but return a location instead of just one node. Am I missing something?

7:55 The reasoning being -- I've done some "modifications" to my tree, now I want to zip up to the top and pass the root to another function which will walk it again.

7:59 ayrnieu: well, the source is here if you want to add this: http://code.google.com/p/clojure/source/browse/trunk/src/clj/clojure/zip.clj

7:59 Youhou: sure -- I just wanted to check, perhaps I'm missing something obvious, or perhaps I'm doing something I'm not supposed to.

8:00 ayrnieu: I think you haven't missed anything.

8:12 acieroid: hmm

8:12 Is there some example of how extends java classes ?

8:13 because I just found that I have to use gen-class

8:13 but I don't know how

8:21 karmazilla: acieroid: "have to use gen-class" - means you have tried with proxy but discarded the approach?

8:22 acieroid: not tried proxy

8:22 Youhou: Hmm. Should I write to the group (about zip/root-loc) or submit an issue?

8:22 acieroid: I didn't find any documentation on this topic, except the api

8:24 karmazilla: acieroid: gen-class, I think, is for when you need to instantiate objects of the class from Java, or control class creation with main methods.

8:25 Youhou: Is there something that corresponds to CL's #-(and) idiom? I would like to be able to "comment-out" entire forms, instead of lines...

8:25 acieroid: ok karmazilla

8:25 karmazilla: ,(doc comment)

8:25 clojurebot: "([& body]); Ignores body, yields nil"

8:25 acieroid: I'll look at proxy so

8:28 Youhou: Thanks, that's what I was looking for.

8:29 Fib: Is there any way to use a macro with 'apply'? Is the idea of doing so misguided?

8:29 Youhou: No, that was not what I was looking for.

8:29 I need a reader macro -- something that will disappear into thin air. (comment) won't let me disable function arguments, for example.

8:31 Reading http://clojure.org/reader seems to imply there is nothing of the kind.

8:31 karmazilla: Fib: use a #()

8:32 leafw: karmazilla: where is #() documented?

8:32 Youhou: leafw: http://clojure.org/reader, which I'm reading right now :-)

8:34 leafw: thanks

8:35 as Isuspected, #() is an anonymous function literal ... so that, wrapping a (comment ..), can make it just disappear?

8:36 clojurebot: svn rev 1232; made eval use ephemeral classloader in all cases

8:36 Fib: karmazilla: what if I have a variable number of args to apply to, though?

8:37 karmazilla: yes, I was wondering about that. You can have %& for var-args in #()'s though

8:37 Youhou: (comment ...) doesn't do what I need -- I want to disable any form within the code, for example one of function arguments. I just want the reader to skip whatever I marked, something that directly corresponds to CL's #-(and) conditional. I would love to see, for example #!() for this. This

8:40 Fib: karmazilla: yeah, but then I'm left with the original problem, since if I have the varargs in the form of a vector, I still need to apply the macro to the varargs

8:40 I suppose there's always eval...

8:43 karmazilla: maybe the idea really is misguided :) supposedly, the number of arguments is not known until runtime, but by then all macros are expanded

8:47 Fib: that's what I thought :)

8:50 Chouser: Youhou: I think something like what you want is planned.

8:50 Youhou: for now perhaps you could write your own macro to do it?

8:52 Youhou: Chouser: I don't think I can -- it needs to be a reader macro. My macro will return nil and that nil will remain.

8:53 Chouser: I'm not saying it'd be as general a solution -- your macro would have to wrap the next level out in order to produce the form you need without the nil in it.

8:55 Youhou: Chouser: then it isn't nearly as convenient :-( -- frankly, it misses the point then, I'd rather reformat the code and use ;; to comment out forms. This really calls for #! or something similar, a built-in reader macro.

8:55 I'm actually surprised no one noticed -- it is such a useful tool when developing code.

8:57 Chousuke: #! is already a comment though :/

8:57 just not what you want.

8:58 Youhou: It is? That is not documented at http://clojure.org/reader, then.

8:59 Chousuke: IIRC it was added to make unix-style clojure scripts possible.

9:00 Youhou: Ouch. I see. Well, then #* or anything else, really, but it has to be short and easy to type, as it is used very often. CL actually doesn't make it very easy with #-(and)

9:03 Chousuke: have you made a post to the group about this yet?

9:29 Chouser: as I said, this has come up before -- I believe Rich has said it's a feature he plans to include.

9:39 Youhou: I will post about this -- and about the zipper issue.

12:19 BigTom: hi

12:20 I am trying to do something like reduce but my reduce function has more than 2 parameters

12:20 one of the parameters is a map for aggregating stuff

12:20 is there an idiom for this?

12:21 I am trying to avoid loops and mutable structures

12:21 kotarak: BigTom: it depends on what you want to do. Several aggregating parameters, or several lists, which are traversed in parallel?

12:22 BigTom: several parameters

12:22 kotarak: (reduce (fn [[aggr1 aggr2] list-item] ....) [init-aggr1 init-aggr2] the-list)

12:22 Your fn has to return a vector.

12:23 BigTom: urgh

12:24 give me a minute to parse that

12:24 kotarak: It uses destructuring in the argument vector.

12:24 ((fn [[a b] x] (+ a b x)) [1 2] 3) => 6

12:25 BigTom: ok, thanks

12:26 I am going to go a bit quiet now while I work it through

12:26 bergermeister: I have a cool but hard slime problem

12:26 Are there any slime experts online?

12:52 BigTom: kotarak: thanks, getting there now

12:53 kotarak: BigTom: good to hear :)

12:53 Do you know about destructuring?

13:00 BigTom: I know the basics

13:00 kotarak: Ok. It's a powerfull tool.

13:00 BigTom: {:keys [:a :b]} etc

13:00 haven't used it on vectors so much

13:01 main problem at the moment is when to pick reduce/for/doseq/doall

13:01 kotarak: doseq for side-effects w/o return value

13:01 doall for side-effects w/ return value

13:01 WizardofWestmarc: reduce is pretty straight forward, when you want to condense a list of values down to one in some form or fashion

13:02 like adding all of the ints in a list together

13:02 or finding the biggest in the list

13:02 kotarak: reduce to transform a list into something else

13:02 durka42: i thought side-effects w/o return is dorun

13:02 BigTom: I am ok with the basic cases, its aggregating structured data out of list/lists

13:03 I think it is nearly always reduce

13:03 kotarak: durka42: dorun over a list containing only nils seems ugly to me. But as always: YMMV.

13:04 I prefer (doseq [line lines] (println line)) over (dorun (map #(println %) lines)).

13:05 durka42: i agree

13:06 BigTom: I had to force an evaluation a while back with doall.

13:06 it blew the stack otherwise

13:06 I still haven't worked out why

13:06 kotarak: dorun/doall might be interesting to get a seq of something depending on a resource. (with-open [stream (open afile)] (doall (map #(do-something-with-line %) (line-seq stream))) or something like that.

13:07 BigTom: I am trying to get a short version to recreate it

13:20 what is the best way to filter specific values out of a map?

13:21 durka42: there is filter, and remove

13:21 for maps dissoc might be useful

13:21 duck1123: Ok, I think I'm ready to start writing test cases using test-is, does anyone know where a good example of an ant task that runs all test is?

13:22 Or better yet, a way to integrate that with emacs

13:22 Chousuke: ,(hash-map (remove (fn [[k v]] (> v 5)) {:a 6 :b 1 :c 7}))

13:22 clojurebot: java.lang.IllegalArgumentException: No value supplied for key: ([:b 1])

13:22 Chousuke: hmm

13:22 not quite like that I guess :/

13:22 BigTom: I am using filter but I am struggling to get the value

13:23 You get a leaf node as the value back from the map don't you?

13:25 kotarak: ,(into {} (filter #(> 0 (second %)) {:a 2 :b 0 :c 7}))

13:25 clojurebot: {}

13:26 Chousuke: wrong predicate :)

13:26 kotarak: ,(apply hash-map (filter (fn [[k v]] (> v 5)) {:a 6 :b 1 :c 7}))

13:26 clojurebot: {[:a 6] [:c 7]}

13:26 Chousuke: ,(apply hash-map (apply concat (remove (fn [[k v]] (> v 5)) {:a 6 :b 1 :c 7})))

13:26 clojurebot: {:b 1}

13:27 durka42: ,(into {} (filter second {:a 1 :b 2 :c nil}))

13:27 clojurebot: {:b 2, :a 1}

13:29 durka42: ,(into {} (filter #(> (second %) 0) {:a 2 :b 0 7}))

13:29 clojurebot: 5

13:29 durka42: huh?

13:30 ,(into {} (filter #(> (second %) 0) {:a 2 :b 0 :c 7}))

13:30 clojurebot: {:c 7, :a 2}

13:30 Chousuke: that's: java.lang.ArrayIndexOutOfBoundsException: 5 (NO_SOURCE_FILE:11)

13:30 durka42: yes, it is

13:30 my irc client didn't copy the :c smiley

13:32 BigTom: wow, almost too much information :-)

13:32 I have it now

13:32 durka42: breaking news: programmers discover more than one way to do the same thing

13:32 BigTom: I didn't know about clojurebot

13:32 durka42: :)

13:32 Chousuke: into is nice though.

13:34 BigTom: Yes it is, though I think my problem works better with the list of vectors

13:34 ,(+ 1 1)

13:34 clojurebot: 2

13:34 BigTom: cool :-)

13:34 durka42: (+ 10 10)

13:34 clojurebot: *suffusion of yellow*

13:35 durka42: ~seen kotarak

13:35 clojurebot: kotarak was last seen in #clojure, 8 minutes ago saying: ,(apply hash-map (filter (fn [[k v]] (> v 5)) {:a 6 :b 1 :c 7}))

13:35 Chousuke: for some reason, clojurebot has a separate maths module that can't count past 7

13:35 (+ 1 2)

13:35 clojurebot: 3

13:35 durka42: i thought it was 4

13:35 Chousuke: ,(+ 7)

13:35 clojurebot: 7

13:35 durka42: (+ 2 2)

13:35 clojurebot: 4

13:35 Chousuke: (+ 4 4)

13:35 clojurebot: *suffusion of yellow*

13:35 durka42: (+ 2 3)

13:35 clojurebot: *suffusion of yellow*

13:36 Chousuke: hmm? :/

13:36 durka42: no trouble with negatives though

13:36 (* 1234 -27)

13:36 Chousuke: I wonder why the functionality even is there.

13:36 durka42: (- 2 1234)

13:36 clojurebot: -1232

13:38 duck1123: (+ 2 2) => 5

13:38 clojurebot: *suffusion of yellow*

13:44 durka42: clojurebot: (+ 2 2) is 5

13:44 clojurebot: c'est bon!

13:44 durka42: clojurebot: (+ 2 2)

13:44 clojurebot: (+ 2 2) is 5

13:44 durka42: clojurebot: (+ 2 2) is 5, for large values of 2

13:44 clojurebot: 'Sea, mhuise.

13:45 durka42: ~(+ 2 2)

13:45 clojurebot: (+ 2 2) is 5, for large values of 2

13:45 bergermeister: Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: clojure.lang.Util.equal(Ljava/lang/Object;Ljava/lang/Object;)Z

13:45 Current svn has a bug in it.

13:46 that line should real clojure.lang.util.equals

13:48 nope, it is fixed

13:54 duck1123: clojurebot: (+ 2 2) is <reply>5 (for large values of 2)

13:54 clojurebot: Ok.

13:54 duck1123: (+ 2 2)

13:54 clojurebot: 4

13:55 duck1123: clojurebot: (+ 2 2)

13:55 clojurebot: 5 (for large values of 2)

14:24 BigTom: (reduce (fn [[n p] c] (+ (* n p) c)) 0 [[2 3] [4 5]])

14:25 durka42: ,(reduce (fn [[n p] c] (+ (* n p) c)) 0 [[2 3] [4 5]])

14:25 clojurebot: java.lang.UnsupportedOperationException: nth not supported on this type: Integer

14:26 BigTom: thanks

14:26 kotarak: The 0 is not a vector.

14:26 you mean probably (fn [c [n p]] ...)

14:27 BigTom: so I did :-/

14:28 Cheers :-)

14:32 Youhou: Ok -- so coming from a CL background, I've been looking for &key. Haven't found it. How do people do without keyword arguments?

14:32 I could probably zip up "& args" into a map and do a destructuring binding -- is there an idiom for that?

14:33 kotarak: (defn foo [arg1 arg2 & options] (let [{:keys [keyword1 keyword2] :or {keyword1 default1 keyword2 default2}} (apply hash-map options)] ...))

14:33 (foo val1 val2 :keyword2 bar)

14:34 clojurebot: svn rev 1233; fixed definline, patch from Chouser

14:34 Youhou: Right -- but this begs to be turned into a macro -- and I'm puzzled -- am I missing something, or do people think that keyword arguments are not the way to go? Or is such a macro in there somewhere?

14:35 kotarak: Obviously keyword args aren't use often enough to be a pain.

14:38 Youhou: Intriguing. Perhaps that's because clojure is still young. After a while you do get libraries with functions that take 40 parameters, and then it becomes unwieldy to use positional arguments. (libraries for fetching with http come to mind)

14:38 WizardofWestmarc: well as you point out you can cheat by putting a dict as a passed in param

14:39 then you just find which values are valid keys in the set and use that to determine what parts they want to do

14:39 Youhou: I'm not disputing the language design choice -- I'm just surprised that some sort of popular way of implementing keyword args hasn't emerged yet.

14:39 WizardofWestmarc: not as pretty/obvious on skim as the CL way I admit

14:40 well, how many projects of significant size exist on clojure?

14:40 BigTom: kotarak, durka42 & Chousuke: thanks for the help

14:40 WizardofWestmarc: because until you have some larger things built on it, stuff like that won't become a common problem.

14:40 kotarak: BigTom: np

14:40 danlarkin: Youhou: http://paste.lisp.org/display/69347

14:40 BigTom: I have nailed euler problem 5

14:40 and learned a lot,

14:40 cheers

14:41 kotarak: BigTom: http://clojure-euler.wikispaces.com SPOILER WARNING!

14:41 Youhou: danlarkin: oh, cool -- that's exactly the kind of macro I've been thinking about

14:42 BigTom: Thanks

14:42 WizardofWestmarc: yeah, lots of spoilers on clojure-euler

14:42 but some SLICK code too

14:42 I learned a lot looking at some other people's solutions

14:42 Lau_of_DK: WizardofWestmarc: You talking about my code cracker? :)

14:42 WizardofWestmarc: like Chouser's way of calculating triangle

14:43 err triangle numbers

14:43 Lau_of_DK: oh...

14:43 WizardofWestmarc: well, I've only looked at the early ones :P

14:43 I don't think I've seen any you posted to the euler wiki yet

14:44 I really need to take the time to wrap my head around lazy seqs/etc better

14:44 I never realized it could use itself to calculate the value of next w/map

14:45 durka42: eh?

14:45 WizardofWestmarc: you can reference a lazy seq inside it's own definition

14:45 durka42: how do you do that?

14:45 i feel like i've wanted to in the past

14:46 BigTom: do they ever use more then one letter for variables?

14:46 WizardofWestmarc: lemme find the fib example, since that one is even crazier

14:46 BigTom: I think my answers look a lot more verbose

14:47 WizardofWestmarc: this is it: (def fibs (lazy-cons 0 (lazy-cons 1 (map + (rest fibs) fibs))))

14:48 Lau_of_DK: WizardofWestmarc: http://clojure-euler.wikispaces.com/Problem+059 This is the only one I was sorta happy with

14:51 WizardofWestmarc: hm

14:51 Lau_of_DK: I like the way you build the combinations set list

14:52 Lau_of_DK: cool

14:53 WizardofWestmarc: I have to say, euler's proving an even better way to learn clojure then I'd hoped

14:53 really have to dig into the api/clojure-contrib to solve some of them

14:53 at least cleanly ;-)

14:53 BigTom: Yeah (though mine are anything but clean so far :-/ )

14:53 sooth: b

14:54 sorry

14:54 Lau_of_DK: WizardofWestmarc: We started clojure-euler partly for fun, and partly to do one-up on the other languages who had attempted the same. Then kotarak went and solved 215 and suddenly we werent playing anymore :)

14:54 WizardofWestmarc: haha

14:54 yeah I noticed 215 was posted

14:54 kotarak: Lau_of_DK: yeah, beat me! Harder! Harder!

14:54 WizardofWestmarc: BigTom: I know what you mean, mine haven't been great beyond the super easy ones

14:54 BigTom: Well, I shall treat that as a challenge...

14:55 WizardofWestmarc: but they're slowly getting better

14:55 BigTom: That is my hope too

14:55 I think I'll post me answers so other beginners don't feel intimidated :-)

14:57 WizardofWestmarc: I've skipped a few problems because I simply don't know a clean enough way to do it to my satisfaction, and I refuse to use the code I see in clojure-euler

14:57 like #8

14:57 oh, another one I liked was some of the posted answers for 9

14:57 it's easy to do that one ugly

14:57 but holy cow the clean way to do it is sexy as hell

14:59 BigTom: (I peeked for 3 :-/ but it spoiled the fun so I'm going to have to wait to see the others

15:08 AWizzArd: rhickey: is there something like a call-arguments-limit for Clojures apply?

15:14 Chouser: AWizzArd: there's no limit on the size of the seq passed to apply. Is that what you're asking?

15:15 AWizzArd: yes

15:15 of course, the limits of the hardware

15:16 Chouser: AWizzArd: nope, not even that.

15:16 AWizzArd: ;-)

15:16 Chouser: I wish there were no limits in hardware

15:16 but I think you are talking about lazyness

15:17 Chouser: well, I'm not *completely* joking. I believe the seq passed to apply could be too large to fit in memory all at once.

15:17 but that might not be right. I haven't tested it.

15:18 AWizzArd: in CL one would for example do (reduce #'+ (loop for i from 1 to 5000 collect i))

15:18 Chousuke: well, you can pass infinite seqs to apply

15:18 so why not.

15:19 AWizzArd: because if you put apply at the place of reduce the system *might* complain about it: APPLY: too many arguments given to + (clisp, 32-Bit, Windows)

15:19 Chousuke: ,(apply + (range 5000))

15:19 clojurebot: 12497500

15:19 Chousuke: ,(apply + (range 500000))

15:19 clojurebot: 124999750000

15:20 Chousuke: ,(apply + (range 50000000))

15:20 AWizzArd: yes

15:20 Chousuke: hmm

15:20 clojurebot: 1249999975000000

15:20 Chousuke: yay

15:20 AWizzArd: and the timing does not differ from reduce

15:20 Chousuke: well, + uses reduce internally

15:22 AWizzArd: ,(with-out-str (time (apply + (range 5000000))))

15:22 clojurebot: "\"Elapsed time: 338.841 msecs\"\n"

15:22 AWizzArd: ,(with-out-str (time (reduce + (range 5000000))))

15:22 clojurebot: "\"Elapsed time: 329.607 msecs\"\n"

15:22 AWizzArd: same

15:33 Chousuke: you don't need the with-out-str

15:34 AWizzArd: (time nil)

15:34 ,(time nil)

15:34 clojurebot: "Elapsed time: 0.09 msecs"

15:34 svn rev 1234; Made Atream.Iter an IFn, so can act as generator

15:35 AWizzArd: What does that mean?

15:35 was is an Atream.Iter?

15:35 what is an..

15:36 rhickey: AWizzArd: streams stuff

15:38 Lau_of_DK: rhickey: All the underlying theory of this streams vs seqs vs nil punning vs speed, where can I go read up on it ?

15:38 rhickey: Lau_of_DK: there's no single place

15:39 Lau_of_DK: oh - you wanna do a short webinar then, Ive got Yugma open :)

15:39 Chouser: there are still decisions to be made, aren't there? A bit early to document very heavily

15:40 rhickey: Chouser: right, and the issues are subtle, but it has been discussed here and on the group

15:40 Lau_of_DK: Chouser: I just meant the theory governing these decisions, nothing to do with docs

15:40 Chouser: Lau_of_DK: If you just want to use it when it's done, I'd wait patiently until it's intergrated into trunk. Then people can work up docs, examples, etc.

15:41 Lau_of_DK: Chouser: I still dont want docs / examples, I just want to understand the power of streams in comparison to what were doing now, and why this is contrary to nil-punning, that type of stuff

15:41 Chouser: if you want in on it earlier than that, I think it's reasonable to expect to have to exert a bit more effort. Search the group, the IRC logs, read http://clojure.org/streams

15:41 Lau_of_DK: I got that streams will give us something like continuations, but thats it

15:42 Chouser: hm, I don't think that's right.

15:45 Chousuke: streams are like unix pipes aren't they. you can only read the data once, and then do whatever you want with it, and pass it forward (or not)

15:47 Lau_of_DK: Is this in anyway connection with LFE?

15:47 Chousuke: I don't think so

15:47 LFE was an alternative model for doing the stream stuff, but I think rhickey scrapped it.

15:49 which is good, I think, since I was completely unable to understand how they worked :P

15:53 hiredman: no

15:54 LFE is for safe resoure usage

15:56 ~seen rhickey

15:56 clojurebot: rhickey was last seen in #clojure, 16 minutes ago saying: Chouser: right, and the issues are subtle, but it has been discussed here and on the group

15:58 AWizzArd: So, LFE won't make it into Clojure?

16:03 Chouser: I believe that's correct.

16:06 BDFL said "LFE offered resource management and safety,

16:06 I think scope + safe streams is easier, and definitely faster"

16:07 AWizzArd: And that Atream.Iter stuff is about this issue?

16:09 Chouser: That's part of "safe streams", yes.

16:15 Chousuke: It's supposed to be AStream though :)

16:17 StartsWithK: Chouser: what do BDFL and LFE acronyms stand for?

16:18 Chouser: LFE is Left Fold Enumerator

16:18 BDFL is Benevolent Dictator For Life, a.k.a. Rich.

16:18 StartsWithK: :)

16:19 what are my options for parser construction under java?

16:20 are there any parser combinators like spirit/yard?

16:20 Chousuke: there's fnparse on github

16:22 hiredman: http://github.com/hiredman/clojurebot/blob/fe80fe2b641b3b8aba6c5ee4064a61f0737c2b37/hiredman/horizon.clj <-- speaking of scope

16:24 durka42: The Universe has ended unexpectedly: RuntimeException: Naked Singularity. We apologize for any inconvenience. (A)bort, (R)etry, (I)gnore, Report to (G)od

16:30 stuarthalloway: Chouser: I have added :dir and :env options to shell-out in SVN r413. Also unit tests for the helper functions (but not for sh itself).

16:31 Lau_of_DK: stuarthalloway: Shell-out was your way of getting the current dir?

16:31 stuarthalloway: Chouser: I am going to let my laptop out of my sight for several hours, but if you find anything that irritates you send me an email or castigate me on the mailing list and I will fix it later tonight. :-)

16:31 Lau_of_DK: shell-out is in contrib, and provides a simple "sh" function

16:32 Lau_of_DK: k

16:32 stuarthalloway: Lau_of_DK: I have added the ability to bind a dir for multiple operations, so I can get some rake-like goodness going in lancet.

16:33 Lau_of_DK: ok :)

16:36 Chousuke: btw, isn't the new stream-utils.clj in contrib misnamed?

16:36 should be stream_utils.clj

17:21 cconstantine: Newbie to clojure here... I have two vectors ([1 2 3] [1 2 3]) and I want to add them together to get a vector like [2 4 6]. How would I go about doing that?

17:22 Chousuke: ,(map + [1 2 3] [1 2 3])

17:22 clojurebot: (2 4 6)

17:22 Chousuke: or ,(into [] (map + [1 2 3] [1 2 3]))

17:22 If you really want a vector

17:22 cconstantine: I knew it was something stupid simple like that, thanks :)

17:24 Chousuke: generally though, forcing things into concrete data structures is not as clojurey as just using seqs

17:25 Chouser: ,(vec (map + [1 2 3] [1 2 3]))

17:25 clojurebot: [2 4 6]

17:25 Chousuke: right, that too :p

17:26 Chouser: ;-)

17:30 AWizzArd: rhickey: would it be difficult to put & rest parameters into a vector instead of a list?

17:30 Chousuke: AWizzArd: yes, as rest can be infinite.

17:30 it's a seq, not a list.

17:31 AWizzArd: ok

17:31 for macros it would be nice though, as it could reduce time for debugging

17:32 Chousuke: well you can always do (let [rest (vec rest)] ...)

17:32 AWizzArd: in several cases where a macro has a & rest parameter and one wants to go through that sequence the typical pattern is '~rest

17:32 but thousands of Clojurists will do ~rest at first, without quoting it

17:32 Chousuke: '~rest? why? :/

17:33 AWizzArd: (map identity 'rest) ==> (map identity (1 2 3)) ==> Can't call 1

17:33 uhm, wrong

17:33 `(map identity ~rest) ==> (map identity (1 2 3)) ==> Can't call 1

17:33 Chousuke: I'd use ~@(map identity rest)

17:33 AWizzArd: but `(map identity '~rest) ==> (map identity '(1 2 3)) ==> (1 2 3)

17:33 Chousuke: or maybe just ~(map identity rest)

17:34 AWizzArd: you don't always want to do this

17:34 Chousuke: well, true.

17:34 AWizzArd: it's not really a big issue

17:34 I just did not think about this infinity thing

17:35 Chousuke: yeah, your code would get quite bloated if you expanded an infinite list :/

17:35 AWizzArd: otherwise, if it would have been no problem to put the & rest into a vector one could have thought about it. Would probably not break code

17:36 Chousuke: well, if your box has infinite memory this may not be a problem anymore

17:36 Chousuke: or if you could have lazy code.

17:37 something that appears in the source file only when it's really read

17:37 AWizzArd: nice

18:11 danlarkin: is there a way to get all "handlers" for a multimethod?

18:12 Chouser: (methods print-method)

18:12 it's new!

18:12 danlarkin: perfect!

18:16 red_fish_: ,(apply (fn [& rest] (println (first rest))) (repeat "hello world!"))

18:16 clojurebot: hello world!

18:18 Chousuke: :)

18:24 hiredman: clojurebot does not deal with newlines well

18:31 durka42: i noticed that when i tried to sendMsg-who with \n's in it it was displayed as one message

18:33 hiredman: yeah there is some stuff to strip newlines

18:34 durka42: i didn't know if that is just an irc custom

18:34 is it better to send as multiple messages?

18:35 hiredman: I dunno

18:49 Chouser: the irc wire protocol is newline-separated, I believe.

19:15 dreish: There's not much need for ' in clojure, is there?

19:15 cooldude127: quote?

19:15 dreish: yes

19:15 cooldude127: why because of literal vector syntax?

19:15 dreish: That and keywords, I think.

19:16 danlarkin: dreish: it's still useful sugar

19:16 dreish: Oh, certainly. I can't imagine a Lisp without it.

19:16 I just realized after finishing a 600-line lib that I hadn't used it once.

19:16 hiredman: heh

19:17 cooldude127: lol

19:37 danlarkin: ,(var (val (first (methods print-method))))

19:37 clojurebot: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol

19:38 danlarkin: :( how do I accomplish that

19:39 hiredman: ,(methods print-method)

19:39 clojurebot: {nil #<core$fn__5228 clojure.core$fn__5228@13bedc4>, clojure.lang.IPersistentMap #<core$fn__5322 clojure.core$fn__5322@1ec4535>, java.lang.Number #<core$fn__5246 clojure.core$fn__5246@4b62a7>, java.lang.Class #<core$fn__5370 clojure.core$fn__5370@88e83d>, java.lang.String #<core$fn__5305 clojure.core$fn__5305@1900f17>, java.util.regex.Pattern #<core$fn__5379 clojure.core$fn__5379@26807f>, clojure.lang.Symbol #<core$fn__52

19:39 hiredman: uh

19:40 you can't

19:40 it is all function objects

19:40 what are you trying to do?

19:40 danlarkin: I want to get metadata for one of the methods

19:41 for my own function, not print-method, that's just for example

19:41 hiredman: matedata is attached to the multimethod var

19:42 the defmethod stuff have no vars and no metadata

19:42 unlessyou do something weird and attach metadata to the function object (dunno if that is possible)

19:42 danlarkin: Oh. damn.

19:42 Hmmmmm

19:43 it would really be nice if the individual methods were allowed metadata

19:43 hiredman: *shrug**

19:55 Chouser: I think it'd be nice to be able to put metadata on Fn objects, but that's apparently a bit tricky to accomplish.

20:00 danlarkin: metadata on defmethods would be perfect

20:00 Chouser: danlarkin: what specific metadata are you looking for?

20:04 danlarkin: well I'd like each function attaching itself to the multimethod to define a :help key for printing to the command line

20:05 AWizzArd: What is Clojures equivalent to CLs subseq? (subseq '(10 20 30 40 50 60 70) 3 6) ==> (40 50 60)

20:05 Chouser: hm... you could write an alternative to defmethod that instead of adding a fn to the table, adds a Var instead.

20:06 hiredman: ,(doc subseq)

20:06 clojurebot: "([sc test key] [sc start-test start-key end-test end-key]); sc must be a sorted collection, test(s) one of <, <=, > or >=. Returns a seq of those entries with keys ek for which (test (.. sc comparator (compare ek key)) 0) is true"

20:06 Chouser: Vars, when called, deref and call their value, so it ought to work transparently, but you'd have a place to hang some extra meta-data.

20:06 AWizzArd: yes, I've already seen that hiredman. That is not the equivalent.

20:06 hiredman: I see

20:07 Chouser: AWizzArd: (take 3 (drop 6 myseq))

20:07 AWizzArd: I need something like subvec, but for lists

20:07 hiredman: I just knew there was something called subseq, and wanted to see what the difference is

20:07 Chouser: oh, (take 3 (drop 3 myseq)) I guess

20:08 danlarkin: Chouser: here's the body of defmethod: `(. ~multifn addMethod ~dispatch-val (fn ~@fn-tail)))

20:08 Chouser: danlarkin: yes

20:08 AWizzArd: Chouser: oki, that would do it, thx

20:33 danlarkin: lisppaste8: url

20:33 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

20:33 danlarkin pasted "defmethod using vars" at http://paste.lisp.org/display/74247

20:34 danlarkin: Chouser: there's my attempt

20:34 kinda works

20:34 Chouser: heh

20:34 "kinda"?

20:34 danlarkin: well it doesn't get the metadata I assign

20:34 but it does have :ns and :file and :line etc

20:34 Chouser: ah

20:38 it might be easiest to accept another arg for the meta-map

20:38 like defn does

20:38 otherwise, if you want to use #^{} before the multifn, you might be able to extract the metadata from that symbol and apply it to the var

20:39 danlarkin: yeah I'm looking at the definition of defn now

20:56 Chouser: greatest-by and greatest already differ only by a predicate, but I guess always providing 'identity' as a first arg for the common case of would be a bit annoying.

21:00 having the defaults act like all-* and using 'first' when you only want one would be sligtly less memory efficient if there are lots of equally-maximal values. Would that be acceptible, or is the goal of reducing the number of global vars not sufficent?

21:03 gnuvince_: Chouser: I guess it depends; if it stays in its own module, I don't see the problem.

21:04 Also, I'd would prefer if I only had to write (greatest x y) instead of (first (greatest identity x y))

21:04 Chouser: heh. yeah.

21:06 gnuvince_: I looked at it last night, and the only way to reduce the number of functions is to make the interface more awkward (IMO)

21:06 Chouser: Has Jason Wolfe responded to your code at all?

21:06 gnuvince_: no

21:07 Chouser: I agree the number of functions is not a problem if it stays in its own lib

21:08 having a whole lib for these seems a little extravagant. I guess it's not a big problem yet.

21:08 gnuvince_: It doesn't really fit into any other existing library

21:12 aperotte: Chouser: I noticed your discussion on google groups about accessing this in gen-class and setting things post-construction. Has there been any more talk about how to get around those constructor issues?

21:39 danlarkin: Hm... (my-defmethod manager-dispatch :default #^{:foo 'bar} [& args] (println args)) is very weird, the my-defmethod macro doesn't get passed the metadata map... it's like I didn't type it

21:42 Chouser: passed using #^{} or just {} ?

21:43 danlarkin: #^{}

21:43 cooldude127: danlarkin: that probably won't work

21:43 it will try to attach that map to the thing after it

21:44 use a plain map

21:44 danlarkin: but it works with defn :(

21:44 Chouser: it gets attached to the following symbol

21:44 cooldude127: exactly

21:45 Chouser: try (prn (meta muti-name)) in there somewhere

21:46 danlarkin: Hm. yep, gets attached to the thing after it

21:47 so I guess (my-defmethod #^{:foo 'bar} manager-dispatch :default [& args] (println args)) should be the syntax?

21:52 gnuvince_: Any of you guys actually works with Clojure?

22:02 hiredman: huh?

22:02 Chouser: you mean get paid for writing Clojure code?

22:06 hiredman: I often find myself writing clojure while I am work...

22:07 LordOfTheNoobs: At work and for work tend to be somewhat different things of course. :)

22:07 hiredman: indeed

22:09 gnuvince_: Chouser: yeah

22:25 arohner: I had a totally random idea, that sounded kind of cool

22:25 cooldude127: do tell

22:26 gnuvince_: indeed

22:26 arohner: let's say I have a function named foo, that I want to do some argument checking, and the arguments are such that it can be done at compile time

22:26 I could make a macro that shadows foo, does the argument checking and then calls the fn-foo, right?

22:27 i.e. (defn foo ... )

22:27 hiredman: no

22:27 macros and functions share a common namespace

22:27 arohner: hiredman: why not?

22:28 hiredman: calling foo inside a macro called foo would just be a recursive macro

22:28 in clojure macros are functions with special metadata

22:29 arohner: could I rename the old function during the macro call?

22:29 hiredman: no

22:29 because creating the macro clobbers the function

22:31 arohner: maybe it would require an extra step, but this still seems possible

22:31 hiredman: :P

22:31 arohner: because wrapping fns is easy and well known

22:31 (defn foo ... )

22:32 (compile-check foo (assert-args ...))

22:32 where compile check is a macro that takes the name of an existing defn

22:32 hiredman: *shrug*

22:32 arohner: it would move foo to a new name, and then create a new macro named foo

22:32 hiredman: the thing is

22:33 orange80a: can anybody recommend a good Clojure tutorial for an experience java programmer who knows nothing about lisp-related languates?

22:34 hiredman: function application happens at a different stage then macro expansion

22:34 arohner: after, right?

22:35 hiredman: so really you want another function

22:35 a macro would do the swapping sure

22:35 but the assert stuff you would need another function

22:35 arohner: I was looking to use a macro to get 'compile time checking', in the case where the arguments can be validated at compile time

22:36 hiredman: not gonna happen

22:36 arohner: oh, ok, I see the problem

22:36 even if the macro expanded to everything I want, that code still won't get run until my function is called at run time

22:38 ayrnieu: Hedgehog had a special form that would generate an error if it survived macroexpansion.

22:38 LordOfTheNoobs: clojurebot: what is tutorial?

22:38 clojurebot: Titim gan �ir� ort.

22:39 ayrnieu: orange, you could try running a scheme tutorial by clojure. You'll need to do a bit of translation.

23:37 technomancy: dang; scala and clojure are neck-and-neck on github

23:37 their book isn't even in beta yet though; weak sauce!

23:43 gnuvince_: technomancy: they got a few books out

23:43 http://www.amazon.com/s/ref=nb_ss_gw?url=search-alias%3Daps&field-keywords=scala&x=0&y=0

23:44 technomancy: oh; I thought the prags' one was the first

23:44 gnuvince_: that's only two books. one of them is out of stock, and one of them is pre-order.

23:45 clojure wins again!

23:46 heh... "Programming Scala" and "Programming in Scala"... these guys should communicate with each other

Logging service provided by n01se.net