#clojure logs

2009-04-26

01:00chessguy,('(fn [x] (x*2)) 4)
01:00clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
01:00chessguy,((fn [x] (x*2)) 4)
01:00clojurebotjava.lang.Exception: Unable to resolve symbol: x*2 in this context
01:00chessguy,((fn [x] (* x 2)) 4)
01:00clojurebot8
01:02hiredman...
01:07chessguysorry just playing
01:07hiredmandon't mind me
01:08chessguyquite alright, bedtime for me anyway
02:01cadshow's this channel's clojurebot secured against some kind of malicious code?
02:01cadsis it hard to do?
02:02hiredman~sandbox
02:02clojurebotsandbox is http://calumleslie.blogspot.com/2008/06/simple-jvm-sandboxing.html
02:13msinghdid anyone reply to me before?
02:25hoeckmsingh: looking at the log, no one answered
02:25hoeck~log
02:25clojurebotlogs is http://clojure-log.n01se.net/
02:25hoeckand I don't know much about SOAP either
02:29replacamsingh: I'll probably be giving the SOAP thing a whirl in a week or two
02:29replacait's mostly just wrapping existing java stuff
02:30replacamsingh: do you have a need for it or just curious
02:30replaca?
02:46msinghreplaca: sorry was afk. Yes i have a need for it. Atm im using a python library (like the one i linked to above) but i'd rather work with lisp
02:53replacamsingh: do you know java?
02:53msinghreplaca: Yeah i work with Java at work
02:54msinghbut i dont want to write java at home :P
02:54replacawell, yeah, you'll have to wrap some
02:54replacaso it's good to know it
02:55msinghi tried googling for soap and java but got some badly outdated links to books from 2000/2001
02:55replacado you know clojure yet, or just getting on board?
02:55msinghjust getting on board
02:55hiredmanI thought everyone is doing rest these days
02:55msinghi know common lisp adequately though
02:56replacayeah, I've got one API that we built where soap just work better cause of it's complexity
02:57replacaso my advice is look at the apache axis library
02:57replacahttp://ws.apache.org/axis
02:57replacaand wrap that to do what you want
02:58replacaI can send you a PDF that shows how to do it in java for our system
02:58replacabut you'd be on your own to make it work in clojure til I get to it
03:00msinghsure please give the link
03:00replacahave to be email, not a public link
03:02replacait's only a semi-public doc
03:03msinghyou should have got a pm from me
03:09msinghgot it, let me have a read.
03:09replacacool, hope it helps!
03:09replacaI'm going to crash now. Goodnight all!
03:10msinghthanks! good night :)
04:30unlinkIs there a shorthand for (let [x 1] (let [y (+ x 1)] y))?
04:30unlink(or with a 3rd level)
04:39cgrand1unlink: (let [x 1 y (+ x 1)] y) ?
04:40unlinkOh, it depends on the ordering.
04:41cgrand1yup (let [y (+ x 1) x 1] y) won't work
04:41unlinkyeah
04:41cgrand1you can evan write (let [x 1 x (+ x 1)] x)
04:41cgrand1even
04:42unlinkBut you can't make recursive calls to x, it seems.
04:43cgrandif you want to define recursive fns use let-fn
04:43unlink(doc let-fn)
04:43clojurebotI don't understand.
04:43unlinkwhoops
04:44unlinkletfn has strange syntax
04:44cgrand,(letfn [(a [x] (inc (b x))) (b [y] (* 2 y))] (a 3))
04:44clojurebot7
04:46unlinkI always expect the ( to come somewhere after the function name
04:46cgrandwith let you would have written (letfn [a (fn [x] (inc (b x))) b (fn [y] (* 2 y))] (a 3)) but it would have failed. To convert from let to letfn rewrite each XXX (fn ....) into (XXX ...) that's all
04:47unlinkI guess if I really want that syntax I can use letfn*
05:00cgrandbetter write you own macro on top of letfn
05:23AWizzArdMoin
06:00Lau_of_DKHey boys
06:01Lau_of_DKI have a very nicely written Clojure program, which I ant-compiled to a jar, and it runs very beautifully, very functionallly, without any errors, but once its finished and the main loop terminates - the program lingers, it doesnt halt - why?
06:01Carka thread is still running
06:02Carki had this problem with a timer
06:04Lau_of_DKYes, it seems one of them lingers - can I force their death ?
06:04Carkwell if you'd kill it, your program wouldn't be beautyfull anymore
06:04Carkyou should gracefully close it =P
06:05unlinkpthread_join
06:05Lau_of_DKI think I'll kill it
06:05Lau_of_DKI can benefit from clojurebots thunk execution
06:10Lau_of_DKSince this is a http stress-tester, then no shame in the server bukling
06:10Lau_of_DKclojurebot: where are you?
06:10clojurebothttp://github.com/hiredman/clojurebot/tree/master
06:12Carkah that looks like cool stuff
06:12Lau_of_DK,(loop [] (recur))
06:12clojurebotExecution Timed Out
06:12Lau_of_DKIt sure is
06:17Lau_of_DKMan, it works beautifully :)
06:27Lau_of_DKThats hot hiredman :)
06:36Lau_of_DKException, the .stop Thread method is horribly deprecated
09:21AWizzArdis there already a function to calculate the average value of l vector of numbers?
09:44karl_"Someone, somewhere" would be my answer. Not in the standard lib as far as I know though.
10:01Chousukemight be in contrib
12:52unlinkuser=> \u1d11e
12:52unlinkjava.lang.IllegalArgumentException: Invalid unicode character: \u1d11e
12:53unlink(char 0x1d11e) gives me \ud11e
13:02dreish(let [chars (make-array Character/TYPE 2)] (Character/toChars 0x1d11e chars 0) chars)
13:08G0SUBany idea how to get M-. to work with Clojure + SLIME?
13:25dreishunlink: Even easier would be just "\uD834\uDD1E"
13:26unlinkI guess I didn't really appreciate that Java doesn't let you put !BMP chars in a "char"
13:26dreishRight, char is UTF-16.
13:27dreishI discovered that some time after getting into Clojure.
13:27unlinkWell, more importantly it's exactly 2 bytes.
13:28unlinkThis is surprising behavior when you're used to Python's unicode handling.
13:29dreishJava was one of the first languages to adopt Unicode, before supplementary characters existed.
13:30unlinkYes. Well it's not clear if UTF-16 is a strength or limitation. There are tradeoffs no matter which encoding you choose.
13:30unlinkIt's clearly a limitation if you have to handle supplementary characters a lot.
13:31G0SUBany idea how to get M-. to work with Clojure + SLIME?
13:32unlinknth can give you 1/2 a character, and length gives you a surprising number when your string countains supplementary chars.
13:36dreish,(let [s "\uD834\uDD1E"] (.codePointCount s 0 (.length s)))
13:36clojurebot1
13:36dreish:-/
13:37unlinkIs that unexpected?
13:37dreishNo, just a little inconvenient.
13:38dreishI don't know why there isn't a no-args version of the method that covers the whole string.
13:39unlink>>> len(u'\U0001d11e')
13:39unlink1
13:40dreishMaybe someday Clojure can be improved to make these kinds of things more convenient, but I doubt it'll be a high priority this year.
13:43unlinkI've never seen a character outside BMP unless I was looking for one.
13:58unlinkI've put up a site you can post interesting clojure projects to: http://trevor.caira.com/clojure-projects/
14:10Chouserwell, shoot.
14:10ChouserI just wrote a nifty little app for use internally at my company.
14:11ChouserI chose Clojure because, well, I'm a fanboi. But also because I was looking forward to providing a single .jar that would give them not only an app, but a Clojure REPL should they ever realize they need one.
14:12Chouserthis is glue stuff -- a very small piece of logic with interfaces for TCP/expect, tftp, and dbus
14:13Chouserthe first two are fine, but dbus needs to use a unix socket in this case.
14:13Chouserjava doesn't support unix sockets without a separate JNI .dll/.so
14:14Chouser...and suddently deployment gets a lot more complicated. Do I ask the user to install a prerequisite package for their particlar repo?
14:14ChouserOr do I try to stick the .so in the .jar, and unpack it for them on startup?
14:15Chouserwhere do I unpack it to, such that it has appropriate permissions without creating a security hazard?
14:15Chouserif they download their own, what if the versions don't match what I bundled?
14:15ChouserWhy didn't I just write it in ruby and deplay a .gem?
14:21dreishChouser: I don't think deploying JNI is so unusual.
14:22ChouserIs there an easy way to do so in a single .jar?
14:22cp2jkljljl
14:22dreishIf I were doing it in Eclipse, on a Mac, I know I would just right click on the project, pick Export ..., and choose Mac application bundle.
14:23dreishNot much help if you're not using Eclipse or deploying for the Mac, I know. :-/
14:23dreishLooking at a resulting app bundle, I see a directory with several jars and two .jnilib files.
14:31Chouserdreish: hm, ok.
14:31Chouserwell, maybe I shouldn't give up just yet.
14:31ChouserI found some answers on forums that were not at all encouraging.
14:31dreishChouser: It might get unreasonably ugly if you absolutely can only deliver one jar file.
14:31Chouser...should teach me to trust the Internet.
14:32dreishThen you're stuck trying to do something like unpack the jnilibs from the jar, in your app, and then ... ? Maybe even have to relaunch the app? I don't know.
14:35danlarkinreal answer: shouldn't have written it in clojure :_/
14:36hiredmanwell, any jvm language
14:37hiredmantargeting the jvm is targeting java space, "The Enterprise"
14:37gnuvince_Hello all
14:39p_lChouser: I guess you'll have to distribute an archive, to be unpacked, which would contain all the parts and a wrapper script...
14:49Chouserhm
14:49Chouserbut I *like* clojure. I don't want to write it in ruby...
14:51dreishYou could write a Clojure program that outputs Ruby code at runtime.
14:59Chouserhm
14:59Chousermaybe perl
15:06dnolenChouser: can you just a shell script and call it from Clojure?
15:06dnolenjust write a shell script I mean.
15:08dnolenI've have something like this in one of my libraries: (defn shell [com] (. (Runtime/getRuntime) (exec com)))
15:09Chouseryes, but the thing I would exec would have to be installed as well.
15:09Chouserhalf of one, six dozen of the other...
15:10dnolenand you can't just package the shell script in the .jar? I have to admit I know very little about deploying .jars, the REPL is everything to me :)
15:39Lau_of_DKHey guys
15:43unlinkhello ??
15:44Chousuke:p
15:46unlinkmik�?
16:22AWizzArd_,(* 1.5 0.4 250)
16:22clojurebot150.00000000000003
16:23AWizzArd,(* 1.5M 0.4M 250)
16:23clojurebot150.00M
17:05gnuvince_~seen Cark
17:05clojurebotCark was last seen in #clojure, 653 minutes ago saying: ah that looks like cool stuff
17:32DTrejo~seen gnuvince
17:32clojurebotgnuvince was last seen in #clojure, 3046 minutes ago saying: I don't know, I don't think I've ever used --rev
17:32DTrejo--rev
18:07Raynes"Never argue with an idiot. They'll drag you down to their level and then beat you with experience."
19:18chessguy'evening
19:20durka42evening
19:21chessguyanybody up for some chat about concurrency in clojure/
19:21chessguy?
19:28hiredmanchessguy: ?
19:28chessguyso this is sort of more of a design question than a technical question, i suppose
19:29chessguyi have this very complex idea, and a pretty good idea of the kind of things i want it to do, but no clue where to start
19:30chessguythe idea is, i want to provide a way of expressing ideas around genetic programming
19:30chessguybut i want it to be a more interactive style than the typical GP engine
19:30techessguy: that sounds familiar
19:31techessguy: I had a massive project/thinking man's fruit sort of idea like yours
19:31techessguy: I can only recommend one thing: plan a little, do a lot
19:31chessguyso i have this notion of a workspace with genetic individuals laying around on it, and also problem instances, and you can use htis sort of DSL to interact with it
19:31chessguyand the DSL will automatically scale up to many cores
19:32chessguyte: what do you mean?
19:33techessguy: idea as abstract and as difficult as yours are only accomplished by doing stuff
19:33teideas*
19:33teit is easy to get into perpetual planning mode with them, redefining the goals etc. all the time
19:33tedon't even consider starting unless you establish some very simple mini goals first
19:33chessguyfair enough
19:33chessguyi don't even have a clue where to start though
19:34chessguylike how do i share the state across commands?
19:34teSTM
19:34tehttp://en.wikipedia.org/wiki/Software_transactional_memory
19:34tehttp://clojure.org/refs
19:35teI recommend Stuart's book
19:35tehe has a good example
19:35chessguyoh nice
19:36chessguyi've been thinking about that
19:38hiredman~jdoc java.util.Formatter
19:38hiredman(don't mind me)
19:39chessguyit took me about 3 seconds to go "was that for me? nah"
19:40chessguyi'm thinking a breadth-first approach would be good
19:40chessguyget a nice variety of features just barely implemented and the build on that
19:44chessguyso i'd want to implement the whole workspace as a ref?
19:47chessguyerr, i mean to say store it in a ref, i suppose
19:55hiredmanman
19:55hiredmanit sure would be nice if tagsoup had a link to the javadoc on the website
20:04chessguywhat's the difference between a form and an expression?
20:04durka42not much
20:05hiredmanclojurebot: what does the hyperspec have to say on the difference between a form and a expression
20:05clojurebothyperspec is not applicable
20:07hiredmanuh, I think it's: everything is an expression, and lists are forms
20:57blbrownjoin #ubuntu
20:58yonatan__hello
20:58yonatan__is there some way to extend a java class from clojure at runtime?
21:02yonatan__nevermind, found it (proxy)
21:02clojurebotproxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.
21:02yonatan__hmm
21:05st3f4nwhat is the clojure equivalent of CL's write-to-string? (to convert a number to a string)
21:09st3f4nah .. str :-)
21:27hiredmanyonatan__: proxy doesn't let you add new methods
21:27yonatan__does it let me override old ones?
21:27hiredmanyes
21:27yonatan__i can live with that. thanks hiredman
21:57st3f4nhmm should compojure trunk work with clojure trunk?
23:00chessguysuppose i needed to do the same thing 10000 times in clojure, and each time resulted in some value, and i'm interested in a collection of the 10000 values. but i want to do this in a way that will split across as many cores as are available. how would i go about that in clojure?
23:01gnuvince_pmap?
23:01chessguy,(doc pmap)
23:01clojurebot"([f coll] [f coll & colls]); Like map, except f is applied in parallel. Semi-lazy in that the parallel computation stays ahead of the consumption, but doesn't realize the entire result unless required. Only useful for computationally intensive functions where the time of f dominates the coordination overhead."
23:03chessguyyou're saying do (pmap f (range 1 10000)) or something?
23:05chessguy,(let (f (fn [] 3)) (f 8))
23:05clojurebotjava.lang.IllegalArgumentException: let requires a vector for its binding
23:05chessguy,(let [f (fn [] 3)] (f 8))
23:05clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--3142$f
23:06chessguyoooh, nasty little error message :)
23:06chessguy,(let [f (fn [] 3)] (f))
23:06clojurebot3
23:06chessguy,(let [f (fn [x] 3)] (f))
23:06clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--3154$f
23:07chessguyso why is pmap only useful if f is expensive?
23:10hiredmanp overhead
23:10hiredmanthread bookkeeping, etc
23:11chessguybut what if f is cheap but the number of times it needs to run is huge?
23:12hiredmanhmmm
23:12hiredmantry it and see
23:12chessguyi don't have multiple cores handy to test with :)
23:36eeehi
23:36eeei kinda need help understanging something
23:36eeeor I'm too lazy to read up
23:36cipher,slurp
23:36clojurebot#<core$slurp__4614 clojure.core$slurp__4614@1625b8c>
23:37cipher,eval
23:37clojurebot#<core$eval__3985 clojure.core$eval__3985@17bcd8f>
23:37eeewhat's the relationship of generics in java to data structures in clojure?
23:37cipherclojurebot: slurp?
23:37clojurebotslurp is worse
23:38ChouserThe type parameters given in java generics are erased before they hit bytecode.
23:38ChouserThey are invisible and completely ignored by Clojure.
23:38Chouser,(doc slurp)
23:38clojurebot"([f]); Reads the file named by f into a string and returns it."
23:38eeeso like what if I make a java data structure that calls specific functions on a template parameter
23:39cadshey, where can i find documentation on clojure that's been generated in the style of an rdoc?
23:39cadslike how can i print out all the functions in a namespace, and their doc strings?
23:39Chousereee: can you do that? I know almost nothing about Java generics.
23:39cipher,(slurp "/proc/cpuinfo")
23:39clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission /proc/cpuinfo read)
23:39ciphercool!
23:40eeelike the heap I am trying to make foe clojure in paraterized on a type T that "extends" (should have been implements but java got it wrong for generics) "Comparable"
23:40eeeis parameterized
23:41Chousereee: my guess (and it's only a guess) is that the instance will be cast to Comparable at any call sites.
23:41eeeso clojure throws out the specifix type, but the type still needs 'compareTo' to be implemented
23:42eeeand, if I made the heap require a template param that has "getPriority()" be implemented, would that make it useless to clojure programmers?
23:43eeeyou'd try to insert something and it would crash because the type you inserted wouldn't have a 'getPriority()' method?
23:44eeesee, my problem right now is that my heap really only takes a priority
23:44eeeit can only compare one priority to another
23:45eeeso if you wanted to say that you had some ADT, say Car A
23:45eeeand it compared equal to Car B
23:45eeeyou could end up deleting the wrong car
23:46eeebecause they both compare equally even though they are different objects
23:46eeehmmmmm
23:47eeealso in clojure if you were to change the priority, you'd change the identity
23:47eeebecause you are what you equal
23:48chessguyhm, you are what you equal. very profound
23:49st3f4ni'm watching the clojure screencast from peepcode.com
23:49eeei just realized something after I said that
23:49eeethat may be true for clojure
23:49eeebut I can check address in clojure
23:49eeecool
23:49eeemight have an idea
23:49eeethanks
23:49eeehows the peepcode, st3f4n
23:50st3f4neee, it is well done, but it touches a LOT of stuff in just an hour
23:50gnuvince_st3f4n: have you watched the screencasts by Rich?
23:50st3f4nno not yet
23:50eeea non-clojure person I know watched it and concluded that there are "just as many gotchas in clojure as in anything else"
23:50st3f4nwell, partly
23:50gnuvince_OK.
23:50gnuvince_st3f4n: if you got a Lisp background, the "Clojure for Lisp Programmers" is a really nice one.
23:51st3f4neee, sure, clojure is not the holy grail :)
23:51st3f4ngnuvince_: thanks, i'll find that one
23:51eeewell, it has to be better than python for some people.
23:51eeeto me, that's not hard
23:51eeebut
23:52eeeif you don't already have a jvm, python can be a lot more low ceremony
23:52gnuvince_eee: the way I figure it, people have more problems when something is consistent than when it has a lot of rules and exceptions.
23:52st3f4nso far i like clojure a lot
23:52eeei agree gnuvince_
23:52st3f4nthe one thing that i don't like is the error reporting .. the java stack traces are completely unusable
23:52eeeI don't see outgrowing clojure
23:52eeeBUT
23:52eeesoooooo many macros and growing
23:53eeedouble edged sword macros
23:53gnuvince_Case in point: people saying that prefix notation is unnatural and can't get used to it, yet these people are able to handle prefix, infix and postfix in the same language with different precedences
23:53eeewell, I'm off to play with my ideantity woes in this heap
23:53gnuvince_identity woes?
23:53eeei agree with that, too
23:53eeebut with macros, you can go just as crazy
23:54st3f4npersonally i think it is weird if a programmer has problems with prefix notation
23:54eeeclojure's concept of identity, ya know? not mine, literally!
23:54eee:)
23:54eeenice chattin
23:55st3f4nthe peepcode screencast is cool but i find a bunch of things that they should do differently .. like using (when ..) instead of (if () (do ...))
23:55gnuvince_I haven't seen it.
23:55st3f4nand i think there was something like 'you create a list with quote (a b c)'
23:56st3f4nwhich is a little misleading and the parens are missing :)
23:56cipherI've been kind of annoyed at having to watch screencasts to learn the language. it feels like the documentation is weaker than the videos.
23:57chessguythe plus side of the peeopcode screencast is a nice demonstration of different concurrency feature
23:57chessguys
23:57st3f4nyeah, it is a nice example
23:57st3f4nand i get all motivated after watching it :)
23:57chessguycipher, it's better than having to go back to the academic papers, like in haskell :)
23:57gnuvince_I think that regardless of whether it's the best screencast ever, it gives Clojure more exposure, which can't be bad.
23:58st3f4ndo you think Clojure can give real errors and stack traces in the future? or will it always be stuck with the stack traces that is has now?
23:58cipherit's nice, but videos like a search feature. implement that and I'm game :)
23:59gnuvince_st3f4n: I don't know. I hope they could be improved somewhat, but ultimately, whatever Java gives, Clojure gives you.