2009-11-20
| 00:00 | technomancy | cgordon: you can't compile an fn that references a var that doesn't exist |
| 00:01 | cgordon | technomancy: got it, thanks again |
| 01:01 | cgordon | are variables like *command-line-args* considered "global variables"? |
| 01:01 | cgordon | i.e., is it a convention that all global variables should have asterix at the start and end? |
| 01:10 | adityo | cgordon: yes it is an accepted convention for LISP languages eg Common Lisp, Clojure |
| 01:11 | cgordon | adityo: is "global variable" the right term to use when referring to them? |
| 01:11 | cgordon | adityo: since Clojure seems to be about "immutable state", I'm wondering if "variable" is ever the right term :) |
| 01:19 | cgordon | is it fair to say that Clojure symbols provide names (i.e. bindings) for just namespaces and vars? |
| 01:20 | cgordon | or are there other things that can be bound to a symbol? |
| 01:20 | cgordon | (sorry, I realize these are really n00b questions, but I'm trying to understand the terminology) |
| 01:25 | adityo | cgordon: a symbol can also have a value,symbol can be stored in a collection, passed as an argument to a function |
| 01:26 | cgordon | adityo: right, but for a symbol to have a value, it has to be bound to a var, right? |
| 01:28 | cgrand | cgordon: you're right -- people coming from other lisps tend to conflate vars and symbols |
| 01:29 | adityo | yes mapped to a var or java.lang.Class objects |
| 01:29 | cgordon | are Java objects stored in vars, or are they bound directly to symbols? |
| 01:29 | cgordon | oops, looks like adityo beat me to that one |
| 01:31 | cgordon | 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). |
| 01:31 | hiredman | clojure symbols have no associated storage |
| 01:31 | hiredman | you can bind something to a var named by a symbol, but you cannot bind something to a symbol |
| 01:33 | cgrand | ,(type (find-ns 'clojure.core)) |
| 01:33 | clojurebot | clojure.lang.Namespace |
| 01: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? |
| 01:33 | cgordon | (again, apologies for the horrific newbieness of these questions and thanks for your patience!) |
| 01:34 | cgrand | cgordon: no apologies, these are good questions |
| 01:35 | hiredman | cgordon: binding is generally the term used for the association of a name and a value |
| 01: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? |
| 01:35 | cgordon | er, meta is probably entirely the wrong word to use there |
| 01:35 | cgordon | since it's so overloaded |
| 01:36 | hiredman | nope |
| 01: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) |
| 01:36 | cgordon | hiredman: or do we consider a var to be a value? |
| 01:36 | hiredman | cgordon: it can be either |
| 01:36 | cgordon | hiredman: so it depends on the context? |
| 01:36 | cgordon | can a var have a var as a value? |
| 01:37 | hiredman | a var is just another object |
| 01:37 | hiredman | ,(clojure.lang.Var/create) |
| 01:37 | clojurebot | #<Var: --unnamed--> |
| 01:37 | hiredman | clojurebot: ping? |
| 01:37 | clojurebot | PONG! |
| 01:38 | hiredman | ,(clojure.lang.Var/create (clojure.lang.Var/create)) |
| 01:38 | clojurebot | #<Var: --unnamed--> |
| 01:38 | hiredman | ,@(clojure.lang.Var/create (clojure.lang.Var/create)) |
| 01:38 | clojurebot | #<Var: --unnamed--> |
| 01:38 | hiredman | ,@(clojure.lang.Var/create (clojure.lang.Var/create 'foo)) |
| 01:38 | clojurebot | #<Var: --unnamed--> |
| 01:38 | hiredman | hmmm |
| 01:39 | cgordon | I haven't learned "@" yet, so I'm way behind here, but I think I see what you're doing |
| 01:39 | hiredman | ,`@(clojure.lang.Var/create (clojure.lang.Var/create)) |
| 01:39 | clojurebot | (clojure.core/deref (clojure.lang.Var/create (clojure.lang.Var/create))) |
| 01:39 | hiredman | @ is deref |
| 01:39 | cgordon | which gives you the name of a var? |
| 01:39 | cgordon | or it's value? |
| 01:39 | hiredman | value |
| 01:39 | hiredman | ,#'+ |
| 01:39 | clojurebot | #'clojure.core/+ |
| 01:40 | hiredman | that is the var that contains the + function |
| 01:40 | hiredman | ,@#'+ |
| 01:40 | clojurebot | #<core$_PLUS___4745 clojure.core$_PLUS___4745@1b9a77c> |
| 01:40 | hiredman | that is the + function |
| 01:40 | cgordon | and that's the function |
| 01:40 | cgordon | alright, that's making sense |
| 01:40 | hiredman | ,(deref (var `+)) |
| 01:40 | clojurebot | java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol |
| 01:40 | hiredman | bah |
| 01:40 | hiredman | ,(deref (var clojure.core/+)) |
| 01:40 | clojurebot | #<core$_PLUS___4745 clojure.core$_PLUS___4745@1b9a77c> |
| 01:41 | cgordon | so does (def a "foo") create a var and give it the name "a" and the value "foo"? |
| 01:41 | hiredman | more or less |
| 01:41 | cgordon | so you could do what you did, above, like (def a #'+), and now a should have a var as a value? |
| 01:41 | hiredman | the acutal name of the var is the fully namespace qualified symbol |
| 01:41 | cgordon | ah, right |
| 01:42 | hiredman | sure |
| 01:42 | cgordon | ,(def a #'+) |
| 01:42 | clojurebot | DENIED |
| 01:42 | cgordon | doh |
| 01:42 | hiredman | ,(#'+ 1 2 3) |
| 01:42 | clojurebot | 6 |
| 01:43 | cgordon | that's very interesting |
| 01:43 | cgordon | so Clojure will resolve either a symbol or a var as a function |
| 01:43 | cgordon | (if used as the first element of a list) |
| 01:44 | hiredman | vars defer to their values if called as a function |
| 01:44 | cgordon | so it is possible to create a var with no name |
| 01:44 | hiredman | ,(.invoke #'+ 1 2 3) |
| 01:44 | clojurebot | 6 |
| 01:44 | cgordon | and possible to have a symbol (name) with no var |
| 01:44 | hiredman | ,(.invoke + 1 2 3) |
| 01:44 | clojurebot | 6 |
| 01:44 | cgordon | is it possible to have a var with multiple name? |
| 01:44 | cgordon | names* |
| 01:45 | gilbertleung | hi everyone |
| 01: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 |
| 01:46 | hiredman | my guess is that the namespace alias stuff doesn't do anything to vars, just jiggers the resolution stuff |
| 01: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 |
| 01:47 | cgordon | since otherwise you would have all the mutable state problems you get with pointers in languages like C |
| 01:47 | hiredman | you shouldn't be changing the values of vars |
| 01:47 | cgordon | so if I do (def a "foo"), then (def a "bar") |
| 01:48 | hiredman | don't do that |
| 01:48 | cgordon | does the second expression create a new var? |
| 01:48 | hiredman | I doubt it |
| 01:48 | cgordon | alright |
| 01:48 | gilbertleung | i downloaded the leiningen script, ran "lein self-install", but all i have is an empty jar in my maven repo |
| 01:48 | cgordon | so if I did (def a "foo") then (def b #'a) then (def a "bar"), what would (deref b) return? |
| 01:49 | gilbertleung | would anyone have any idea what's going on? |
| 01:49 | cgordon | (clojurebot doesn't seem to want me to try) |
| 01:49 | hiredman | changing the value of a var is a thread safe swap |
| 01:50 | hiredman | cgordon: is that something you would be inclined to do? |
| 01:50 | cgordon | hiredman: not at all :) |
| 01:50 | cgordon | hiredman: I'm just trying to understand the underlying model |
| 01:51 | cgordon | hiredman: thanks a lot, this has been immensely helpful |
| 01:51 | cgordon | hiredman: I have more questions, but I think I can answer most of them by playing with the repl |
| 01:52 | hiredman | the reader actually uses anonymous vars to keep track of various pieces of state |
| 01:52 | cgordon | how does it access them? |
| 01: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 |
| 01:53 | hiredman | (def a (clojure.lang.Var/create)) |
| 01:53 | hiredman | that will create a unamed var, that is stored in a var, whose name is something/a |
| 01:54 | cgordon | woah |
| 01:54 | cgordon | why would you do that? |
| 01:54 | hiredman | (the reader is written in java at the momemt, so it actually stores the unamed var in a java field) |
| 01:54 | hiredman | cgordon: no idea |
| 01:55 | cgordon | ah, that makes sense (the reader being written in Java). So the unnamed vars are just being accessed from Java directly |
| 01:55 | hiredman | yeah |
| 01:56 | cgordon | so that's interesting, vars are mutable, but values (like lists, arrays, maps) are not |
| 01:57 | cgordon | but a var can be a value, so sometimes values are mutable |
| 01:57 | hiredman | vars are a special case reference type |
| 01:57 | hiredman | like agents, atoms, or refs |
| 01:58 | hiredman | ,(ref (ref nil)) |
| 01:58 | clojurebot | #<Ref@1fd3297: #<Ref@45886: nil>> |
| 02:02 | cgordon | ah, rtfm, this answers a lot of my questions: http://clojure.org/vars |
| 02:59 | adityo | ,(int \A) |
| 02:59 | clojurebot | 65 |
| 04:04 | duncanm | anyone awake? |
| 04:05 | AWizzArd | Sure :-) |
| 04:05 | AWizzArd | Moiners |
| 04:05 | duncanm | i'm trying to write a simple method to download some binary files online |
| 04:05 | duncanm | but it doesn't seem to be working |
| 04:05 | duncanm | http://gist.github.com/239370 |
| 04:05 | AWizzArd | hiredman: I see (about deftype caring about primitives). |
| 04:08 | AWizzArd | duncanm: i only had a fast look and it looked not bad. Could you maybe print something inside the loop? |
| 04:08 | AWizzArd | So you will know that the loop is run and you can get some info from inside. |
| 04:08 | duncanm | AWizzArd: it runs, but the file seems to be corrupted |
| 04:14 | _ato | duncanm: you need to pass bytes to write |
| 04:14 | _ato | as the buffer may not have been filled |
| 04:14 | _ato | (eg at the end of the file it might read less than 1024 bytes) |
| 04:15 | _ato | duncanm: like so: http://gist.github.com/239374 |
| 04:16 | duncanm | ahh |
| 04:23 | duncanm | _ato: heh, thanks for the tip |
| 04:23 | duncanm | _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 |
| 04:24 | duncanm | because i can just use wget ;-) |
| 04:24 | duncanm | (run (wget --continue ,url)) |
| 04:24 | duncanm | the RUN form has implicit quasiquoting |
| 04:34 | piccolino | Does anyone know what exactly the sequence of commands you should use for swank-clojure-project in Emacs is? |
| 04:34 | duncanm | it's funny to go back to scheme/lisp and seeing all the alists where a plist would be in Clojure |
| 04:36 | _ato | duncanm: well if you're going to cheat: (clojure.contrib.shell-out/sh "wget" "-c" url) |
| 04:36 | _ato | :p |
| 04:36 | duncanm | _ato: does that work? |
| 04:36 | duncanm | ooh |
| 04:36 | duncanm | i might have done that |
| 04:36 | Maddas | duncanm: Do you know if scsh is still being developed? |
| 04:37 | duncanm | Maddas: a few of my friends still dabble in it |
| 04:37 | duncanm | Maddas: we're all students (or in my case, ex-student) of Olin |
| 04:37 | Maddas | Neat. I always thought it was awesome :) |
| 04:37 | duncanm | Maddas: do you wanna work on it? ;-) |
| 04:37 | Maddas | I'm afraid I don't actually use it ;-) |
| 04:37 | duncanm | Maddas: if you have a unix machine, you can start using it |
| 04:38 | Maddas | I have that, just no strong need :-) |
| 04: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 |
| 04:38 | duncanm | Maddas: i've been busy with work, and at work, i use Windows, so i use clojure instead |
| 04:38 | duncanm | Maddas: oh no no |
| 04:38 | Maddas | :-P |
| 04: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. |
| 04:39 | Maddas | Oh, wait, I confused Olin and Oleg for a moment. I assume he writes good code too, though :-) |
| 04:39 | piccolino | And tells you how to cancel. |
| 04:39 | piccolino | I tried various combinations of starting slime first, or using slime-connect. |
| 04:39 | duncanm | oh |
| 04:39 | duncanm | Maddas: well, Olin did SRFI-1 and SRFI-13 ;-) |
| 04:39 | _ato | piccolino: hmm... it does that for me if clojure.jar is missing from lib |
| 04:39 | duncanm | Maddas: if i had infinite time, i'd love to port the Clojure data structures to Scheme |
| 04:39 | Maddas | duncanm: Yeah, I can see that. |
| 04:40 | piccolino | Ah, clojure-1.1.0-alpha-.... won't do the trick? |
| 04:40 | Maddas | Unfortunately infinite time is mor than a constant factor away :( |
| 04:40 | Maddas | More, even. |
| 04:40 | _ato | piccolino: yeah that should be fine, any clojure jar should do :/ |
| 04:40 | piccolino | Hm. |
| 04:40 | piccolino | Strange. |
| 04:40 | duncanm | Maddas: also, some of the clojure syntax i really like, like the [] {} literals, and perhaps the #() shorthand |
| 04:41 | Maddas | Yup. It seems like a very nicely chosen trade-off between purity and pragmatism. |
| 04: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 |
| 04:41 | _ato | piccolino: see if you get a repl |
| 04:41 | duncanm | it'd too bad that R6RS defined []s to be identical to ()s ;-P |
| 04:41 | _ato | err command-line not link :p I sound like some retro scifi novel |
| 04:41 | duncanm | okay, off to bed |
| 04:41 | piccolino | Yeah, that gave me a repl. |
| 04:42 | _ato | piccolino: hmm very strange |
| 04:42 | piccolino | Yeah, thanks for your help anyhow. |
| 04:43 | Maddas | duncanm: Good night :) |
| 05:11 | Licenser_ | good day everyone how is the Clojure World doing today? |
| 05:13 | hoeck | Licenser_: fine! thanks |
| 05:13 | Licenser_ | glad to hear |
| 05:14 | Licenser_ | 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? |
| 05:16 | piccolino | _ato, one last thing. Are you using the most recent version of swank-clojure and clojure-mode that technomancy released? |
| 05:16 | Chousuke | Licenser_: well, at least not GPL, because it's not compatible with Clojure's licence. |
| 05:17 | Chousuke | Licenser_: I guess EPL is pretty popular. |
| 05:17 | Licenser_ | Hmm not compatible means I could not do it or I should not do it? |
| 05:17 | Chousuke | I'm not really sure about that. |
| 05:18 | Licenser_ | wait waiiit, does that mean It's not entirely sure that I'm allowed to use GPL'ed code with clojure? |
| 05:19 | Chousuke | you're not, as far as I know. |
| 05:19 | hiredman | I'd suggest consulting a lawyer |
| 05: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]."' |
| 05:20 | Licenser_ | so if a library is under GPL it's technically untoucable from clojure? |
| 05:20 | hiredman | the gpl, I believe, has a clause exempting system libraries |
| 05:20 | Licenser_ | geez |
| 05:20 | Chousuke | Licenser_: yep. you can complain to the library makers :) |
| 05:20 | hiredman | so if your lawyer feels he can defend clojure as a system library |
| 05:21 | Licenser_ | this is just nuts o.O |
| 05:21 | Licenser_ | compleatly entirely nuts |
| 05:21 | hiredman | *shrug* |
| 05:21 | jabley | Licenser_: are you distributing your work? |
| 05:21 | hiredman | never really cared for the gpl anyway |
| 05:21 | Licenser_ | jabley: I plan to, it is booring to write stuff for your own :P |
| 05:21 | Chousuke | the incompatibility is the GPL's fault though. |
| 05:21 | jabley | Since it's a library, then I guess so! |
| 05:23 | Licenser_ | Chousuke: I know that much I got, it still is sadd that Open Source Licenses start to battle each other -.- |
| 05:23 | jabley | That falls under the viral aspect of the GPL then (IANAL) |
| 05:24 | Licenser_ | okay I'm lucky the jsch library isn't GPL'ed |
| 05:24 | Licenser_ | and the license is short and clear enough so that even I understand it :P |
| 05: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. |
| 05:26 | Licenser_ | Don't get me wrong, I don't mind clojures license - I don't even know wich exactly it is o.O |
| 05:26 | Chousuke | it's EPL |
| 05:26 | Licenser_ | ah |
| 05:26 | Licenser_ | I'll read up on the EPL then I guess |
| 05:26 | hiredman | pircbot, which clojurebot uses, is gpl'ed |
| 05:26 | hiredman | so clojurebot is illegal |
| 05:26 | hiredman | (don't tell anyone) |
| 05:26 | Chousuke | oops :P |
| 05:27 | hiredman | I'm waiting for FSF to come after me |
| 05:27 | Chousuke | quick, refactor it on top of some other IRC library. |
| 05:27 | hoeck | to me it looks like the GPL is C-specific, so are there even Java projects that use it? |
| 05:27 | hiredman | meh |
| 05:27 | Chousuke | Lisp at least has problems with the GPL |
| 05:27 | Chousuke | or actually, the LGPL |
| 05:28 | Chousuke | you need an additional clause to prevent macros from "spreading" the licence |
| 05:28 | tsdh | If you do a GPL project using clojure (or any other incompatible OS license), you can add a simple exception rule. |
| 05:29 | Chousuke | tsdh: you still can't use GPL libraries though :/ |
| 05:29 | tsdh | Chousuke: You mean, use GPL libs in a EPL project? |
| 05:29 | tsdh | Well, yes. |
| 05:30 | tsdh | Till now, I only had problems the other way round. |
| 05:31 | Chousuke | hmm |
| 05:32 | Chousuke | 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 |
| 05: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. |
| 05:32 | fanatico | Chousuke: see any binary driver for linux. |
| 05:33 | hiredman | Chousuke: I think the gpl specifies a certain kind of linkage |
| 05:33 | Chousuke | fanatico: those are a grey area |
| 05:33 | fanatico | Who would sue who? |
| 05:33 | hiredman | (very nonspecificly) |
| 05:33 | Chousuke | fanatico: basically, no-one is suing anyone because the binary drivers are useful |
| 05:34 | hiredman | fanatico: anyone who recieves the binary drivers |
| 05:34 | fanatico | the gpl only deals with distribution. |
| 05:34 | fanatico | the binary drivers are legal, they don't include a single bit of gpl'd code. |
| 05:37 | Licenser_ | well lunch time here, see you all later :) and thanks for all the advice I'll look into the EPL |
| 05:38 | fanatico | Licenser: if its a library, and you'd rather not deal with the legalese, I'd suggest the MIT license. |
| 05:38 | hiredman | :D |
| 05:45 | djpowell | ure |
| 05:45 | djpowell | offtopic: but does anyone know a minimal web templating thing for java that doesn't think of html-escaping as an afterthought |
| 05:58 | rfgpfeiffer | depending on what you mean by "for java", maybe jinja/Jython |
| 05:58 | ordnungswidrig | djpowell: I heared good things about stringtemplate. |
| 05: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. |
| 06:04 | djpowell | ordnungswidrig: yeah me too, but i'm getting the impression that html escaping is an afterthought |
| 06:05 | djpowell | 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. |
| 06:07 | djpowell | if some of these tools had PNG output, I think they'd just insert the text string into the file |
| 06: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 |
| 06:23 | hoeck | hamza: so I guess its as limited as the SAXParser and your available memory |
| 06:24 | hiredman | this came up on the group recently |
| 06:24 | hiredman | there is some library on github that uses, uh, I think it's called a pull parser? |
| 06:26 | djpowell | I'd imagine that SAX based parsing should stream fairly effectively. Probably best to just try it? |
| 06:28 | hiredman | http://github.com/marktriggs/xml-picker-seq |
| 06:29 | hamza | djpowell: right now on a dial up like connection wating for it to download :(, just planning ahead. |
| 06:30 | hamza | hiredman: thanks for the link. |
| 06: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 |
| 07:02 | _ato | octe: the download link is broken :( lemme find the working one, just a sec |
| 07:03 | _ato | octe: try using this one instead: http://github.com/technomancy/leiningen/raw/0.5.0/bin/lein |
| 07:03 | octe | _ato: yeah, i just found that too :) |
| 07:04 | octe | changed the version in the lein-script to 0.5.0 and it worked |
| 07:04 | _ato | cool |
| 07: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? |
| 07: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 |
| 07:38 | hamza | i mean if i pass them 10k jobs it will not spawn 1k threads right they work on a fixed thread pool. |
| 07:39 | _ato | oh right, no it uses a fixed thread pool (as long as you're using send not send-off) |
| 07:39 | _ato | so yeah, it won't create thousands of threads |
| 07:39 | hamza | ,(doc send-off) |
| 07: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)" |
| 07:41 | _ato | send-off creates a new thread for each call |
| 07:41 | _ato | send uses the thread pool |
| 07:43 | hamza | _ato: thanks. |
| 07:48 | Licenser_ | so back from lunch, and thank you all for your advice |
| 07:54 | hoeck | Licenser_: wow, that was a long lunch break :) |
| 07: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? |
| 08: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) |
| 08: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? |
| 08:04 | _ato | not sure |
| 08:04 | _ato | it uses java "CachedThreadPool": http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool(java.util.concurrent.ThreadFactory) |
| 08:05 | _ato | ah.. "unbounded thread pool, with automatic thread reclamation" so no limit on the number of threads that send-off creates |
| 08:06 | gerry` | hello |
| 08:06 | gerry` | what's fn*? |
| 08:07 | gerry` | ,((fn* [x] x) 'me) |
| 08:07 | clojurebot | me |
| 08:07 | gerry` | same with fn? |
| 08:08 | Licenser_ | hoeck: ^^ |
| 08:08 | Licenser_ | but it was good pizza |
| 08:09 | _ato | gerry`: fn* is the basic version of fn, it doesn't support fancy thins like destructuring binds |
| 08:09 | _ato | gerry`: fn is a macro that implements the fancier features on top of fn* |
| 08:10 | _ato | it's mainly for core use, there's no point in using fn* in your own code |
| 08:10 | gerry` | _ato: ic, thx |
| 08: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. |
| 08:26 | chouser | actually, it's probably even stronger than that -- fn* is unsupported and might change or go away |
| 08: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? |
| 09:13 | gerry` | (deftype person [#^String name #^java.util.Vector sons]) not work? |
| 09:13 | gerry` | deftype support any java type hints |
| 09:14 | chouser | I think it's just primitives and Object for now |
| 09:16 | gerry` | include compling to class file? AOT |
| 09:17 | gerry` | you mean when i (deftype a [#^anyclass b]) compiled to one object field ? |
| 09:20 | AWizzArd | When I call (person 47 11) I get a person instance. |
| 09:20 | AWizzArd | If I had hinted those fields as #^long and gave \x or "hi" as arg, then I would have gotten an Exception. |
| 09:34 | octe | lol |
| 09:34 | octe | my slime/swank/emacs setup has been broken for months |
| 09:35 | octe | 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 |
| 09:35 | octe | solution: echo "anything" > ~/.slime-secret |
| 09:36 | Licenser_ | there we go :D my first github project ^^ |
| 09:47 | AWizzArd | Can any slime user please confirm that swank-clojure does not work with new versions of slime? |
| 09:48 | AWizzArd | repl starts up in emacs but does not eval any inputs |
| 09:51 | aking | AWizzArd: yup - it's broken - see the slime thread here: http://thread.gmane.org/gmane.lisp.slime.devel/9178/focus=9197 |
| 09: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. |
| 09:55 | AWizzArd | aking: so it seems that slime is broken, and not swank-clojure? |
| 09:56 | AWizzArd | esj: 1.1 alpha was working perfectly in slime until recently |
| 09:56 | aking | I guess that's the point that's being 'debated' - who's the more broken. |
| 09: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 | AWizzArd | 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 | AWizzArd | 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 | tmountain | 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 | fro0g | howt he -> how the |
| 11:38 | fro0g | 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 | ulfster | and the second (with-session "user" "pass" "host45" |
| 11:55 | ulfster | seconds version makes more sense to em |
| 11:55 | ulfster | 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 | johnmn3 | I would have thought there'd be a little more uploaded, even now. |
| 12:19 | johnmn3 | oh, it's working I think! |
| 12:29 | johnmn3 | nope |
| 12:29 | johnmn3 | is there a forum to discuss clojars/lein issues? |
| 12:31 | johnmn3 | looks to me like scp isn't actually uploading it |
| 12:31 | johnmn3 | hello-world.jar 100% 1976KB 1.9MB/s 00:00 |
| 12:31 | johnmn3 | I know my connection can't upload 2 megs in under a second. |
| 12:33 | technomancy | johnmn3: there's a #leiningen channel |
| 12:34 | technomancy | 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 | lisppaste8 | 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 | StartsWithK | 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 | hiredman | (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 | technomancy | 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 | StartsWithK | i am trying to load a clojure file with my own calls to read and then eval |
| 15:24 | StartsWithK | 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 | hiredman | well |
| 15:26 | hiredman | ~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 | hiredman | yeah, so don't use add-classpath |
| 15:27 | StartsWithK | http://paste.pocoo.org/show/151979/ |
| 15:27 | StartsWithK | well i have to use add-classpath |
| 15:27 | StartsWithK | but that is not the problem |
| 15:27 | StartsWithK | if i do simple (eval '(add-classpath (.toURL (File. "test")))) |
| 15:27 | StartsWithK | it works |
| 15:28 | StartsWithK | i thint problem is with my namespace usage |
| 15:28 | StartsWithK | 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 | hiredman | 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 | StartsWithK | i don't know before runtime what that path will be |
| 15:30 | StartsWithK | also, works in 1.0, and in repl inside user namespace just fine |
| 15:31 | hiredman | so? |
| 15:32 | hiredman | 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 | StartsWithK | 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 | the-kenny | ,(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 | the-kenny | ,(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 | StartsWithK | 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 | the-kenny | 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 | StartsWithK | 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 | dnolen | 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 | kzar | 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 | the-kenny | ,(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 | rlb | 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 | the-kenny | ,(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 | the-kenny | Now I've got it |
| 16:01 | the-kenny | 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 | rlb | (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 | Knekk | , (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 | hiredman | you cannot have #{1 2 2} |
| 16:48 | hiredman | ,#{2 2} |
| 16:48 | clojurebot | #{2} |
| 16:48 | Knekk | yeah, wasn't clear. something like set/intersection, for lists |
| 16:49 | Knekk | 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 | StartsWithK | 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 | jasapp | is there a better way of getting a list of unique items rather than calling (seq (set my-list)) |
| 16:58 | jasapp | 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 | hiredman | ,(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 | ohpauleez | 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 | ohpauleez | ie: Is it like regular Java exceptions underneath or is like CL conditions |
| 17:10 | ohpauleez | ? |
| 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 | chouser | if you want something more like CL conditions, you might look at error-kit |
| 17:14 | chouser | 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 | qed | 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 | ohpauleez | 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 | qed | 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 | qed | 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 | ohpauleez | 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: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 | ohpauleez | chouser: it doesn't save you the cost of the let biding? |
| 17:41 | ohpauleez | binding* |
| 17:44 | chouser | in the outer-most loop? I'd be surprised if it made a noticable difference. |
| 17:44 | chouser | 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 | ohpauleez | also: http://gnuvince.wordpress.com/2009/05/11/clojure-performance-tips/ |
| 17:47 | ohpauleez | 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 | hiredman | functions don't have names |
| 18:07 | hiredman | 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 | hiredman | 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 | hiredman | 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 | qed | 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 | qed | 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 | qed | 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 | hiredman | 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 | qed | (def add2 (make-adder 2)) |
| 18:42 | qed | (add2 4) ; -> 6 |
| 18:42 | qed | 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 | qed | im on the brink of lisp snobbery |
| 18:43 | qed | and it feels so good |
| 18:43 | qed | lol |
| 18:44 | qed | there's already sort of a running rule going between me and some of my programmer friends |
| 18:44 | qed | when they're complaining about a problem they're having in x language, i cannot mention clojure |
| 18:45 | qed | cause they will just get angry |
| 18:45 | jasapp | I had to stop talking about lisp with my friends that program |
| 18:45 | jasapp | their eyes just glaze over anymore |
| 18:45 | qed | yeah it kind of sucks |
| 18:46 | qed | i feel like im imparting wisdom |
| 18:46 | qed | and they feel like im being a cocky jerk |
| 18:46 | qed | once i start telling them "ummm yeah, it's slow, you're using mutable data structures, what do you expect?" |
| 18:46 | qed | 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 | qed | gbt: hear hear! |
| 18:47 | qed | 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 | qed | 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 | tomoj | where mutable is usually faster |
| 18:54 | qed | ah |
| 18:54 | qed | yea |
| 19:04 | qed | no matching method found for aget? |
| 19:05 | JayM | what do people write with clojure? |
| 19:06 | JayM | 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 | _mst | some code I'm fiddling with gets a nice little speedup (about 30%) from switching it to use transients |
| 19:10 | _mst | 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 | _ato | 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 | StartsWithK | 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 | tomoj | 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 | StartsWithK | 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 | tomoj | 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 | StartsWithK | 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: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 | joshua-choi | 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 | twbray | 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 | twbray | Just ignore me for a while |
| 20:10 | technomancy | twbray: shouldn't you be working on *ruby* at rubyconf? =) |
| 20:11 | technomancy | as is stuart h |
| 20:11 | technomancy | 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 | _ato | 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 | tomoj | 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 | fanatico | You'd use :refer-clojure to exclude certain functions, for example. |
| 20:54 | tomoj | ooh |
| 20:54 | tomoj | thanks |
| 20:54 | tomoj | so (:refer-clojure) is redundant |
| 20:55 | tomoj | 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 | tomoj | I feel like it might be cool if ns could be extended |
| 20:59 | tomoj | would that be cool or evil? |
| 21:00 | tomoj | 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 | polypus | no :else |
| 21:21 | hiredman | any non-nil value will do |
| 21:21 | hiredman | well |
| 21:21 | hiredman | besides false |
| 21:21 | polypus | yeah, i'm just thinking of the aesthetics more than anything |
| 21:23 | polypus | (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 | hiredman | just stick a let in the cond macro expansion |
| 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 | qed | How does (fn [z] get 4)? |
| 21:31 | qed | err (fn [z]) get 4? |
| 21:32 | tomoj | make-adder returns that fn |
| 21:32 | tomoj | 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 | hiredman | 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 | tomoj | 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 | tomoj | I mean, fn params are "locals" too, right? |
| 21:35 | hiredman | fn params are fields |
| 21:35 | hiredman | er |
| 21:35 | hiredman | no |
| 21:35 | hiredman | thats not right, closed over values are fields |
| 21:38 | hiredman | 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 | qed | 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 | hiredman | :foo |
| 21:43 | qed | maybe it was something like ([] fn) |
| 21:43 | hiredman | or 'foo |
| 21:43 | hiredman | sure |
| 21:43 | hiredman | ,([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 | hiredman | like |
| 21:44 | tomoj | oh yeah I see |
| 21:44 | tomoj | ,('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 | joshua-choi | 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 | joshua-choi | Say, it has two fields: (deftype result [product state]) |
| 22:22 | joshua-choi | (I meant (deftype Result ...)) |
| 22:22 | joshua-choi | Can I override any interface methods to get it so that (Result :something :some |
| 22:23 | joshua-choi | 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 | zaphar_ps | it is pointed at the contrib jar |
| 22:37 | zaphar_ps | yet does not see the contrib namespaces |
| 22:37 | _ato | zaphar_ps: did you mean "use" instead of "refer"? |
| 22:37 | zaphar_ps | use had the same problem |
| 22:37 | zaphar_ps | that was attempt number three |
| 22:38 | zaphar_ps | I'm using head from github as of yesterday if that makes a difference |
| 22:38 | zaphar_ps | 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 | zaphar_ps | the previous compiled version did work |
| 22:40 | zaphar_ps | the clj-stacktrace.repl namespace is unavailable as well |
| 22:40 | zaphar_ps | 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 | _ato | 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 | _ato | that's what I get if I do (use foo) instead of (use 'foo) |
| 22:42 | zaphar_ps | no I did not |
| 22:42 | zaphar_ps | heh |
| 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 | zaphar_ps | _ato: yeah I think the :use vs use difference is what thew me |
| 22:46 | zaphar_ps | I was building a tap testing library as a learning excercise and just noticed that the clojure test lib has one already :-) |
| 22:46 | zaphar_ps | same namespace as mine whoops |
| 22:47 | zaphar_ps | well not exactly same namespace cause mine doesn't have the clojure prefix |
| 22:52 | zaphar_ps | in clojure what's the preferred way to prefix your namespaces for libraries? |
| 22:55 | tomoj | I use the java convention |
| 22:55 | tomoj | (reverse domain name) |
| 22:56 | zaphar_ps | I see some doing name/last/first |
| 22:56 | zaphar_ps | is that standard for individual contributors? |
| 22:56 | _ato | that's a domain name |
| 22:56 | _ato | last.name |
| 22:58 | _ato | personally I don't like the domain name thing, so I just try to choose a unique name for the project |
| 22:58 | _ato | 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 | tomoj | but I suck at thinking of them |
| 23:14 | tomoj | 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:16 | tomoj | I want a web app that just generates random unique names for software |
| 23:16 | tomoj | ...that are relatively pronouncable - not just strings of random characters :) |
| 23:17 | tomoj | 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 | tomoj | (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 | tomoj | in clojure 2 is just as good as true |
| 23:22 | tomoj | 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 | hamza | 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 | tomoj | 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 | tomoj | 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 |