#clojure logs

2010-04-11

00:51DrakesonAfter deftype'ing foo, how can I create an instance with named arguments? (deftype foo [a b]) (foo {:a 1 :b 2}) fails.
00:52hiredman(defn foo-named [& {:keys [a b]}] (foo a b))
00:55Drakesonhiredman: thanks. I was hoping for a deftypek or something like that
00:58carkh,(let [a (fn [& {:keys [a b]}] [a b])] (a {:a 1 :b 2})
00:58clojurebotEOF while reading
00:58carkh,(let [a (fn [& {:keys [a b]}] [a b])] (a {:a 1 :b 2}))
00:58clojurebot[nil nil]
00:58carkhok the & was an error, right ?
00:58carkhi hoped for a new syntaw for named parameters
00:59hiredmanright
00:59hiredmanif you are passing a map
00:59hiredman ,(let [a (fn [& {:keys [a b]}] [a b])] (a :a 1 :b 2))
00:59hiredman,(let [a (fn [& {:keys [a b]}] [a b])] (a :a 1 :b 2))
00:59clojurebot[nil nil]
00:59hiredmanbah
00:59hiredmanclojurebot isn't running a new enough clojure
00:59carkhok so that's a new syntax ? cool !
01:00carkhbeause defnk has the problem that it's not showing a very informative parameter list in slime
01:00hiredmanclojurebot: git 277f0235c1387ddd6247a72857597814a3e10bc3
01:00clojurebotadd &form and &env implicit args to macros
01:00hiredmanbah
01:00hiredman:D
01:01hiredmanclojurebot: git 5772be9fc5ac9ddf92b727908c20b9aab971224a
01:01clojurebotgitorious mirror is http://gitorious.org/clojure/clojure
01:01Drakesonit is a commit of march 23
01:01hiredmanclojurebot: github 5772be9fc5ac9ddf92b727908c20b9aab971224a
01:01clojurebothttp://github.com/richhickey/clojure/tree/master
01:01hiredmanclojurebot: you suck
01:01clojurebotexcusez-moi
01:01hiredmananyway, a patch of mine made it in
01:01hiredmansweet
01:02carkhyay for you =)
01:03carkhi can't wait for 1.2
01:03hiredmanhttp://github.com/richhickey/clojure/commit/5772be9fc5ac9ddf92b727908c20b9aab971224a
01:59defnhow does one "turn on" the new {} = everything syntax?
02:00defn{reduce + {1 2 3 4}}, etc.
02:00chouser??
02:01defnI saw an example where there are no []s or ()s, just {}s
02:01chousernever heard of it
02:01defnhuh, really?
02:02hiredmanno such thing
02:02defnill see if i can find the post that mentioned it
02:02chouseryou're sure it was clojure and not some kind of scheme?
02:02defni wonder if it was on april 1st
02:02defn:)
02:03TakeVdefn: That was April Fools, yeah. :P
02:04defnbahahaha i feel so silly
02:04defnwho wrote that?
02:04defni need to kill them...
02:06defnah yes, sean devlin
02:06defnthat monster...
02:08TakeVThat was along with something like "Everything returns void now, so it's really easy to make all your function full of side effects. This is awesome."
02:09defnhahaha yes now that im watching it again i get the joke -- i was just listening along working on something else and looked over when he mentioned the "new" syntax
02:52scottjin joy of clojure they have (in C like languages), "a == b && b == c && a == c". Why do you need the last one? What would be a case where the first two tests being true wouldn't have the third be true?
03:01greghperhaps the case where == is an overloaded operator that does not have the transitive property
03:01gregh== is transitive for usual data types like integers and strings
03:01gregha non-transitive == operator would be highly unusual, actually :)
03:26Raynes,(macroexpand '(doseq [x [1 2 3]] (println x))
03:26clojurebotEOF while reading
03:27Raynes,(macroexpand '(doseq [x [1 2 3]] (println x)))
03:27clojurebot(loop* [seq_9167 (clojure.core/seq [1 2 3]) chunk_9168 nil count_9169 (clojure.core/int 0) i_9170 (clojure.core/int 0)] (if (clojure.core/< i_9170 count_9169) (clojure.core/let [x (.nth chunk_9168 i_9170)] (do (println x)) (recur seq_9167 chunk_9168 count_9169 (clojure.core/unchecked-inc i_9170))) (clojure.core/when-let [seq_9167 (clojure.core/seq seq_9167)] (if (clojure.core/chunked-seq? seq_9167) (clojure.core/let [c__52
03:27RaynesOh boy.
03:30chouseryou think that's bad, you should look at 'for'
03:30RaynesLicenser: ping.
03:31Rayneschouser: For some reason, clj-sandbox isn't whitelisting that. That means that one of of the functions it uses isn't whitelisted, but it looks like everything but println is whitelisted, and println is whitelisted locally in sexpbot so I think it should be working.
03:32RaynesThis sucks.
03:33Raynes$(for [x [1 2 3]] (+ x 3))
03:33sexpbotDENIED!
03:33RaynesSame problem there, looks like.
03:35RaynesMacros are tricky little buggers.
03:38Rayneschunk-buffer and chunk-append weren't whitelisted, so maybe I can get for to work. :O
03:43RaynesOr not.
03:54RaynesOh no.
03:55RaynesWell, we're screwed. doseq and for both use the '.' special form. It's what's causing the problem here.
03:56RaynesMaybe this will be incentive to fix the . problem.
04:01Crowbar7time to invent a new key on the keyboard
04:10LicenserRaynes: pong
04:10RaynesLicenser: We has us a problem. :p
04:11RaynesLooks like several useful macros can't be whitelisted unless '.' is whitelisted. :o
04:11LicenserRaynes: there are no prolems there are only challanges :P
04:11RaynesIndeed.
04:11Raynescondp uses throw as well.
04:12Licenserhrm
04:12Licenserheh
04:12RaynesIt's not telling me why condp isn't working.
04:12RaynesJust ().
04:12RaynesBut, it's obvious throw is probably part of that reason.
04:12Raynesdoseq and for both do (.nth ..)
04:13RaynesWhich is killing us.
04:13Licenser,(condp = 1 1 "a" 2 "b")
04:13clojurebot"a"
04:13Raynes,(throw (Exception. "Hai"))
04:13clojurebotjava.lang.Exception: Hai
04:13Licenserhrm seems I've to make this . replacement soon :(
04:13RaynesThe sooner the better. ;)
04:15RaynesWell, I guess throw isn't the only problem in condp. Still didn't whitelist it.
04:15RaynesMaybe it's because it mentions a Java class?
04:17RaynesLicenser: I just pushed with some new chunk functions that I missed.
04:17Licenserneat
04:17LicenserI've an 'simple' idea for . but I'll have to give that a look later got to go sadly
04:18RaynesKay. Have fun. :)
04:18Licenserthanks see you later
04:24defnhello all
04:30defnls
06:02imran_srHi. I was wondering if there is an equivalent of pmap for filter? I see some references online to a clojure.parallel namespace, but I don't see that anywhere in clojure.core or clojure-contrib
06:07Rayneschouser: Which one of you wrote the self-licking lollipop bit in Joy?
06:11imran_srRaynes: (intejecting, clojure newbie here), is there an equivalent to pmap for filter? I can't find the clojure.parallel namespace which is mentioned in Volkman's tutorial
06:11Raynesimran_sr: I'm not sure. :(
06:12imran_srok
06:13patrkrisimran_sr: http://clojure.org/other_libraries - perhaps this is what you're looking for
06:13patrkrisat the top
06:13patrkrisbut the library is deprecated
06:13imran_srpatrkris: thanks, I'll check that out
06:19patrkrisimran_sr: perhaps you can do something with the partition function, pmap and filter - but maybe that'll add too much overhead
06:21imran_srpatrkris: you mean roll my own pfilter?
06:21patrkrisimran_sr: yeah, sort of
06:22imran_srpatrkris: (strip-out-nulls (pmap my-filter-func? sequence))
06:22imran_srkind of like that?
06:23patrkrisyeah, or you could use partition to divide your sequence into pieces, and each piece can be handed to your filter function, which will then filter out some elements
06:23ChousukeThat's only useful if the filter function is really slow
06:24patrkrisChousuke: because the partitioning will be too slow in most cases?
06:24dcnstrcthi. The "lein deps" command has never worked for me with any project. I'm having difficult time I must be missing something obvious.. could anyone take a look and give me a pointer ? thanks; http://gist.github.com/362636
06:24Chousukeand the overhead of threading
06:24patrkrisah
06:24Chousukeand it's not like it can divide the sequence in pieces. it still needs to go over it linearly
06:25patrkrisChousuke: yeah, that's what I meant by it being too slow
06:25Chousukeso the operations on individual items much take enough time for parallelisation to make sense at all
06:25imran_srbtw, does using pmap have any consequences for laziness (in other words, does it somehow make it un-lazy)?
06:25Chousukeyes
06:25Chousukeit stays ahead by a few items I think
06:26Chousukebut it's not completely strict
06:26imran_srChousuke: but only by a few?
06:26patrkrisChousuke: do you happen to know whether partition works more efficiently if it detects a vector being partitioned?
06:26Chousukepatrkris: no.
06:26Chousukeas in, no, it doesn't. :)
06:26patrkrisok
06:27ChousukeThere is an experimental parallel library for reducing/mapping over vectors efficiently
06:27Chousukein the par branch of the git repo.
06:28Chousukeit works by mapping/reducing in parallel over the chunks that a vector is made of
06:28bsteuberdcnstruct: could you also post you project.clj?
06:28ChousukeBut it depends on a JDK7 feature (which is available as a jar for JDK6). I guess that's why it's not merged to master yet.
06:29patrkrisChousuke: so what would be the ideal way to parallelize on large sequences in clojure as of now?
06:30Chousukepatrkris: pmap
06:30imran_srGentlemen, I have a (overly verbose, fairly dumb and brute force) solution for project euler 5, which I wanted to use a base to try out simple parallelization. Mind if I post a pastebin of it? I'm not sure how I would roll my own pfilter that would work for that
06:30Chousukepatrkris: sequences are inherently non-parallelisable
06:30patrkrisChousuke: i see what you mean
06:30Chousukepatrkris: they are, after all, sequences. :)
06:31dcnstrcthttp://gist.github.com/362640 <--- project.clj thanks for taking a look. the proejc tI'm trying to build is here: http://github.com/ugglan/cljaws
06:31patrkrisChousuke: you are right, of course
06:31ChousukeHm
06:31ChousukeLooks like some tickets in contrib assembla should be closed ;P
06:32imran_srhttp://clojure.pastebin.com/cJLEu3et
06:34patrkrisChousuke: is there any way of efficiently partitioning a vector? Maybe there is something fundamental I don't understand :)
06:34Chousukepatrkris: that's what the par library does
06:35Chousukepatrkris: internally, vectors are trees so they are very amenable to parallel processing
06:35patrkrisChousuke: ah ok
06:35Chousukepatrkris: but that fact is not exposed via a public API
06:35Chousukeyet.
06:36patrkrisChousuke: but I guess one could use arrays as an alternative?
06:36bsteuberdcnstruct: lein deps for cljaws works on my machine
06:37bsteuberdcnstrct, I mean
06:37Chousukepatrkris: well, arrays are sequential too, but since they're indexed I suppose they can be partitioned easily
06:37bsteuberso it seems like something might be wrong with your lein / maven install
06:38bsteuberdo you happen to use windoze?
06:38dcnstrctubuntu 9.10
06:38dcnstrctI installed lein with the install script
06:38dcnstrctabout 3 weeks ago
06:38dcnstrctI can try removing it and doing that again I suppose
06:39dcnstrctis that what you're using ? the stable lein
06:39bsteuberyes, same ubuntu, same lein
06:39bsteuberweird
06:40dcnstrctwell thnx for the confirmation that it's a weird problem and I didn't miss anything really obvious.. that's good enough for now :)
06:41bsteuber:)
06:49Chousukehm
06:50Chousukeassembla could use some "needs approval from Rich" toggle for tickets
06:51ChousukeThere seem to be quite many tickets that float in a limbo because they have neither been accepted nor rejected :/
08:41mikem~def to-byte-array
08:41clojurebotexcusez-moi
08:59defnat clojure.core$seq__3538.invoke(core.clj:107) at clojure.core$map__4077$fn__4078.invoke(core.clj:1877)
08:59defnhow do you read that?
08:59defnwhere is invoke called?
09:00defnis there a good resource to trace the roots of invoke?
09:02Chousukeit's the step function of a map
09:02Chousuke-a
09:03Chousukeclojure.core/seq calls an anonymous function defined within clojure.core/map and that throws an exception
09:06Chousukeinvoke is the java method that actually contains the code of a clojure function, so you can just ignore it and think "function call"
09:08defnChousuke: by step function are you referring to something like (map #(+ % 4 2) [1 2 3 4])
09:08defnChousuke: where #(+ % 4 2) is the step function?
09:08Chousuke~def map
09:09Chousukeeh, that's out of sync again
09:10defnChousuke: im reading it -- a little thrown by the lazy-seq and chunked stuff still
09:10Chousukelazy-seq might create a function too.
09:10defncould you clarify step function? is that a piece of the lazy seq?
09:10defnChousuke: ah
09:11ChousukeI mean just the function that gives the "rest" of the sequence
09:11defnChousuke: but does not necessarily evaluate it?
09:12Chousukewell, of course not. except for its first element.
09:12Chousukebut the rest is only generated when the first element is needed so that's okay
09:12defnChousuke: okay, i see, thanks
09:12Chousukeanyway, most likely something is wrong with the function you're passing to map
10:46Licenserdefn: as a advice, if you encounter things like that name your anonymous functions
10:46Licenseruse (fn function-name [] ...) instead of #(...)
11:03RaynesI'm strongly against naming anonymous functions. Goes against everything they believe in. ;)
11:03RaynesLicenser: What's your "simple idea" for '.'? :o
11:07Ankouhi, is there something like memfn for static methods?
11:08RaynesAnkou: You don't want to use memfn.
11:08RaynesUse an anonymous function instead.
11:08RaynesIn both cases.
11:24Ankouwhy not memfn?
11:33chousermemfn predates the #() syntax -- since it's less general, it probably will be deprecated
11:35LicenserRaynes: beasically to alias a function to . in the namespace
11:36RaynesLicenser: Indeed. That would be dead simple.
11:36Licenseryea but I'm not sure if it works/how good it works :P
11:36RaynesWell, it's an idea. Ideas make me happy. :>
11:38Licenser^^
11:40Licenserhrm
11:40Licenserbut not working
11:41Raynes:(
11:41Licenserforms take priority over functions
11:42Licenserso it actually is back to walking the entire form and replacing all . wiht dot or whatever
11:42Licenserand keep . itself blacklisted
11:42Licensernarf this will be horrible
11:42LicenserI'm not sure if this is going to work
11:42Licenserhmm I see a flaw here
11:43Licenseris there a macro that runs stuff while being evaluated?
11:45Licenserso defmacro is a way out
11:45Licenser,(defmacro x)
11:45clojurebotDENIED
11:45Licenserokay nice
11:51Licenserhrm
11:53RaynesIs there some sort of tool to count the number of lines of every file in a directory and it's sub directories recursively?
11:53Raynes:o
11:54LicenserRaynes: (for i in `find .`; do cat $i; end) | wc -l
11:54Licenseror something along the line
11:55StartsWithKwc -l `find .`
11:55ducki2pfind . -type f -exec wc -l {} \; | awk '{total += $1} END{print total}'
11:55Licenser(for i in `find src`; do cat $i; done;) | wc -l
11:55StartsWithKwc -l `find . | grep .clj` for clj only
11:56Raynes:o
11:56RaynesThanks, everybody. :p
11:56Licenserheh there are so many ways
11:56ducki2pplenty of choice; pick one :)
11:56Licenseralso you could write a clojure program to do that for you
11:56RaynesMy bashfoo is weak.
11:56LicenserI love for :P
11:56ducki2pthere is also a special tool for this class of problems
11:56ducki2p'google' :)
11:57StartsWithKRaynes, http://paste.pocoo.org/show/200415/
11:57StartsWithKto count clojure files, no empty lines and no comments
11:57RaynesSexpbot is 938 lines. O.O
11:57RaynesStartsWithK: Cool. Thanks.
11:57StartsWithK.. so support for (comment ..)
11:58StartsWithKso=no
11:59Raynes884 lines. :D
11:59Licenserheh
11:59RaynesThat makes it the largest project I've ever written in any language.
11:59LicenserI am urprised that find . -name *.clj does not go into sub directories o.O
12:00LicenserRaynes: heh
12:00ducki2pLicenser: put quotes around *.clj, so your shell doesnt expand that
12:00Licenserah darn it I feel stuid now thanks ducki2p
12:01RaynesOf course, you have to subtract around 40-50 lines for the bf interpreter, which I didn't have the heart and courage to write myself.
12:01RaynesAnd around 20 for Rich's Norvig's spelling corrector. :>
12:01LicenserRaynes: it also counts newlines which are not LOC :P
12:02ducki2panother useful tool for this is sloccount; not sure if it natively recognizes Clojure
12:02Raynesducki2p: It doesn't.
12:02Licenserclj-cat `find . -name "*.clj"` | grep -v "^$" | grep -v "^;" | wc -l
12:02Licensertry this
12:02ducki2pdarn
12:02Licensercoderay does that too, but also not for clojure
12:03LicenserI think that is a pretty good aproximation
12:03Raynes861
12:03Licenserclj-sandbox gets about 400 there
12:03LicenserAlso I'm not sure that many LOC are a good thing :P
12:03asimjalisHi
12:04Licenserhi asimjalis
12:04LicenserI personally would be glad of the sandbox code had less, well we could technically substract save-fn's since it is more a database then code
12:04Licensernearly 90 LOC in there
12:06AsimJalisI was checking to see if I could post to the channel. Now that I can I have nothing else to say. At least for now.
12:06Licenserheh
12:13AsimJalis Are there any examples of generating Java or some other language using Clojure?
12:13AsimJalisI mean human-readable code rather than .class files.
12:13AsimJalisOr just code -- it doesn't have to be human-readable. But still actual code.
12:15LicenserAsimJalis: there is something that generates JS from clojure
12:15Licenserand it is pretty readable too
12:15AsimJalisAlso I am not looking for a Clojure translator. I just want to define my own mini language inside Clojure and then have a translator that translates a sexp composed of this mini-language into the target language.
12:15AsimJalisLicenser: What is it called?
12:15LicenserI don't remember :(
12:16AsimJalisWell, at least now it's no longer an unknown unknown. So thanks for that :-)
12:16Licenserscryptica and scrypticus
12:17LicenserAsimJalis: now it's even a known to you :P
12:17Licenserscryptica is the up to date one it seems
12:18Licenserwell I'm dead tired :( night people
12:18Licenser(doc macroexpand)
12:18clojurebot"([form]); Repeatedly calls macroexpand-1 on form until it no longer represents a macro form, then returns it. Note neither macroexpand-1 nor macroexpand expand macros in subforms."
12:19AsimJalisNeat. Thanks!
12:33AsimJalisYeah, Scryptica looks more complete.
12:39RaynesAsimJalis: COBOL is for Cwitters!!!! :p
12:53Drakesonwhere are things like swank:pprint-eval defined? in slime or in swank-clojure?
12:57chouserI've got to shuffle network boxes around. Nobody say anything important... :-)
13:53asimjalisThe recursive solution seems more flexible -- if I want to bite off different amounts each time.
13:54kirasWhen I have a line that starts with only one ; emacs indents it to column 40. This happens in elisp-mode and clojure-mode. I was told in #emacs that this is the convention in elisp and that those comments are typically used after other text and to use ;; otherwise. Is this the convention in clojure as well? In Programming Clojure, there are examples where ; is used and it's not indented in this way and at http://clojure.org/reader, it ju
13:54kirasSingle-line comment, causes the reader to ignore everything from the semicolon to the end-of-line. with nothing about indentation.
13:55kjellskiHi there =)
13:56kjellskiSomeone familiar with the labrepl arround?
13:58asimjalisWhat is labrepl?
13:58kjellskiThere was an example with a "data/words" file. I wanted to get the frequencies of characters in all the words and I´m struggling with the summing part...
13:58zakwilsonIf I have maps of keywords to ints and I want to speed up (merge-with + foo bar), can I do that with type hints? Unchecked math?
13:58kjellskilabrepl is a project from stuart halloway... it´s ment to explain clojure...
13:58asimjalisI asked the same question when it was mentioned on HN -- the README does not say what it is, just how to get it.
13:59kjellskiBasically it´s a local website with some stuff to play with for leaning and exploring clojure...
13:59asimjalisOk.
14:00kirasIn vim, the comments are indented as in Programming Clojure...
14:01asimjaliskjellski: Ok. Thanks. Your summary should be snuck in somewhere at http://github.com/relevance/labrepl
14:02kjellskiExcuse me, what does snuck mean?
14:02chousersneak
14:02chousersneaked
14:03asimjalisOh, sorry. It should be inserted somewhere at http://github.com/relevance/labrepl
14:03kjellskiOkay... I´ll try to find a good solution first ;)
14:03dcnstrct,(gen-and-load-class 'my.CoolException :extends Exception)
14:03clojurebotjava.lang.Exception: Unable to resolve symbol: gen-and-load-class in this context
14:03dcnstrcthrmmm
14:04chousergen-and-load-class is ancient -- been gone for ages
14:05dcnstrctahhh damn ancient wikibook confused me http://en.wikibooks.org/wiki/Clojure_Programming/Concepts#User_Defined_Exceptions
14:05dcnstrctwhat should I google then ?
14:05asimjalisis proxy the current way to do this?
14:05chouserproxy is okay except you can't really rely on the classname that it generates
14:06chousergen-class is your best option, but it requires AOT compilation.
14:06hoeckkiras: when in doubt, consider looking at core.clj :)
14:06kirashoeck: ah... i should have thought of that. ty
14:07chouserare you sure you need your own named exception class? I'd recommend looking at clojure.contrib.condition
14:08hoeckkiras: in core, I found both ; and ;; for whole-line comments
14:08kirasso it's being indented incorrectly in emacs?
14:09The-Kennykiras: ;; is the correct comment for a whole-line comment in my and emacs' opinion
14:09The-KennyAs far as I remember, ; gets indented wrong by emacs
14:09The-Kenny(right-aligned)
14:09dcnstrcthrmmm now that I think about it there's no reason why I need singly-typed errors. thnx
14:10kirasThe-Kenny: that's my experience too, but I'm wondering if emacs is right or wrong
14:10The-KennyI think emacs is right. I read about this loose-convention somewhere on cliki.net
14:10kirasThe-Kenny: since i've seen clojure ; comments formatted the other way too
14:11kirasThe-Kenny: I was told it was correct for elisp, just would like to be sure that it's also correct for clojure
14:12hoeckkiras: I guess those are "standard" lisp comment conventions
14:12The-Kennyhoeck: I think so too. Saw it on cliki.net somewhere
14:12asimjalisI was reading the comments about jobs at the clojure site in a recent conversation here http://clojure-log.n01se.net/date/2009-12-14.html . . .
14:12hoeckkiras: eg, see http://norvig.com/luv-slides.ps p. 41
14:12kirasas hoeck pointed out, in core.clj ; is not indented to column 40
14:12The-KennyIt's also described here: http://www.labri.fr/perso/strandh/Teaching/Langages-Enchasses/Common/Strandh-Tutorial/indentation.html
14:12kirasfor example:
14:12kiras;during bootstrap we don't have destructuring let, loop or fn, will redefine later
14:12kiras(def
14:12kiras #^{:macro true}
14:12kiras let (fn* let [& decl] (cons 'let* decl)))
14:13asimjalisThe clojure jobs I see here list it as something interesting to have with no expectation that it will be used at the job . . .
14:13asimjalisFor example, "Interest/experience in interesting languages (Lisp, Scheme, Erlang, Scala, Smalltalk, Haskell, Forth, Clojure)"
14:13asimjalisThis is from http://sfbay.craigslist.org/sfc/sof/1667187845.html
14:14kirasI was just wondering if the same conventions held in clojure... it seems kind of strange that it wouldn't be followed in core.clj of all places?
14:14asimjalisAre there companies using Clojure in production?
14:14asimjalisHow does one find them?
14:16dcnstrctif you're good @ clojure and looking for a clojure job in the bay area check out this company
14:16dcnstrcthttp://www.runa.com/company/careers/
14:16dcnstrctthey're running clojure in production
14:17dcnstrctthey're the guys who made this http://github.com/amitrathore/swarmiji
14:18dcnstrctsupposidly everything there is in clojure except one rails app.. they use swarmiji in front of hbase to power all their stuff
14:20dcnstrctif you get the job paypal me 10% of your first 3 months salary for the recuritment fee
14:20dcnstrct;)
14:23hoeckasimjalis: http://www.infoq.com/articles/deadline-clojure-appengine
14:23asimjalisOk.
14:23asimjalisHeh.
14:23asimjalisHow about 20% -- you're selling yourself short.
14:24dcnstrctdeal
14:27kjellskiasimjalis: This is my solution... could you have a look wethere there is a better way to do it? http://paste.lisp.org/display/97649
14:30Blackfootis there a way to break out of loops? sometime the like (doseq [foo bar-seq] (if foo (println ok) (break))
14:30Chousukethrow an exception
14:31dcnstrctclojure.contrib.condition is your friend
14:31Chousukeof course, the better way is to filter your sequence so that it is not longer than you need it to be.
14:31Chousuketake-while is helpful
14:35Blackfootok, reading through those, thanks. It is not an exception in the logical sense, but it may work
14:35lopex(doseq [x '(1 2 3 4 5) :while (< x 3)] (println x))
14:38Blackfootlopex: perfect! thank you
15:01Hali_303what do you use for debugging? nothing I've tried seems to be able to do single stepping or at least tracing
15:03Hali_303eg. cc.trace/dotrace is pretty limited (can only instrument functions which are in the form given, but not those which are called within deeper levels)
15:09opqdonutyeah
15:09opqdonutso I use prns and staring at code
15:13ChousukeJava debuggers should work on Clojure.
15:25zkimIf you're adventurous there's hugo duncan's break stuff: http://hugoduncan.org/post/2010/swank_clojure_gets_a_break_with_the_local_environment.xhtml havn't tried it myself though
15:35dcnstrctif a certain function requires Ahead Of Time compilation what does that mean exactly ?
15:35dcnstrctdoes it mean I can't start a normal clojure repl and use it ?
15:36StartsWithKdcnstrct, yes, you will need to compile the namespace where that function is declared
15:36StartsWithKand then add compiled version to classpath
15:37dcnstrctargg
15:37dcnstrctdoes anyone know of a way to work with user definied exceptions in clojure that does not require AOT compilation ?
15:37asimjalisWhat's the specific problem you are dealing with?
15:37StartsWithKbut fns don't need aot, is there a gen-class in there?
15:37dcnstrctI have a function that needs to be able to throw a couple different kinds of exceptions as well as return a value
15:38dcnstrctI have a gen-class yeah
15:38asimjalisCould you just throw Runtime exceptions? Or subclasses of some well-known exceptions?
15:39dcnstrctwell my original approach was to subclass java.lang.Exception: (gen-and-load-class 'user.UserException :extends Exception)
15:39dcnstrctbut then I found out gen-and-load-class is gone
15:39dcnstrctI could throw Runtime exceptions
15:40dcnstrctthats a good idea
15:40StartsWithKdefine all your exceltions in one package, but as java files, and stick http://paste.pocoo.org/show/200563/ something like this in your build
15:40StartsWithKand your done
15:41dcnstrctoh right.. just use java to define the exceptions.. good idea too
15:41dcnstrctthnx people
15:41asimjalisOr you could use proxy and create subclasses of Exception or some special Java Exception that is already defined.
15:45sattvikdcnstrct: If you are using Clojure 1.1, proxy may be your best bet, although it is a bit limited. In one project I used both proxy and gen-class within the same namespace so that I could use proxy during development and gen-class for deployment. With Clojure 1.2, you get deftype which is fairly flexible given many of the advantages of proxy and gen-class all in one.
15:47StartsWithKbut deftype can't extend Exception
15:47StartsWithKor it can now?
15:49sattvikStartsWithK: Hmm.. not sure. I can give it a try.
15:50StartsWithKsattvik, i think it can only extend interfaces from java side
15:55sattvikStartsWithK: I think you are right.
16:11TakeVHmm, so with Penumbra, is there a trick to making it be an executable jar? Using the standalone, but it still doesn't work.
16:13StartsWithKTakeV, not sure about Penumbra, but JLine keeps its native libs inside the jar and unpacks them to temp dir before executing rest of its code
16:13StartsWithKother options is something like webstart (supports jogl)
16:14TakeVStartsWithK: It seems to not be able to find the main class. I didn't know that clojure had main classes. 0_o
16:14Hali_303zkim: does that work with swank-clojure in ELPA?
16:14StartsWithKTakeV, everything on java must have entry point
16:15StartsWithKi guess, it is something you will define for your app and not something penumbra provides for you
16:15TakeVStartsWithK: How do I do that?
16:16zkimHali_303: Not sure, I wouldn't think so unless the ELPA package is running off of swank-clojure's HEAD
16:16zkimIt's on my list of things to look at though, I was really excited to see that post come across my reader
16:17StartsWithKTakeV, define one of your namespaces as (ns my.entrypoint (:gen-class :main true)) and create function named "-main" that takes no arguments in that namespace
16:17Hali_303zkim: I see. so println is the best thing I can have now, right?
16:17StartsWithKthen compile that namespace with clojure.compile
16:17TakeVHuh, thanks.
16:17zkimHali_303: AFAIK, yes. JSwat or YourKit might help also
16:18StartsWithKother options are, you use clojure.main -e "(require 'my.entrypoint) (-main)"
16:18Hali_303zkim: I tried JSwat without any luck a few months ago
16:18StartsWithKor custom java launcher
16:19zkimHali_303: yeah, when I was starting out with clojure I was really aware of the lack of debugging tools, and as I've done more and more it hasn't been a big problem
16:19asimjalisIs there an easy way to deploy Clojure desktop apps? I created an app and I have it compiled into an uberjar, but my users might not have Java installed.
16:19TakeVLein keeps throwing all kinds of errors now. Hmm...
16:19zkimHali_303: although I'd qualify that with the fact that I havn't done anything really big with the language
16:19dcnstrctasimjalis, yes... use jaunch4j
16:20dcnstrcterr launch4j
16:20StartsWithKTakeV, can you paste what it is?
16:20StartsWithKlisppaste8, help
16:20zkimHali_303: off topic, but 303 as in Denver?
16:20StartsWithKhttp://paste.pocoo.org/
16:20TakeVException in thread "main" Java returned: 1 (NO_SOURCE_FILE:0)
16:21asimjalisdcnstrct: Thanks! For a second I thought jaunch4j was the Clojure version of launch4j. I'm looking at it right now.
16:21TakeVThe rest of the error is quite long.
16:21StartsWithKuse the paste.pocoo.org
16:22Hali_303zkim: no, it is just random string, so my name does not conflict with others
16:22Hali_303:D
16:22TakeVhttp://paste.pocoo.org/show/200581/
16:22zkimHali_303: ah, got it :)
16:23asimjalisI am almost scared of asking questions because they all get answered -- do I really want to know in some cases?
16:23zkimHali_303: but yeah, I mostly use println and c.c.pprint
16:23Hali_303zkim: hm I've not yet used pprint, but looks nice, thanks
16:23zkimHali_303: np
16:25TakeVStartsWithK: Would you like me to post my code and project.clj?
16:26StartsWithKTakeV, sure, maybe some can spot the error
16:27TakeVhttp://paste.pocoo.org/show/200583/ --- Project.clj is on the top, the source file is on the bottom.
16:28StartsWithKwhat did you use as argument for -e option
16:29StartsWithKit looks like eval throws the error
16:29TakeV-e option?
16:29StartsWithKuf, and, just to be safe, use two segment namespace names
16:29StartsWithKwings.foo
16:30TakeVAh.
16:31TakeVNot sure what the -e option is. Trying to compile it with "lein compile", after running "lein deps" and "lein native-deps".
16:31StartsWithKone of the problems i see
16:31StartsWithKis app/start
16:31StartsWithKits outside any function
16:31StartsWithKplace that inside your new -main
16:31StartsWithKas lein compiles the namespace, clojure will execute your code
16:34TakeVhttp://paste.pocoo.org/show/200586/ -- Result of running "java -jar wings-standalone.jar -Djava.library.path=native/linux/x86".
16:37kzarWhat's wrong with this? (for [[x y] (range 10)] [x y]) I'm trying to grab values out of the range in pairs
16:37opqdonut, (partition 2 (range 10))
16:37clojurebot((0 1) (2 3) (4 5) (6 7) (8 9))
16:38opqdonutthat tries to do a destructuring bind
16:38StartsWithKTakeV, when you type jar -tf wings-standalone.jar can you see "wings/core.class" file inside your jar?
16:38opqdonut, (let [thing [[1 2] [3 4] [5 6]]] (for [[x y] thing] y))
16:38clojurebot(2 4 6)
16:39opqdonutthat's how destructuring works
16:40TakeVStartsWithK: No.
16:40StartsWithKTakeV, hmm.. did you update :main in your project.clj to wings.core?
16:41TakeVYes. Hmm... let me clean and recompile.
16:42TakeVHuh, still not appearing...
16:42technomancydcnstrct: do you know about clojure.contrib.condition?
16:43technomancyit's much nicer than defining your own Exception subclasses
16:43StartsWithKTakeV, same error? and no .class file in jar?
16:43TakeVYes, to both.
16:43StartsWithKis there some kind od buld/classes dir in your project
16:43StartsWithKcan you see .class file in there
16:43TakeVYes, there is a dir. But there are no files in there. 0_o
16:45StartsWithKTakeV, hmm
16:45kzaropqdonut: But what if the 'thing' isn't a vector of vectors, it's just a vector? (let [thing [1 2 3 4 5 6]] (for [[x y] thing] y))
16:45opqdonutkzar: then you get an error :)
16:45kzarheh
16:45opqdonut, (let [thing [1 2]] (for [[x y] thing] y))
16:45clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: Integer
16:46opqdonutbecause 1 is not a sequence
16:46StartsWithKTakeV, what is compile step saying?
16:46StartsWithKdo you see something like compiling wings.core
16:46TakeVThe only thing it prints is "All :namespaces already compiled."
16:47kzaropqdonut: ah ok I see, but what if I want to take items from the front of a vector each time?
16:47opqdonutwell one answer is partition
16:47StartsWithKTakeV, maybe you then need to add :namespaces [wings.core] to your project
16:48kzaropqdonut: Ah sweet I got it working thanks
16:48StartsWithKis there a lein user in the house? :)
16:49StartsWithKit looks compile will search for :namespaces and then skip to some kind of namespace guessing
16:50StartsWithKby matching file names
16:50StartsWithKis your file in src/wings/core.clj
16:50TakeVNo.
16:50Fossiyes
16:51StartsWithKTakeV, place the file in src/wings/core.clj
16:51StartsWithKclean and recompile ad you did before
16:52asimjalisopqdonut: "for" expects thing to be a sequence of pairs. Try this instead:
16:53asimjalis,(let [things [[1 2] [3 4]]] (for [[x y] things] y))
16:53clojurebot(2 4)
16:53TakeVStill just printing "all :namespaces already compiled". Also added :namespaces [wings.core] to the project.
16:53StartsWithKso you have wings/project.clj wings/src/wings/core.clj
16:53StartsWithKin your project
16:54TakeVAh, didn't rename it to core. One sec.
16:55opqdonutasimjalis: i was demonstrating that fact to kzar :)
16:55LauJensenDo we have some clojure wrapper for copying a file ?
16:55clojurebotclojurebot has a lot of features
16:55asimjalisok
16:55TakeVOh good, now it's throwing errors again. >_>
16:55StartsWithKTakeV, aha add :namespaces :all
16:56StartsWithKthat will search for namespaces by filename matching in your src dir
16:56technomancyLauJensen: give two File objects to the copy method in duck-streams
16:56technomancyaka c.c.io
16:57LauJensenthanks phil
16:57technomancygood old duck-streams =)
16:59TakeVhttp://paste.pocoo.org/show/200598/
17:00StartsWithKTakeV, add another ) at the end of your -main
17:00TakeV-_-
17:01StartsWithK:)
17:01asimjalisopqdonut: How could this be done using destructuring recursively in a loop for example instead of using partition?
17:01opqdonutsure
17:01StartsWithKTakeV, also, its ok to place app/start inside the -main
17:01opqdonutthere should be a higher-level construct for this
17:02opqdonutsomething like haskell's tails or common lisp's loop :on or mapcdr
17:03TakeVStill getting the same error. This is starting to become irritating. :P
17:04StartsWithKsame error about missing paren?
17:04TakeVThe EOF thing.
17:04StartsWithKTakeV, you are missing one ) at the end of ns too
17:04TakeVOh. >_>
17:04StartsWithK:)
17:06TakeVhttp://paste.pocoo.org/show/200599/
17:07StartsWithKthere is no jlwgl on classpat while you are compiling
17:07StartsWithKtry :native-dependencies [[lwjgl "2.2.2"]] adding lwjgl dep to :dependencies too
17:08TakeVIn project?
17:08StartsWithKyes
17:08StartsWithKadd [lwjgl "2.2.2."] after penubra
17:19hamza,(proxy [javax.swing.TransferHandler] [] (canImport [s] (println "s")) (canImport [c f] (println "c f")))
17:19clojurebotjava.lang.IllegalStateException: Var null/null is unbound.
17:19hamzais it possible to somehow define two canImport calls?
17:20Crowb4rSpeaking of proxy, is there a good example of using proxy around?
17:43chouserhamza: use (proxy [...] [] (canImport ([s] ...) ([c f] ...)))
17:43StartsWithKTakeV, any progress?
17:53hamzachouser: thanks that worked..
17:53TakeVStartsWithK: Not really. :\
17:54StartsWithKwhats the current error?
17:55TakeVStartsWithK: Same as last time. Got some lunch and just got back. :P
17:55StartsWithKhehe
17:56StartsWithKwhen you type jar -t wings-standalone.jar
17:57StartsWithKdo you see opengl jars inside?
17:58TakeVI can't build the jar, as it will not compile.
18:02StartsWithKok, are the opengl libs in your lib/ directory?
18:03TakeVEr, it started randomly being able to compile.
18:03StartsWithKthat is a good sign :)
18:05danlarkinI'm drawing a blank, what's the best way to subsection an array
18:05danlarkinlike subs does to strings
18:05TakeVOk, yeah, the lwjgl and all required libs are in lib.
18:05TakeVdanlarkin: Partition?
18:05StartsWithK,(doc subvec)
18:05clojurebot"([v start] [v start end]); Returns a persistent vector of the items in vector from start (inclusive) to end (exclusive). If end is not supplied, defaults to (count vector). This operation is O(1) and very fast, as the resulting vector shares structure with the original and no trimming is done."
18:06StartsWithKoh, array, System/arraycopy
18:06danlarkinja but an array, not a seq or a vec
18:06danlarkinoh there we go
18:07danlarkinthanks StartsWithK
18:10carkh
18:12TakeVCaused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path (core.clj:1)
18:12TakeVEr...
18:12TakeVCaused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path (core.clj:1)
18:12TakeVException in thread "main" java.lang.ExceptionInInitializerError
18:12StartsWithKis your lib path ok?
18:12TakeVI don't know. >_>
18:12StartsWithKwhat your lib path?
18:13TakeVwings/lib?
18:14StartsWithKcan you paste "ls -R" from the root of your project
18:15StartsWithKalso, can you try with absolute path
18:16TakeVhttp://paste.pocoo.org/show/200632/
18:18StartsWithKTakeV, your java.library.path shoubl be native/<your-os-arch>/
18:20TakeVStartsWithK: That is what I am passing to java -jar wings-standalone.jar
18:20StartsWithKjava -Djava.library.path=native/linux/x86_64 wing-standalone.jar
18:20StartsWithK?
18:21StartsWithKs*
18:21StartsWithKwith the -D prefix and =
18:21TakeVYeah, only x86. 32-bit for the fail. >_>
18:22TakeVAh, but not in that order.
18:22TakeVOk, that works!
18:22StartsWithK:)
18:23TakeVThank you so very much. :)
18:23StartsWithKnp
18:32StartsWithKwhat is the name of text indexing project for clojure?
18:32StartsWithKi remeber there was one
18:32technomancylucene works fine
18:33StartsWithKcaponia :)
18:35StartsWithKlucene is ~1mb, thats not so bad
18:36TakeVClojure is garbage collected, right? What exactly gets collected, since there are no real variables.
18:37carkhthere are values anyways, and all the java stuff, and persostent data structures
18:38hiredmanTakeV: gc doesn't have anything to do with variables
18:38hiredmanvariables aren't gc, things that are referenced by variables are gc'ed
18:39hiredmanif I create a big map of stuff, but don't keep a reference to it, the map is garbage since I can never use it
18:41asimjalisYou can prod the garbage collector with (System/gc) if you think it's not being aggressive enough.
18:41rlbTakeV: ...or if you create a big sequence, reduce it, etc. The gc will collect anything that's no longer reachable, and computations allocate things with limited lifespans all the time.
18:41asimjalis,(System/gc)
18:41clojurebotnil
18:41hiredmanasimjalis: :(
18:41hiredmannever do that
18:41asimjalisWhy?
18:41clojurebotwhy not?
18:42asimjalishiredman: Why not?
18:44hiredmanit negates the purpose of having a gc
18:44hiredmanbetter to tune heap params
18:45hiredmanhttp://java-monitor.com/forum/showthread.php?t=188
18:45hamzaAFAIK you can't force java gc to run it will only hint it.
18:45hiredmanetc
18:54TakeVrlb: That makes sense.
18:56asimjalisI've found it useful in testing from the REPL to get some idea about the memory footprint of processes.
19:05asimjalisI am writing a Clojure library that lets me write Java as sexps and to use defmacro. Any good starting points?
19:06asimjalisHere is some code in Common Lisp I am using as a starting point: http://www.keyongtech.com/4689544-how-to-do-java-in#14
19:06hiredmanwhy bother?
19:07hiredmanI would either just write clojure, or write clojure to generate jvm bytecode via one of the bytecode engineering libraries
19:07asimjalisI need to deliver Java for work.
19:07hiredman:(
19:08asimjalisI know where you are coming from. I might be taking an overly circuitous solution to this problem.
19:08asimjalisI could switch jobs. So that's another option.
19:08carkhwhat if someone in your team makes a change to the produced java code ?
19:09asimjalisI'll have to quickly backport it.
19:10carkhalso you'll be debugging java code and correcting lisp code ... this will be annoying
19:10asimjalisOr maybe write a Java to Jaja translator that goes backwards (where Jaja is a tentative name for this Clojure-esque Java).
19:10carkherror at line 45 which is line 2 of your lisp code
19:11hiredmandeliver java code that drives a "library" that you provide as a jar
19:11hiredmanyou can call clojure's eval from java :)
19:12asimjalisSo I own a whole module at work. No one else modifies it very much. Everyone lives in their own modules. So this kind of thing does not happen very much. Once in a while some small change bubbles across the whole system.
19:13asimjalisThe problem is that this is a shipping product -- there is not much interest in management to add Clojure to the code-base.
19:13hiredman"I'd like to start replacing some of my java with a dsl"
19:13hiredmanyou've asked?
19:13asimjalisMaybe I just suck at selling. Anyway, I made a case and it was politely declined.
19:13asimjalisYes. I actually brought it up with my manager.
19:14hiredman:/
19:14carkhif yuou leave tha company they need to find someone that will be able to take ownership on your code
19:14asimjalisHe did say though that if there was a compelling feature that could be done with Clojure that couldn't be done with Java or would be nearly impossible with Java then I'd have a stronger case.
19:15asimjalisYeah. So I see his point. They don't want to turn the code base into a Tower of Babel.
19:15carkhwell ...closures is one
19:15carkhand persistent data structures
19:15asimjalisWhat's a customer-facing feature that closures could enable?
19:15carkhless bugs =P
19:15hiredman"witing java makes work so horrible that I do additional unpaid work creating frameworks to generate java code from nicer languages"
19:16hiredmanwriting
19:16asimjalisThis captures my feelings.
19:16carkhwhat language could provide a customer-facing feature that unique to it ?
19:17hiredmananyway, java isn't that bad if you just ignore the type system
19:17hiredmando everything via runnables and callables
19:17asimjalisHe gave me the example of ActionScript which enabled some new flashy UI features that were not possible with JSPs and Javascript.
19:17hiredmanlots of unsafe casts everwhere
19:18asimjaliscarkh: He gave me the example of ActionScript which enabled some new flashy UI features that were not possible with JSPs and Javascript.
19:18carkhit's not the language but the platform
19:18asimjalisTrue.
19:18carkhbut yes i see the point
19:20asimjaliscarkh: So theoretically I don't see how Clojure could provide a concrete user-level feature that Java could not provide. Although I suspect that many features will just be very complicated and hard to write in Java and might be easier in Clojure.
19:20asimjaliscarkh: So there is a stereotype that Lispy languages are better for AI. Is this really true? Theoretically you can make decision trees and prune them in any language.
19:20hiredmanwell, you'll end up reimplementing clojure
19:21asimjalisWe are using a C library called SVM-Light for Machine Learning.
19:21carkhasimjalis: lisps where used for ai because of garbage collection and list processing ....every other language has that now
19:22carkhmaybe macros played a role too i don't know
19:23asimjaliscarkh: Yes, it seems like you can do it in Java if you wanted to. Although I still thing the fluidity of design that Clojure gives you will make it easier to converge to a good design and solution. So the development speed and product quality and flexibility might be higher
19:23hiredmanclojurebot: the evolution of lisp?
19:23clojurebotmy lisp machine is the jvm
19:23hiredmanclojurebot: you suck
19:23clojurebotTitim gan éirí ort.
19:23hamzaasimjalis: since in lisp code is data, it is really trivial for lisp programs to read and modify them selfs.
19:24hiredmanI have a (pdf)copy of some memo from MIT where someone said "I ask for examples of real world uses of lisp, not ai since we all know ai isn't real, but got no responses, so obviously lisp has no real world applications"
19:25carkhsymbols and keywords word decisive for ai too i think
19:25carkhword->were
19:25asimjalisBut things like development-speed and flexibility are so fuzzy.
19:26carkhsymbols and keyword enable the data is code counterpart to code is data
19:26asimjaliscarkh: The data drives the code?
19:26carkhright
19:26carkhlike hum ...in those html libraries for instance
19:27asimjalishum? Is that a library?
19:27carkhyou know type this : [:h1 "hello world"] and it gets transofrmed to html
19:27asimjalisRight.
19:27carkhthat's a simplistic example i guess
19:28asimjalisRight. I know what you mean about [:html ...]. ("Hum" was just a sound.)
19:28carkhah ...hehe sorry
19:29asimjalisThe way libraries are being named right now every typo could potentially be a library or project name. Can't be too careful.
19:30kirashow do you know about project hum?
19:31carkhwho doesn't ?
19:32kirasi see...
19:33carkhhttp://www.dcs.qmul.ac.uk/research/imc/hum/
19:33carkh=)
19:34kiraslol
19:35asimjalisHeh.
19:36kirasso is leiningen pretty much the standard build tool for clojure projects at this point?
19:36The-Kennykiras: I think so
19:37hiredmanthere is a very vocal maven faction
19:38carkhso i'm the only one using ant i guess =/
19:38glogiccarkh: i use ant
19:38glogiccarkh: heh
19:38kirasheh
19:38kirasok
19:38kirasgood to know
19:38glogickiras: ya file that away right
19:38glogickiras: lol
19:38kiraslol
19:43glogichttp://en.wikipedia.org/wiki/Cheney's_algorithm
19:43glogiccheney was a crazy kind of guy
19:44glogicmy head hurts
19:45asimjalisI stopped using leiningen because it wouldn't let me easily include a local jar file that was not published on git -- for example see http://stackoverflow.com/questions/2404426/leiningen-how-to-add-dependencies-for-local-jars
19:45asimjalisI built using a straight bash script -- yeah it's very old-fashioned
19:47tomojyou can just install a jar into your local maven repo
19:47tomojof course, no one else will be able to build the project, then, unless they also install these jars
20:05asimjalisIs clojure being used for machine learning or document classification by anyone?
20:05asimjalisAny references would be great.
20:06hiredmanthe big one would be flightcaster
20:06hiredman~google flightcaster
20:06clojurebotFirst, out of 2160 results is:
20:06clojurebotFlightCaster
20:06clojurebothttp://flightcaster.com/
20:08tomojI heard some of their ml stuff was getting into incanter
20:28tomojthe algorithm I'm implementing uses a global incrementing counter. I was thinking of just using gensym, as all that really matters is that the values are unique, but they need to be unique across jvm restarts
20:28tomojideas?
20:29tomojfairly easy to do the same old incrementing counter with an atom, but you run into trouble across jvm restarts
20:29carkhstore it in a file =P
20:29hiredmanuuid
20:30hiredmangensyms are really not that unique
20:30carkhtho how slow is it to make an uuid ?
20:31hiredmanuh, why would it be slow?
20:31hiredmanuuidgen 0.00s user 0.00s system 67% cpu 0.006 total
20:31carkhi don't know never really looked intop it , surely needs a system call to get time, and maybe another to get mac address ?
20:31tomojreading java.util.UUID
20:33asimjalisThe mac address requires reading the network card.
20:33asimjalisSo it is expensive.
20:34asimjalisBut you could get the UUID once -- and then append your counter to it. So this way it's a one-time cost for the UUID call.
20:34hiredmanwhy do you think a uuid includes a mac address?
20:34tomojI can make 10000 UUIDs in 274ms
20:34tomojplenty quick enough for me
20:35carkhVersion 1 (MAC address)
20:35asimjalisThere are 4 classes of UUIDs. If you use the MAC address you guarantee uniqueness. Version 1 uses the MAC address. The others don't. http://en.wikipedia.org/wiki/Universally_Unique_Identifier
20:35asimjalisWait 5, not 4.
20:36hiredmanthe javadocs don't mention mac addresses at all
20:36carkhlooks like version 4 would be the fastest ?
20:36asimjalisThis is what Windows does.
20:36carkhjava's uuid aren't complete
20:36hiredmanso?
20:36asimjalisBut it might cache the MAC address so multiple UUIDs might not be that expensive.
20:36asimjalisI don't know how it's implemented.
20:36tomojI'm using type 4 (pseudorandom), and I don't care :)
20:37carkhanyways, quick enough for tomoj =P
20:37hiredmanI'm saying who cares about mac addresses if don't need to?
20:37carkhwell i just discovered that not every uuid uses the mac address =P
20:38carkhthat's why i said _maybe_
20:38carkhlooks like not every uuid uses time either =P
20:38asimjalisAlthough the Wiki says that Java uses Versions 3 or 4: ``Java: The J2SE 5.0 release of Java provides a class that will produce 128-bit UUIDs, although it only implements version 3 and 4 generation methods, not the original method (due to lack of means to access MAC addresses using pure Java).''
20:39carkhanyways 10k uuids in 250ms is very slow
20:40carkhcompared to incrementing an integer
20:40tomojsure
20:40carkhso it all depends on the use case i guess
20:40hiredmanpersisting + incrementing an integer
20:40tomojbut it will allow me to focus on the important stuff for now
21:44dcnstrctI finally figured out the bizarre problem I had with lein that was making it never work..
21:44dcnstrctit boils down to this: don't do sudo lein self-install
21:44dcnstrctunless you intend on using lein as root
21:44dcnstrctI don't know why I would have done that anyways... so insecure.. I guess I wasn't thinking
21:45dcnstrctworks great now though :)
21:54tomojdcnstrct: what's wrong with lein self-install?
22:01_atotomoj: he ran it with sudo, so presumably it either installed into /root or messed up the permissions on ~/.m2
22:02tomojoh, I missed the sudo
22:02tomojof course
22:02tomojI've been wondering how you might set up a system-wide lein
22:02Licensergreetings
22:03Licenserhey _ato I'd wanted to ask for another clojars featre :P
22:03Licenser*feature
22:03tomojlein always uses ~/.m2 ?
22:04_atoif you set M2_HOME it'll probably use somewhere else
22:04_atoLicenser: ok
22:04_atoLicenser: what's the feature?
22:04Licenser_ato: very simple thing, a hash of the current feed.clj.gz so people don't download it twice
22:04Licenserit's more to save clojars bandwith then for compfort :P
22:05_atoah, good idea, I'm surprised that didn't occur to me
22:05_atojust a sec
22:05Licenserwell must not be a hash can be anything that identifies if the feed.clj changed
22:07Licenser_ato: it didn't occured to you so it can be a team effort :P
22:08_atohttp://clojars.org/repo/feed.clj.gz.md5 http://clojars.org/repo/feed.clj.gz.sha1
22:08tomojetag?
22:08Licenser_ato: thank you :)
22:13defnhttp://floating-point-gui.de/
22:13Licenser_ato: with this I can make add and search automatically check for new versions and get them :)
22:14Licensergreetings defn :)
22:14defnhello sir!
22:14defn,(+ 0.2 0.1)
22:14clojurebot0.30000000000000004
22:14defnhehe, this is interesting...
22:15Licenserthat is why floats are evil!
22:15Licenserdefn: are you using lein search already? :P I made it specially for you!
22:15_atotomoj: yeah good point, I should make it only touch the file when it actually differs, then the etag and last modified will be correct as well
22:15chouser,(+ 2/10 1/10)
22:15clojurebot3/10
22:16defnchouser: oh of course! i didn't consider clojure's rationals.
22:16defnchouser: either way i was interested as I didn't know about this problem tbqh
22:16defnchouser: the latest edit of JoC looks great btw
22:16clojurebotparedit commands is http://mumble.net/~campbell/emacs/paredit.html
22:17defnLicenser: where do i go to get lein search?
22:17defnis it in the main repo?
22:17Licenserdefn: add [lein-search "0.2.0"] to your dev deps :)
22:17defnooo!
22:17Licenser:)
22:17chouserdefn: great, thanks. should be a substantial treatment of floating point numbers in there.
22:18LicenserJoC
22:18defnchouser: excellent. also i love your dr. seuss quote in there -- the one about beetle battle muddle...something like that
22:18Licenser?
22:19defnLicenser: Joy of Clojure -- chouse and fogus' book
22:19Licenseroh
22:19Licenseris it out?
22:19defnthe first 5 chapters are so far
22:19chouserdefn: yeah, fogus found that quote -- fit perfectly.
22:20Licenserit is open source or is there like a pre purchase preview?
22:21defnpre purchase preview
22:21Licensercan someone give me a link? I am curiose :P
22:21defnof course -- one second
22:22defnhttp://www.manning.com/fogus/
22:22chouserLicenser: http://joyofclojure.com/
22:22LicenserI mean of the purchase page not the preview of caus
22:22Licenserthanks mates
22:23defnchouser: im really excited for the types,protocols, and reify section, and the concurrency /mutation idioms section
22:23defnthe descriptions of "when to use..." make me most excited i think
22:24Licenserneat
22:24chouserdefn: I'm working on the types,protocols, and reify right now. The hard part, as always, is coming up with good examples.
22:25LicenserNeat
22:26defnchouser: i hope i dont presume too much but i am somewhat curious about using examples from JoC in my walton project. Obviously, as you just said, finding good examples is incredibly time consuming. Are there restrictions that preclude my use of the examples in JoC or Stuart's book, for instance? Is it a matter of EPL? The publisher?
22:34asimjalisI am reading the first chapter (the free preview). Looks pretty interesting. Looking forward to it.
22:34asimjalisWhat is the Walton project?
22:35Licenserwalton is an awsome project to let you find example code
22:35defnhttp://github.com/defn/walton , http://getclojure.org:8080/examples/let (replace let with whatever function you'd like examples for)
22:35defnLicenser: you are too kind
22:35defn:)
22:36Licenserand I didn't even start :P
22:38chouserdefn: standard copyright rules, whatever that means in your case.
22:38Licenserdefn: it gets cooler and cooler
22:40chouserdefn: actually, I think the source snippets from Halloway's book are all open source on github
22:41chouserI don't think ours are yet, though that's something I suppose we should look into.
22:46Licenserneat neat!
22:47Licenseris there something like tree-map I missed?
22:52Licenserhmm is there a way to 'appy' things to a form
22:52Licenser?
22:54LicenserI'd need to do something like (apply . object method args)
22:54Licenserhmm defn I just had an idea for walton
22:55Licensersince you use click to expand count the clicks on every string and sort them by the number of clicks :)
22:56chouserLicenser: if you don't know the number of args at compile time, you can use Reflector.
22:56Licenserwith a special form?
22:57chouserno, for a method call
22:57Licenseror instead of .
22:57chouserright
22:57Licenserah sneaky sneaky
22:57Licenserthank you chouser
22:57chouserthere's nothing like apply that would work for arbitrary special forms.
22:57Licensergeez clj-sandbox will be slow :P
22:57hiredmanyou can always use eval to generate a function that does what you want
22:58chouseryeah, that's a good idea too
22:58Licenserhmm true too and a very neat idea hiredman :)
22:58Licensersweet!
22:59Licenserbut is this save or am I opening up a hole *ponder*
23:00hiredmanif you wanted to be safe you shouldn't have left home this morning
23:00asimjalischouser: I tried (infix 1 + 2 + 3) and it didn't work. Where is this defined?
23:00asimjalis,(infix 1 + 2 + 3)
23:00clojurebotjava.lang.Exception: Unable to resolve symbol: infix in this context
23:01chouserasimjalis: infix is defined only in the book. It's just an example, not really meant to be used.
23:01asimjalisok
23:02Licenserhiredman: I am sitting in my bed :P
23:02asimjalisOkay. I just saw that. It was on the next page.
23:03chouserasimjalis: ah. yeah, sometimes the example usage comes before the code.
23:04defnLicenser: lein search is awesome! thank you!
23:04Licenserdefn: :) thank _ato too he's done a hell lot on the clojars side to make it happen
23:05defn_ato: thanks much for the work on lein search -- it's a very helpful utility
23:05Licenserdefn: it makes it more gem like I feel :P at lest there is something neat as search and add now
23:20Licenserwell time to go to work see you alter people
23:20Licenser*later
23:24asimjalisSee ya.
23:25asimjalisClojure is such a dangerous addiction. I almost wish there was a kind of warning label on it. You might not be able to go back to programming as usual after this.
23:25asimjalisIt's too late for me now.
23:25asimjalisAlso I am half-joking (obviously).
23:28asimjalisMaybe this is the difference: When I am programming in Java for a while now I have resigned myself to the realization that almost all code is one-off -- it doesn't matter how it's designed it won't be reused. But with Clojure I feel like the code is always so general that I can't imagine not reusing it again. It feels a lot more valuable somehow.
23:30glogicasimjalis: what's usual?
23:31glogicasimjalis: i'm concerned i can't go back to programming unusual
23:31SirNickIs there anyway to setup lein so that it works something like fsc, Scala's fast compiler, so the startup for the compiler doesn't take so long?
23:32glogicwhen people ask "what's your favorite compiler implementation" i'm going to jsut start saying "Eclipse!"
23:32glogicfeel free to replace eclipse with whatever your favorite huge code generator / editor is
23:34glogicIDE etc..
23:35asimjalisThe code bloat creates two problems: (a) it takes a lot of time to create it (b) it hides the essense of what's going on -- in Eclipse I constantly feel like I am looking for a lost child in a mall.
23:36glogicasimjalis: aren't you?
23:36glogicasimjalis: maybe, Eclipse makes you feel like you ARE the lost child in the mall
23:36glogiclol
23:36asimjalisYes. The child is my train of thought. It's so interruptive.
23:37albinolost child looking for parentage?
23:37glogicthis was pretty awesome btw: http://www.pidjin.net/2010/04/11/stop-me-if-i-can/
23:40asimjalisThat's funny.
23:41glogicasimjalis: right
23:43asimjalisHow to I mention on my resume that I only want to work with Clojure without sounding like some kind of a moron. What's a polite way to say this?
23:43glogicasimjalis: say you'er a java programmer, just fail to mention you program java by way of Clojure
23:44asimjalisIt sounds kind of fanboy-ish and immature. I've always listed the languages I've programmed in.
23:44asimjalisI think it is fanboy-ish and immature if it was said about any other language. But Clojure needs to be an exception.
23:45asimjalisI realize this is all very inconsistent. Hence my dilemma.
23:46glogici think the simplest thing is to do what you've always done, but add Clojure, then in interviews it will make an interesting conversation piece, which you might be able to convince new people to also use Clojure
23:46glogicadding it to your list ofp rogramming languags will make you sound interesting (as lame as that sounds)
23:47tomojI happened to mention clojure only to discover that my CTO loves it and had done SICP in clojure
23:47glogicsee there you go