#clojure log - Nov 20 2009

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

0:00 technomancy: cgordon: you can't compile an fn that references a var that doesn't exist

0:01 cgordon: technomancy: got it, thanks again

1:01 are variables like *command-line-args* considered "global variables"?

1:01 i.e., is it a convention that all global variables should have asterix at the start and end?

1:10 adityo: cgordon: yes it is an accepted convention for LISP languages eg Common Lisp, Clojure

1:11 cgordon: adityo: is "global variable" the right term to use when referring to them?

1:11 adityo: since Clojure seems to be about "immutable state", I'm wondering if "variable" is ever the right term :)

1:19 is it fair to say that Clojure symbols provide names (i.e. bindings) for just namespaces and vars?

1:20 or are there other things that can be bound to a symbol?

1:20 (sorry, I realize these are really n00b questions, but I'm trying to understand the terminology)

1:25 adityo: cgordon: a symbol can also have a value,symbol can be stored in a collection, passed as an argument to a function

1:26 cgordon: adityo: right, but for a symbol to have a value, it has to be bound to a var, right?

1:28 cgrand: cgordon: you're right -- people coming from other lisps tend to conflate vars and symbols

1:29 adityo: yes mapped to a var or java.lang.Class objects

1:29 cgordon: are Java objects stored in vars, or are they bound directly to symbols?

1:29 oops, looks like adityo beat me to that one

1:31 cgrand: it is namespace names that are throwing me right now. I get that a symbol can be bound to a var (or class) via a namespace binding, but I don't understand how it is that a symbol can refer to a namespace (i.e., namespaces are named by symbols, but aren't really first class entities. Saying "(type clojure.core)" at the repl gets me a blank look).

1:31 hiredman: clojure symbols have no associated storage

1:31 you can bind something to a var named by a symbol, but you cannot bind something to a symbol

1:33 cgrand: ,(type (find-ns 'clojure.core))

1:33 clojurebot: clojure.lang.Namespace

1:33 cgordon: hiredman: so is it true that a var always has one (and only one) symbol that "names" it? You seem to be saying that the word "binding" refers to the process of assigning a value to a var?

1:33 (again, apologies for the horrific newbieness of these questions and thanks for your patience!)

1:34 cgrand: cgordon: no apologies, these are good questions

1:35 hiredman: cgordon: binding is generally the term used for the association of a name and a value

1:35 cgordon: cgrand: so there is a "meta" namespace of some sort, and you use find-ns to lookup bindings between namespace names (symbols) and the actual namespace var?

1:35 er, meta is probably entirely the wrong word to use there

1:35 since it's so overloaded

1:36 hiredman: nope

1:36 cgordon: hiredman: this is what I'm trying to understand. Does a var contain a value (this is how we talk about things in the relational world, for instance)

1:36 hiredman: or do we consider a var to be a value?

1:36 hiredman: cgordon: it can be either

1:36 cgordon: hiredman: so it depends on the context?

1:36 can a var have a var as a value?

1:37 hiredman: a var is just another object

1:37 ,(clojure.lang.Var/create)

1:37 clojurebot: #<Var: --unnamed-->

1:37 hiredman: clojurebot: ping?

1:37 clojurebot: PONG!

1:38 hiredman: ,(clojure.lang.Var/create (clojure.lang.Var/create))

1:38 clojurebot: #<Var: --unnamed-->

1:38 hiredman: ,@(clojure.lang.Var/create (clojure.lang.Var/create))

1:38 clojurebot: #<Var: --unnamed-->

1:38 hiredman: ,@(clojure.lang.Var/create (clojure.lang.Var/create 'foo))

1:38 clojurebot: #<Var: --unnamed-->

1:38 hiredman: hmmm

1:39 cgordon: I haven't learned "@" yet, so I'm way behind here, but I think I see what you're doing

1:39 hiredman: ,`@(clojure.lang.Var/create (clojure.lang.Var/create))

1:39 clojurebot: (clojure.core/deref (clojure.lang.Var/create (clojure.lang.Var/create)))

1:39 hiredman: @ is deref

1:39 cgordon: which gives you the name of a var?

1:39 or it's value?

1:39 hiredman: value

1:39 ,#'+

1:39 clojurebot: #'clojure.core/+

1:40 hiredman: that is the var that contains the + function

1:40 ,@#'+

1:40 clojurebot: #<core$_PLUS___4745 clojure.core$_PLUS___4745@1b9a77c>

1:40 hiredman: that is the + function

1:40 cgordon: and that's the function

1:40 alright, that's making sense

1:40 hiredman: ,(deref (var `+))

1:40 clojurebot: java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol

1:40 hiredman: bah

1:40 ,(deref (var clojure.core/+))

1:40 clojurebot: #<core$_PLUS___4745 clojure.core$_PLUS___4745@1b9a77c>

1:41 cgordon: so does (def a "foo") create a var and give it the name "a" and the value "foo"?

1:41 hiredman: more or less

1:41 cgordon: so you could do what you did, above, like (def a #'+), and now a should have a var as a value?

1:41 hiredman: the acutal name of the var is the fully namespace qualified symbol

1:41 cgordon: ah, right

1:42 hiredman: sure

1:42 cgordon: ,(def a #'+)

1:42 clojurebot: DENIED

1:42 cgordon: doh

1:42 hiredman: ,(#'+ 1 2 3)

1:42 clojurebot: 6

1:43 cgordon: that's very interesting

1:43 so Clojure will resolve either a symbol or a var as a function

1:43 (if used as the first element of a list)

1:44 hiredman: vars defer to their values if called as a function

1:44 cgordon: so it is possible to create a var with no name

1:44 hiredman: ,(.invoke #'+ 1 2 3)

1:44 clojurebot: 6

1:44 cgordon: and possible to have a symbol (name) with no var

1:44 hiredman: ,(.invoke + 1 2 3)

1:44 clojurebot: 6

1:44 cgordon: is it possible to have a var with multiple name?

1:44 names*

1:45 gilbertleung: hi everyone

1:45 hiredman: you can create various kinds of aliases via namespaces, but I don't know if that actually involves vars at all, or just namespace symbol resolution stuff

1:46 my guess is that the namespace alias stuff doesn't do anything to vars, just jiggers the resolution stuff

1:46 cgordon: right, it seems like things are set up so that if you change the value of a var, it can only affect one symbol

1:47 since otherwise you would have all the mutable state problems you get with pointers in languages like C

1:47 hiredman: you shouldn't be changing the values of vars

1:47 cgordon: so if I do (def a "foo"), then (def a "bar")

1:48 hiredman: don't do that

1:48 cgordon: does the second expression create a new var?

1:48 hiredman: I doubt it

1:48 cgordon: alright

1:48 gilbertleung: i downloaded the leiningen script, ran "lein self-install", but all i have is an empty jar in my maven repo

1:48 cgordon: so if I did (def a "foo") then (def b #'a) then (def a "bar"), what would (deref b) return?

1:49 gilbertleung: would anyone have any idea what's going on?

1:49 cgordon: (clojurebot doesn't seem to want me to try)

1:49 hiredman: changing the value of a var is a thread safe swap

1:50 cgordon: is that something you would be inclined to do?

1:50 cgordon: hiredman: not at all :)

1:50 hiredman: I'm just trying to understand the underlying model

1:51 hiredman: thanks a lot, this has been immensely helpful

1:51 hiredman: I have more questions, but I think I can answer most of them by playing with the repl

1:52 hiredman: the reader actually uses anonymous vars to keep track of various pieces of state

1:52 cgordon: how does it access them?

1:53 gilbertleung: anyways, it seems like the version in the leiningen script is wrong; i changed it from 1.0.0-SNAPSHOT to 0.5.0, and now it 's downloading the proper file

1:53 hiredman: (def a (clojure.lang.Var/create))

1:53 that will create a unamed var, that is stored in a var, whose name is something/a

1:54 cgordon: woah

1:54 why would you do that?

1:54 hiredman: (the reader is written in java at the momemt, so it actually stores the unamed var in a java field)

1:54 cgordon: no idea

1:55 cgordon: ah, that makes sense (the reader being written in Java). So the unnamed vars are just being accessed from Java directly

1:55 hiredman: yeah

1:56 cgordon: so that's interesting, vars are mutable, but values (like lists, arrays, maps) are not

1:57 but a var can be a value, so sometimes values are mutable

1:57 hiredman: vars are a special case reference type

1:57 like agents, atoms, or refs

1:58 ,(ref (ref nil))

1:58 clojurebot: #<Ref@1fd3297: #<Ref@45886: nil>>

2:02 cgordon: ah, rtfm, this answers a lot of my questions: http://clojure.org/vars

2:59 adityo: ,(int \A)

2:59 clojurebot: 65

4:04 duncanm: anyone awake?

4:05 AWizzArd: Sure :-)

4:05 Moiners

4:05 duncanm: i'm trying to write a simple method to download some binary files online

4:05 but it doesn't seem to be working

4:05 http://gist.github.com/239370

4:05 AWizzArd: hiredman: I see (about deftype caring about primitives).

4:08 duncanm: i only had a fast look and it looked not bad. Could you maybe print something inside the loop?

4:08 So you will know that the loop is run and you can get some info from inside.

4:08 duncanm: AWizzArd: it runs, but the file seems to be corrupted

4:14 _ato: duncanm: you need to pass bytes to write

4:14 as the buffer may not have been filled

4:14 (eg at the end of the file it might read less than 1024 bytes)

4:15 duncanm: like so: http://gist.github.com/239374

4:16 duncanm: ahh

4:23 _ato: heh, thanks for the tip

4:23 _ato: i feel bad, i ended up going back to using Scheme - i used scsh a lot, and it's super easy to write it in scsh

4:24 because i can just use wget ;-)

4:24 (run (wget --continue ,url))

4:24 the RUN form has implicit quasiquoting

4:34 piccolino: Does anyone know what exactly the sequence of commands you should use for swank-clojure-project in Emacs is?

4:34 duncanm: it's funny to go back to scheme/lisp and seeing all the alists where a plist would be in Clojure

4:36 _ato: duncanm: well if you're going to cheat: (clojure.contrib.shell-out/sh "wget" "-c" url)

4:36 :p

4:36 duncanm: _ato: does that work?

4:36 ooh

4:36 i might have done that

4:36 Maddas: duncanm: Do you know if scsh is still being developed?

4:37 duncanm: Maddas: a few of my friends still dabble in it

4:37 Maddas: we're all students (or in my case, ex-student) of Olin

4:37 Maddas: Neat. I always thought it was awesome :)

4:37 duncanm: Maddas: do you wanna work on it? ;-)

4:37 Maddas: I'm afraid I don't actually use it ;-)

4:37 duncanm: Maddas: if you have a unix machine, you can start using it

4:38 Maddas: I have that, just no strong need :-)

4:38 _ato: piccolino: what do you mean? you don't need a sequence of commands :/ just make a project directory, create src and lib in it and put all the jars you want (including clojure.jar) in lib

4:38 duncanm: Maddas: i've been busy with work, and at work, i use Windows, so i use clojure instead

4:38 * Maddas would not dare touch Olin's code in any way, it would feel like defiling something sacred :-)

4:38 duncanm: Maddas: oh no no

4:38 Maddas: :-P

4:38 piccolino: Hm. That's what I did. But then when I issue swank-clojure-project, it just sits there repeating an error message about Polling on some file in /var.

4:39 Maddas: Oh, wait, I confused Olin and Oleg for a moment. I assume he writes good code too, though :-)

4:39 piccolino: And tells you how to cancel.

4:39 I tried various combinations of starting slime first, or using slime-connect.

4:39 duncanm: oh

4:39 Maddas: well, Olin did SRFI-1 and SRFI-13 ;-)

4:39 _ato: piccolino: hmm... it does that for me if clojure.jar is missing from lib

4:39 duncanm: Maddas: if i had infinite time, i'd love to port the Clojure data structures to Scheme

4:39 Maddas: duncanm: Yeah, I can see that.

4:40 piccolino: Ah, clojure-1.1.0-alpha-.... won't do the trick?

4:40 Maddas: Unfortunately infinite time is mor than a constant factor away :(

4:40 More, even.

4:40 _ato: piccolino: yeah that should be fine, any clojure jar should do :/

4:40 piccolino: Hm.

4:40 Strange.

4:40 duncanm: Maddas: also, some of the clojure syntax i really like, like the [] {} literals, and perhaps the #() shorthand

4:41 Maddas: Yup. It seems like a very nicely chosen trade-off between purity and pragmatism.

4:41 _ato: piccolino: maybe it check it works okay from the command-link. cd to your project dir and do: java -cp "src:classes:lib/*" clojure.main

4:41 piccolino: see if you get a repl

4:41 duncanm: it'd too bad that R6RS defined []s to be identical to ()s ;-P

4:41 _ato: err command-line not link :p I sound like some retro scifi novel

4:41 duncanm: okay, off to bed

4:41 piccolino: Yeah, that gave me a repl.

4:42 _ato: piccolino: hmm very strange

4:42 piccolino: Yeah, thanks for your help anyhow.

4:43 Maddas: duncanm: Good night :)

5:11 Licenser_: good day everyone how is the Clojure World doing today?

5:13 hoeck: Licenser_: fine! thanks

5:13 Licenser_: glad to hear

5:14 I've a not entirely clojure related question, I've been working on a little library and wonder what License to put it under? Any advice, pros cons?

5:16 piccolino: _ato, one last thing. Are you using the most recent version of swank-clojure and clojure-mode that technomancy released?

5:16 Chousuke: Licenser_: well, at least not GPL, because it's not compatible with Clojure's licence.

5:17 Licenser_: I guess EPL is pretty popular.

5:17 Licenser_: Hmm not compatible means I could not do it or I should not do it?

5:17 Chousuke: I'm not really sure about that.

5:18 Licenser_: wait waiiit, does that mean It's not entirely sure that I'm allowed to use GPL'ed code with clojure?

5:19 Chousuke: you're not, as far as I know.

5:19 hiredman: I'd suggest consulting a lawyer

5:20 Chousuke: quote wikipedia: 'The GPL requires that "[any distributed work] that ... contains or is derived from the [GPL-licensed] Program ... be licensed as a whole ... under the terms of [the GPL]."'

5:20 Licenser_: so if a library is under GPL it's technically untoucable from clojure?

5:20 hiredman: the gpl, I believe, has a clause exempting system libraries

5:20 Licenser_: geez

5:20 Chousuke: Licenser_: yep. you can complain to the library makers :)

5:20 hiredman: so if your lawyer feels he can defend clojure as a system library

5:21 Licenser_: this is just nuts o.O

5:21 compleatly entirely nuts

5:21 hiredman: *shrug*

5:21 jabley: Licenser_: are you distributing your work?

5:21 hiredman: never really cared for the gpl anyway

5:21 Licenser_: jabley: I plan to, it is booring to write stuff for your own :P

5:21 Chousuke: the incompatibility is the GPL's fault though.

5:21 jabley: Since it's a library, then I guess so!

5:23 Licenser_: Chousuke: I know that much I got, it still is sadd that Open Source Licenses start to battle each other -.-

5:23 jabley: That falls under the viral aspect of the GPL then (IANAL)

5:24 Licenser_: okay I'm lucky the jsch library isn't GPL'ed

5:24 and the license is short and clear enough so that even I understand it :P

5:25 Chousuke: It's still possible to change Clojure's licence though. I don't think Rich is inclined to do so, but it's at least a possibility.

5:26 Licenser_: Don't get me wrong, I don't mind clojures license - I don't even know wich exactly it is o.O

5:26 Chousuke: it's EPL

5:26 Licenser_: ah

5:26 I'll read up on the EPL then I guess

5:26 hiredman: pircbot, which clojurebot uses, is gpl'ed

5:26 so clojurebot is illegal

5:26 (don't tell anyone)

5:26 Chousuke: oops :P

5:27 hiredman: I'm waiting for FSF to come after me

5:27 Chousuke: quick, refactor it on top of some other IRC library.

5:27 hoeck: to me it looks like the GPL is C-specific, so are there even Java projects that use it?

5:27 hiredman: meh

5:27 Chousuke: Lisp at least has problems with the GPL

5:27 or actually, the LGPL

5:28 you need an additional clause to prevent macros from "spreading" the licence

5:28 tsdh: If you do a GPL project using clojure (or any other incompatible OS license), you can add a simple exception rule.

5:29 Chousuke: tsdh: you still can't use GPL libraries though :/

5:29 tsdh: Chousuke: You mean, use GPL libs in a EPL project?

5:29 Well, yes.

5:30 Till now, I only had problems the other way round.

5:31 Chousuke: hmm

5:32 I wonder if it would be possible to interpret the thing so that you can't distribute Clojure and a GPL project together, but separately it's possible

5:32 fanatico: Using (licensing) gpl'd java code in a non-gpl'd codebase is what you're talking about here. There shouldn't be any problem licensing your own clojure code as gpl.

5:32 Chousuke: see any binary driver for linux.

5:33 hiredman: Chousuke: I think the gpl specifies a certain kind of linkage

5:33 Chousuke: fanatico: those are a grey area

5:33 fanatico: Who would sue who?

5:33 hiredman: (very nonspecificly)

5:33 Chousuke: fanatico: basically, no-one is suing anyone because the binary drivers are useful

5:34 hiredman: fanatico: anyone who recieves the binary drivers

5:34 fanatico: the gpl only deals with distribution.

5:34 the binary drivers are legal, they don't include a single bit of gpl'd code.

5:37 Licenser_: well lunch time here, see you all later :) and thanks for all the advice I'll look into the EPL

5:38 fanatico: Licenser: if its a library, and you'd rather not deal with the legalese, I'd suggest the MIT license.

5:38 hiredman: :D

5:45 djpowell: ure

5:45 offtopic: but does anyone know a minimal web templating thing for java that doesn't think of html-escaping as an afterthought

5:58 rfgpfeiffer: depending on what you mean by "for java", maybe jinja/Jython

5:58 ordnungswidrig: djpowell: I heared good things about stringtemplate.

5:58 hamza: does xml-seq work on large files? or should i look for a java alternative? i am going to be playing with dmoz rdf dump(300mb compressed.) extracting some urls.

6:04 djpowell: ordnungswidrig: yeah me too, but i'm getting the impression that html escaping is an afterthought

6:05 urgh, i hate talk about 'escaping'. it implies that the user is supposed to maybe do some work just to get a string to appear as a string in the output. that's not escaping, that is just the difference between working and broken.

6:07 if some of these tools had PNG output, I think they'd just insert the text string into the file

6:22 hoeck: hamza: xml-seq uses a clojure.xml/parse'd tree, which in turn uses javax.xml.parsers.SAXParser and a ContentHandler to get stuff into clojure maps

6:23 hamza: so I guess its as limited as the SAXParser and your available memory

6:24 hiredman: this came up on the group recently

6:24 there is some library on github that uses, uh, I think it's called a pull parser?

6:26 djpowell: I'd imagine that SAX based parsing should stream fairly effectively. Probably best to just try it?

6:28 hiredman: http://github.com/marktriggs/xml-picker-seq

6:29 hamza: djpowell: right now on a dial up like connection wating for it to download :(, just planning ahead.

6:30 hiredman: thanks for the link.

6:56 octe: anyone using leiningen? i tried it out with self-install, but running any command with lein results in Exception in thread "main" java.lang.NoClassDefFoundError: leiningen.core

7:02 _ato: octe: the download link is broken :( lemme find the working one, just a sec

7:03 octe: try using this one instead: http://github.com/technomancy/leiningen/raw/0.5.0/bin/lein

7:03 octe: _ato: yeah, i just found that too :)

7:04 changed the version in the lein-script to 0.5.0 and it worked

7:04 _ato: cool

7:33 hamza: while using agents, assume that i would like to build a vector of stuff that requires some network i/o, can i pass as much work as i want or do i have say pass 1000 jobs wait a while then pass another, in other words can i dump as much work as i want without bogging the machine?

7:37 _ato: you mean can you just send agents a flood of jobs? I think if your send rate is faster than the rate the agents process jobs that they'll just keep happily accepting them until you run out of memory

7:38 hamza: i mean if i pass them 10k jobs it will not spawn 1k threads right they work on a fixed thread pool.

7:39 _ato: oh right, no it uses a fixed thread pool (as long as you're using send not send-off)

7:39 so yeah, it won't create thousands of threads

7:39 hamza: ,(doc send-off)

7:39 clojurebot: "([a f & args]); Dispatch a potentially blocking action to an agent. Returns the agent immediately. Subsequently, in a separate thread, the state of the agent will be set to the value of: (apply action-fn state-of-agent args)"

7:41 _ato: send-off creates a new thread for each call

7:41 send uses the thread pool

7:43 hamza: _ato: thanks.

7:48 Licenser_: so back from lunch, and thank you all for your advice

7:54 hoeck: Licenser_: wow, that was a long lunch break :)

7:59 hamza: _ato: i was looking at programming clojure book, and it says for blocking actions use send-off if i use send is there a possibility getting corrupt data?

8:00 _ato: hamza: no, the only problem with using send with a blocking action is the thread pool can be used up (which just means everything blocks until a task is finished)

8:01 hamza: ok, i don't mind that. one other thing, for send-off isn't there a limit on number of threads that will be spawned?

8:04 _ato: not sure

8:04 it uses java "CachedThreadPool": http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool(java.util.concurrent.ThreadFactory)

8:05 ah.. "unbounded thread pool, with automatic thread reclamation" so no limit on the number of threads that send-off creates

8:06 gerry`: hello

8:06 what's fn*?

8:07 ,((fn* [x] x) 'me)

8:07 clojurebot: me

8:07 gerry`: same with fn?

8:08 Licenser_: hoeck: ^^

8:08 but it was good pizza

8:09 _ato: gerry`: fn* is the basic version of fn, it doesn't support fancy thins like destructuring binds

8:09 gerry`: fn is a macro that implements the fancier features on top of fn*

8:10 it's mainly for core use, there's no point in using fn* in your own code

8:10 gerry`: _ato: ic, thx

8:13 esj: guys, I've been playing with getting me head around dealing with live data sequences in clojure and have mocked up some code http://pastie.org/707517 showing my current understanding of how this could be done. If anybody has a few minutes to have a look and make a few comments I'd really appreciate it.

8:26 chouser: actually, it's probably even stronger than that -- fn* is unsupported and might change or go away

8:40 AWizzArd: rhickey: is there a plan to support type hints for non-primitive types for deftype? For example hinting something as #^clojure.lang.IPersistentMap?

9:13 gerry`: (deftype person [#^String name #^java.util.Vector sons]) not work?

9:13 deftype support any java type hints

9:14 chouser: I think it's just primitives and Object for now

9:16 gerry`: include compling to class file? AOT

9:17 you mean when i (deftype a [#^anyclass b]) compiled to one object field ?

9:20 AWizzArd: When I call (person 47 11) I get a person instance.

9:20 If I had hinted those fields as #^long and gave \x or "hi" as arg, then I would have gotten an Exception.

9:34 octe: lol

9:34 my slime/swank/emacs setup has been broken for months

9:35 got "Lisp connection closed unexpectedly: connection broken by remote peer" when i tried to run M-x slime or M-x slime-connect to an external swank-server

9:35 solution: echo "anything" > ~/.slime-secret

9:36 Licenser_: there we go :D my first github project ^^

9:47 AWizzArd: Can any slime user please confirm that swank-clojure does not work with new versions of slime?

9:48 repl starts up in emacs but does not eval any inputs

9:51 aking: AWizzArd: yup - it's broken - see the slime thread here: http://thread.gmane.org/gmane.lisp.slime.devel/9178/focus=9197

9:51 esj: AWizzArd: Something has gone haywire. I was under the impression it was Clojure > 1.0 that was causing the issue, but am unsure. My repl starts but doesn't connect properly with slime.

9:55 AWizzArd: aking: so it seems that slime is broken, and not swank-clojure?

9:56 esj: 1.1 alpha was working perfectly in slime until recently

9:56 aking: I guess that's the point that's being 'debated' - who's the more broken.

9:59 esj: AWizzArd: OK, thanks. My experience started with a clj upgrade that took everything down, so I guess I'm pointing finger unfairly :)

10:00 AWizzArd: chouser: currently it is not decided if deftypes are j.u.Map right? So, assoc, update-in, etc. won't work?

10:02 chouser: AWizzArd: "If you specify IPersistentMap as an interface, but don't define methods for it, an implementation will be generated automatically."

10:02 AWizzArd: k

10:06 Btw, is there a sorted-set-by?

10:06 chouser: AWizzArd: in sufficiently recent versions of clojure, yes.

10:07 AWizzArd: ah, so it is in Master, but not in New

10:11 tmountain: reading the docs for require, I see that it allows you to operate on all files matching a given prefix, but I can't figure out how this works. can anyone give an example?

10:15 AWizzArd: (require '[clojure.contrib def str-utils])

10:16 tmountain: or even more useful: (require '[clojure.contrib [def :as d] [str-utils :as su]])

10:18 tmountain: AWizzArd: sweet, is it possible to require everything in a given namespace?

10:18 AWiizzArd: kind of like in Java, import java.util.*;

10:46 ordnungswidrig: Is there sth like when for multiple test/body pairs?

10:46 Chousuke: cond?

10:47 ordnungswidrig: Chousuke: I'll check.

10:47 Chousuke: see also condp

10:47 ordnungswidrig: Chousuke: thx

11:30 Licenser_: so my first clojure lib, if someone wants to take a look and give me some input if it's good/bad I'd be very glad (http://github.com/Licenser/Clossher)

11:37 fro0g: Licenser_: sorry for being picky, there's a spelling error in the README.

11:37 howt he -> how the

11:38 commands,c onnect -> commands, connect

11:52 Licenser_: fro0g: thank you that isn't picky but helpfull :)

11:53 fro0g: Licenser_: glad to be of service :)

11:53 Licenser_: ^^

11:55 ulfster: Licenser_: is it alright that the first example is (with-session "user" "host" "ip"

11:55 and the second (with-session "user" "pass" "host45"

11:55 seconds version makes more sense to em

11:55 to me

12:08 Licenser_: ulfster: you'Re right, messed up there

12:10 johnmn3: Is clojars.org broken right now?

12:12 chouser: seems to work for me

12:13 johnmn3: I've been trying to upload a basic jar

12:13 chouser: oh, I haven't tried uploading yet

12:14 johnmn3: it looks like only 2 or 3 people have.. unless uploading is broken atm

12:14 I would have thought there'd be a little more uploaded, even now.

12:19 oh, it's working I think!

12:29 nope

12:29 is there a forum to discuss clojars/lein issues?

12:31 looks to me like scp isn't actually uploading it

12:31 hello-world.jar 100% 1976KB 1.9MB/s 00:00

12:31 I know my connection can't upload 2 megs in under a second.

12:33 technomancy: johnmn3: there's a #leiningen channel

12:34 and a mailing list on google groups, but IRC is probably quicker

12:34 johnmn3: ahkkkhaa, thank you

12:37 StartsWithK: lisppaste8: help

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

12:40 StartsWithK pasted "Classloader problem in 1.1a" at http://paste.lisp.org/display/90807

12:41 StartsWithK: when i tried clojure 1.1 i get this error i didn't have with 1.0

12:41 any ideas how to fix this?

12:48 Licenser: I am back, fear my incompetence!

13:33 mrSpec: Sorry about this question... but how can I push element to list ? I've found pop function, but cant find push...

13:33 chouser: conj

13:34 mrSpec: ah, thanks :)

13:59 hiredman: technomancy: any particular reason lein uses #!/bin/bash instead of #!/bin/sh ?

13:59 (the whole world doesn't have bash installed in /bin/

14:03 danlarkin: hiredman: oversight I'm sure

14:07 tmountain: if you do a (seq? [1]), you get a false, but you can obviously still call (first [1]) and other ISeq functions, is there some implicit conversion that happens behind the scenes?

14:17 StartsWithK: what is with-loading-context?

14:18 chouser: tmountain: yes, most fns that operate on seqs call seq on their collection argument first

14:19 technomancy: hiredman: I didn't want to depend on any bash-specific functionality by accident without being explict about it

14:19 since on Linux /bin/sh *is* /bin/bash

14:20 Licenser: so not on solaris

14:20 technomancy: didn't realize anyone kept bash out of /bin

14:21 ohpauleez: ? who does that?

14:21 chouser: BSD

14:21 Licenser: solaris's /bin/sh is a very simple shell

14:21 ohpauleez: ahh

14:22 arbscht: technomancy: debian squeeze uses dash

14:23 Licenser: geez the sh under solaris not even sais who it is :P

15:04 defn: 'lo

15:23 StartsWithK: uf, ok, what is this DynamicClassLoader and why am i losing it?

15:24 i am trying to load a clojure file with my own calls to read and then eval

15:24 but in separate namespace from my own

15:25 hiredman: StartsWithK: lets see some code

15:25 StartsWithK: everything work, but i get this error when doing add-classpath

15:26 hiredman: ah

15:26 well

15:26 ~add-classpath

15:26 clojurebot: add-classpath is Fraught with Peril!

15:26 hiredman: ~add-classpath

15:26 clojurebot: add-classpath is Fraught with Peril!

15:26 hiredman: hmmm

15:26 yeah, so don't use add-classpath

15:27 StartsWithK: http://paste.pocoo.org/show/151979/

15:27 well i have to use add-classpath

15:27 but that is not the problem

15:27 if i do simple (eval '(add-classpath (.toURL (File. "test"))))

15:27 it works

15:28 i thint problem is with my namespace usage

15:28 think*

15:28 hiredman: the problem is add-classpath should not be used

15:29 StartsWithK: in clojure 1.0 it works

15:29 hiredman: if you use add-classpath you will see odd classloader failures here and there

15:29 StartsWithK: *shrug*

15:29 StartsWithK: so.. i will have to start new jvm instance?

15:29 hiredman: just put the things you need on your classpath on your classpath

15:30 StartsWithK: i can't do that

15:30 i don't know before runtime what that path will be

15:30 also, works in 1.0, and in repl inside user namespace just fine

15:31 hiredman: so?

15:32 add-classpath behaves unpredictably, using it's past behaviour to try and predict it's future behaviour is silly

15:33 StartsWithK: its not silly, its silly that it dosn't work

15:34 hiredman: the reason people are told not to use add-classpath is it inevitably leads to just this kind of weird mode of failure

15:34 dnolen: StartsWithK: there any many reasons why it might not work, it was only designed for one and one thing only - for interaction at the REPL - not for code. rhickey has explicitly said as much.

15:34 StartsWithK: ok, what is then *the* way to add classpath at runtime?

15:35 some external java library?

15:35 dnolen: there is no reliable way to do that. I'm curious as to why you don't know the classpath until runtime.

15:37 kzar: say if an function takes 3 numbers for its arguments, you can't pass it (repeat 3 example-num) because that gives it a seq of the 3 numbers. Is there a way to do that?

15:37 the-kenny: kzar: apply

15:37 ,(doc apply)

15:37 clojurebot: "([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."

15:37 the-kenny: (apply + (take 10 (iterate inc 0)))

15:37 ,(apply + (take 10 (iterate inc 0)))

15:37 clojurebot: 45

15:38 StartsWithK: dnolen: plugin system, position of test and source files i need to compile and execute tests on specified as properties in build script

15:38 first one not a problem for now, but it will be in the future too

15:38 kzar: the-kenny: I want to do something like (fun-example (repeat 3 example-num)) instead of (fun-example example-num example-num example-num). Does apply apply?

15:39 the-kenny: kzar: You want to apply for example [1 2 3] as three seperate arguments to a fn?

15:39 That's exactly what apply does.

15:42 dnolen: StartsWithK: so this an issue with your development environment?

15:43 StartsWithK: dnolen: not realy, this is the build system app, it has to read a build script

15:43 and it looks like i lost my current thread classloader when i switched namespaces

15:44 dnolen: StartWithK: any reason you can dynamically output build instructions to be read by some like lein?

15:44 can't

15:46 kzar: the-kenny: I was trying to be a smart arse and figure out a way of avoiding typing rand-int three times. (new Color (rand-int 256) (rand-int 256) (rand-int 256))

15:47 the-kenny: I tried (apply #(new Color %) (repeat 3 (rand-int 256))) which doesn't work + I noticed that repeat seems to only eval the thing once.. so the random numbers are all the same

15:47 StartsWithK: dnolen: lein is to different from what i have in mind

15:48 the-kenny: kzar: Use repeatedly

15:48 ,(doc repeatedly)

15:48 clojurebot: "([f]); Takes a function of no args, presumably with side effects, and returns an infinite lazy sequence of calls to it"

15:48 the-kenny: ,(take 4 (repeatedly rand-int))

15:48 clojurebot: java.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args passed to: core$rand-int

15:49 the-kenny: ,(take 4 (repeatedly #(rand-int 256)))

15:49 clojurebot: (168 188 153 49)

15:49 rlb: (take 3 (repeatedly #(rand-int 256)))

15:49 StartsWithK: when executing the load-build, and while i am inside in this generated namespace, my classloader is set to com.sun.misc.Launcher$AppClassLoader

15:51 mrSpec: How can I do something like "(loop for i from 0 to 1 by 0.1 do (print i)" in Clojure, the simpliest way?

15:51 the-kenny: mrSpec: (doseq [i (range 0 1 0.1)] (println i)) or so

15:51 StartsWithK: hmm.. my classloader is set to that even before i start to load the script

15:51 the-kenny: ,(range 0 1 0.1)

15:51 clojurebot: (0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6 0.7 0.7999999999999999 0.8999999999999999 0.9999999999999999)

15:52 the-kenny: (silly floating point numbers)

15:52 hiredman: (yay floats!)

15:55 Knekk: what's the easiest way to count the number of times x is in a coll?

15:55 mrSpec: thanks!

15:55 the-kenny: Knekk: I would do it so: (count (filter #(= s %) seq))

15:55 Knekk: thanks :0

15:58 rlb: Just out of curiousity, does clojure actually (incrementally) allocate the result list in the (count (filter ...)) case, or is it capable of optimizing that away?

15:58 StartsWithK: dnolen: leiningen has hardcoded source directory in code, and in launcher script

15:58 the-kenny: rlb: Clojures makes heavy use of lazy evaluation

15:58 robewald_: hi, I have problems with swank-clojure. Everytime I try to use completion emacs hangs and I don't know where to start looking closer into the problem.

15:59 StartsWithK: it is "src" by default and it looks like you can't change that

15:59 the-kenny: rlb: If you do something like (map heavy-function (range 1e100)), it will do nothing before you access an element in the list.

15:59 rlb: the-kenny: right, but that's not quite what I'm asking -- i.e. filter can't "know" what's being done with the result...

16:00 the-kenny: ,(doc filter)

16:00 clojurebot: "([pred coll]); "

16:00 rlb: the-kenny: right, but will it allocate 1e100 times when it doesn't need to.

16:00 i.e. in lisp, you'd need to allocate 1e1000 cons cells, even if you don't keep any of them.

16:00 the-kenny: I think it won't do that either until you access an element from the map

16:00 ,(doc range)

16:00 clojurebot: "([end] [start end] [start end step]); Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step, where start defaults to 0 and step to 1."

16:00 rlb: the-kenny: I'm not sure it's clear what I'm asking.

16:01 the-kenny: ahhh sorry

16:01 Now I've got it

16:01 hm.. dunno if it keeps everything in memory, sorry.

16:02 rlb: i.e. you *could* rewrite the count via recur and avoid allocating any (temporary bits) of the result list that count counts.

16:02 (Though I'm not saying it would necessarily be worth the effort -- just curious ATM.)

16:10 _mst: rlb: I would expect count to consume the seq one element at a time and for that element to be immediately available for GC--it shouldn't need the whole thing in memory at once at any point

16:11 rlb: _mst: right - I just wondered if it could avoid that per-item gc.

16:12 _mst: I'm not sure that it could... it needs to produce the 'next' item to find out whether it's finished or not

16:16 rlb: Yeah -- it's clear how you might translate that by hand, but perhaps not automatically (at least not easily).

16:32 technomancy: robewald_: does it say anything in *inferior-lisp* ?

16:44 Knekk: hmm, is there something like clojure.set/intersection that will not dedupe?

16:45 , (clojure.set/intersection #{1 2 2 2} #{1 2 2 8 9})

16:45 clojurebot: #{1 2}

16:45 Knekk: should return #{1 2 2}

16:48 hiredman: Knekk: sets hold unique elements

16:48 you cannot have #{1 2 2}

16:48 ,#{2 2}

16:48 clojurebot: #{2}

16:48 Knekk: yeah, wasn't clear. something like set/intersection, for lists

16:49 my bad, too distracted

16:50 StartsWithK: ok, i think i see now why this is working in repl only, in clojure.main/repl function (the one called when using clojure.main -r) function is changing the classloader to clojures dynamic classloader

16:51 but when executed with only clojure.main, this is not happening, so (add-classpath (.toURL (File. "test"))) works from repl, but not if you save that in file and load with clojure.main

16:52 ohpauleez: Knekk: I would just filter the two vectors

16:56 jasapp: speaking of sets..

16:57 is there a better way of getting a list of unique items rather than calling (seq (set my-list))

16:58 that's probably a horrible way to do it, but it's what I've been doing lately

16:58 hiredman: ,(doc unique)

16:58 clojurebot: Huh?

16:58 hiredman: ,(doc uniq)

16:58 clojurebot: It's greek to me.

16:58 hiredman: bah

16:59 ,(doc distinct)

16:59 clojurebot: "([coll]); Returns a lazy sequence of the elements of coll with duplicates removed"

16:59 jasapp: ahh, distinct

16:59 hiredman: that being said, I generally just call set

16:59 chouser: if you don't need lazy, 'set' might actually be better

16:59 jasapp: ok

17:08 ohpauleez: chouser: I have a question about contrib/conditions that you might be able to answer

17:09 does it fully unwind the stack when an exception happens or does it hold it's place while it looks for a match via handler

17:10 ie: Is it like regular Java exceptions underneath or is like CL conditions

17:10 ?

17:13 chouser: I think acts like a regular java throw/catch. The difference is you don't need to AOT compile to get a new unique exception class.

17:13 ohpauleez: right, thank you. That's what I thought

17:14 chouser: the exception class it provides allows you to stash whatever info you want in there, and catch it based on whatever criteria you want instead of just exception type hierarchy

17:14 if you want something more like CL conditions, you might look at error-kit

17:14 also in contrib

17:14 ohpauleez: is that your thing?

17:14 chouser: yes

17:15 ohpauleez: ah, thank you. I'll have a look

17:15 chouser: error-kit currently has a ill-conceived mini object-model in it that I have vague plans to remove. :-P

17:16 ohpauleez: haha, it looks awesome though

17:19 qed: hmmm i wonder if there will be a live feed of the clojure talk tomorrow at rubyconf

17:19 by s. halloway

17:19 technomancy: qed: it's not live, but it should be available in a few weeks

17:20 ohpauleez: Good ol' stu is giving a tALK?

17:20 ah awesome, please hit the mailing list with a link when it becomes available

17:21 qed: im trying to talk my friend into qik'ing it

17:22 so i have some awfully slow code that id like to speed up, was wondering if anyone here had any thoughts...

17:23 ohpauleez: what does the profiler say?

17:23 qed: http://www.devinwalters.com/posts/21

17:23 i havent used it

17:24 ohpauleez: I'd start there, and figure out where you're spending your time. Make your highest called area faster if you can, and speed up where you spend the majority of your time

17:24 qed: right now it takes like 30s to run

17:24 ohpauleez: I'm looking at the code now

17:25 qed: count-and-track seems like the problem

17:31 ohpauleez: qed, do any repeat, if so you could memoize some of it

17:32 another thing you can do is partition the original set, and send agents off

17:33 mjm: wow it's been a long time since i visited clojure land

17:33 ohpauleez: welcome home

17:33 mjm: thank you

17:34 ohpauleez: qed: I have no basis for this claim, but loop might be faster than recur'ing back to the fn call with a let

17:34 * mjm tries to figure out what's changed since around may

17:39 qed: ohpauleez: thanks

17:40 chouser: I'm pretty sure recur'ing to a fn is just as fast as recur'ing to a loop.

17:40 ohpauleez: qed: no problem, I'll play around with it this weekend and see if I get anywhere. Please post a follow up blog post with results from whatever you do

17:41 chouser: it doesn't save you the cost of the let biding?

17:41 binding*

17:44 chouser: in the outer-most loop? I'd be surprised if it made a noticable difference.

17:44 qed: you might want to look at using primitive numbers. Everything you've got there is boxed.

17:46 ohpauleez: qed: http://clojure.org/java_interop#toc36

17:46 also: http://gnuvince.wordpress.com/2009/05/11/clojure-performance-tips/

17:47 primitives + binary ops + == + partition and agent should get you there

18:04 kzar: you can't put numbers in function names?

18:05 hiredman: eh?

18:06 functions don't have names

18:07 functions can be stored in a var which has a name, or bound locally to a name

18:07 qed: kzar: you can put numbers in function names

18:07 hiredman: in which case the name is a symbol

18:07 you can read about symbols: http://clojure.org/reader#toc1

18:08 kzar: I did (defn 2d-array ...) and it gave me a invalid number java error

18:08 hiredman: kzar: did you read about symbols yet?

18:08 the first line there

18:09 kzar: ok so another answer would have been "you can but not at the start"

18:09 qed: yes

18:10 pretty standard for most programming languages ive worked with...

18:11 hiredman: kzar: yes, but that answer is not as informative as the reader page on clojure.org

18:12 gbt: hiredman: I'm a noob at lisp so I always like reading your answers as I'm hoping you'll drum the finer details into my think skull :)

18:13 kzar: yea that's true, I'll read it again. I have been reading that stuff and watching the videos but it reached the point where I needed to try writing some code

18:14 qed: kzar: yeah, hiredman is a good reference, but he will generally point you at stuff and tell you things that are of no direct importance to you at the moment

18:15 hiredman: :|

18:15 qed: no offense hiredman, just saying -- the guy wanted to know if he can start a fn name with a number, a simple yes or no would have sufficed

18:18 _mst: or "mu" :)

18:20 hiredman: last time I answered a question with "mu" I got banned from that channel

18:20 _mst: some people have no sense of humour

18:20 qed: lol

18:20 mu just proves you've read GEB

18:21 hiredman: or read a book or two on zen

18:21 qed: i appreciate the mu answer tough

18:21 42 is also acceptable

18:22 the-kenny: 42 is always acceptable.

18:23 fanatico: With the latest clojure, I'm getting a bunch of "java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V". Something break?

18:25 hiredman: fanatico: means you need to recompile contrib

18:27 kzar: oo I like clojure already

18:27 fanatico: Just noticed the clojure-contrib 'new' branch. I guess I should be using that instead of the master branch?

18:27 hiredman: fanatico: not unless you are using the 'new' branch of clojure

18:28 and even then, you don't have to

18:29 fanatico: hiredman: odd. My clojure-contrib is up-to-date (at least with master), and built using the proper clojure jar.

18:29 hiredman: fanatico: ant clean and rebuild it

18:30 fanatico: hiredman: that did it. thanks.

18:32 hiredman: clojurebot: clojure.lang.RestFn is <reply>ant clean and rebuild contrib

18:32 clojurebot: In Ordnung

18:33 the-kenny: Wow.. I just thought "We should clojurebot teach to say this"

18:41 qed: (defn make-adder [x] (let [y x] (fn [z] (+ y z))))

18:42 (def add2 (make-adder 2))

18:42 (add2 4) ; -> 6

18:42 that's so cool...

18:43 jasapp: just wait, if you use them long enough, you'll be pissed when you have to write in a language that can't do that

18:43 qed: im already getting there

18:43 im on the brink of lisp snobbery

18:43 and it feels so good

18:43 lol

18:44 there's already sort of a running rule going between me and some of my programmer friends

18:44 when they're complaining about a problem they're having in x language, i cannot mention clojure

18:45 cause they will just get angry

18:45 jasapp: I had to stop talking about lisp with my friends that program

18:45 their eyes just glaze over anymore

18:45 qed: yeah it kind of sucks

18:46 i feel like im imparting wisdom

18:46 and they feel like im being a cocky jerk

18:46 once i start telling them "ummm yeah, it's slow, you're using mutable data structures, what do you expect?"

18:46 they just glare at me

18:46 jasapp: "oh no, he's talking about the benefits of consistent structure again"

18:46 gbt: now you know what all the old lispers felt like for the last 40 years :)

18:46 qed: lol

18:46 gbt: hear hear!

18:47 people who think lisp is just an academic sort of exercise are in for a rude awakening if clojure keeps the pace

18:48 tomoj: mutable data structures slow?

18:48 jasapp: waiting for locks?

18:49 qed: what jasapp said

18:49 jasapp: really? that's weird

18:49 qed: ?

18:50 jasapp: it's slow because the code is waiting for locks?

18:50 qed: jasapp: is that not a benefit of consistent structure?

18:50 in concurrent applications...

18:51 jasapp: I was thinking mostly of the ability to write macros when I said consistent structure

18:52 qed: deterministic behavior in the presence of concurrency

18:54 jasapp: ahh

18:54 tomoj: oh I see

18:54 jasapp: when I said consistent structure, I was talking about how the language was written in one of it's own data structures

18:54 tomoj: I thought you meant basic algorithms for data structures

18:54 where mutable is usually faster

18:54 qed: ah

18:54 yea

19:04 no matching method found for aget?

19:05 JayM: what do people write with clojure?

19:06 i'm interested, but can't think of a project through which to learn

19:10 _mst: hm, can anyone think of a reason that clojure.core/memoize couldn't be modified to use a (transient {}) for its cache?

19:10 some code I'm fiddling with gets a nice little speedup (about 30%) from switching it to use transients

19:10 and I can't see anywhere else in clojure's source that depends on memoize

19:11 _ato: hmm.. are transients thread safe?

19:11 Knekk: hmm, for mutable variables I'd wanna use (ref) ?

19:11 _mst: it's wrapped in an atom

19:11 hiredman: "That's all there is to using transients, but they have another important property: Transients enforce thread isolation."

19:11 _ato: yep but atoms only get you thread-safety with immutable data structures, transients aren't

19:12 hiredman: http://clojure.org/transients

19:12 _mst: ahh yes

19:12 _ato: ah cool

19:12 gbt: JayM: what sort of programs do you normally like to write? its probably better to stick to a problem you understand if you're just learning the language

19:12 _mst: so it'll blow up if two threads try to access it :) oh well

19:14 hiredman: if you are looking at transients because they are mutable, that is a mistake, while transients are mutable, they are designed as a drop in replacement optimization, not for use unless you have alread designed around the immutable datastructures and need to optimize

19:15 _mst: yep, I was looking to squeeze better performance out of qed's code above through dirty trickery :)

19:15 chouser: if you want a mutable collection, use one of java's

19:19 fanatico: and there are bigger problems with using memoize as at a production-level besides speed. It holds onto every (args,result) pair, so the map can expand to take over all available memory.

19:19 littleidea: (not-every? nil? '(1 nil 2))

19:20 StartsWithK: ok, is the only way to load, in clojure, something at runtime to launch another jvm instance with updated classpath?

19:21 hiredman: StartsWithK: you can just load a clojure file

19:21 StartsWithK: hiredman: and for non clojure parts?

19:22 hiredman: *shrug*

19:22 StartsWithK: lets say i want to load my ant wrapper, how will i do that?

19:23 hiredman: I can't say I looked at your code at all after you mentioned add-classpath

19:23 StartsWithK: or bether yet, lets say in my build is something like (plugin proguard) so the build will require a proguard to execute, and i need to first fetch it from remote repository

19:23 hiredman: but if you have ant.clj, you do something like (load-file "ant.clj")

19:24 StartsWithK: and ant.jar? i can't find a way to load that

19:24 hiredman: StartsWithK: technomancy was doing something where he unpacked jars into a directory

19:24 StartsWithK: that requires a restart

19:24 hiredman: not the last I heard

19:25 _ato: StartsWithK: it's a limitation of the way the JVM's classloader hierachy works, you can't reliably change the classpath at runtime

19:25 hiredman: you put ./foo/ on the classpath and unzip jars into ./foo/

19:25 StartsWithK: _aot: yes you can, or something like osgi (and eclipse) would never work

19:26 _ato: you can create a new classloader and load things in that

19:26 but it's hard to get it to work for all jars, as you've seen with add-classpath

19:26 StartsWithK: _ato: not realy, at least i don't know any way to do it in clojure

19:27 hiredman: i'll try that, if it works.. wee

19:27 _ato: just do whatever eclipse and osgi do

19:27 tomoj: I don't like that swank-clojure-project adds the jars in lib/ to the classpath instead of adding lib/*

19:27 _ato: I assume they probably use some scary thing like this: http://classworlds.codehaus.org/

19:27 tomoj: I wonder if there's a reason it does that

19:28 _ato: tomoj: lib/* doesn't work with java 5

19:28 tomoj: ah

19:28 if I patch it to use lib/*, I should be able to drop a jar in there and load it without restarting, right?

19:28 _ato: nope

19:28 StartsWithK: _ato: i would use osgi i could :)

19:29 if*

19:29 tomoj: oh, lib/* is just sugar for listing all the jars in lib/?

19:29 _ato: java just expands the * on startup, it won't monitor the directory and add new stuff you drop in

19:29 tomoj: darn

19:29 oh well

19:30 _ato: yeah... the way java handles classpaths is just a huge nuisance :(

19:32 StartsWithK: hiredman: wow, that worked!

19:32 any side effect with meta-inf stuff?

19:40 hiredman: StartsWithK: no idea

19:46 StartsWithK: thanks for help, night all

19:53 lisppaste8: timbray pasted "contrib build borked?" at http://paste.lisp.org/display/90831

19:53 joshua-choi: Hey, has anyone played with the new deftype/protocol features for Clojure 1.1?

19:54 twbray: Taking all the defaults, can't seem to build the clojure-1.0.0-compatible contrib... http://paste.lisp.org/display/90831

19:56 * twbray sighs heavily.... Maven crap

19:57 twbray: Surely there must be a way to get clojure-contrib without building a Maven environment?

19:58 spuz: twbray: last time I used it, the contrib build was just an ant script

19:58 joshua-choi: I'm pretty sure it still has the ant script

19:59 Have you tried "cd your-contrib-directory; ant"?

19:59 twbray: spuz: Yep, it's ant all right, but by default it fails unless you have some Maven dung in place

19:59 spuz: twbray: what's the error?

20:00 twbray: spuz: http://paste.lisp.org/display/90831

20:00 joshua-choi: I don't know anything about Maven, but I don't even have it installed on my computer—but building with Ant works for me

20:00 twbray: The README.txt seems to say perfectly clearly that some Maven Ant Tasks are required to build. pfffffffffffffffffrghl

20:01 spuz: twbray: that looks like an ant error, not a maven error...

20:01 twbray: spuz: Agreed

20:02 spuz: twbray: are you building off the latest version of the master contrib branch?

20:02 twbray: spuz: clojure-1.0-compatible branch

20:03 Maybe I have an old ant here. Never mind, off to shave yaks.

20:04 spuz: what version of ant do you have?

20:04 twbray: spuz: OMG from 2005. <blushes>

20:04 Just ignore me for a while

20:10 technomancy: twbray: shouldn't you be working on *ruby* at rubyconf? =)

20:10 * technomancy is guilty of the same, don't worry.

20:11 technomancy: as is stuart h

20:11 and possibly ola bini too

20:14 kzar: Is there a way to do something like range but with just the start number?

20:16 _ato: (iterate inc 5)

20:16 to start at 5 and keep going forever

20:20 kzar: ah sweet

20:48 djork: Is there a handy fn to turn a keyword into a "clean" string?

20:49 _mst: ,(name :foo)

20:49 clojurebot: "foo"

20:49 hamza: ,(name :keyword)

20:49 clojurebot: "keyword"

20:49 tomoj: what is refer-clojure for?

20:50 I used to put (:refer-clojure) in my ns declarations, but stopped and noticed no difference

20:51 fanatico: It's included automatically.

20:51 You'd use :refer-clojure to exclude certain functions, for example.

20:54 tomoj: ooh

20:54 thanks

20:54 so (:refer-clojure) is redundant

20:55 ah yes, now I understand. I peeked at the source for ns and was confused that it refers to clojure.core when there's no (:refer-clojure), which seems backwards

20:59 I feel like it might be cool if ns could be extended

20:59 would that be cool or evil?

21:00 I guess that doesn't even make sense because you'd need to load your extensions before using them

21:20 polypus: would be nice if else were def'd in core to true. conds would look a bit nicer imho

21:20 no :else

21:21 hiredman: any non-nil value will do

21:21 well

21:21 besides false

21:21 polypus: yeah, i'm just thinking of the aesthetics more than anything

21:23 (cond p x q y else z)

21:27 tomoj: your idea is to replace :else with else?

21:28 hiredman: you wouldn't have to (def else true) in core

21:29 just stick a let in the cond macro expansion

21:29 * chouser prefers :else

21:30 qed: anyone care to explain (defn make-adder [x] (let [y x] (fn [z] (+ y z)))) (def add2 (make-adder 2)) (add2 4)

21:31 How does (fn [z] get 4)?

21:31 err (fn [z]) get 4?

21:32 tomoj: make-adder returns that fn

21:32 you then name that fn add2 and pass 4 to it

21:32 qed: yeah i just noticed that

21:32 hiredman: make-adder evaluates to (let [y x] (fn [z] (+ y z)))

21:32 tomoj: is there a reason for that let?

21:32 hiredman: with each x replaced with 4

21:33 tomoj: it is from one of the examples on clojure.org, demoing closing over locals

21:33 tomoj: seems to work just fine without the let renaming

21:33 hiredman: tomoj: sure

21:33 tomoj: oh, hmm

21:33 is closing over locals significantly different from closing over fn params?

21:34 hiredman: I've never looked at let

21:34 tomoj: are fn params significantly different from let locals?

21:35 I mean, fn params are "locals" too, right?

21:35 hiredman: fn params are fields

21:35 er

21:35 no

21:35 thats not right, closed over values are fields

21:38 huh

21:38 tomoj: huh

21:42 qed: there was this example i wass looking at that showed how you can do something like (10 fn) i think

21:43 it was something that seemed counterintuitive to me

21:43 tomoj: taht doesn't look right to me

21:43 qed: like you could call 10 on a function

21:43 tomoj: 10 doesn't implement IFn

21:43 qed: or you could call something on a function that didnt seem normal

21:43 hiredman: you can't

21:43 :foo

21:43 qed: maybe it was something like ([] fn)

21:43 hiredman: or 'foo

21:43 sure

21:43 ,([1 2 3] 0)

21:43 clojurebot: 1

21:44 qed: oh right :)

21:44 tomoj: what do symbols do as functions?

21:44 hiredman: just keywords

21:44 like

21:44 tomoj: oh yeah I see

21:44 ,('foo {'foo 3})

21:44 clojurebot: 3

21:49 rhickey: aargh - my messages to the group seem to be going to the ether :(

21:58 JAS415: you need to get approved by a moderator... oh wait... :-P

22:01 hamza: is there a merge like function that will add keys together or do i have to roll my own?

22:02 jkkramer: ,(doc merge-with)

22:02 clojurebot: "([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."

22:04 hamza: thank you. that worked.

22:17 JAS415: ,(doc i-need-something-to-persist-data)

22:17 clojurebot: I don't understand.

22:17 JAS415: ,(doc it-doesn't-have-to-be-sql)

22:17 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$my-doc

22:20 joshua-choi: I've got a question about the datatypes in Clojure's new branch

22:20 I want to deftype a type so that it can be compared for equality with vectors and lists

22:21 hamza: JAS415: you can write objects using clojure.core/prn to a file as string and read it back using clojure.core/read-string..

22:21 joshua-choi: Is that possible at all, like by overriding interface methods?

22:22 Say, it has two fields: (deftype result [product state])

22:22 (I meant (deftype Result ...))

22:22 Can I override any interface methods to get it so that (Result :something :some

22:23 Oops... can I make it so that (= (Result :x :y) [:x :y])?

22:23 JAS415: yeah i was thinking i would work with that idea. it would be cool if you could encode the binary forms for the objects being that a lot of them implement serializable

22:24 _ato: joshua-choi: I think so. Looking at the source of vector's equality test you just have to implement either the List or Sequential interfaces

22:34 zaphar_ps: Why is clojure not picking up the classes in my classpath?

22:35 joshua-choi: _ato: Thanks, I'm trying that out now.

22:36 zaphar_ps: http://clojure.pastebin.com/m5a7d668

22:36 it is pointed at the contrib jar

22:37 yet does not see the contrib namespaces

22:37 * zaphar_ps is confused

22:37 _ato: zaphar_ps: did you mean "use" instead of "refer"?

22:37 zaphar_ps: use had the same problem

22:37 that was attempt number three

22:38 I'm using head from github as of yesterday if that makes a difference

22:38 about to pull down any changes and recompile to see if that fixes it

22:39 _ato: strange... yeah maybe there's something wrong with your contrib jar

22:39 zaphar_ps: nothing in my classpath works

22:39 the previous compiled version did work

22:40 the clj-stacktrace.repl namespace is unavailable as well

22:40 and I haven't recompiled that and it worked before

22:40 _ato: weird

22:41 zaphar_ps: very

22:41 _ato: you should be getting a could not find types.clj error

22:41 not namespace is unavailable

22:41 zaphar_ps: if I do a use I get: java.lang.ClassNotFoundException: clojure.contrib.types

22:41 _ato: did you quote it?

22:42 that's what I get if I do (use foo) instead of (use 'foo)

22:42 zaphar_ps: no I did not

22:42 heh

22:42 * zaphar_ps slaps forhead

22:43 _ato: yeah, I'm always making that mistake as well. (use '...) needs a quote while (ns (:use ...)) doesn't

22:43 JAS415: that'll happen the first 10 times or so

22:43 zaphar_ps: now that I feel stupid I'll go back to learning this clojure stuff :-)

22:43 JAS415: i have a post-it next to my computer about that

22:43 zaphar_ps: heh

22:44 _ato: yeah I think the :use vs use difference is what thew me

22:46 I was building a tap testing library as a learning excercise and just noticed that the clojure test lib has one already :-)

22:46 same namespace as mine whoops

22:47 well not exactly same namespace cause mine doesn't have the clojure prefix

22:52 in clojure what's the preferred way to prefix your namespaces for libraries?

22:55 tomoj: I use the java convention

22:55 (reverse domain name)

22:56 zaphar_ps: I see some doing name/last/first

22:56 is that standard for individual contributors?

22:56 _ato: that's a domain name

22:56 last.name

22:58 personally I don't like the domain name thing, so I just try to choose a unique name for the project

22:58 but the domain-name way is probably more popular

23:01 zaphar_ps: ahhh ok

23:14 tomoj: I like unique names better too

23:14 but I suck at thinking of them

23:14 so I just use my domain name

23:15 technomancy: tomoj: just be aware that if the project ever outlives your interest it will be awkward to move

23:15 tomoj: when using the domain name?

23:15 technomancy: yeah

23:15 * technomancy is a fan of library-name.core

23:16 tomoj: I want a web app that just generates random unique names for software

23:16 ...that are relatively pronouncable - not just strings of random characters :)

23:17 I guess I can do fairly well by using lojban lujvo, maybe I'll try that

23:19 hamza: is there a some like function that will give me a boolean i am checking a map against a vector like (some {"a" 2 "b" 4 "c" 5} ["c" "b"]) but i want a true false value not the value form the map?

23:20 tomoj: why do you want a boolean?

23:21 (boolean (some ...)) works, but is not very useful I think unless you're passing booleans to java

23:21 hamza: i would like to know any of the values in the vector is present in the mac as a key.

23:22 tomoj: right

23:22 in clojure 2 is just as good as true

23:22 e.g. (if (some {...} [..]) ... ...) would work just fine

23:22 hamza: ok, so i can safely use this in a if.. you just answered it

23:22 thanks..

23:22 tomoj: the only reason to prefer booleans I can think of is java interop

23:23 hamza: i was thinking in terms of java..

23:23 tomoj: false and nil count as falsey things and every thing else is truthy

23:23 so, actually, using (some {...} [..]) will be problematic if any of the values in the map is false

23:24 hamza: no they are all integers

23:26 tomoj: ,(some #(contains? {"a" false "b" false "c" false} %) ["c" "b"])

23:26 clojurebot: true

23:26 tomoj: ,(some {"a" false "b" false "c" false} ["c" "b"])

23:26 clojurebot: nil

23:27 tomoj: (some #(contain? {...} %) ...) will give you a boolean, but it only matters if the map has nil or false as a value, I think

23:27 er, contains?

23:29 hamza: heheh missed that one.

23:31 tomoj: I think actually the only reason we have true and both false and nil is for java

Logging service provided by n01se.net