#clojure logs

2010-10-28

00:00defn^double negative
00:00defnshows how smart I am...
00:01defncemerick: have you had a chance to look at cljc?
00:01replacaback in the day, I knew a guy who picked which language to build his company around by going to conferences and seeing which group seemed smarter
00:01defnreplaca: lol that's awesome
00:01replacahe picked RoR and has been quite happy with the choice
00:01defnwhat if you just get a bunch of arrogant jerks
00:01cemerickdefn: Using double negatives is not a contraindicator of intelligence ;-)
00:02replacawell, it does depend on how good a judge of people you are
00:02replacahis strength was more there than tech, so it was a good call
00:02cemerickArrogance is OK. Jerk is no good. :-)
00:02cemerickreplaca: getting back to normal yet?
00:02replacabut we're better w/o arrogance too
00:03replacano, not really
00:03defncemerick: :) i was wading into uncharted waters with the compiler talk on saturday. my brain is vapor on that subject. lisp in small pieces is slowly making me feel adequate.
00:03replacareminded me of getting home from burning man
00:03replacaa long time to readjust
00:03cemerickreplaca: I was wondering if that tweet was informed by experience. When were you at burning man?
00:03defnit's sort of like a religious experience
00:03replacacemerick: how about you?
00:04defnlike "i've seen clojure you can only hope to imagine."
00:04cemerickdefn: I've not looked at cljc yet, no. It looks like a formidable piece of work.
00:04replacaI've been a whole bunch of times, but only once since kids
00:04defncemerick: yeah i was quite surprised to see it just /pop up/
00:04defnthat's the sort of thing that sits around for awhile collecting opinion and design
00:05cemerickreplaca: I almost got into a groove this afternoon. Working on the contrib build stuff has been a good catalyst for restarting things.
00:05defnor at least that was my impression of it
00:05defni suppose if someone has vision they ought to just go for it
00:05dthomasHi, is there a way to tell if an object is an instance of an array? Like "x instanceof StackTraceElement[]" in Java?
00:05defndthomas, of Wendy's fame?
00:05dthomasYes. Have you seen our $1 menu? It's dynamite.
00:05replacacemerick: I've been doing some clean up. It's been a big fire drill week at work, but I feel like Neo at the end of the Matrix
00:06replacajust looking at the bullets in a very bored way
00:06dthomasAlso I have been dead for years. I should change my nick to zombiedthomas.
00:06defnor rob thomas
00:06defnhe's /basically/ dead
00:06technomancyI've never been one to turn down an offer for discount dynamite from the undead.
00:06defn(inc technomancy)
00:06sexpbot=> 1
00:07cemerick-> (.isArray (class (make-array Object 0)))
00:07sexpbotjava.lang.SecurityException: Code did not pass sandbox guidelines: ()
00:07cemerickuk
00:07defnd'oh
00:07cemerickdthomas: .isArray will work
00:07defnreplaca: i did strangeloop and clojureconj in two successive weekends
00:07defnmy life is in a shambles
00:07cemerickyeah, that sounds tough
00:08dthomastechnomancy: Heh, are you technomancy of swank-clojure fame? I'm actually hacking on that right now.
00:08replacadefn: I'm jealous!
00:08defnlots of dropped balls as a result
00:08replacaI bet
00:08technomancydthomas: any such fame is undeserved; I only maintain it from a distance
00:08technomancylove to get patches though
00:08defnthey'll be back in the air in a few days -- can't go around working all the time, need some hammock time every once and again
00:09dthomascemerick: Yeah, OK, that'll actually work here since it's either going to be an array or not, not varying types of arrays.
00:09replacadefn: :)
00:10cemerickdthomas: you can use instanceof? as well, if you prefer
00:11cemerickbah, instance? I mean
00:11dthomascemerick: What is the second argument? Array?
00:12cemerickdthomas: to instance?
00:12cemerick-> (instance? (class (make-array Object 0)) (make-array String 0))
00:12sexpbotjava.lang.SecurityException: Code did not pass sandbox guidelines: ()
00:13cemericksandbox hell :-P
00:13dthomascemerick: Yeah. I don't know how to spell the type.
00:13cemerickdthomas: The easiest way is (class (make-array base-type 0))
00:13dthomascemerick: Oh, sorry, thought class was the second arg not the first.
00:14dthomascemerick: OK, that was the trouble I was running in to. I someone using Class/forName with the ugly "[Ljava.lang.StackTraceElement;" name too.
00:14dthomascemerick: Thanks!
00:14cemerickthat should work, too *shrug*
00:15dthomasIt does, but I can't decide what's worse: creating an instance just to get its class or using what looks like an implementation detail to look that class up by name.
00:16cemerickClass/forName is definitely not an impl detail :-)
00:16dthomasI'm liking (class (make-array base-type 0)) better.
00:16cemerickYou can stick that in a var and reuse it, thereby avoiding the array creation cost.
00:17dthomascemerick: Certainly not, but the class name of "[Ljava.lang.StackTraceElement;"? I was guessing that was at best how Java serializes the class name, and the serialization format is probably defined along with the language.
00:17dthomascemerick: That class name is for an array of StackTraceElement BTW.
00:17cemerickdthomas: yes, that's part of the java language spec
00:17defncemerick: okay to PM you?
00:17cemerickdefn: indeed, tho I'm off to bed in 5 min :-)
00:33replacacemerick: you're not going to power through for another hour so I can say, "Chas, it's 1:30"? :)
00:36cemerickreplaca: crap no :-D
00:37cemerickI've almost got a normal schedule back down
00:37cemerick5:30 – 5:30
00:37cemerickIt's all hugod's fault that I fell off the wagon tonight. ;-)
00:38replacacemerick: yeah, you really did!
00:39cemerickI used to keep such absurd hours. 53 straight, once. Those were the days.
00:39cemerickNot.
00:42replacayeah, better to keep a sustainable rhythm
00:42replacacemerick: loved the talk on pallet, btw. really learned a lot there
00:45cemerickreplaca: Thanks. :-) I hope it was helpful.
00:46cemerickI was pretty leery about following up such insightful material with a methods and tools talk.
00:46cemerickbut, that's my pay grade, as it were.
01:02RaynesI'm fixing that damned sandbox tomorrow if it kills me.
01:21tomojpinging solr clojure hackers
01:49defnanyone know if stuarthalloway's slides are online?
01:56_rata_hi
01:57amalloymorning _rata_
01:57_rata_hi amalloy
02:12tomojI'm doing sums of a bunch of sparse high-dimensional signed integer vectors
02:12tomojmahout has fast sparse random access vectors, but they only store doubles or floats
02:13tomojwould switching to integer math speed those sums up a whole lot?
02:16amalloytomoj: i don't think so
02:17tomojcool
02:18amalloy->(dorun (map #(time (dotimes [_ 1e7] (+ % %))) [15 1.5]))
02:18sexpbot⟹ "Elapsed time: 166.978 msecs" "Elapsed time: 301.631 msecs" nil
02:19amalloytomoj: so it looks like integers are ~2x as fast
02:19amalloyin this wholly unreliable microbenchmark
02:19tomojwhen i just ran it, I got 3.41x
02:19tomojerr
02:20_rata_hahahaaha... 2x is a lot though
02:20amalloyand on my computer, i get that doubles are 35% faster. like i said, not so reliable
02:20tomojhuh, yeah, ran it again and the doubles went faster
02:21amalloytomoj: although type-hinting and/or using primitives may make a bigger difference; i'm hardly a performance expert
02:22_rata_is there a function like xor in clojure.core?
02:22tomojwell, the choice is, use the fast java stuff written by people way smarter than I (but under the assumption of floats), or write clojure stuff assuming ints
02:22amalloyah
02:23tomojI'll just use the java stuff :)
02:23_rata_tomoj, is it important for you the exactness of the result?
02:24tomojno
02:24_rata_ok, then use the java stuff :)
02:24_rata_or what's the idiomatic/simplest way to write a xor (if I can't think that by myself should be going to sleep)
02:25_rata_s/or //
02:25sexpbot<_rata_> what's the idiomatic/simplest way to write a x(if I can't think that by myself should be going to sleep)
02:25_rata_really should be going to sleep
02:25_rata_ok guys... see you tomorrow
02:39zmyrgelhi, how can I test if function arg is some record type?
02:40zmyrgelso if I have defined (defrecord Node [label children]) I want to be able to tell if fn arg is of that type
02:52amalloy->(doc instance?)
02:52sexpbot⟹ "([c x]); Evaluates x and tests if it is an instance of the class c. Returns true or false"
02:52amalloyzmyrgel: ^^ records are java classes
02:54zmyrgelamalloy: ok, thank you
02:56amalloyclojuredocs seems to link to nonexistent github pages
03:01amalloyspecifically, i'm looking at c.contrib.duct-streams/copy, and the Source section links to http://bit.ly/czekSl (shortening mine)
03:02amalloydunno who owns clojuredocs, but i'm off to bed so i'm putting it out there. night, folks
03:27TobiasRaedermorning :)
05:43notsonerdysunnyis file io in clojure basically same as that in java? is there a good place for me to just get started ..?
06:05raeknotsonerdysunny: yes, with some helper functions
06:05raeknotsonerdysunny: http://clojure.github.com/clojure/clojure.java.io-api.html is very handy
06:07raeklazy sequence of lines in a file (line-seq (io/reader "filename"))
06:08raekc.j.io/reader works with URLs too
06:12notsonerdysunnyraek: I am not used to java io .. ..
06:12notsonerdysunnythanks for the pointers
06:18raekcrash course: {File "a path to a file", #{InputStream OutputStream} "byte-oriented stream (use these for binary data)", #{Reader Writer} "character-oriented stream (use these for text)"}
06:24notsonerdysunnythanks raek .. ..
06:26notsonerdysunnywhat is this parent child thing in the documentation of io/file ?
06:27notsonerdysunny,(doc 'clojure.java.io)
06:27clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
06:27notsonerdysunny->(doc 'clojure.java.io)
06:27sexpbotjava.lang.SecurityException: Code did not pass sandbox guidelines: (clojure.java.io)
06:27notsonerdysunny~(doc 'clojure.java.io)
06:27clojurebotthe doctor is out
06:29raek,(clojure.java.io/file "foo" "bar")
06:29clojurebot#<File foo/bar>
06:29raekallows you to build paths in a platform independent manner
06:29raekalso:
06:31raekhttp://download.oracle.com/javase/6/docs/api/java/io/package-summary.html <-- javadoc for the classes in java.io (if you have to call the methods directly, which you might need some times)
06:31raekclojure's reader and writer returns BufferedReader (which has the readLine method) and BufferedWriter
06:33raeknotsonerdysunny: unfortunately, you cannot use doc to lookup docs on namespaces...
06:33notsonerdysunnyraek: i just realized that .. :)
06:33raekalso, it is a macro, so you don't quote the argument
06:36notsonerdysunny->(clojure.java.io/file "hello" "world" "in" "clojure")
06:36sexpbotjava.lang.SecurityException: Code did not pass sandbox guidelines: (#'clojure.java.io/file)
06:53notsonerdysunnywhat is clojure.core/read ? I it the one that understands all the clojure-datastructures and creates the data-structure for eval to evaluate?
06:53notsonerdysunny*Is it
06:54raekyes
06:55raekwhat kind of io are you doing?
06:55notsonerdysunnyraek .. I am considering using a s-exp like file format .. I feel that would be very easy to read...
06:56notsonerdysunnyand load the data in
06:56raekif you use the Clojure reader, it's very easy
06:57notsonerdysunnysuppose my file "inp.txt" has "(+ 1 2)" .. how would I use read to read it in?
06:58raek(require '[clojure.java.io :as io]) (import 'java.io.PushBackReader)
06:58raek(with-open [r (PushBackReader. (io/reader "inp.txt"))] (read r))
07:02raekthe opposite of read is pr, btw
07:02notsonerdysunnyraek .. I am getting java.io.PushBackReader class not found exception .. do i need to do anything special?
07:03raekoh, sorry for that... the B should be lowercase
07:03raekjava.io.PushbackReader
07:03raekno, you shouldn't need anything special
07:04notsonerdysunnythanks raek .. it works so beautifully .. reading couldn't have been easier
07:28Bootvishi I have this string: ". 17,00" (in my client I see a dot, it's a euro sign in some charset). What is the best way to parse this to a number?
07:34raek,(when-let [[_ euros cents] (re-find #"\u20ac\s+(\d+)[,.](\d+)" "\u20ac 17,01")] (+ (Integer/parseInt euros) (/ (Integer/parseInt cents) 100)))
07:34clojurebot1701/100
07:34raekdunno if this is the _best_ way...
07:36raek,(when-let [[_ euros cents] (re-find #"\u20ac\s+(\d+)[,.](\d+)" "\u20ac 17,01")] (+ (Integer/parseInt euros) (/ (Integer/parseInt cents) 100M)))
07:36clojurebot17.01M
07:36raek(BigDecimal version)
07:37TordmorNow again with propper locale support :)
07:37raek*sigh* :)
07:38raekat least I made it parse both strings with commas and points...
07:39Bootvisthanks
07:42Bootvis,"."
07:42clojurebot"."
07:46Bootvisthanks raek, your code works great outside of SLIME
07:47raekBootvis: as far as I can tell, my IRC client receives that character as an ASCII full stop
07:48raekBootvis: note that slime's default encoding is latin1, which does not inlcude the uro character
07:48raek*euro
07:48raekyou can configure slime and swank to use UTF-8. then you can use all unicode characters
07:50Bootvisok, i'll google that
07:51raekI have this in my .emacs: (custom-set-variables '(slime-net-coding-system (quote utf-8-unix)))
07:53raekand you can start swank this way: lein swank 4005 ':encoding' '"UTF-8"'
07:53raekhrm, that doesn't seem to work anymore...
07:57raekah, found it...
07:57raeklein swank 4005 localhost ':encoding' '"UTF-8"'
07:59AWizzArdChousuke: ping
08:01Bootvisthis works!
08:02BootvisI also set the encoding following advice from leonel on http://stackoverflow.com/questions/3101279/how-do-i-use-unicode-utf-8-characters-in-clojure-regular-expressions
08:05raekah, yes. when you save that, you will get what I wrote before in your .emacs file... anyway, you still need to tell swank to use that encoding too
08:08raekto test that all encoding stuff works, you can try to eval (seq "日本語") at the repl. if everything works correctly, you should get a sequence of *three* characters: (\日 \本 \語)
08:08Bootvisyes I noticed, this should be documented somewhere...
08:09raekI could add some instructions too http://www.assembla.com/wiki/show/clojure/Getting_Started_with_Emacs
08:09Bootvisit needs further work then, I'm getting 6 chars back
08:09Bootvisbut that could be an irssi thing
08:10AWizzArd~seen Chousuke
08:10clojurebotIt's greek to me.
08:10AWizzArd$seen Chousuke
08:10sexpbotChousuke was last seen talking on #clojure 1 day, 1 hour ago.
08:11raekBootvis: have you restarted the slime session (or emacs)?
08:12raekalso, note that lein repl uses JLine, which does not support UTF-8 at all (in case you were trying this there)
08:12Bootvisyes
08:13Bootvisrestarted emacs
08:13Bootvisand lein swank ... from a shell
08:14hiredmanJAVA_OPTS=-Dswank.encoding=utf8 -Dfile.encoding=utf8
08:14hiredmanthen there are emacs settings which I don't recall off the top of my head
08:16raekah, is that how you set java system properties?
08:17raekBootvis: do you happen to run emacs in a terminal? if so, you have to configure teh coding of the terminal as well.
08:21Tordmor,(let [nf (java.text.NumberFormat/getInstance java.util.Locale/GERMANY)] (.parse nf "17,01"))
08:21clojurebot17.01
08:21Tordmor,(let [nf (java.text.NumberFormat/getCurrencyInstance java.util.Locale/GERMANY)] (.parse nf "17,01"))
08:21clojurebotjava.text.ParseException: Unparseable number: "17,01"
08:21Tordmor:(
08:33Bootvisraek: no and it stil fails your 3-char test
08:33BootvisI blame irssi
08:34kumarshantanuTordmor: that's strange
08:34kumarshantanubecause getInstance and getCurrencyInstance and supposed to behave the same
08:36raekBootvis: what happens when you eval "\u65e5\u672c\uu8a9e" and (seq "\u65e5\u672c\uu8a9e") ?
08:36raeksorry... \u65e5\u672c\u8a9e
08:37Bootvisit returns \.
08:38Bootviswith . a character
08:38Bootvisfrom japan i guess
08:39Bootvisthe seq returns three chars
08:39Bootvisand the last matches the output of the first
08:43Tordmorkumarshantanu: yea, that's what I thought
08:46kumarshantanuTordmor: can you try this on another JDK? maybe IBM?
08:47kumarshantanuTordmor: can you try this on another JDK? maybe IBM?
08:47raekBootvis: what settings were save to your .emacs?
08:47Tordmorkumarshantanu: getCurrencyInstance needs currency format to parse it with the currency symbol at the end
08:48kumarshantanuah!
08:48TordmorIt's obvious when you think about it :)
08:48Bootvis(custom-set-variables '(slime-net-coding-system (quote utf-8-unix)))
08:49kumarshantanuTordmor: but the Javadoc says both methods are the same
08:50Tordmor:/ k, that's a bug
08:51kumarshantanuyeah, even though the behaviour is logical, I would consider the Javadoc a spec
09:01djpowelldid accounts get copied across from assembla then?
09:02BahmanHi all!
09:02bmhdoes anyone have experience deploying clojure apps with Java Webstart?
09:03djpowellnot tried it, but I'd think it'ld work. I've even deployed native code using webstart before
09:05djpowellwell - by deployed, I really mean: wrote an helloworld-ish demo
09:05bmhheh
09:08djpowellif you aot compile, then clojure applets work
09:10hoeckbmh: it works with aot-compiled code as it would do with java
09:10hoeckbmh: to be able to load and eval *.clj files in an applet, you have to sign it and patch a line in the clojure sources
09:10bmhhm
09:12hoeckbmh: as an example, see http://www.turbojugend-cossebaude.de/demo.html, a small project of mine, it uses clj-pivot for its gui
09:12hoeckquite large and takes ages to load, and doesn't work on my ubuntu box, only on windows :/
09:12hoeckbut the webstart works on both systems
09:16jwr7clojure.contrib.json is broken, I've reported the bug, and I have a fix (and a signed CA). How do I submit the fix?
09:18bmhhoeck: dies on my OSX box too
09:18chouserjwr7: you attached the patch to the ticket?
09:18raekjwr7: clojure.org/patches <-- the official procedure
09:20jwr7raek: Hmm. The ticket was opened by my colleague. I don't think I'm able to edit the ticket or attach anything — does someone need to add me as a contributor for this to happen?
09:21jwr7btw, this is #98 in clojure contrib in assembla
09:21hoeckbmh: yeah, I gave up because I did not find a way to grab the java console :/
09:21raekjwr7: yes. when you're logged in, does it say watcher or member at the top right corner
09:21hoeckbmh: http://www.turbojugend-cossebaude.de/demo.jnlp <-- this is the webstart version, should work
09:22jwr7Well, I'm a watcher, then. Which is suboptimal.
09:22hiredmanassembla is toast
09:23chouserjwr7: the initial friction on this kind of thing is too high, but it's getting changed.
09:23chouserjwr7: and the new way hasn't settled in yet, being ~1 day old
09:23hiredmanhttp://groups.google.com/group/clojure/browse_thread/thread/b7090cff317a47db?hl=en
09:24jwr7chouser: ok :-) But I'm really interested in getting this fix in, as clojure.contrib.json is currently broken, and I need it because it is way faster than org.danlarkin.json. Any suggested next steps?
09:24chouserhopefully once it has settled in, the friction (especially for contrib) will be significantly lower.
09:24chouserjwr7: what's the aseembla ticket number?
09:24jwr7chouser: 98
09:26bmhhoeck: thanks. neat. I'm working on some roleplaying software and I'd like to deploy as a webstart app
09:26jwr7chouser: the fix is simple and I have it sitting right in front of me. Keys need to be properly escaped, (as-str) won't do.
09:26tonylmorning
09:28chouseroh, is contrib assembla not moved over to jira yet?
09:29jwr7chouser: it seems so. I think the process is halfway done (clojure has migrated, but clojure-contrib has not)
09:32chouserjwr7: well, drat, you might just have to be patient. I think the best you can do right now is to ask for your assembla account to get bumped
09:32chouser...and use your own patched version for now.
09:33stuartsierraWould it be fair to say that Clojure was the first language to implement something like Protocols on a mainstream platform (JVM) ?
09:33chouserI can't change your assembla status, nor can I apply a patch unless it's been submitted through an "official channel" like assembla, for legal reasons.
09:34chouserstuartsierra: depends on how narrowly you mean "like protocols" I suppose.
09:34jwr7chouser: right... I'll send an E-mail to Rich, then (I'm assuming he's the one to change my status). I want to make sure this fix goes in as soon as possible, it's rather important for anyone who uses c.c.json.
09:34chouserscala had traits (or whatever their equiv is) first
09:34stuartsierraDon't traits use wrapper classes?
09:35chouserHm, I don't know.
09:36chouserThe Expression Problem in Scala
09:36chouser"
09:42chouserugh. more than five-minutes work to understand all that.
09:45stuartsierraIf I recall, Scala Traits can't be applied to existing classes, e.g. String.
09:46hiredmanthey have implicit conversions
09:47stuartsierraRight, which does use wrappers.
09:47hiredmanand there own string class
09:47hiredmantheir
09:47chouser"I know, I'll use traits!" ...and now you have 3 problems
09:48hiredmanit's not a "wrapper" it's take this thing and make it into another thing
09:48stuartsierraI'm writing about Protocols, want to make sure to describe how they're different from Traits.
09:50chouserI don't think I even understood traits well enough to help. sorry.
09:50stuartsierrano worries
09:51chouser s/even/ever/
09:52bobo_scala people like to compare traits to mixins in ruby atleast
09:52bobo_or "interfaces with implementation"
09:53fogus_"I know, I'll use implicits!" ... the good part is that you have no idea when you have a problem.
09:53hiredmanclojurebot: tell me about scala
09:53clojurebotthe scala compiler | is | <reply> see: http://harrah.github.com/browse/samples/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala.html#65760
09:55stuartsierraheh
09:55stuartsierraglass houses...
09:57spicycodestuarsierra: ....?
10:00stuartsierraspicycode: I'm sure the Clojure compiler has ugly bits too.
10:00spicycodestuartsierra: roger that, we were digging through the asm bits last night
10:01stuartsierracompilers are like sausage grinders: if you saw the process, you wouldn't eat the result
10:02fogus_stuartsierra: WRT being first. I would consider that maybe ABCL was first.
10:06hiredmanwell the clojure compiler doesn't have incriminating comments
10:06hiredman(or any)
10:07fogus_Seems to go against the virtues of static checking to defer your crashes until runtim!
10:07fogus_runtime even
10:07hiredmansure
10:13nDuffDid the proposal to implement a *clojure-version* global ever happen?
10:14technomancy,*clojure-version*
10:14clojurebot{:major 1, :minor 2, :incremental 0, :qualifier ""}
10:15nDuffoops -- I was trying to check **clojure-version**
10:16stuartsierraAt what point does a Protocol function look up an implementation in its internal map?
10:18notsonerdysunnyI am new to java/clojure io .. raek say I could read a s-exp file with (with-open [r (PushbackReader. (io/reader "project.clj"))] (read r)) .. and it worked very well .. now I would like to be able to write it .. and he mentioned that I use pr .. but can somebody help me with the complete expression?
10:22notsonerdysunny,(doc pr)
10:22clojurebot"([] [x] [x & more]); Prints the object(s) to the output stream that is the current value of *out*. Prints the object(s), separated by spaces if there is more than one. By default, pr and prn print i...
10:51notsonerdysunnyhow do I write the value contained in a symbol p to a file "out.txt"
10:52replaca(spit "out.txt" (println p))
10:53chouserI don't think so
10:53replacaoh wait
10:54replaca(spit (java.io.File. "out.txt") (println p))
10:54replacachouser: better?
10:54chouserdoubt it :-)
10:54Tordmortop hit on google for "clojure io": (binding [*out* (java.io.FileWriter. "some.dat")] (prn {:a :b :c :d}))
10:56gary_posterI don't understand something a bit fundamental. Given ``(defn f [x y z & args] (apply (fn [& a] a) x y z args))`` and ``(f 1 2 3 4 5)`` I'd expect the result ``(1 2 3 (4 5))``. Instead, you get ``(1 2 3 4 5)``. Many built in functions rely on this. Can somebody clarify what I'm missing?
10:56chouser(spit "/tmp/foo.txt" (prn-str p))
10:57fliebelgary_poster: the latest arg of eval takes a seq.
10:57fliebel*apply
10:57replacachouser: why prn-str instead of println?
10:57chouserprintln prints to *out* and returns nil
10:57replacaunless you're looking for readability?
10:57fliebelIs there still any use for clojure.contrib.generic.arithmetic, or can this stuff be handled by extend-type?
10:57replacaoh, of course
10:58gary_posterfliebel: ah, got it, thanks
10:58fliebelOr in other words, can I use extend-type to make + support other types of objects?
10:58chouserreplaca: :-)
10:59stuartsierrafliebel: not at present
10:59fliebelstuartsierra: Why not? It's only for interfaces or something like that?
10:59stuartsierra1) Protocols only support single-argument dispatch, although this can be extended to multiple arguments.
11:00stuartsierra2) Clojure's arithmetic operations are not defined in terms of interfaces or Protocols
11:00stuartsierrafor efficiency, although the compiler may support it someday
11:00stuartsierrabut if you're doing serious math, you wouldn't want the performance hit of multimethods anyway
11:01notsonerdysunnythanks chouser and replaca .. it worked .. :)
11:01fliebelCool, thanks! I think Overtone is using a good deal of multimethod magic for working with ugens. I thought I'd have a look at the extend-type thing.
11:04stuartsierraAges ago, I posted an example of multiple-argument dispatch with protocols http://paste.lisp.org/display/93387
11:06chouserstuartsierra: all your old code feels differents to me now that I imagine you writing it with blue hair (though I reliaze your hair may not have been blue at the time)
11:06stuartsierraI tend to have blue hair in the Fall, so you can interpolate on that.
11:11pdloganI love fall colors.
11:11pdlogandon't see a lot of blue in the PNW though
11:12fliebelpdlogan: Yea, you should make fall-chemed-rainbow parens for your editor.
11:12fliebel*themed
11:27jcromartieWell this makes me that much more reluctant to go with CouchDB http://wiki.apache.org/couchdb/Installing_on_Windows
11:27jcromartieanyway
11:28jcromartieNoSQL is so tempting but choosing Clojure is enough of a risk I wonder what the value is
11:28cemerickjcromartie: No need to build it: http://www.couch.io/get#win
11:28jcromartieoh, I should check the date on those wiki pages
11:28jcromartieI get the feeling that Couch is more mature, but I know Mongo is popular with Clojure
11:29cemerickyeah, both are used a fair bit
11:30cemerickI don't know if it makes sense to speculate on relative usage.
11:30jcromartieyeah I guess so
11:31jcromartieI am trying to weigh the tradeoffs... JavaDB/Derby is appealing too, since I could basically have a single Jarfile for small demo/testing deployments
11:31cemerickAFAIK, couch has been around for far longer, and the basis for it is pretty hard to argue with from a reliability standpoint (i.e. the legacy of notes, etc)
11:31jcromartieyeah, just being written in Erlang wins there
11:31cemerickA Clojure impl of couchdb would be interesting, actually.
11:32jcromartiewe are looking at building a new version of our company's main product, and it seems like a good candidate for a document store
11:32jcromartie_our data is very self-contained and denormalized
11:32jcromartie_each record is really kind of an island
11:33jcromartie_a very large island
11:33jcromartie_with an airport
11:33jcromartie_anyway
11:33hiredmanmongo is popular with clojure?
11:34cemerickpeople have said they use it, sure
11:35jcromartie_I thought it had a bit more traction and adapter projects
11:35jcromartie_:)
11:35jcromartie_I guess saying anything is "popular" within the clojure community is kind of relative
11:35stuartsierraParentheses are popular within the Clojure comumnity.
11:36technomancyI heard mongo supports sharding
11:36apgwozcemerick: A Clojure impl of _____ would be interesting, actually. (applies for most values of _____)
11:36nDuffwhereas CouchDB uses MVCC
11:36nDuffand of course everyone here loves MVCC :)
11:36apgwozmongo has concurrency semantics?
11:36nDuffwell, that's the question
11:36apgwozit's event-driven
11:37cemerickapgwoz: eh, almost ;-)
11:37cemerick(re: the adlib bit)
11:37LOPPwhat's the easiest way to make a servlet in clojure
11:37apgwozcemerick: yeah, i got that :)
11:37cemerickCouch's semantics are simple enough that it's a reasonable small project though.
11:38cemerickReimplement mongo in Clojure? No thanks.
11:38fliebelLOPP: The ring servlet adapter.
11:38fliebelThere is FleetDB, which is written in Clojure :)
11:38apgwozcemerick: this is all true.
11:39cemerickfliebel: in-memory stores aren't super useful for me :-)
11:40apgwozcemerick: so, add write ahead logging :)
11:40cemerickit does persist things eventually, no?
11:40cemerickapgwoz: I assumed it was redis-esque (dataset cannot be larger than available memory)?
11:41apgwozcemerick: i don't know. but it does have logging, so my statement before doesn't make sense
11:41replacachouser: no that I've had my coffee, is there any difference between: (spit "out.txt" (prn-str p)) and (spit "out.txt" p)?
11:41replacaA quick experiment says no
11:41stuartsierraonly if p is as tring
11:41stuartsierra* a string
11:42apgwozcemerick: i think you're write, the persistence is meant for restarts, but not for unbounded databases
11:42replacawell I get teh same result when I pass it a vector of numbers
11:42apgwozcemerick: (based on my quick look of the documentation..)
11:43stuartsierrareplaca: because pr-str and str of a vector of numbers happen to look the same
11:43replacawhat are they different for?
11:44replaca(oh, in my example they differ by a trailing newline, too)
11:44stuartsierra"pr" and "pr-str" attempt to reformat their argument so it can be read back
11:44stuartsierra"print" and "str" produce strings for human consumption
11:45replacastuartsierra: ah, so readability, ok
11:45stuartsierra,(str "foo")
11:45clojurebot"foo"
11:45stuartsierra,(pr-str "foo")
11:45clojurebot"\"foo\""
11:45replacayup, gotchya.
11:46replacaso, print is to str as pr is to pr-str?
11:46replacano, but print-str exists too
11:46stuartsierrayes
11:47stuartsierraprint-str will insert spaces between its arguments the same way print does
11:47stuartsierra,(print-str 1 2 3)
11:47clojurebot"1 2 3"
11:47stuartsierra,(str 1 2 3)
11:47clojurebot"123"
11:48replacaoh, right. I never thought very hard about all these subtle points until this morning
11:48vibrant<- reading 'the joy of clojure'
11:49replaca(plus I always use cl-format cause I know what it does :))
11:52muhdikclosure looks weird
11:53muhdiki mean does it look ugly?
11:55replacamuhdik: What you're not used to looks weird and ugly. Most of us that have used Clojure for a while think it's baeutiful compared to C/Java syntax
11:55replacamuhdik: but in the end, it's a matter of taste
11:56technomancyreplaca: closure is a javascript library =P
11:56technomancyso the correct answer is "yes"
11:57replacatechnomancy: oh, good reading. I was conflating that Q with the "JoC" statement above.
11:57replacaI'm sure glad I'm not taking the SATs this morning!
11:58vibranthehe
11:58muhdikoh ok
11:58technomancyI don't know if that's what he meant, but it's what he asked
11:58muhdiki mean doesnt it have too many ))))))
12:00technomancysure, just like Mozart has "too many notes" http://www.youtube.com/watch?v=dCud8H7z7vU
12:01quollit has no more than other languages (like Java), but the syntax often leads to closing parens all appearing together
12:02vibrantdeath to java!
12:02muhdikwhy u say death to java?
12:02nDuff"meh" to java!
12:03muhdiki thought clojure came from java?
12:03muhdiki hate java personally
12:03jcromartieJava is Clojure's C
12:03jcromartiedon't knock it
12:03muhdikdid all the cool java kids go to ruby and clojure?
12:04muhdikcause i dont think java is cool anymore
12:04muhdiksince oracle took over
12:04nDuffthere are too many things called "Java" to have that discussion without more clarity
12:05quollit reads like muhdik is talking about Java-the-language
12:05muhdiki mean
12:05muhdikjava
12:05nDuffit's specifically Java-the-language I was referring to, and its issues as a language are quite separate from ownership concerns.
12:05muhdikj2ee
12:05muhdikejb
12:06muhdiku know
12:06nDuffmuhdik, ...so it's more the standard-library set than the language itself?
12:06muhdiki mean the whole java package
12:07nDuffwell, that's the thing -- "the whole Java package" is too many things to talk about cogently; the components are worthy of their own opinions.
12:07muhdiki mean
12:07muhdiksun had this whole website devoted to java crap
12:07muhdikthat was the worst
12:07muhdikand tried to make something like msdn for java
12:08muhdikim talkin bout all the stuff in that
12:08muhdiklike i mean
12:08muhdiknow kids are doing ruby clojure and node.js
12:09ubiione does not necessarily need to be coffee drinker to partake of clojure, but one should at least appreciate the efforts of all of those bean pickers :)
12:09muhdikand java has been pretty much eclipsed
12:09muhdikand about node.js
12:10LOPPjava is just failing to evolve as a language
12:10LOPPall they do is add some more libraries to JRE each version
12:11chouserand it's design goals never lined up very well with my desires. I was never Java's target audience. Hard to blame it for that.
12:11muhdikwell whats the difference between clojure and scala then
12:11LOPPjava isn't dying out any time soon, too much server side software is running on java
12:11ScriptorI've heard what clojure really needs to expand to non-jvm platforms is for it to be completely self-hosting, is that true?
12:12muhdiki mean
12:12muhdikarent they both functional java?
12:12jcromartieJava and the JVM are just simple stable and fast, and very widespread and mature, and with a huge set of available libraries to do pretty much anything you want.
12:12jcromartieThat's why I'm not that excited about CinC
12:12chouserScriptor: that would be the route of least total work. But various versions of Clojure have already been ported to CLR, JavaScript, and I think flash.
12:12jcromartiebecause the interop with the platform is what makes Clojure so useful
12:12jcromartiefor just getting stuff done
12:13Scriptorhmm, anything going on for the LLVM?
12:13technomancyjcromartie: cinc also means having a compiler that is comprehensible by more than just rich, even staying on the jvm
12:13chouserScriptor: not yet, that I know of.
12:14Scriptorhmm, wish I knew C++ (or clojure for that matter)
12:14jcromartietechnomancy: I see :)
12:16ubiijust curious, how much interest and effort is currently being put towards CinC?
12:16chousermost of it
12:16cemerickheh
12:17jcromartiewhere "it" is the interest and effort of clojure core?
12:17cemerickchouser: how much (if at all) have you looked at cljc?
12:18chousercemerick: only saw it was there. do we know who jarpiain is?
12:18chouserI do intend to read through the code.
12:22cemerickNo idea. I've only perused it for a few minutes myself. At the very least, it seems like we should give him a holler.
12:23chouseryeah. I've got a small but growing list of people who may actually be willing to chip in on the compiler work.
12:24LOPPdo you screen these people?
12:24chouserwe can't use his code at all without a CA of course
12:25chouserI screen nobody
12:25LOPPok
12:25ubiichouser: CA?
12:26chouserubii: http://clojure.org/contributing Contributor Agreement
12:26ubiichouser: ah, thx
12:26cemerickLOPP: we're working on a Clojure Contributor Certification Exam.
12:27chousersheesh
12:27cemericklol
12:27cemerickLOPP: sorry, had to do it ;-)
12:27Raynes:o
12:27chouserif your code makes rhickey show the Sign of the Cross to ward you away, then ... you're in the same boat as the rest of us.
12:28cemerickchouser: c'mon, those Cisco certification exam books are *huge* money! :-P
12:29ubiitell me about it, I have too many of them sitting on my shelves
12:29chousercemerick: ruby drama link?
12:32cemerickchouser: oy. http://oppugn.us/posts/1282122987.html
12:33apgwozcemerick: you're forgetting that there's drama whenever you *mention* the name Zed Shaw
12:34cemerickI've no idea who the jets and the sharks are in that world.
12:34ubiiZed is the man, I met him at RubyFringe in Toronto, super nice guy in person
12:34technomancyhe's just trying to be bad and nationwide
12:36hsuhis a jetty+ring+compojure app single-threaded?
12:38cemerickhsuh: no, jetty manages the concurrency in that realm. Each *request* is single-threaded, though.
12:39jwr7…which reminds me I need to find out how to change the threading model that jetty uses. I think there are several.
12:40hsuhwhere can i read more about that? like "the life of a request" or something
12:40cemerickhsuh: There are slight variations from container to container, but any search for "servlet lifecycle" will probably lead you to the right spot.
12:41hsuhtks
12:41hsuhand from that to clojure code is just a function call, no thread involved
12:44cemerickright
12:52quolldoes anyone know how I can make a binding work down in "map"?
12:53quollor, more precisely, how a (binding....) can be recognized by the function being supplied to (map .....)
12:54fliebelquoll: Oh, I can't remember… Someone recently blogged about this.
12:54quollHmmm, OK. I'll search then
12:54chouserquoll: simplest solution is to wrap (doall ...) around your (map ...)
12:54chouserquoll: but it's worth understanding what's going on there.
12:54quollwell, I'm guessing that map is creating a new thread
12:54amalloychouser: dorun works too, doesn't it? if so it's more useful
12:55quollif I replace map with my own implementation, then it works as expected
12:55chouserdorun returns nil
12:55fliebelchouser: Is laziness killing it because the closure doesn't pick up the binding? Or what?
12:55quollfor instance: (defn mymap [f s] (if (nil? (first s)) s (cons (f (first s)) (mymap f (rest s)))))
12:55quollthat keeps the binding just fine
12:56chouserquoll: right, because that's not lazy
12:56quollyup
12:56chouserremember, 'binding' is dynamic scope, not lexical
12:56quolllet me try it lazily
12:56chouserthe fact that your map call is lexically inside 'binding' doesn't really matter at all
12:57quollunfortunately, I don't really understand the distinction
12:57chouserany elements of your lazy seq that are realized outside the dynamic scope of the binding will the vars values from outside the binding
12:57chouserwill see
12:58quollI'm pretty sure I understand that
12:59fliebelOh, I'm going to work out some evil things...
12:59quollbut I also know that I don't quite get it, since I don't see how lazy ends up being different
12:59LOPPlexical binding = where in code your stuff is
12:59pdloganquoll: another way to visualize "dynamic binding" is that it does not look at the text of your code for a binding. It looks "up the call stack" for a binding.
12:59LOPPdynamical binding = where in call stack your stuff is
12:59pdloganjinx
13:01quollpdlogan: that was what I thought was happening. I couldn't figure out a way to avoid that though (while staying lazy)
13:03quollso to be sure I have it..... by the time I'm trying to access the lazy-seq, I'm out of scope of the binding, so I get whatever binding is currently in place at that point
13:03quollis that it?
13:03pdloganquoll: not sure that you can - it's not like a lexical closure which has captured an environment
13:03chouserquoll: if you want to stay lazy, look at bound-fn
13:04quollwell, in this case I don't HAVE to stay lazy. I just like to whenever possible :-)
13:04pdloganit's generally better not to be dynamic than not to be lazy
13:04quollmy point is.... is the lazy sequence picking up the binding of the value when I access the sequence, as opposed to when the sequence was created?
13:06quollchouser: btw, bound-fn looks to be useful. Thanks.
13:06pdloganquoll: generalizing laziness --- consider any function that references a dynamic value will get that value as of it's nearest binding in the call stack.
13:06quollI'll go with non-lazy this time. I just wanted to understand what was happening
13:07quollpdlogan: do you mean the "current call stack"? As in, when the lazy value is accessed
13:07quollas opposed to when the lazy structure was created
13:07pdloganyes - "dynamic" --> "runtime call stack for the current thread"
13:07JamesIryA dynamically bound symbol (logically) searches back through the call stack at the moment of evaluation to find its meaning.
13:08JamesIryAlthough in practice that's now how they're typically implemented
13:08quollOK, I get it then. Thanks for the elucidation
13:10fliebel,(def s (repeat 1))
13:10clojurebotDENIED
13:11fliebelGuess what this returns: (take 2 (binding [s (repeat 2)] (cons (first s) (lazy-seq s))))
13:12raek(2 1)?
13:12fliebelyea :)
13:13chaslemleyHey folks, I just put up a templating engine for clojure on github http://github.com/chaslemley/slim.clj check it out if you need to render html, xml from compojure or any other framework
13:13fliebelFirst time I managed to write some sort of obfuscated Clojure :)
13:13raekis it true that rich is rethinking binding?
13:14AWizzArdraek: it is already happening
13:14raeknice. good.
13:14AWizzArdjust download Clojure 1.3 α2
13:15fliebelAnyone knows what's up with the mysterious "improved stacktraces"?
13:15chousermysterious? (pst)
13:16fliebelchouser: Yea, in the message he mentioned them, but I can;t find what's improved. disclaimer: I havn't tested any of the alphas.
13:17AWizzArdAnyone here from Finland?
13:18Chousukeo/
13:18AWizzArdaah, wb
13:18AWizzArdChousuke: please look into your private
13:19pyrtsao/
13:34@rhickeychouser: it was just an X
13:37chouserrhickey: ha! oh, ok.
13:37@rhickeyyou're not vampires, are you?
13:38chousersucking your life's work dry of it's simplicity?
13:38chouserits
13:39chouserrhickey: have you seen http://github.com/jarpiain/cljc ?
13:41chouserthe author has clearly put a *lot* of effort into it, including reimplementing bytecode generation to avoid depending on ASM
13:42@rhickeynever saw it
13:42@rhickeybytecode gen w/o ASM seems needless wheel reinventing
13:46AWizzArdWill (char 65) return on all JVMs on all OSes always \A ?
13:47cemerickunless there's one that's using ebcdic…
13:47AWizzArdwhere is the encoding set which determins what char returns?
13:47cemerickAWizzArd: it's all UTF-16. That was a joke. :-)
13:48AWizzArdStrings always use char[] internally as their value.
13:49jarpiainheh, actually I wrote the class file parser/assembler first and then kind of figured a compiler would be a good way to generate test input :)
13:50jarpiainand also a more interesting project
13:50AWizzArdcemerick: so, on all official JVMs (char n) for n between 0 and 65535 will return the identical char.
13:52cemerickAWizzArd: I believe so, yes. (char n) is the equivalent of (char)n in Java.
13:52chouserjarpiain: so what are your plans/goals for the thing?
13:53AWizzArdgood
13:55jarpiainin short term to implement the remaining few special forms, then I guess wait to see if there's any interest to take it further
13:55jarpiainI'm going to send the CA in any case
13:56amalloyhey, speaking of CA, should i expect some kind of notification when mine gets in? put it in the mail last monday
13:56Raynesamalloy: No notification.
13:56Raynesamalloy: Just keep an eye on the contributor list.
13:56Raynes$whatis CA
13:56sexpbotCA = The Clojure contributors agreement: http://clojure.org/contributing
13:57amalloyah cool
13:57drewr$whatis CYA
13:57sexpbotCYA does not exist in my database.
13:57drewrlame
13:57Raynesamalloy: Also, I think (I'm pretty sure) I've fixed clj-sandbox, and should be able to use a blacklisting scheme rather than a whitelisting scheme in sexpbot. Theoretically, this will make sexpbot's evaluation equivalent to clojurebot's when I'm finished.
13:58danlarkin$whatis raynes
13:58sexpbotraynes does not exist in my database.
13:58danlarkinbam!
13:58pjstadigCLABANGO!
13:58hiredman~suddenly
13:58clojurebotCLABANGO!
13:58nickikI don't know mutch about compiler (jet) but what does it mean to not depend on ASM?
13:59chousernickik: ASM is a Java library the current Clojure compiler uses to generate JVM bytecode.
13:59Nafaitechnomancy: Around? I'm having some problems with slime from your git repo, perhaps you have a moment to help me debug?
14:00_rata_hi
14:00kotarakWah! CLABANGO!
14:01pjstadigis ASM needless wheel reinvention? what about cross compiling from .NET to Java or something?
14:02chouserwow
14:03abrooksHeh, "Grand Theft Wumpus: The most violent programming example ever put into a textbook." http://nostarch.com/lisp.htm (third page sample)
14:04mabescan you tell leiningen to ignore certain sub-dependencies in the project.clj?
14:04abrooksThat's from Conrad Barski's "The Land of LISP" book which looks hysterical.
14:04cemerickpjstadig: I think it's assumed that every potential host has suitable bytecode/executable generation facilities.
14:04Bootvisabrooks: it is
14:04cemerickI don't think anyone would be happy with cross compilation as a long-term solution in any case.
14:04pjstadigsure
14:05pjstadigit's a use case
14:05_rata_has anybody seen jkkramer?
14:05pjstadigmaybe not eminently useful, but a use case
14:06lrennmabes: there is an :exclusions key
14:06nickikhttp://landoflisp.com/ follow the arrow to the comic its really funny
14:07lrennmabes: see http://github.com/technomancy/leiningen/blob/master/sample.project.clj for an example
14:08mabeslrenn: great, thanks!
14:16hiredmanTowards Performance Measurements for the Java Virtual Machine’s invokedynamic: http://www.cs.iastate.edu/~design/vmil/2010/papers/p06-kaewkasi.pdf
14:16Raynes,clojure.lang.RT
14:16clojurebotclojure.lang.RT
14:17BorkdudeCan someone give me guidance to how I can create a GWT Project in Eclipse and use Clojure for the server side?
14:22fogus_Borkdude: GWT can talk any number of protocols to your server.
14:29Raynes,(Thread/sleep 10000)
14:29clojurebotExecution Timed Out
14:30kotarakIs there someone windows script kiddie hanging around, who would help poor vim users on Windows with some cmd magic?
14:37technomancy"script kiddie" is kind of a derogatory term actually.
14:37technomancymight not be a good thing to say if you are looking for volunteers. =)
14:39kotaraktechnomancy: I know the term. It was not intended as an offense, though. Rather a (slightly too) bold call.
14:42Raynes,(println "blah")
14:42clojurebotblah
14:45Raynessexpbot's evaluation should be much less sucky now.
15:00@rhickeyhiredman: thanks for the link
15:02alpheusUsing deftrace, there's a nice tree printed when the function is called. Should dotrace print the tree for functions defined with defn?
15:05jcromartietrace!? what have I been missing
15:06alpheusclojure.contrib.trace/trace
15:08jcromartieawesomesauce bolognese!
15:09TeXnomancydotrace is really great
15:10alpheusI must be using it wrong
15:11TeXnomancyalpheus: dotrace works on vars IIUC. fn literals can't be affected by it
15:13rickmodeUsing clojure.contrib.def/name-with-attributes is a bit awkward when not all macro arguments beyond name are variadic. Am I missing something? Example: http://gist.github.com/652096
15:22alpheusdeftrace doesn't understand docstrings
15:22jcromartiedoes anybody else think that the metadata system adds a burden to library authors?
15:23chouserwhat kind of burden?
15:23jcromartiebecause there's a whole class of operations that can destroy metadata on objects, right?
15:24jcromartieand if you want to maintain metadata you have to be careful of the way you approach things
15:24chouserhm
15:24jcromartieI mean it could be that everything in clojure's core libraries maintains metadata
15:25jcromartie,(meta (seq (with-meta [] {:foo :bar})))
15:25clojurebotnil
15:26jcromartiebut I guess not
15:26chouserbut ... seq doesn't return the same object
15:26chousernot even the same type
15:26jcromartieno
15:26jcromartiethat's true I guess
15:26jcromartieI suppose metadata is something you'd be using very mindfully anyway
15:26jcromartieI've never found a big use for it
15:26chousermost of your normal collection ops maintain metadata: conj, assoc, dissoc, disj, etc.
15:27kotarak,(meta (pop (with-meta [:a] {:foo :bar})))
15:27clojurebot{:foo :bar}
15:27kotarakI think the burden is on type implementors.
15:27chouserkotarak: yeah, I think that's fair
15:27jcromartieyeah I guess "destroy" is the wrong word
15:27jcromartiesince there's no contract about what should or shouldn't return an object with metadata
15:28cemerickkotarak: which is an unfortunate thing, insofar as so few people use metadata, and aren't generally aware of the small details involved.
15:28chousernot many people implement types
15:29kotarakcemerick: I personally have no idea what to use metadata for besides talking to clojure and taint checks. But when I implemented my list with fast random lookup, the metadata was kind of annoying.
15:30chouserI haven't added metadata support yet to finger-trees. We'll see how annoying it is there. :-)
15:30chouserit's brilliant for passing extra data along with code
15:30TeXnomancyRobert Hooke and Radagast rely heavily on metadata; those would have been awful to implemnet without it.
15:31TeXnomancywhen did (name "stringy") start to work? was it around the time 1.2 was released?
15:31kotarakchouser: I probably should investigate factory functions. ;)
15:31chouserTeXnomancy: does work in 1.2
15:33jcromartieof course it would be simple enough to have something that maintains the metadata for a value at both ends of some operations
15:34hiredmantechnomancy: you are being recalled
15:35kotarakjcromartie: the is a question where a new copy of the type is created. Then the operations don't really matter.
15:45rickmodeHas anyone else hit awkwardness using name-with-attributes?
15:47chouserrickmode: never used it
15:48arkhtechnomancy: I filed an issue with leiningen on github yesterday - should I be able to see it when I go to "Issues"?
15:49kotarakrickmode: what awkwardness?
15:49KirinDaveI think I hate gen-class and static methods.
15:49KirinDaveThere are all these weird little issues when scala is trying to call my gen-class forms
15:49chouserKirinDave: hate of gen-class is a natural consuequence of using it
15:50rickmodekotarak: it works but I had to cons together my none name macro args, e.g. (cons a (cons b rest)) with [name a b & rest], then pull the back apart after the name-with-attributes call. http://gist.github.com/652096
15:50KirinDavechouser: Even the docs are poor.
15:50KirinDaveIt's like a layer cake of hate. A layer-hate, if you will.
15:50chouserKirinDave: but I don't understand why static methods are still causing you problems
15:50KirinDavechouser: Neither do I.
15:50KirinDavechouser: Some vars it just insists are unbound.
15:50KirinDavechouser: My last problem was it choked on (declare ...)
15:50KirinDavechouser: So I changed all my (declares ) in my macro to (def sym identity)
15:51KirinDavechouser: But now even some *functions* are coming back unbound.
15:51hiredmanoh wait, your macros are failing you?
15:51chouserthere's got to be something wrong with your setup
15:51KirinDavehiredman: No.
15:51hiredmanshould have gone with conduit
15:51KirinDavechouser: It's not just my setu
15:52KirinDavehiredman: Maybe, just maybe, you should take your shoe and swallow it. It's not the macros, unless the clojure compiler itself is freaking otu that them
15:52kotarakrickmode: ehm, well, then don't name the arguments in the arg list. Just use [& macrotail], do the destructuring afterwards.
15:53KirinDavehiredman: And I may still go with conduit. Because of my macros, I actually get to change that as I go.
15:53KirinDaveAll I did was encode the logic of the graph, rather than how it's actually executed.
15:53raekKirinDave: have you made a simple working example, and then gradually added stuff until it breaks?
15:53KirinDaveraek: No, because I keep running into new problems.
15:54KirinDaveI can reliably break (declares ...) under (do ...)
15:54KirinDaveI have a deadline I am trying to hit before I start submitting bugs.
15:54KirinDaveSo I stopped doing that.
15:54KirinDaveBut this problem is unrelated to any macro-ness
15:54KirinDaveIt's just saying a var in my clothesline.util module is unbound, when it's called from scala or java.
15:54KirinDaveBut it doesn't happen in Clojure.
15:55rickmodekotarak: I thought of that, but it makes the code less obvious visually and using (doc ...)
15:56rickmodekotarak: no worries - I was mainly curious if I missed something
15:56kotarakrickmode: the doc part is broken anyway, because it should read [docstring? metamap? your stuff here ...]
15:57chouserKirinDave: I don't mean to be stubborn or anything, but I can assure you I generate a Java class with static methods using gen-class, and use the results from both Clojure and Java code, in unit tests and integration tests on a regular basis, and have done so for many months.
15:57chouserKirinDave: so it *can* work. clearly there's some difference between the code here and the code there
15:57KirinDavechouser: I believe you.
15:57KirinDaveI am stressing something, somehow.
15:57chouserthat difference is probably not in clojure itself
15:58kotarakrickmode: you can use a metamap like this: http://paste.pocoo.org/show/282847/
15:58KirinDaveWell this only happens when called from scala.
15:58KirinDaveI mean, it's saying an fn is unbound.
15:58KirinDaveBut it doesn't fail from the clojure repl.
15:58chouserwhat's the exact exception message for that?
15:58KirinDavechouser: https://gist.github.com/6486c21ed45dfc776321
15:59KirinDaveSome variation of that.
15:59rickmodekotarak: I see.. override the arglists the compiler would build. Good suggestion.
15:59KirinDaveOr, if we use "use" instead of "use ... :only"
15:59KirinDavehttps://gist.github.com/3a1d9830452f3c155c56
16:01cemerickKirinDave: "Maybe, just maybe, you should take your shoe and swallow it"? :-(
16:02KirinDavecemerick: I'm a little tired of hiredman telling me macros are bad 600 oblique ways.
16:03cemerickKirinDave: Whatever. As incredibly civil as the community has been in aggregate, we can all be moreso.
16:04chouser"does not exist" is not quite the same as "is unbound"
16:04KirinDavechouser: Are there any sorts of issues in my setup that might be worth investigating?
16:04KirinDavechouser: Right
16:05KirinDavechouser: It depends on how we use (:use )
16:05KirinDaveIf I say (:use clothesline.util) it does the dne, if I change it to :only it says unbound.
16:06KirinDavehard to debug this, tho... since it's a thing involving what happens when a clojure function is called from scala...
16:07tlockneyKirinDave: actually, other way around. with :only we're getting DNE
16:07KirinDavetlockney: Ah
16:07chouserinteresting, that makes more sense
16:08tlockneythe DNE is coming from the defn for refer in core.clj, fwiw
16:08chousersounds like the namespace is getting loaded by :use -- with :only [], you'd expect the var to not be referred, and thus "does not exist"
16:08tlockneywhich makes sense, since that one blows up trying to create an instance of the class
16:09chouserbut without :only [], all the names will be referred, and if the var has no root binding, you'd expect "is unbound"
16:10chouseryou might trying printing out the value of map-keys at the end of clothesline/util.clj and verify that the namespace is indeed getting loaded before you try to use it, and that the value is what you expect.
16:11chouserbut that's just general debugging advice: verify what you think you know
16:11chouserhard to be more specific without all the code, build env, etc.
16:11tlockneychouser: I'm confused by the first part of your statement. the var we put in :only is the one that's getting the "does not exist"
16:11tlockneyso, it is getting referred
16:11tlockneyor, should be anyway
16:11chouserthe only use of :only anyone has mentioned to me is :only [] which refers nothing
16:12KirinDaveAh, well of course we put a symbol in the [] dude. :)
16:12tlockneyI think that was a miscommunication
16:12tlockneyit's :only [map-keys]
16:13technomancy:only [] is actually a pretty reasonable thing to do
16:13chouserKirinDave: well, I actually recommend the use of :only [] with an empty vector.
16:13chouserbut anyway...
16:13technomancybut only through historical accident
16:13chouserheh, right.
16:14chouserKirinDave, tlockney: but my debugging advice still stands
16:16KirinDavechouser: we'll keep at it. Thanks for your time.
16:18arkhHaving a lein issue with dashes in namespaces (unrelated to my last IRC post)
16:18arkhin project.clj, I have '(defproject ... :main syslog-relay.core)'. My directory structure is ./src/syslog_relay/core.clj, my namespace in that file is '(ns syslog-relay.core ...)', and when I do a lein jar it throws a 'Exception in thread "main" java.lang.NoClassDefFoundError: syslog_relay/core'
16:19arkhugh ... I'm sorry, when I do a 'java -jar syslog-relay-0.0.5-SNAPSHOT.jar' it throws the above error. lein jar is fine
16:20raekdoes 'lein jar' imply 'lein compile'?
16:21arkhI would think so (?) - I have generated .class files
16:22arkhmy MANIFEST.MF says 'Main-Class: syslog_relay.core', fwiw
16:22raekI browsed through the source, and it looks like it does
16:22arkhoh - I guess I should have done that too! ; )
16:23raekarkh: do you have a :gen-class thingy in the ns form?
16:23arkhI do not
16:23KirinDavearkh: Ah. Yes. Well. There, as they say, is your problem. :)
16:24arkhoh .. I need a :gen-class just for lein jar?
16:24raeklooks like a (:gen-class) is sufficient
16:24raekthen the "-main" function will be the main method of the main class
16:26raekarkh: you need :gen-class in order to generate a class that has a main method
16:26raekthe namespace foo.bar will become the class foo/bar__init.class
16:26arkhI'm wondering how I missed that - where should I have read that before?
16:27raekhttp://clojure.org/compilation is where I found out about this
16:27arkhis creating a jar the same thing as "aot compile"?
16:28raek...but you can control what method that class gets. so you use :gen-class to generate another class which can have the methods you like
16:28raek*but you can't
16:28technomancyarkh: I think the lein tutorial covers it
16:30arkhsorry for asking a question that's in the documentation - raek, KirinDave, technomancy, thank you for your help
16:31raeknp
16:31Nafaitechnomancy: Question about slime from your github repo; when I execute something in the repl that causes an error (but not all errors), like trying to use a non-existant namespace, Emacs becomes unhappy and starts spitting out this:
16:31Nafaierror in process filter: Wrong type argument: characterp, nil
16:31Nafaierror in process filter: define-key: Wrong type argument: characterp, nil
16:31NafaiI have to kill emacs because I can't even do anything after this
16:31NafaiAny hints on how to debug this?
16:33technomancyNafai: maybe make sure you've got the latest swank-clojure 1.3.0-SNAPSHOT
16:33AWizzArdIs that available as a .jar too?
16:34technomancyit's on clojars
16:34raekis it safe to use that one for clojure 1.2?
16:35raekmeh. I could as well upgrade everything to 1.3.0-alpha2
16:35technomancysure; it's "lein multi test"ed against 1.1, 1.2, and 1.3-snapshot
16:35technomancynot that the test suite is any good
16:36Nafaitechnomancy: Yeah, running the latest swank-clojure snapshot
16:42technomancysorry, not sure what's going on there
16:43Nafaiok
17:01duncanmdum de dum
17:01duncanmfinally fixed a bug that has been haunting me for 3 days
17:01duncanmturns out it was just because I couldn't read the order of the arguments to the AffineTransform constructor correctly
17:02AWizzArd3 days?
17:02AWizzArdThose are the pitfalls of dynamically typed langs.
17:02ohpauleezDoes anyone in here use paredit.vim?
17:03duncanmyeah, m00 m10 m01 m11 m02 m12 vs. m00 m01 m02 m10 m11 m12
17:03duncanmrows first, or columns first
17:04duncanmi paid attention to the multimethod that took in a vector, and got that right, but forgot to check how i destructure the incanter.matrix
17:04duncanmanyhoo
17:04duncanmi have this code to do some other destructuring, and it's a bit long, i was hoping to see if someone could figure out a better, more concise way
17:04duncanmit goes "From a map of {key, {:entries {s [sx sy] ...} ...}} and 's', return a map of {key, [sx sy]}"
17:05duncanmi put mine here: http://gist.github.com/652322
17:16_seanc_Is there a simple way in Clojure, without using Java, to replace one character in a string with another. Say, replace spaces with a dash
17:17RaynesWhy do you not want to use Java here?
17:17Raynes&(.replace "foo bar baz" " " "-")
17:17sexpbot⟹ "foo-bar-baz"
17:17_seanc_I'm a Java dev, I want to try and learn Clojure without Java
17:18raekif we define "without using Java" as "by only calling clojure functions", clojure.string/replace seems to be a match
17:18raekhttp://clojuredocs.org/clojure_core/clojure.string/replace
17:18RaynesClojure embraces Java quite a bit. Where Java isn't broke, Clojure doesn't really aspire to fix it.
17:18raek,(require '[clojure.string :as str])
17:18clojurebotnil
17:18_seanc_whoa, ClojureDocs, how the hell hasn't Google shown me this before?!
17:18RaynesThere is the replace function in clojure.string and raek just pointed out, but it uses .replace under the hood. Hell, I think it even takes the arguments in the same order.
17:19raek,(str/replace "foot" \o \e)
17:19clojurebot"feet"
17:20raekyeah, clojure.string is a very thin wrapper
17:20_seanc_I appreciate the help. I'm learning more and more :)
17:22_seanc_@raek where you put (require '[clojure.string :as str]), does that have no negative impact on clojure.core's str?
17:22scottj_seanc_: I think clojuredocs.org is fairly new, maybe not a high pagerank bc few links to it
17:24raek_seanc_: no, the "src" it introduces is a namespace prefix, which are always distinct from var names from context
17:28_seanc_raek: So since require creates a new str in a new namespace. Does that mean when you use str, without specifying the namespace that clojure has to figure out which is the correct one to use?
17:29raekrequire does two things in this case: 1) makes sure that the namespace gets loaded 2) adds a namespace alias in the current namespace
17:30raekso writing str instead of clojure.string (which you can still use) only works in the namespace you made the require
17:30raekno
17:30raeknow
17:30raeknamespaces does not have var entries in other namespaces
17:31_seanc_I think I may have misunderstood something. I'll do some more reading. I appreciate the help
17:32duncanmla la la
17:32technomancyis there any way to add a method to a defmulti for which you only have the var at runtime?
17:32technomancyother than eval
17:32raekwhen clojure evaluates the symbol str, it will first resolve it to fully qualified form: str -> clojure.core/str
17:33raekif the symbol already has a namespace part, then that part will be looked up in the alias table and replaced with the full form, of there is any
17:33Raynes&(resolve 'str)
17:33sexpbot⟹ #'clojure.core/str
17:34raekso namespaces only go before the slash, and var names only after the slash
17:35raek(on exception is when you use quoted symbols to refer to namespaces, like when calling 'require' or 'use')
17:35raekbut since they are quoted, normal rules don't apply
17:35_seanc_quoted being ' ?
17:36raekyes
17:36_seanc_You know, I don't want to bother you guys all day. Do any of you know of some good resources for clojure? I can honestly say none of the things I've read really cover much
17:37nickikhow do i get a normal map from a record?
17:37nickik(because i want to use the data as a function)
17:37raek_seanc_: I haven
17:38technomancy~peepcode
17:38raek't read this, but it seems to cover many things: http://en.wikibooks.org/wiki/Learning_Clojure
17:38raekI learned very much about clojure from the pages of clojure.org, but then I had programmed in Lisp before...
17:39_seanc_raek, you're the (wo)man!
17:40_seanc_(I have no idea if you're a dude or dudette, no offense intended)
17:40raekhow politically correct of you... :) but I'm just a male geek as you would expect
17:41nickikis there a better way then this (apply hash-map (interleave (keys <The Record>) (vals <The Record>)))
17:41_seanc_Hah, I know a few female devs so you can never be sure
17:41amalloy|brbnickik: (into {} <The Record>)?
17:41raeknickik: (into {} the-record)
17:42nickikah of course why did i not think of that
17:42amalloy|brbif you want to be verbose, you can use (apply zipmap ((juxt keys vals) the-record))
17:43raekamalloy's brain and mine seems to be in lockstep... or should I say "juxed"? :-)
17:44raekhey, you managed to sneak in a juxt there too... :)
17:44nickiksais something about the clojure api too
17:45raeknickik: another way would be #(get the-record %)
17:45raekif you don't want to build a new data structure
17:45a_strange_guyHello Clojurians
17:46nickikoh my good a strange guy
17:46nickikhallo :)
17:46a_strange_guyis anyone else building clojure and contrib himself
17:46a_strange_guy?
17:46raeknot since lein was released... :-)
17:48raekif you're just going to use them (and not fix bugs or something) there is little benefit of compiling them yourself
17:48RaynesMost people just use cake or lein these days.
17:48nickiki never did :)
17:49a_strange_guyi just like playing with the bleeding-edge versions
17:49ohpauleeza_strange_guy: you can pull the daily snapshots with lein
17:49ohpauleezor cake
17:49RaynesThe bleeding edge versions are on in a maven repository, I believe.
17:49RaynesLike he said.
17:50a_strange_guyare those the same as the ones at build.clojure.org?
17:50raekyes
17:50ohpauleeza_strange_guy: you want to use alpha2 as your 1.3.0 artifact, that's the last major step. If you want snapshots, you can use snapshots, but the alpha cuts are better (imo)
17:51raekthere's both http://build.clojure.org/releases/ and http://build.clojure.org/snapshots/
17:51a_strange_guya lot seems to have changed since I last used clojure xD
17:52ohpauleeza_strange_guy: http://gist.github.com/652400
17:52ohpauleezand example where I use alpha2 in my project.clj
17:52raekwell, Leiningen (pretty much the first useful Clojure build system) was released in november last year, IIRC
17:53ohpauleezThere's also commented lines how how to get snapshots
17:53raeka_strange_guy: yes, indeed.
17:54raekI remember the times before lein...
17:54a_strange_guyI stopped programming last spring for a while, and now so much had changed ^^
17:55a_strange_guyi remember the times before 1.0 ...
17:55ohpauleezyes, I too remember those days
17:56joegalloWhen we had to walk uphill, both ways, to read a sexp.
17:56joegalloAnd we liked it!
17:56ohpauleezIt's going to be funny when we say things like, "Remember when all we had were transients and type hints"
17:57technomancyremember the tarbomb releases?
17:57joegalloYou kids today! I once wrote a lexer/parser using nothing but closing parens!
17:57technomancythat was my first bug reports
17:57technomancy*report
17:58a_strange_guy"Did you know that once apon a tome, clojure was written in a strange language called 'Java'?"
17:58a_strange_guy^^
17:59a_strange_guyi just asked if someone builds clojure from scratch, because I cant get contrib to build against my clojure.jar
17:59a_strange_guythe -Dclojure.jar option doesnt seem to work
18:00a_strange_guyit still downloads a clojure.jar via maven
18:00a_strange_guyand the resulting satandalone.jar ist binary incompatible
18:01ohpauleezIs it possible to destructure in an anon func?
18:01amalloyyes
18:01amalloy,((fn [[a b]] [b a]) [1 2])
18:02amalloy&((fn [[a b]] [b a]) [1 2])
18:02sexpbot⟹ [2 1]
18:02amalloyi'll get over this comma habit yet!
18:02ohpauleezI'm mapping something across a map, and I want the key and value
18:02amalloyohpauleez: ^^
18:02ohpauleezahh, cool, thanks amalloy
18:02ohpauleezI knew I had done it before, I don't know what I'm doing wrong right now haha
18:02amalloy*laugh* what does your broken attempt look like?
18:03ohpauleezit's sitting on a repl right now, let me poke it a little more, and if I can't fix it, I'll gist it
18:04apgwozwhat's the proper way to add metadata in the `ns` macro? i've seen (ns #^{..} ..) and i've seen (ns x.core {:blah blah}...) ?
18:04apgwozor, are they equivalent?
18:05apgwoz... though, i've also seen (ns ^{..}...) too..
18:05ohpauleezamalloy: solved. I was being foolish
18:05amalloyapgwoz: i don't know about the ns form, but i think #^ is deprecated in favor of ^ these days
18:05MayDanielapgwoz: (ns ^{:doc "..."} user)
18:06apgwozamalloy, MayDaniel: ah, sweet.
18:07ohpauleezapgwoz: I do (ns some-name ^{:author Me} (:require ...))
18:07technomancyyou don't need that syntax for just :doc; just put a string after the ns name
18:07MayDanielJust an example..
18:07apgwoztechnomancy: right, but, for :author as well
18:08apgwozohpauleez: does that actually attach the metadata to the namespace?
18:08technomancyI fail to understand why that belongs in code rather than version history, but if you wanted to do it, that's how you would.
18:08apgwozi thought the metadata shortcut only worked for the preceeding element.
18:09ohpauleezI don't know actually, let me try on the repl real quick. It's just what I've seen done
18:10apgwoztechnomancy: while i'd normally agree with you, some companies have rules regarding these things where everything has to be documented, who wrote it, etc. that metadata seems like an appropriate place.
18:10hiredman,(symbole "\o")
18:10hiredman,(symbol "\o")
18:10amalloyapgwoz: comments with version-control tags?
18:11apgwozamalloy: that works too, but by not meta data with version-control tags?
18:11apgwoz:)
18:11technomancyapgwoz: true; better than comments
18:11ohpauleezapgwoz: both forms don't actually attach meta data for me
18:12technomancyactually it needs to be before the namespace name
18:13ohpauleeztechnomancy: does it?
18:13MayDanielYes.
18:15ohpauleezMayDaniel: http://gist.github.com/652449
18:15apgwozyeah, looks like it.
18:15ohpauleezOhhhh
18:15ohpauleeznvm
18:15ohpauleezIt's attaching to the require, not the ns
18:15ohpauleezI understand now
18:17scottjwhat's the oldform param in if-let for?
18:18apgwozyeah, it seems the reader effectively does: 1. if find a ^form, push it on a stack 2. read next form 3. if stack not empty, add meta data to result of 2.
18:19scottjoh nm, guess old version must not have used binding vector so it's to show an error
19:02duncanmis there a shortcut syntax for writing {:x x :y y} ?
19:03MayDanielNo
19:03duncanmthat's too bad
19:03RaynesWhat would the shortcut look like?
19:04duncanmi don't really know
19:04duncanmthere is something like it in destructuring, with :keys, which is why i asked
19:04bhenrywhat might be the opposite of not-any?
19:04RaynesI'm just not sure what your shortcutting. :p
19:05MayDanielsome is similar to the opposite.
19:05Raynes-> (doc every?)
19:05sexpbot⟹ "([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false."
19:05bhenry,(doc some)
19:05tomojdo you also have a (let [x ... y ...]) around it?
19:05clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence,...
19:05MayDanielOops.
19:07tomojduncanm: https://gist.github.com/2f060dde83ac1bfbe551
19:07tomojif so
19:07tomojbut you could change it from into to just macroexpanding to a literal map
19:07tomojsince the let ensures evaluation order
19:07MayDanielduncanm: Do you mean {x :x y :y} as in how you'd use it in destructuring?
19:08tomojif you had a macroexpand to {:x x :y y}.. be careful
19:08tomojs/macro/macro /
19:08sexpbot<tomoj> if you had a macro expand to {:x x :y y}.. be careful
19:10duncanmtomoj: that's very cute
19:11duncanm(let [min-x ..., min-y ..., max-x ..., max-y ...] {:min-x min-x :min-y min-y :max-x max-x :max-y max-y})
19:11duncanmthat's what i have
19:11duncanmtomoj: so your macro would make it nicer
19:11duncanmbut i don't think i'll use that macro for just this instance
19:11tomojthat's exactly the pattern I had
19:11duncanmtomoj: it'd be cool if it were part of clojure.core ;-)
19:12tomojI was also independently doing macros that generated big maps which caused all my code to execute in scrambled order
19:12duncanmthen, i'd definitely use it
19:12duncanmi don't even bind the dummy thing, i think that's quite nice
19:12duncanms/bind/mind/
19:12sexpbot<duncanm> i don't even mind the dummy thing, i think that's quite nice
19:13duncanmi posted a bit of destructuring code earlier, it'd be cool if someone can show me some better way to write it: http://gist.github.com/652322
19:13duncanmmy version works, but it seems kinda too verbose
19:14duncanmmaybe if i use for instead of map and then let, it'll be more concise
19:14scottja couple weeks ago someone posted a macro where you could do (with-keys a b c) I think and get {:a a :b b :c c). Anyone remember the name of it?
19:15tomojduncanm: that was the first thing I noticed
19:16duncanmtomoj: oh?
19:16tomojI don't understand the rest of it
19:17duncanmtomoj: i posted a version with for, it looks a little better?
19:17duncanm(first (get (:entries trail) section)) still seems too busy
19:17tomojcool
19:18tomojwell
19:18tomojhmm
19:18mattrepltechnomancy: I'm trying to use a hook in leiningen to set the classpath in used by the lein-swank plugin. I can't see how to do it without modifying lein-swank to accept a handler which it could pass to eval-in-project. Am I doing it wrong or should I find a workaround (dynamic var of handlers in eval-in-project) and submit a patch to lein?
19:18raekduncanm: I would write (for [[id trail] trails] :let [entries (get (:entries trail) section)] [id (->vpoint (first entries))])
19:18duncanmtomoj: i'm also using maps when i could be using vectors, i guess?
19:18duncanmyeah, i don't know what to do about that
19:18raekI personally prefer 'for' over 'map' + 'fn'
19:18mattrepls/in used/used
19:18raekalso, you can do lets with it
19:19duncanmraek: yeah, i'm slowly warming up to the list comprehension syntax
19:19hsuhclojure macros expand at compile time, right ?
19:19duncanmhsuh: macros expand at compile time
19:19tomoj(-> trail entries section first ->vpoint) ?
19:19duncanmtomoj: hehe
19:20tomojI dunno
19:20duncanmtomoj: that wouldn't work when 'section' is a number, it'd work if it were a keyword
19:20RaynesMacros expand at macroexpansion time.
19:20tomojfunny how not knowing what the heck its doing makes it so much harder to read
19:20duncanmtomoj: is the comment not clear?
19:20duncanmi guess the ...s are a bit too abstract
19:20tomojI just am too dump to try to understand right now
19:21tomojI guess knowing what the code is doing gives you shortcuts for reading chunks of it
19:21duncanmtomoj: well, this function is *just* destructuring
19:23duncanmi have a map of {key, T} and each T is a map of {:entries { section-id [[x1 y1] [x2 y2]...] }
19:24duncanmfor some section-id, i want {key, [x1 y1]}
19:25duncanmeither way
19:34duncanmi used to think that polymorphic sequence operators are the "missing things" in Scheme
19:35duncanmbut now that i've used them in Clojure, while I do like them generally, I can see that they could get confusing sometimes
19:35duncanmmaybe it's just me not being experienced enough with them
19:35duncanmi find it 'annoying' that (map #(..) some-map) returns a seq of MapEntrys
19:35duncanmsame with filter
19:36amalloyduncanm: destructuring is the answer again :P
19:36duncanmmaybe all i need is to write my own map-map and filter-map
19:36duncanmamalloy: how so?
19:36amalloy&(map (fn [[k v]] [k (+ 1 v)]) {:k 10, :t 5})
19:36sexpbot⟹ ([:t 6] [:k 11])
19:37amalloyif you want it as a map again, just use into
19:37duncanmbut i want {:t 6 :k 11} instead of ([:t 6] [:k 11])
19:37amalloy&(into {} (map (fn [[k v]] [k (+ 1 v)]) {:k 10, :t 5}))
19:37sexpbot⟹ {:t 6, :k 11}
19:37duncanmamalloy: yeah, that's the bit that bothers me
19:37duncanmmaybe i'll learn to accept it
19:37amalloyi agree we could use an into {} function
19:37amalloybut it's convenient for map to always return a seq
19:38amalloyrather than try to guess what to return based on the class it's passed
19:38duncanmamalloy: yeah, but most of the time, you *do* want it to be the class that you put in
19:38Raynes& (def into-map (partial into {}))
19:38sexpbot⟹ #'net.licenser.sandbox.box9126/into-map
19:38amalloyRaynes: sure, of course it's not hard to write one
19:39Raynes&(into-map (map (fn [[k v]] [k (+ 1 v)]) {:k 10, :t 5}))
19:39sexpbot⟹ {:t 6, :k 11}
19:39MayDanielThere's clojure.contrib.generic.functor/fmap
19:39amalloy&(def def inc)
19:39sexpbot⟹ #'net.licenser.sandbox.box9126/def
19:39amalloy&(def def inc)
19:39sexpbot⟹ #'net.licenser.sandbox.box9126/def
19:39duncanmi wrote a update-val in my code
19:39duncanm(defn update-vals [m update] (into {} (for [[k v] m] [k (update v)])))
19:39amalloyRaynes: neat. we get a sandbox per user?
19:39Raynes&(def 3)
19:39sexpbotjava.lang.Exception: First argument to def must be a Symbol
19:39amalloyor no
19:40amalloy&def
19:40sexpbot⟹ #<core$inc clojure.core$inc@f334db>
19:40amalloy???
19:40duncanmhaving select-keys for maps different from filter is also one of the things i had to learn the hard way
19:40amalloy&(identity def)
19:40sexpbot⟹ #<core$inc clojure.core$inc@f334db>
19:40amalloy&((identity def) 1)
19:40sexpbot⟹ 2
19:40amalloy&(def 1)
19:40sexpbotjava.lang.Exception: First argument to def must be a Symbol
19:40duncanmand i guess the other pair is dissoc/remove
19:41Raynesamalloy: There is a reason that bots shouldn't allow def and defn.
19:41amalloyRaynes: what is it doing under the hood here?
19:41amalloyyeah, i agree
19:41RaynesI think I allowed it ages ago for playing with it in another channel and just never disallowed it.
19:41amalloywhich is why i'm surprised it knows def is inc ever. but i don't understand what it's doing that makes it def sometimes, and inc other times
19:43duncanmi always prefered the Smalltalk's names for sequence operators over Lisp's: collect: instead of map, select: instead of filter, and inject:into: instead of reduce/fold
19:43Raynesamalloy: def is a special form.
19:43amalloyoh
19:43Raynesamalloy: It behaves the same way in an REPL.
19:44amalloyduncanm: so use them. nobody's stopping you from (def collect map)
19:44duncanmamalloy: i know i know
19:44duncanmamalloy: well, it's probably bad form for others having to read the code
19:46amalloyyeah, i agree. but (a bit tongue in cheek here, no offense) i'd prefer that your code reflect your dislike, rather than your chat in #clojure do it
19:47amalloyie, rich isn't going to rename them anytime soon
19:48RaynesI strongly disagree.
19:48RaynesExcept for fold. I'd take fold over reduce, I guess.
19:48amalloyRaynes: disagree with whom?
19:48RaynesBoth of you.
19:48amalloyheh
19:48duncanmheh
19:48Raynes:p
19:48amalloywell, yes. if i were giving selfless advice, it would be to complain in #clojure but write standards-conforming code
19:49RaynesI was implying that I disagree with your agreement. Not the rest of the message.
19:50amalloyoh
19:50amalloyno, i agree that it's bad form to re-def in his code
19:50amalloyi like map/reduce/filter, myself
19:50RaynesOh. Then I agree with you and disagree with him. I think. :|
19:51amalloyif we ever get unfold and/or foldl/foldr then i'll support a name-change for reduce, but until then i prefer reduce
19:51RaynesI'm neutral as far as reduce vs fold.
19:51RaynesEither one would work for me.
19:53duncanmi just found out that Select in .NET/LINQ is the equivalent of #collect: in the Smalltalk naming scheme, how confusing!
19:54amalloyduncanm: best to stick with map and filter then, eh?
19:54duncanmamalloy: yeah, i suppose ;-D
19:55RaynesHaskell uses map and filter as well.
19:55Raynes$he map + [1..10]
19:55sexpbot=> Couldn't match expected type `(a -> b) -> [a] -> [b]' against inferred type `[a1]'
19:56RaynesMan, I haven't used Haskell in so long.
19:56Raynes$he map (+) [1..10]
19:56sexpbot=> Overlapping instances for GHC.Show.Show (a -> a) arising from a use of `M1800505397.show_M1800505397' at <interactive>:(2,0)-(4,33)Matching instances: instance (Data.Typeable.Typeable a, Data.Typeable.Typeable b) => GHC.Show.Show (a -> b) -- Defined in show-0.3.4:ShowFun instance (Test.SmallCheck.Serial a, GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (a -> b) -- Defined in smallc
19:56RaynesScrew it.
19:56duncanmwow, there's a haskell REPL here too? what else can i write?
19:56RaynesThats about it. It needs to truncate text though.
19:56RaynesI'm surprised I overlooked that.
20:03RaynesThere.
20:08bhenryRaynes: is ruby learning down or is it my workplace's horrible network that seems to give me trouble with it every time.
20:08bhenrythe latter is my speculation based on your answer to the former
20:08RaynesIt's down.
20:08Raynes$ping rubylearning.org
20:08sexpbotRaynes: FAILURE!
20:11guandaosuppose i figured out how to capture *out*, would it be thread-safe?
20:11guandaoand what i mean is ... would i get the stream of a single thread in it, without mixing the other threads output in the stream...
20:13guandaoi guess with-out-writer does that
20:20tlockneyanyone got a pointer on how I can create a Clojure function from Java?
20:21tlockneyand, please, before anyone asks why I would want to do such a thing, just... well, don't
20:21RaynesWhy would yo... damn. ._>
20:22tlockneyI'm guessing the easiest thing to do is going to be to have the clojure side somehow wrap it, but wondering if there's a more direct way
20:44notsonerdysunnycan somebody tell me when to use #^ and ^ for providing type(or meta info) information?
20:44notsonerdysunnyor are they both equivalent?
20:45MayDanielI think #^ is deprecated from version 1.2.0
20:46RaynesWhat he said.
20:46notsonerdysunnythanks MayDaniel and Raynes
20:47RaynesI wish everybody thanked me for repeating other people's answers.
20:47notsonerdysunny:) confirmations adds weight to the answer ..
20:48amalloyRaynes: don't forget MayDaniel and i both said that an hour or two ago too, when apgwoz asked
20:51amalloyhey, i just managed to ping/highlight/alert three different people in one message, none of whom actually care what i said
20:52Deranderamalloy: cool
21:03duncanmis there no page on clojure.org on futures/promises?
21:04duncanmi have a task to take an image and transform it and then write it to disk, i'd like to do that in parallel, so that i can use all my cores to run the transformation, should i just use pmap and fire off (future (render %)) inside the pmap?
21:40chaslemley,(+ 5 5)
21:40clojurebot10
21:51technomancymattrepl: pong
21:51mattrepltechnomancy: hola
21:52technomancyso did you try adding a hook to leiningen.classpath/get-classpath?
21:53technomancy(add-hook #'leiningen.classpath/get-classpath (fn [f & args] (conj (apply f args) "/my/new/classpath/entry.jar")))
21:53mattreploh, I feel silly. I had it in my head that I needed to hook a plugin for some reason.. yes, that works perfect
21:54mattreplthanks, that should do it
21:54technomancyschweet
21:55mattreplwhat an awesome setup, robert.hooke may find it's way into crane... =)
21:57technomancyrobert hooke has real ultimate power
21:59maravillasi never knew his last name was hooke
22:01Ploujhey guys
22:02Ploujdid anyone here see job openings at Akamai for Clojure development?
22:02hiredmanthey had a table at the conj
22:02arscottpretty sure they had a sign out saying they were hiring
22:02Ploujthere's no way I'm moving to that area (Cambridge, MA), but maybe you guys would be interested
22:02Ploujoh, I see
22:03Ploujsounds like a posistive point for Clojure as a whole
22:04Ploujpositive*
22:08technomancynothing like a little corporate backing
22:15amalloycan someone help me out with defmulti? i can't figure out the syntax and clojuredocs has no examples. i want to define a multifn that dispatches on the class of its first argument
22:16amalloy(defmulti do-thing (comp class first)) doesn't seem to work
22:16duncanm(defmulti distance #(class %1)) ;; this ought to work
22:19amalloyduncanm: hm, thanks. i think the issue is actually that my defmulti is stale. if i (defmulti name func) and then later in the same repl session (defmulti name other), it still dispatches based on func instead of other
22:21amalloy&(#(class %1) "1" 2)
22:21sexpbotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: box12631$eval12833$fn
22:22amalloythat doesn't actually work duncanm, but it gets me to understand the syntax
22:25duncanmamalloy: oh right, the implicit % works kinda funky
22:25amalloyduncanm: (comp class first list) works as a dispatch fn
22:25duncanm(fn [a _] (class a))
22:25duncanmor (fn [a & ignored] (class a))
22:25amalloyyeah
22:25duncanmis there no page on clojure.org on futures/promises?
22:26technomancyunderscore is preferred to "ignored"
22:26duncanmtechnomancy: does _ bind varargs?
22:26technomancyduncanm: I mean with a &
22:26duncanmoh oh
22:26duncanm(fn [a & _] (class a))
22:27duncanmi'm trying to figure out how to use futures
22:31technomancycreating a future is like spawning a pooled thread, but you get a value back when it's done
22:32technomancypromises are just simple reference types; no code executes inside them. they're just placeholders into which a value can be placed asynchronously (only once)
22:33technomancykind of like atoms, but they don't need swap concurrency semantics since they can only be set once
22:34somniumany adventurous clojure hackers interested in kicking the tires on a javascript compiler?
22:35duncanmtechnomancy: can you take a quick look at this? http://gist.github.com/652780
22:35duncanmtechnomancy: render! is my CPU and IO intensive task
22:36amalloy&(macroexpand '(-> 1 #(inc)))
22:36sexpbot⟹ (fn* 1 [] (inc))
22:36amalloywhat's an idiomatic form using -> that will result in (fn [] (inc 1))?
22:37_rata_,(macroexpand '(-> 1 inc))
22:37clojurebot(inc 1)
22:37sexpbot=> 1
22:37amalloy_rata_: yes, but i need a function, not a result
22:37_rata_oh ok
22:37hiredman,((-> inc (partial 1)))
22:38clojurebot2
22:38duncanmhey hiredman
22:38hiredmanhello
22:39amalloy&(-> inc (partial 1))
22:39sexpbot⟹ #<core$partial$fn__3678 clojure.core$partial$fn__3678@909348>
22:39amalloy&(macroexpand '(-> inc (partial 1)))
22:39sexpbot⟹ (partial inc 1)
22:39duncanmi've used future before like this (def f (future (do-some-io-work)))
22:39hiredmanI wouldn't use future in a def
22:41duncanmhiredman: i do that so i can query the status of the work
22:41hiredmanthat thread will start running anytime that def is loaded
22:42duncanmhiredman: oh, i only do that in the REPL
22:45duncanmhiredman: is that not a good thing to do?
22:45duncanmoh, maybe i should do send-off instead of send
22:45duncanmhmm, nope
22:58duncanmdum de dum
23:02amalloy&\newline
23:02sexpbot⟹ \newline
23:02amalloy&\nonsense
23:02sexpbotjava.lang.Exception: Unsupported character: \nonsense
23:09duncanmhow do i tell a future to start running?
23:09ohpauleezduncanm: A future will start running right away
23:09ohpauleez"right away"
23:10ohpauleezyou get back the value from it, by deref'ing it
23:10duncanmohpauleez: so what am i doing wrong here? http://gist.github.com/652780
23:13ohpauleezI'm not sure you want a future there, that's already being run in an agent, which will be in a different thread
23:14ohpauleezotherwise, there's nothing super obvious. You might want to look at if you want to be using send vs send-off
23:14duncanmohpauleez: right
23:14ohpauleezand if you're calling this on the repl, you'll want to call (shutdown-agents)
23:14ohpauleezif it's hanging
23:19duncanmohpauleez: is there a upper-bound to the number of futures i have running? or will they use a threadpool?
23:20ohpauleezthey will use the threadpool. What symptom are you seeing?
23:20duncanmnothing's running ;-P
23:20ohpauleezAs in, when you deref, you get nothing back?
23:20duncanmohpauleez: should i use agent/send-off or future?
23:20duncanmohpauleez: right
23:21duncanmi think i know how to do it with just future
23:21ohpauleezI would personally just use futures, and map deref across them
23:22ohpauleezYou might also just want to use a ref and pmap, chunked appropriately
23:23duncanmohpauleez: i was chunking manually
23:23duncanmohpauleez: so by now i'm a little lost in how to put it all together
23:23duncanmohpauleez: oh, the ref holds the list of futures?
23:24ohpauleezright, you want to be chunking your data 2+ number of cores, and run pmap on that
23:24duncanmohpauleez: and i just (map deref futures) to get all of them started
23:24ohpauleezright, that's one approach
23:24duncanmohpauleez: how do i put the futures into the ref?
23:24hiredmanderef doesn't start futures
23:24ohpauleezthe other one is just to use pmap and no futures
23:24hiredmanfutures start right away
23:25ohpauleezhiredman: right, I think he knows that
23:25duncanm(future-done? (future-call (fn [])))
23:25ohpauleezohhh, nvm, I didn't read his last line
23:25duncanmi tried doing that
23:25duncanmand it always says false
23:25ohpauleezduncanm: futures start right away, jump on the repl and play around with them a little bit
23:25duncanmi'm still a bit lost
23:25ohpauleezlet me make a gist for you, hang on
23:26duncanmohpauleez: thanks so much
23:26duncanmthis is kinda silly, i have counted this - if i do this sequentially, it'll only take like 2 hrs
23:26duncanmand i've spent close to 2 hrs trying to learn how to do it in parallel
23:26duncanmi'm trying to render 1200 images
23:29_seanc_Hey guys, so I know two asterisks are use to denote *globals*, but what exactly are two pluses for in say: +db-path+ ?
23:30_rata__seanc_, in common lisp that's used for constants... not sure in clojure
23:31amalloyin clojure it's frowned on, mostly. there are a few people who use it for constants
23:31technomancy_rata_: they're used by common lispres writing clojure
23:31_seanc_Oh ok, but I am right about the * * for constants?
23:31technomancy_seanc_: not globals but values which are intended for rebinding
23:31duncanm_seanc_: i think the java convention of UPPER_CASE is ok too
23:32_rata_hahahaha ok, I didn't know that
23:32technomancyall non-privates are globals
23:32itistodayshit... how do i switch channels in erc (emacs)?
23:32duncanmitistoday: by switching buffers?
23:32dakroneitistoday: channels are buffers
23:32itistodayi've auto-logged in to both #emacs and #clojure
23:32itistodayoh
23:32itistodayC-x b
23:32itistodaydakrone: thanks!
23:32_seanc_I guess I don't really understand the concept of binding and rebinding yet. It's not as simple as assigning a new value is it?
23:33duncanmohpauleez: i'm trying something like this now: http://gist.github.com/652780
23:34_rata__seanc_, no, it's like "stacking" a new value on it and then you get back to the original value (when you live the "binding" form)
23:34duncanmoh wait, i forgot about the dorun
23:34_rata_+ it's thread-safe
23:35_seanc_thread safe aside, when would you need to stack a value?
23:35technomancy_seanc_: if you're pretty-printing, you would bind the current indentation level, for example
23:36_rata_for example when you want to redirect standard output in some function calls
23:36duncanmi feel kinda stupid today
23:36ohpauleezduncanm: http://gist.github.com/652858
23:37_seanc_Interesting. So it keeps the new value for the duration of that execution then changes back?
23:37_rata_yes
23:37_rata_you bind it, call some functions and inside that functions standard output will be redirected
23:37_seanc_Fascinating
23:37duncanmwhoa
23:37duncanmdoes *1 work?
23:37_seanc_So it's like a dependency injection on a per function basis almost
23:37ohpauleezyes
23:37duncanmoh sweet
23:37duncanmi didn't know that
23:37ohpauleez*1 *2 and *3
23:37technomancy,*e
23:37clojurebotjava.lang.IllegalStateException: Var clojure.core/*e is unbound.
23:38technomancy,botsmack
23:38clojurebotjava.lang.Exception: Unable to resolve symbol: botsmack in this context
23:38ohpauleezalso, I left out one line, where I (def num-of-cores 2)
23:38technomancy~botsmack
23:38clojurebotOwww!
23:38defnevening folks
23:38defnclojurebot: hey
23:38clojurebothey is for horses
23:38defnclojurebot: horses?
23:38clojurebotCool story bro.
23:38ohpauleezhaha
23:38defnlol
23:49ohpauleezduncanm: How are things working out?
23:49duncanmohpauleez: i got it running now
23:50ohpauleezperfect!
23:50duncanmi just have map and future
23:50duncanmohpauleez: and i chunk into 4 futures
23:50duncanminside each, i have a doseq
23:50ohpauleezsweet
23:50duncanmi dunno if that's optimal use of my hardware, though
23:50duncanmi have a 2 yo Mac Pro at work, i have 8 cores here
23:50ohpauleezchunk it into 10 pieces
23:51duncanmohpauleez: so this is silly, but the total number isn't divisible by 10, so partition doesn't work....
23:51ohpauleezpartition-all
23:51ohpauleezis what you want
23:52duncanmoh wow
23:52ohpauleezwhich will have 9 full pieces, and one slightly smaller part