#clojure logs

2009-11-20

00:00technomancycgordon: you can't compile an fn that references a var that doesn't exist
00:01cgordontechnomancy: got it, thanks again
01:01cgordonare variables like *command-line-args* considered "global variables"?
01:01cgordoni.e., is it a convention that all global variables should have asterix at the start and end?
01:10adityocgordon: yes it is an accepted convention for LISP languages eg Common Lisp, Clojure
01:11cgordonadityo: is "global variable" the right term to use when referring to them?
01:11cgordonadityo: since Clojure seems to be about "immutable state", I'm wondering if "variable" is ever the right term :)
01:19cgordonis it fair to say that Clojure symbols provide names (i.e. bindings) for just namespaces and vars?
01:20cgordonor are there other things that can be bound to a symbol?
01:20cgordon(sorry, I realize these are really n00b questions, but I'm trying to understand the terminology)
01:25adityocgordon: a symbol can also have a value,symbol can be stored in a collection, passed as an argument to a function
01:26cgordonadityo: right, but for a symbol to have a value, it has to be bound to a var, right?
01:28cgrandcgordon: you're right -- people coming from other lisps tend to conflate vars and symbols
01:29adityoyes mapped to a var or java.lang.Class objects
01:29cgordonare Java objects stored in vars, or are they bound directly to symbols?
01:29cgordonoops, looks like adityo beat me to that one
01:31cgordoncgrand: 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:31hiredmanclojure symbols have no associated storage
01:31hiredmanyou can bind something to a var named by a symbol, but you cannot bind something to a symbol
01:33cgrand,(type (find-ns 'clojure.core))
01:33clojurebotclojure.lang.Namespace
01:33cgordonhiredman: 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:33cgordon(again, apologies for the horrific newbieness of these questions and thanks for your patience!)
01:34cgrandcgordon: no apologies, these are good questions
01:35hiredmancgordon: binding is generally the term used for the association of a name and a value
01:35cgordoncgrand: 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:35cgordoner, meta is probably entirely the wrong word to use there
01:35cgordonsince it's so overloaded
01:36hiredmannope
01:36cgordonhiredman: 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:36cgordonhiredman: or do we consider a var to be a value?
01:36hiredmancgordon: it can be either
01:36cgordonhiredman: so it depends on the context?
01:36cgordoncan a var have a var as a value?
01:37hiredmana var is just another object
01:37hiredman,(clojure.lang.Var/create)
01:37clojurebot#<Var: --unnamed-->
01:37hiredmanclojurebot: ping?
01:37clojurebotPONG!
01:38hiredman,(clojure.lang.Var/create (clojure.lang.Var/create))
01:38clojurebot#<Var: --unnamed-->
01:38hiredman,@(clojure.lang.Var/create (clojure.lang.Var/create))
01:38clojurebot#<Var: --unnamed-->
01:38hiredman,@(clojure.lang.Var/create (clojure.lang.Var/create 'foo))
01:38clojurebot#<Var: --unnamed-->
01:38hiredmanhmmm
01:39cgordonI haven't learned "@" yet, so I'm way behind here, but I think I see what you're doing
01:39hiredman,`@(clojure.lang.Var/create (clojure.lang.Var/create))
01:39clojurebot(clojure.core/deref (clojure.lang.Var/create (clojure.lang.Var/create)))
01:39hiredman@ is deref
01:39cgordonwhich gives you the name of a var?
01:39cgordonor it's value?
01:39hiredmanvalue
01:39hiredman,#'+
01:39clojurebot#'clojure.core/+
01:40hiredmanthat is the var that contains the + function
01:40hiredman,@#'+
01:40clojurebot#<core$_PLUS___4745 clojure.core$_PLUS___4745@1b9a77c>
01:40hiredmanthat is the + function
01:40cgordonand that's the function
01:40cgordonalright, that's making sense
01:40hiredman,(deref (var `+))
01:40clojurebotjava.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol
01:40hiredmanbah
01:40hiredman,(deref (var clojure.core/+))
01:40clojurebot#<core$_PLUS___4745 clojure.core$_PLUS___4745@1b9a77c>
01:41cgordonso does (def a "foo") create a var and give it the name "a" and the value "foo"?
01:41hiredmanmore or less
01:41cgordonso you could do what you did, above, like (def a #'+), and now a should have a var as a value?
01:41hiredmanthe acutal name of the var is the fully namespace qualified symbol
01:41cgordonah, right
01:42hiredmansure
01:42cgordon,(def a #'+)
01:42clojurebotDENIED
01:42cgordondoh
01:42hiredman,(#'+ 1 2 3)
01:42clojurebot6
01:43cgordonthat's very interesting
01:43cgordonso Clojure will resolve either a symbol or a var as a function
01:43cgordon(if used as the first element of a list)
01:44hiredmanvars defer to their values if called as a function
01:44cgordonso it is possible to create a var with no name
01:44hiredman,(.invoke #'+ 1 2 3)
01:44clojurebot6
01:44cgordonand possible to have a symbol (name) with no var
01:44hiredman,(.invoke + 1 2 3)
01:44clojurebot6
01:44cgordonis it possible to have a var with multiple name?
01:44cgordonnames*
01:45gilbertleunghi everyone
01:45hiredmanyou 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:46hiredmanmy guess is that the namespace alias stuff doesn't do anything to vars, just jiggers the resolution stuff
01:46cgordonright, it seems like things are set up so that if you change the value of a var, it can only affect one symbol
01:47cgordonsince otherwise you would have all the mutable state problems you get with pointers in languages like C
01:47hiredmanyou shouldn't be changing the values of vars
01:47cgordonso if I do (def a "foo"), then (def a "bar")
01:48hiredmandon't do that
01:48cgordondoes the second expression create a new var?
01:48hiredmanI doubt it
01:48cgordonalright
01:48gilbertleungi downloaded the leiningen script, ran "lein self-install", but all i have is an empty jar in my maven repo
01:48cgordonso if I did (def a "foo") then (def b #'a) then (def a "bar"), what would (deref b) return?
01:49gilbertleungwould anyone have any idea what's going on?
01:49cgordon(clojurebot doesn't seem to want me to try)
01:49hiredmanchanging the value of a var is a thread safe swap
01:50hiredmancgordon: is that something you would be inclined to do?
01:50cgordonhiredman: not at all :)
01:50cgordonhiredman: I'm just trying to understand the underlying model
01:51cgordonhiredman: thanks a lot, this has been immensely helpful
01:51cgordonhiredman: I have more questions, but I think I can answer most of them by playing with the repl
01:52hiredmanthe reader actually uses anonymous vars to keep track of various pieces of state
01:52cgordonhow does it access them?
01:53gilbertleunganyways, 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:53hiredman(def a (clojure.lang.Var/create))
01:53hiredmanthat will create a unamed var, that is stored in a var, whose name is something/a
01:54cgordonwoah
01:54cgordonwhy would you do that?
01:54hiredman(the reader is written in java at the momemt, so it actually stores the unamed var in a java field)
01:54hiredmancgordon: no idea
01:55cgordonah, that makes sense (the reader being written in Java). So the unnamed vars are just being accessed from Java directly
01:55hiredmanyeah
01:56cgordonso that's interesting, vars are mutable, but values (like lists, arrays, maps) are not
01:57cgordonbut a var can be a value, so sometimes values are mutable
01:57hiredmanvars are a special case reference type
01:57hiredmanlike agents, atoms, or refs
01:58hiredman,(ref (ref nil))
01:58clojurebot#<Ref@1fd3297: #<Ref@45886: nil>>
02:02cgordonah, rtfm, this answers a lot of my questions: http://clojure.org/vars
02:59adityo,(int \A)
02:59clojurebot65
04:04duncanmanyone awake?
04:05AWizzArdSure :-)
04:05AWizzArdMoiners
04:05duncanmi'm trying to write a simple method to download some binary files online
04:05duncanmbut it doesn't seem to be working
04:05duncanmhttp://gist.github.com/239370
04:05AWizzArdhiredman: I see (about deftype caring about primitives).
04:08AWizzArdduncanm: i only had a fast look and it looked not bad. Could you maybe print something inside the loop?
04:08AWizzArdSo you will know that the loop is run and you can get some info from inside.
04:08duncanmAWizzArd: it runs, but the file seems to be corrupted
04:14_atoduncanm: you need to pass bytes to write
04:14_atoas 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_atoduncanm: like so: http://gist.github.com/239374
04:16duncanmahh
04:23duncanm_ato: heh, thanks for the tip
04:23duncanm_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:24duncanmbecause i can just use wget ;-)
04:24duncanm(run (wget --continue ,url))
04:24duncanmthe RUN form has implicit quasiquoting
04:34piccolinoDoes anyone know what exactly the sequence of commands you should use for swank-clojure-project in Emacs is?
04:34duncanmit's funny to go back to scheme/lisp and seeing all the alists where a plist would be in Clojure
04:36_atoduncanm: well if you're going to cheat: (clojure.contrib.shell-out/sh "wget" "-c" url)
04:36_ato:p
04:36duncanm_ato: does that work?
04:36duncanmooh
04:36duncanmi might have done that
04:36Maddasduncanm: Do you know if scsh is still being developed?
04:37duncanmMaddas: a few of my friends still dabble in it
04:37duncanmMaddas: we're all students (or in my case, ex-student) of Olin
04:37MaddasNeat. I always thought it was awesome :)
04:37duncanmMaddas: do you wanna work on it? ;-)
04:37MaddasI'm afraid I don't actually use it ;-)
04:37duncanmMaddas: if you have a unix machine, you can start using it
04:38MaddasI have that, just no strong need :-)
04:38_atopiccolino: 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:38duncanmMaddas: i've been busy with work, and at work, i use Windows, so i use clojure instead
04:38duncanmMaddas: oh no no
04:38Maddas:-P
04:38piccolinoHm. 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:39MaddasOh, wait, I confused Olin and Oleg for a moment. I assume he writes good code too, though :-)
04:39piccolinoAnd tells you how to cancel.
04:39piccolinoI tried various combinations of starting slime first, or using slime-connect.
04:39duncanmoh
04:39duncanmMaddas: well, Olin did SRFI-1 and SRFI-13 ;-)
04:39_atopiccolino: hmm... it does that for me if clojure.jar is missing from lib
04:39duncanmMaddas: if i had infinite time, i'd love to port the Clojure data structures to Scheme
04:39Maddasduncanm: Yeah, I can see that.
04:40piccolinoAh, clojure-1.1.0-alpha-.... won't do the trick?
04:40MaddasUnfortunately infinite time is mor than a constant factor away :(
04:40MaddasMore, even.
04:40_atopiccolino: yeah that should be fine, any clojure jar should do :/
04:40piccolinoHm.
04:40piccolinoStrange.
04:40duncanmMaddas: also, some of the clojure syntax i really like, like the [] {} literals, and perhaps the #() shorthand
04:41MaddasYup. It seems like a very nicely chosen trade-off between purity and pragmatism.
04:41_atopiccolino: 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_atopiccolino: see if you get a repl
04:41duncanmit'd too bad that R6RS defined []s to be identical to ()s ;-P
04:41_atoerr command-line not link :p I sound like some retro scifi novel
04:41duncanmokay, off to bed
04:41piccolinoYeah, that gave me a repl.
04:42_atopiccolino: hmm very strange
04:42piccolinoYeah, thanks for your help anyhow.
04:43Maddasduncanm: Good night :)
05:11Licenser_good day everyone how is the Clojure World doing today?
05:13hoeckLicenser_: fine! thanks
05:13Licenser_glad to hear
05:14Licenser_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:16piccolino_ato, one last thing. Are you using the most recent version of swank-clojure and clojure-mode that technomancy released?
05:16ChousukeLicenser_: well, at least not GPL, because it's not compatible with Clojure's licence.
05:17ChousukeLicenser_: I guess EPL is pretty popular.
05:17Licenser_Hmm not compatible means I could not do it or I should not do it?
05:17ChousukeI'm not really sure about that.
05:18Licenser_wait waiiit, does that mean It's not entirely sure that I'm allowed to use GPL'ed code with clojure?
05:19Chousukeyou're not, as far as I know.
05:19hiredmanI'd suggest consulting a lawyer
05:20Chousukequote 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:20Licenser_so if a library is under GPL it's technically untoucable from clojure?
05:20hiredmanthe gpl, I believe, has a clause exempting system libraries
05:20Licenser_geez
05:20ChousukeLicenser_: yep. you can complain to the library makers :)
05:20hiredmanso if your lawyer feels he can defend clojure as a system library
05:21Licenser_this is just nuts o.O
05:21Licenser_compleatly entirely nuts
05:21hiredman*shrug*
05:21jableyLicenser_: are you distributing your work?
05:21hiredmannever really cared for the gpl anyway
05:21Licenser_jabley: I plan to, it is booring to write stuff for your own :P
05:21Chousukethe incompatibility is the GPL's fault though.
05:21jableySince it's a library, then I guess so!
05:23Licenser_Chousuke: I know that much I got, it still is sadd that Open Source Licenses start to battle each other -.-
05:23jableyThat falls under the viral aspect of the GPL then (IANAL)
05:24Licenser_okay I'm lucky the jsch library isn't GPL'ed
05:24Licenser_and the license is short and clear enough so that even I understand it :P
05:25ChousukeIt'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:26Licenser_Don't get me wrong, I don't mind clojures license - I don't even know wich exactly it is o.O
05:26Chousukeit's EPL
05:26Licenser_ah
05:26Licenser_I'll read up on the EPL then I guess
05:26hiredmanpircbot, which clojurebot uses, is gpl'ed
05:26hiredmanso clojurebot is illegal
05:26hiredman(don't tell anyone)
05:26Chousukeoops :P
05:27hiredmanI'm waiting for FSF to come after me
05:27Chousukequick, refactor it on top of some other IRC library.
05:27hoeckto me it looks like the GPL is C-specific, so are there even Java projects that use it?
05:27hiredmanmeh
05:27ChousukeLisp at least has problems with the GPL
05:27Chousukeor actually, the LGPL
05:28Chousukeyou need an additional clause to prevent macros from "spreading" the licence
05:28tsdhIf you do a GPL project using clojure (or any other incompatible OS license), you can add a simple exception rule.
05:29Chousuketsdh: you still can't use GPL libraries though :/
05:29tsdhChousuke: You mean, use GPL libs in a EPL project?
05:29tsdhWell, yes.
05:30tsdhTill now, I only had problems the other way round.
05:31Chousukehmm
05:32ChousukeI 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:32fanaticoUsing (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:32fanaticoChousuke: see any binary driver for linux.
05:33hiredmanChousuke: I think the gpl specifies a certain kind of linkage
05:33Chousukefanatico: those are a grey area
05:33fanaticoWho would sue who?
05:33hiredman(very nonspecificly)
05:33Chousukefanatico: basically, no-one is suing anyone because the binary drivers are useful
05:34hiredmanfanatico: anyone who recieves the binary drivers
05:34fanaticothe gpl only deals with distribution.
05:34fanaticothe binary drivers are legal, they don't include a single bit of gpl'd code.
05:37Licenser_well lunch time here, see you all later :) and thanks for all the advice I'll look into the EPL
05:38fanaticoLicenser: if its a library, and you'd rather not deal with the legalese, I'd suggest the MIT license.
05:38hiredman:D
05:45djpowellure
05:45djpowellofftopic: but does anyone know a minimal web templating thing for java that doesn't think of html-escaping as an afterthought
05:58rfgpfeifferdepending on what you mean by "for java", maybe jinja/Jython
05:58ordnungswidrigdjpowell: I heared good things about stringtemplate.
05:58hamzadoes 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:04djpowellordnungswidrig: yeah me too, but i'm getting the impression that html escaping is an afterthought
06:05djpowellurgh, 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:07djpowellif some of these tools had PNG output, I think they'd just insert the text string into the file
06:22hoeckhamza: 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:23hoeckhamza: so I guess its as limited as the SAXParser and your available memory
06:24hiredmanthis came up on the group recently
06:24hiredmanthere is some library on github that uses, uh, I think it's called a pull parser?
06:26djpowellI'd imagine that SAX based parsing should stream fairly effectively. Probably best to just try it?
06:28hiredmanhttp://github.com/marktriggs/xml-picker-seq
06:29hamzadjpowell: right now on a dial up like connection wating for it to download :(, just planning ahead.
06:30hamzahiredman: thanks for the link.
06:56octeanyone 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_atoocte: the download link is broken :( lemme find the working one, just a sec
07:03_atoocte: try using this one instead: http://github.com/technomancy/leiningen/raw/0.5.0/bin/lein
07:03octe_ato: yeah, i just found that too :)
07:04octechanged the version in the lein-script to 0.5.0 and it worked
07:04_atocool
07:33hamzawhile 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_atoyou 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:38hamzai mean if i pass them 10k jobs it will not spawn 1k threads right they work on a fixed thread pool.
07:39_atooh right, no it uses a fixed thread pool (as long as you're using send not send-off)
07:39_atoso yeah, it won't create thousands of threads
07:39hamza,(doc send-off)
07:39clojurebot"([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_atosend-off creates a new thread for each call
07:41_atosend uses the thread pool
07:43hamza_ato: thanks.
07:48Licenser_so back from lunch, and thank you all for your advice
07:54hoeckLicenser_: wow, that was a long lunch break :)
07:59hamza_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_atohamza: 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:01hamzaok, 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_atonot sure
08:04_atoit 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_atoah.. "unbounded thread pool, with automatic thread reclamation" so no limit on the number of threads that send-off creates
08:06gerry`hello
08:06gerry`what's fn*?
08:07gerry`,((fn* [x] x) 'me)
08:07clojurebotme
08:07gerry`same with fn?
08:08Licenser_hoeck: ^^
08:08Licenser_but it was good pizza
08:09_atogerry`: fn* is the basic version of fn, it doesn't support fancy thins like destructuring binds
08:09_atogerry`: fn is a macro that implements the fancier features on top of fn*
08:10_atoit's mainly for core use, there's no point in using fn* in your own code
08:10gerry`_ato: ic, thx
08:13esjguys, 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:26chouseractually, it's probably even stronger than that -- fn* is unsupported and might change or go away
08:40AWizzArdrhickey: is there a plan to support type hints for non-primitive types for deftype? For example hinting something as #^clojure.lang.IPersistentMap?
09:13gerry`(deftype person [#^String name #^java.util.Vector sons]) not work?
09:13gerry`deftype support any java type hints
09:14chouserI think it's just primitives and Object for now
09:16gerry`include compling to class file? AOT
09:17gerry`you mean when i (deftype a [#^anyclass b]) compiled to one object field ?
09:20AWizzArdWhen I call (person 47 11) I get a person instance.
09:20AWizzArdIf I had hinted those fields as #^long and gave \x or "hi" as arg, then I would have gotten an Exception.
09:34octelol
09:34octemy slime/swank/emacs setup has been broken for months
09:35octegot "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:35octesolution: echo "anything" > ~/.slime-secret
09:36Licenser_there we go :D my first github project ^^
09:47AWizzArdCan any slime user please confirm that swank-clojure does not work with new versions of slime?
09:48AWizzArdrepl starts up in emacs but does not eval any inputs
09:51akingAWizzArd: yup - it's broken - see the slime thread here: http://thread.gmane.org/gmane.lisp.slime.devel/9178/focus=9197
09:51esjAWizzArd: 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:55AWizzArdaking: so it seems that slime is broken, and not swank-clojure?
09:56AWizzArdesj: 1.1 alpha was working perfectly in slime until recently
09:56akingI guess that's the point that's being 'debated' - who's the more broken.
09:59esjAWizzArd: OK, thanks. My experience started with a clj upgrade that took everything down, so I guess I'm pointing finger unfairly :)
10:00AWizzArdchouser: currently it is not decided if deftypes are j.u.Map right? So, assoc, update-in, etc. won't work?
10:02chouserAWizzArd: "If you specify IPersistentMap as an interface, but don't define methods for it, an implementation will be generated automatically."
10:02AWizzArdk
10:06AWizzArdBtw, is there a sorted-set-by?
10:06chouserAWizzArd: in sufficiently recent versions of clojure, yes.
10:07AWizzArdah, so it is in Master, but not in New
10:11tmountainreading 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:15AWizzArd(require '[clojure.contrib def str-utils])
10:16AWizzArdtmountain: or even more useful: (require '[clojure.contrib [def :as d] [str-utils :as su]])
10:18tmountainAWizzArd: sweet, is it possible to require everything in a given namespace?
10:18tmountainAWiizzArd: kind of like in Java, import java.util.*;
10:46ordnungswidrigIs there sth like when for multiple test/body pairs?
10:46Chousukecond?
10:47ordnungswidrigChousuke: I'll check.
10:47Chousukesee also condp
10:47ordnungswidrigChousuke: thx
11:30Licenser_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:37fro0gLicenser_: sorry for being picky, there's a spelling error in the README.
11:37fro0ghowt he -> how the
11:38fro0gcommands,c onnect -> commands, connect
11:52Licenser_fro0g: thank you that isn't picky but helpfull :)
11:53fro0gLicenser_: glad to be of service :)
11:53Licenser_^^
11:55ulfsterLicenser_: is it alright that the first example is (with-session "user" "host" "ip"
11:55ulfster and the second (with-session "user" "pass" "host45"
11:55ulfsterseconds version makes more sense to em
11:55ulfsterto me
12:08Licenser_ulfster: you'Re right, messed up there
12:10johnmn3Is clojars.org broken right now?
12:12chouserseems to work for me
12:13johnmn3I've been trying to upload a basic jar
12:13chouseroh, I haven't tried uploading yet
12:14johnmn3it looks like only 2 or 3 people have.. unless uploading is broken atm
12:14johnmn3I would have thought there'd be a little more uploaded, even now.
12:19johnmn3oh, it's working I think!
12:29johnmn3nope
12:29johnmn3is there a forum to discuss clojars/lein issues?
12:31johnmn3looks to me like scp isn't actually uploading it
12:31johnmn3hello-world.jar 100% 1976KB 1.9MB/s 00:00
12:31johnmn3I know my connection can't upload 2 megs in under a second.
12:33technomancyjohnmn3: there's a #leiningen channel
12:34technomancyand a mailing list on google groups, but IRC is probably quicker
12:34johnmn3ahkkkhaa, thank you
12:37StartsWithKlisppaste8: help
12:37lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
12:40lisppaste8StartsWithK pasted "Classloader problem in 1.1a" at http://paste.lisp.org/display/90807
12:41StartsWithKwhen i tried clojure 1.1 i get this error i didn't have with 1.0
12:41StartsWithKany ideas how to fix this?
12:48LicenserI am back, fear my incompetence!
13:33mrSpecSorry about this question... but how can I push element to list ? I've found pop function, but cant find push...
13:33chouserconj
13:34mrSpecah, thanks :)
13:59hiredmantechnomancy: any particular reason lein uses #!/bin/bash instead of #!/bin/sh ?
13:59hiredman(the whole world doesn't have bash installed in /bin/
14:03danlarkinhiredman: oversight I'm sure
14:07tmountainif 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:17StartsWithKwhat is with-loading-context?
14:18chousertmountain: yes, most fns that operate on seqs call seq on their collection argument first
14:19technomancyhiredman: I didn't want to depend on any bash-specific functionality by accident without being explict about it
14:19technomancysince on Linux /bin/sh *is* /bin/bash
14:20Licenserso not on solaris
14:20technomancydidn't realize anyone kept bash out of /bin
14:21ohpauleez? who does that?
14:21chouserBSD
14:21Licensersolaris's /bin/sh is a very simple shell
14:21ohpauleezahh
14:22arbschttechnomancy: debian squeeze uses dash
14:23Licensergeez the sh under solaris not even sais who it is :P
15:04defn'lo
15:23StartsWithKuf, ok, what is this DynamicClassLoader and why am i losing it?
15:24StartsWithKi am trying to load a clojure file with my own calls to read and then eval
15:24StartsWithKbut in separate namespace from my own
15:25hiredmanStartsWithK: lets see some code
15:25StartsWithKeverything work, but i get this error when doing add-classpath
15:26hiredmanah
15:26hiredmanwell
15:26hiredman~add-classpath
15:26clojurebotadd-classpath is Fraught with Peril!
15:26hiredman~add-classpath
15:26clojurebotadd-classpath is Fraught with Peril!
15:26hiredmanhmmm
15:26hiredmanyeah, so don't use add-classpath
15:27StartsWithKhttp://paste.pocoo.org/show/151979/
15:27StartsWithKwell i have to use add-classpath
15:27StartsWithKbut that is not the problem
15:27StartsWithKif i do simple (eval '(add-classpath (.toURL (File. "test"))))
15:27StartsWithKit works
15:28StartsWithKi thint problem is with my namespace usage
15:28StartsWithKthink*
15:28hiredmanthe problem is add-classpath should not be used
15:29StartsWithKin clojure 1.0 it works
15:29hiredmanif you use add-classpath you will see odd classloader failures here and there
15:29hiredmanStartsWithK: *shrug*
15:29StartsWithKso.. i will have to start new jvm instance?
15:29hiredmanjust put the things you need on your classpath on your classpath
15:30StartsWithKi can't do that
15:30StartsWithKi don't know before runtime what that path will be
15:30StartsWithKalso, works in 1.0, and in repl inside user namespace just fine
15:31hiredmanso?
15:32hiredmanadd-classpath behaves unpredictably, using it's past behaviour to try and predict it's future behaviour is silly
15:33StartsWithKits not silly, its silly that it dosn't work
15:34hiredmanthe reason people are told not to use add-classpath is it inevitably leads to just this kind of weird mode of failure
15:34dnolenStartsWithK: 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:34StartsWithKok, what is then *the* way to add classpath at runtime?
15:35StartsWithKsome external java library?
15:35dnolenthere is no reliable way to do that. I'm curious as to why you don't know the classpath until runtime.
15:37kzarsay 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:37the-kennykzar: apply
15:37the-kenny,(doc apply)
15:37clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
15:37the-kenny(apply + (take 10 (iterate inc 0)))
15:37the-kenny,(apply + (take 10 (iterate inc 0)))
15:37clojurebot45
15:38StartsWithKdnolen: plugin system, position of test and source files i need to compile and execute tests on specified as properties in build script
15:38StartsWithKfirst one not a problem for now, but it will be in the future too
15:38kzarthe-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:39the-kennykzar: You want to apply for example [1 2 3] as three seperate arguments to a fn?
15:39the-kennyThat's exactly what apply does.
15:42dnolenStartsWithK: so this an issue with your development environment?
15:43StartsWithKdnolen: not realy, this is the build system app, it has to read a build script
15:43StartsWithKand it looks like i lost my current thread classloader when i switched namespaces
15:44dnolenStartWithK: any reason you can dynamically output build instructions to be read by some like lein?
15:44dnolencan't
15:46kzarthe-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:47kzarthe-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:47StartsWithKdnolen: lein is to different from what i have in mind
15:48the-kennykzar: Use repeatedly
15:48the-kenny,(doc repeatedly)
15:48clojurebot"([f]); Takes a function of no args, presumably with side effects, and returns an infinite lazy sequence of calls to it"
15:48the-kenny,(take 4 (repeatedly rand-int))
15:48clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args passed to: core$rand-int
15:49the-kenny,(take 4 (repeatedly #(rand-int 256)))
15:49clojurebot(168 188 153 49)
15:49rlb(take 3 (repeatedly #(rand-int 256)))
15:49StartsWithKwhen executing the load-build, and while i am inside in this generated namespace, my classloader is set to com.sun.misc.Launcher$AppClassLoader
15:51mrSpecHow can I do something like "(loop for i from 0 to 1 by 0.1 do (print i)" in Clojure, the simpliest way?
15:51the-kennymrSpec: (doseq [i (range 0 1 0.1)] (println i)) or so
15:51StartsWithKhmm.. my classloader is set to that even before i start to load the script
15:51the-kenny,(range 0 1 0.1)
15:51clojurebot(0 0.1 0.2 0.30000000000000004 0.4 0.5 0.6 0.7 0.7999999999999999 0.8999999999999999 0.9999999999999999)
15:52the-kenny(silly floating point numbers)
15:52hiredman(yay floats!)
15:55Knekkwhat's the easiest way to count the number of times x is in a coll?
15:55mrSpecthanks!
15:55the-kennyKnekk: I would do it so: (count (filter #(= s %) seq))
15:55Knekkthanks :0
15:58rlbJust 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:58StartsWithKdnolen: leiningen has hardcoded source directory in code, and in launcher script
15:58the-kennyrlb: Clojures makes heavy use of lazy evaluation
15:58robewald_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:59StartsWithKit is "src" by default and it looks like you can't change that
15:59the-kennyrlb: If you do something like (map heavy-function (range 1e100)), it will do nothing before you access an element in the list.
15:59rlbthe-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:00the-kenny,(doc filter)
16:00clojurebot"([pred coll]); "
16:00rlbthe-kenny: right, but will it allocate 1e100 times when it doesn't need to.
16:00rlbi.e. in lisp, you'd need to allocate 1e1000 cons cells, even if you don't keep any of them.
16:00the-kennyI think it won't do that either until you access an element from the map
16:00the-kenny,(doc range)
16:00clojurebot"([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:00rlbthe-kenny: I'm not sure it's clear what I'm asking.
16:01the-kennyahhh sorry
16:01the-kennyNow I've got it
16:01the-kennyhm.. dunno if it keeps everything in memory, sorry.
16:02rlbi.e. you *could* rewrite the count via recur and avoid allocating any (temporary bits) of the result list that count counts.
16:02rlb(Though I'm not saying it would necessarily be worth the effort -- just curious ATM.)
16:10_mstrlb: 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:11rlb_mst: right - I just wondered if it could avoid that per-item gc.
16:12_mstI'm not sure that it could... it needs to produce the 'next' item to find out whether it's finished or not
16:16rlbYeah -- it's clear how you might translate that by hand, but perhaps not automatically (at least not easily).
16:32technomancyrobewald_: does it say anything in *inferior-lisp* ?
16:44Knekkhmm, is there something like clojure.set/intersection that will not dedupe?
16:45Knekk, (clojure.set/intersection #{1 2 2 2} #{1 2 2 8 9})
16:45clojurebot#{1 2}
16:45Knekkshould return #{1 2 2}
16:48hiredmanKnekk: sets hold unique elements
16:48hiredmanyou cannot have #{1 2 2}
16:48hiredman,#{2 2}
16:48clojurebot#{2}
16:48Knekkyeah, wasn't clear. something like set/intersection, for lists
16:49Knekkmy bad, too distracted
16:50StartsWithKok, 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:51StartsWithKbut 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:52ohpauleezKnekk: I would just filter the two vectors
16:56jasappspeaking of sets..
16:57jasappis there a better way of getting a list of unique items rather than calling (seq (set my-list))
16:58jasappthat's probably a horrible way to do it, but it's what I've been doing lately
16:58hiredman,(doc unique)
16:58clojurebotHuh?
16:58hiredman,(doc uniq)
16:58clojurebotIt's greek to me.
16:58hiredmanbah
16:59hiredman,(doc distinct)
16:59clojurebot"([coll]); Returns a lazy sequence of the elements of coll with duplicates removed"
16:59jasappahh, distinct
16:59hiredmanthat being said, I generally just call set
16:59chouserif you don't need lazy, 'set' might actually be better
16:59jasappok
17:08ohpauleezchouser: I have a question about contrib/conditions that you might be able to answer
17:09ohpauleezdoes 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:10ohpauleezie: Is it like regular Java exceptions underneath or is like CL conditions
17:10ohpauleez?
17:13chouserI 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:13ohpauleezright, thank you. That's what I thought
17:14chouserthe 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:14chouserif you want something more like CL conditions, you might look at error-kit
17:14chouseralso in contrib
17:14ohpauleezis that your thing?
17:14chouseryes
17:15ohpauleezah, thank you. I'll have a look
17:15chousererror-kit currently has a ill-conceived mini object-model in it that I have vague plans to remove. :-P
17:16ohpauleezhaha, it looks awesome though
17:19qedhmmm i wonder if there will be a live feed of the clojure talk tomorrow at rubyconf
17:19qedby s. halloway
17:19technomancyqed: it's not live, but it should be available in a few weeks
17:20ohpauleezGood ol' stu is giving a tALK?
17:20ohpauleezah awesome, please hit the mailing list with a link when it becomes available
17:21qedim trying to talk my friend into qik'ing it
17:22qedso i have some awfully slow code that id like to speed up, was wondering if anyone here had any thoughts...
17:23ohpauleezwhat does the profiler say?
17:23qedhttp://www.devinwalters.com/posts/21
17:23qedi havent used it
17:24ohpauleezI'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:24qedright now it takes like 30s to run
17:24ohpauleezI'm looking at the code now
17:25qedcount-and-track seems like the problem
17:31ohpauleezqed, do any repeat, if so you could memoize some of it
17:32ohpauleezanother thing you can do is partition the original set, and send agents off
17:33mjmwow it's been a long time since i visited clojure land
17:33ohpauleezwelcome home
17:33mjmthank you
17:34ohpauleezqed: I have no basis for this claim, but loop might be faster than recur'ing back to the fn call with a let
17:39qedohpauleez: thanks
17:40chouserI'm pretty sure recur'ing to a fn is just as fast as recur'ing to a loop.
17:40ohpauleezqed: 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:41ohpauleezchouser: it doesn't save you the cost of the let biding?
17:41ohpauleezbinding*
17:44chouserin the outer-most loop? I'd be surprised if it made a noticable difference.
17:44chouserqed: you might want to look at using primitive numbers. Everything you've got there is boxed.
17:46ohpauleezqed: http://clojure.org/java_interop#toc36
17:46ohpauleezalso: http://gnuvince.wordpress.com/2009/05/11/clojure-performance-tips/
17:47ohpauleezprimitives + binary ops + == + partition and agent should get you there
18:04kzaryou can't put numbers in function names?
18:05hiredmaneh?
18:06hiredmanfunctions don't have names
18:07hiredmanfunctions can be stored in a var which has a name, or bound locally to a name
18:07qedkzar: you can put numbers in function names
18:07hiredmanin which case the name is a symbol
18:07hiredmanyou can read about symbols: http://clojure.org/reader#toc1
18:08kzarI did (defn 2d-array ...) and it gave me a invalid number java error
18:08hiredmankzar: did you read about symbols yet?
18:08hiredmanthe first line there
18:09kzarok so another answer would have been "you can but not at the start"
18:09qedyes
18:10qedpretty standard for most programming languages ive worked with...
18:11hiredmankzar: yes, but that answer is not as informative as the reader page on clojure.org
18:12gbthiredman: 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:13kzaryea 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:14qedkzar: 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:15hiredman:|
18:15qedno 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_mstor "mu" :)
18:20hiredmanlast time I answered a question with "mu" I got banned from that channel
18:20_mstsome people have no sense of humour
18:20qedlol
18:20qedmu just proves you've read GEB
18:21hiredmanor read a book or two on zen
18:21qedi appreciate the mu answer tough
18:21qed42 is also acceptable
18:22the-kenny42 is always acceptable.
18:23fanaticoWith the latest clojure, I'm getting a bunch of "java.lang.NoSuchMethodError: clojure.lang.RestFn.<init>(I)V". Something break?
18:25hiredmanfanatico: means you need to recompile contrib
18:27kzaroo I like clojure already
18:27fanaticoJust noticed the clojure-contrib 'new' branch. I guess I should be using that instead of the master branch?
18:27hiredmanfanatico: not unless you are using the 'new' branch of clojure
18:28hiredmanand even then, you don't have to
18:29fanaticohiredman: odd. My clojure-contrib is up-to-date (at least with master), and built using the proper clojure jar.
18:29hiredmanfanatico: ant clean and rebuild it
18:30fanaticohiredman: that did it. thanks.
18:32hiredmanclojurebot: clojure.lang.RestFn is <reply>ant clean and rebuild contrib
18:32clojurebotIn Ordnung
18:33the-kennyWow.. I just thought "We should clojurebot teach to say this"
18:41qed(defn make-adder [x] (let [y x] (fn [z] (+ y z))))
18:42qed(def add2 (make-adder 2))
18:42qed(add2 4) ; -> 6
18:42qedthat's so cool...
18:43jasappjust 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:43qedim already getting there
18:43qedim on the brink of lisp snobbery
18:43qedand it feels so good
18:43qedlol
18:44qedthere's already sort of a running rule going between me and some of my programmer friends
18:44qedwhen they're complaining about a problem they're having in x language, i cannot mention clojure
18:45qedcause they will just get angry
18:45jasappI had to stop talking about lisp with my friends that program
18:45jasapptheir eyes just glaze over anymore
18:45qedyeah it kind of sucks
18:46qedi feel like im imparting wisdom
18:46qedand they feel like im being a cocky jerk
18:46qedonce i start telling them "ummm yeah, it's slow, you're using mutable data structures, what do you expect?"
18:46qedthey just glare at me
18:46jasapp"oh no, he's talking about the benefits of consistent structure again"
18:46gbtnow you know what all the old lispers felt like for the last 40 years :)
18:46qedlol
18:46qedgbt: hear hear!
18:47qedpeople who think lisp is just an academic sort of exercise are in for a rude awakening if clojure keeps the pace
18:48tomojmutable data structures slow?
18:48jasappwaiting for locks?
18:49qedwhat jasapp said
18:49jasappreally? that's weird
18:49qed?
18:50jasappit's slow because the code is waiting for locks?
18:50qedjasapp: is that not a benefit of consistent structure?
18:50qedin concurrent applications...
18:51jasappI was thinking mostly of the ability to write macros when I said consistent structure
18:52qeddeterministic behavior in the presence of concurrency
18:54jasappahh
18:54tomojoh I see
18:54jasappwhen I said consistent structure, I was talking about how the language was written in one of it's own data structures
18:54tomojI thought you meant basic algorithms for data structures
18:54tomojwhere mutable is usually faster
18:54qedah
18:54qedyea
19:04qedno matching method found for aget?
19:05JayMwhat do people write with clojure?
19:06JayMi'm interested, but can't think of a project through which to learn
19:10_msthm, can anyone think of a reason that clojure.core/memoize couldn't be modified to use a (transient {}) for its cache?
19:10_mstsome code I'm fiddling with gets a nice little speedup (about 30%) from switching it to use transients
19:10_mstand I can't see anywhere else in clojure's source that depends on memoize
19:11_atohmm.. are transients thread safe?
19:11Knekkhmm, for mutable variables I'd wanna use (ref) ?
19:11_mstit's wrapped in an atom
19:11hiredman"That's all there is to using transients, but they have another important property: Transients enforce thread isolation."
19:11_atoyep but atoms only get you thread-safety with immutable data structures, transients aren't
19:12hiredmanhttp://clojure.org/transients
19:12_mstahh yes
19:12_atoah cool
19:12gbtJayM: 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_mstso it'll blow up if two threads try to access it :) oh well
19:14hiredmanif 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_mstyep, I was looking to squeeze better performance out of qed's code above through dirty trickery :)
19:15chouserif you want a mutable collection, use one of java's
19:19fanaticoand 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:19littleidea(not-every? nil? '(1 nil 2))
19:20StartsWithKok, is the only way to load, in clojure, something at runtime to launch another jvm instance with updated classpath?
19:21hiredmanStartsWithK: you can just load a clojure file
19:21StartsWithKhiredman: and for non clojure parts?
19:22hiredman*shrug*
19:22StartsWithKlets say i want to load my ant wrapper, how will i do that?
19:23hiredmanI can't say I looked at your code at all after you mentioned add-classpath
19:23StartsWithKor 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:23hiredmanbut if you have ant.clj, you do something like (load-file "ant.clj")
19:24StartsWithKand ant.jar? i can't find a way to load that
19:24hiredmanStartsWithK: technomancy was doing something where he unpacked jars into a directory
19:24StartsWithKthat requires a restart
19:24hiredmannot the last I heard
19:25_atoStartsWithK: it's a limitation of the way the JVM's classloader hierachy works, you can't reliably change the classpath at runtime
19:25hiredmanyou put ./foo/ on the classpath and unzip jars into ./foo/
19:25StartsWithK_aot: yes you can, or something like osgi (and eclipse) would never work
19:26_atoyou can create a new classloader and load things in that
19:26_atobut it's hard to get it to work for all jars, as you've seen with add-classpath
19:26StartsWithK_ato: not realy, at least i don't know any way to do it in clojure
19:27StartsWithKhiredman: i'll try that, if it works.. wee
19:27_atojust do whatever eclipse and osgi do
19:27tomojI don't like that swank-clojure-project adds the jars in lib/ to the classpath instead of adding lib/*
19:27_atoI assume they probably use some scary thing like this: http://classworlds.codehaus.org/
19:27tomojI wonder if there's a reason it does that
19:28_atotomoj: lib/* doesn't work with java 5
19:28tomojah
19:28tomojif I patch it to use lib/*, I should be able to drop a jar in there and load it without restarting, right?
19:28_atonope
19:28StartsWithK_ato: i would use osgi i could :)
19:29StartsWithKif*
19:29tomojoh, lib/* is just sugar for listing all the jars in lib/?
19:29_atojava just expands the * on startup, it won't monitor the directory and add new stuff you drop in
19:29tomojdarn
19:29tomojoh well
19:30_atoyeah... the way java handles classpaths is just a huge nuisance :(
19:32StartsWithKhiredman: wow, that worked!
19:32StartsWithKany side effect with meta-inf stuff?
19:40hiredmanStartsWithK: no idea
19:46StartsWithKthanks for help, night all
19:53lisppaste8timbray pasted "contrib build borked?" at http://paste.lisp.org/display/90831
19:53joshua-choiHey, has anyone played with the new deftype/protocol features for Clojure 1.1?
19:54twbrayTaking all the defaults, can't seem to build the clojure-1.0.0-compatible contrib... http://paste.lisp.org/display/90831
19:57twbraySurely there must be a way to get clojure-contrib without building a Maven environment?
19:58spuztwbray: last time I used it, the contrib build was just an ant script
19:58joshua-choiI'm pretty sure it still has the ant script
19:59joshua-choiHave you tried "cd your-contrib-directory; ant"?
19:59twbrayspuz: Yep, it's ant all right, but by default it fails unless you have some Maven dung in place
19:59spuztwbray: what's the error?
20:00twbrayspuz: http://paste.lisp.org/display/90831
20:00joshua-choiI 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:00twbrayThe README.txt seems to say perfectly clearly that some Maven Ant Tasks are required to build. pfffffffffffffffffrghl
20:01spuztwbray: that looks like an ant error, not a maven error...
20:01twbrayspuz: Agreed
20:02spuztwbray: are you building off the latest version of the master contrib branch?
20:02twbrayspuz: clojure-1.0-compatible branch
20:03twbrayMaybe I have an old ant here. Never mind, off to shave yaks.
20:04spuzwhat version of ant do you have?
20:04twbrayspuz: OMG from 2005. <blushes>
20:04twbrayJust ignore me for a while
20:10technomancytwbray: shouldn't you be working on *ruby* at rubyconf? =)
20:11technomancyas is stuart h
20:11technomancyand possibly ola bini too
20:14kzarIs there a way to do something like range but with just the start number?
20:16_ato(iterate inc 5)
20:16_atoto start at 5 and keep going forever
20:20kzarah sweet
20:48djorkIs there a handy fn to turn a keyword into a "clean" string?
20:49_mst,(name :foo)
20:49clojurebot"foo"
20:49hamza,(name :keyword)
20:49clojurebot"keyword"
20:49tomojwhat is refer-clojure for?
20:50tomojI used to put (:refer-clojure) in my ns declarations, but stopped and noticed no difference
20:51fanaticoIt's included automatically.
20:51fanaticoYou'd use :refer-clojure to exclude certain functions, for example.
20:54tomojooh
20:54tomojthanks
20:54tomojso (:refer-clojure) is redundant
20:55tomojah 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:59tomojI feel like it might be cool if ns could be extended
20:59tomojwould that be cool or evil?
21:00tomojI guess that doesn't even make sense because you'd need to load your extensions before using them
21:20polypuswould be nice if else were def'd in core to true. conds would look a bit nicer imho
21:20polypusno :else
21:21hiredmanany non-nil value will do
21:21hiredmanwell
21:21hiredmanbesides false
21:21polypusyeah, i'm just thinking of the aesthetics more than anything
21:23polypus(cond p x q y else z)
21:27tomojyour idea is to replace :else with else?
21:28hiredmanyou wouldn't have to (def else true) in core
21:29hiredmanjust stick a let in the cond macro expansion
21:30qedanyone care to explain (defn make-adder [x] (let [y x] (fn [z] (+ y z)))) (def add2 (make-adder 2)) (add2 4)
21:31qedHow does (fn [z] get 4)?
21:31qederr (fn [z]) get 4?
21:32tomojmake-adder returns that fn
21:32tomojyou then name that fn add2 and pass 4 to it
21:32qedyeah i just noticed that
21:32hiredmanmake-adder evaluates to (let [y x] (fn [z] (+ y z)))
21:32tomojis there a reason for that let?
21:32hiredmanwith each x replaced with 4
21:33hiredmantomoj: it is from one of the examples on clojure.org, demoing closing over locals
21:33tomojseems to work just fine without the let renaming
21:33hiredmantomoj: sure
21:33tomojoh, hmm
21:33tomojis closing over locals significantly different from closing over fn params?
21:34hiredmanI've never looked at let
21:34tomojare fn params significantly different from let locals?
21:35tomojI mean, fn params are "locals" too, right?
21:35hiredmanfn params are fields
21:35hiredmaner
21:35hiredmanno
21:35hiredmanthats not right, closed over values are fields
21:38hiredmanhuh
21:38tomojhuh
21:42qedthere was this example i wass looking at that showed how you can do something like (10 fn) i think
21:43qedit was something that seemed counterintuitive to me
21:43tomojtaht doesn't look right to me
21:43qedlike you could call 10 on a function
21:43tomoj10 doesn't implement IFn
21:43qedor you could call something on a function that didnt seem normal
21:43hiredmanyou can't
21:43hiredman:foo
21:43qedmaybe it was something like ([] fn)
21:43hiredmanor 'foo
21:43hiredmansure
21:43hiredman,([1 2 3] 0)
21:43clojurebot1
21:44qedoh right :)
21:44tomojwhat do symbols do as functions?
21:44hiredmanjust keywords
21:44hiredmanlike
21:44tomojoh yeah I see
21:44tomoj,('foo {'foo 3})
21:44clojurebot3
21:49rhickeyaargh - my messages to the group seem to be going to the ether :(
21:58JAS415you need to get approved by a moderator... oh wait... :-P
22:01hamzais there a merge like function that will add keys together or do i have to roll my own?
22:02jkkramer,(doc merge-with)
22:02clojurebot"([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:04hamzathank you. that worked.
22:17JAS415,(doc i-need-something-to-persist-data)
22:17clojurebotI don't understand.
22:17JAS415,(doc it-doesn't-have-to-be-sql)
22:17clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$my-doc
22:20joshua-choiI've got a question about the datatypes in Clojure's new branch
22:20joshua-choiI want to deftype a type so that it can be compared for equality with vectors and lists
22:21hamzaJAS415: you can write objects using clojure.core/prn to a file as string and read it back using clojure.core/read-string..
22:21joshua-choiIs that possible at all, like by overriding interface methods?
22:22joshua-choiSay, it has two fields: (deftype result [product state])
22:22joshua-choi(I meant (deftype Result ...))
22:22joshua-choiCan I override any interface methods to get it so that (Result :something :some
22:23joshua-choiOops... can I make it so that (= (Result :x :y) [:x :y])?
22:23JAS415yeah 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_atojoshua-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:34zaphar_psWhy is clojure not picking up the classes in my classpath?
22:35joshua-choi_ato: Thanks, I'm trying that out now.
22:36zaphar_pshttp://clojure.pastebin.com/m5a7d668
22:36zaphar_psit is pointed at the contrib jar
22:37zaphar_psyet does not see the contrib namespaces
22:37_atozaphar_ps: did you mean "use" instead of "refer"?
22:37zaphar_psuse had the same problem
22:37zaphar_psthat was attempt number three
22:38zaphar_psI'm using head from github as of yesterday if that makes a difference
22:38zaphar_psabout to pull down any changes and recompile to see if that fixes it
22:39_atostrange... yeah maybe there's something wrong with your contrib jar
22:39zaphar_psnothing in my classpath works
22:39zaphar_psthe previous compiled version did work
22:40zaphar_psthe clj-stacktrace.repl namespace is unavailable as well
22:40zaphar_psand I haven't recompiled that and it worked before
22:40_atoweird
22:41zaphar_psvery
22:41_atoyou should be getting a could not find types.clj error
22:41_atonot namespace is unavailable
22:41zaphar_psif I do a use I get: java.lang.ClassNotFoundException: clojure.contrib.types
22:41_atodid you quote it?
22:42_atothat's what I get if I do (use foo) instead of (use 'foo)
22:42zaphar_psno I did not
22:42zaphar_psheh
22:43_atoyeah, I'm always making that mistake as well. (use '...) needs a quote while (ns (:use ...)) doesn't
22:43JAS415that'll happen the first 10 times or so
22:43zaphar_psnow that I feel stupid I'll go back to learning this clojure stuff :-)
22:43JAS415i have a post-it next to my computer about that
22:43zaphar_psheh
22:44zaphar_ps_ato: yeah I think the :use vs use difference is what thew me
22:46zaphar_psI was building a tap testing library as a learning excercise and just noticed that the clojure test lib has one already :-)
22:46zaphar_pssame namespace as mine whoops
22:47zaphar_pswell not exactly same namespace cause mine doesn't have the clojure prefix
22:52zaphar_psin clojure what's the preferred way to prefix your namespaces for libraries?
22:55tomojI use the java convention
22:55tomoj(reverse domain name)
22:56zaphar_psI see some doing name/last/first
22:56zaphar_psis that standard for individual contributors?
22:56_atothat's a domain name
22:56_atolast.name
22:58_atopersonally I don't like the domain name thing, so I just try to choose a unique name for the project
22:58_atobut the domain-name way is probably more popular
23:01zaphar_psahhh ok
23:14tomojI like unique names better too
23:14tomojbut I suck at thinking of them
23:14tomojso I just use my domain name
23:15technomancytomoj: just be aware that if the project ever outlives your interest it will be awkward to move
23:15tomojwhen using the domain name?
23:15technomancyyeah
23:16tomojI want a web app that just generates random unique names for software
23:16tomoj...that are relatively pronouncable - not just strings of random characters :)
23:17tomojI guess I can do fairly well by using lojban lujvo, maybe I'll try that
23:19hamzais 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:20tomojwhy do you want a boolean?
23:21tomoj(boolean (some ...)) works, but is not very useful I think unless you're passing booleans to java
23:21hamzai would like to know any of the values in the vector is present in the mac as a key.
23:22tomojright
23:22tomojin clojure 2 is just as good as true
23:22tomoje.g. (if (some {...} [..]) ... ...) would work just fine
23:22hamzaok, so i can safely use this in a if.. you just answered it
23:22hamzathanks..
23:22tomojthe only reason to prefer booleans I can think of is java interop
23:23hamzai was thinking in terms of java..
23:23tomojfalse and nil count as falsey things and every thing else is truthy
23:23tomojso, actually, using (some {...} [..]) will be problematic if any of the values in the map is false
23:24hamzano they are all integers
23:26tomoj,(some #(contains? {"a" false "b" false "c" false} %) ["c" "b"])
23:26clojurebottrue
23:26tomoj,(some {"a" false "b" false "c" false} ["c" "b"])
23:26clojurebotnil
23:27tomoj(some #(contain? {...} %) ...) will give you a boolean, but it only matters if the map has nil or false as a value, I think
23:27tomojer, contains?
23:29hamzaheheh missed that one.
23:31tomojI think actually the only reason we have true and both false and nil is for java