#clojure logs

2010-03-05

00:01joshua-choiAnd I use a plain text editor: sometimes TextEdit; lately TextWrangler. I've been trying NetBeans-Enclojure lately, but it makes my laptop pretty hot even idly.
00:01technomancyanecdotally: everyone I know who uses clojure uses a repl
00:02dnolentechnomancy: heh :) yes I suppose I meant REPL oriented development. compile a little bit. type expr a REPL, correct, repeat.
00:03joshua-choiHow do you do it? When you modify a library's code, what do you do in a REPL? Just evaluate test expressions? Doesn't that get tedious without factoring them into a test file?
00:03danlarkinhow can you not write clojure interactively? it's like... giving up half the benefit of a lisp? crazy!
00:04joshua-choiI'd love for someone to write a tutorial for the *philosophy* of REPL-driven Clojure development. I'd read it voraciously.
00:04Raynesjoshua-choi: You just play with stuff. You can use an REPL as a debugging tool by evaluating pieces of code until you find hte problem. You can write expressions just to see what they'll do, look up documentation, etc.
00:04Raynesthe*
00:05joshua-choiCan you evaluate pieces of code other than top-level functions?
00:05RaynesIt's not just static test expressions.
00:05RaynesYou can evaluate any code.
00:05RaynesHave you ever used an REPL before?
00:05joshua-choiYeah, but just a standalone one, like clojure.main.
00:06joshua-choiWhen I tried using it, I'd (require my-library) (do-something top-level-fn), but I'd reload and re-evaluate over and over again.
00:07joshua-choiWhenever I changed my library. Right now I figure that just running a test script in my terminal is less tedious. But there's got to be something that I'm missing.
00:07RaynesIt's not just for evaluation test expressions. You can try out anything in an REPL, like I said, just to see if it works. Find out what things to, and know if something is going to work /before/ you write it.
00:07Raynesevaluating*
00:07Raynesdo*
00:07RaynesWow, I can't type today. :\
00:08joshua-choiYou mean, running bits of code and then putting them together?
00:08joshua-choiHow do you deal with lexical contexts?
00:08joshua-choiAnd isn't it annoying to copy and paste code you put in REPLs in your actual library code?
00:08RaynesNot really...
00:08joshua-choiMmm. Maybe using an actual IDE would make it better.
00:09RaynesYou can def code that you want to save for use in later code. Also, the last expression evaluated is saved in *1, and so on until *3.
00:09RaynesMeh, IDEs don't have anything to do with it. I think you might just be missing the point. Maybe this is something you need to do before you'll understand the reason behind it.
00:10joshua-choiYeah. I feel like I need to figure this out, and that it'd make me a lot more productive.
00:10joshua-choiI'm just using a text editor and a terminal.
00:10joshua-choiWell, here's one thing: how do you deal with reloading libraries?
00:11joshua-choiI'd have to paste "(require [blah.blah :as blah])" every time I changed my library even a little bit.
00:11RaynesStuff like Emacs and other IDEs make it easier to load code into the REPL with keybindings.
00:11joshua-choiDo you just not modify your actual Clojure file often?
00:11joshua-choiI see.
00:12rickmodejoshua-choi: sounds like you need to embrace Emacs + SLIME + Swank
00:12joshua-choiI'm very afraid of Emacs.
00:12rickmodeit's a bit of a mind bender at first, but it'll pay off quick
00:13rickmodeI'm using Aquamacs which mashes up Emacs with the usual mac os'isms
00:14joshua-choiPerhaps. When I mucked in Emacs for the first time, it wasn't the bindings that were that hard—it was the buffers. I'd do something accidentally, and something really weird and apparently destructive happens to my screen.
00:14joshua-choiAquamacs?
00:14rickmodebut you'll hit some fun wonky stuff getting swank-closure set up properly with the stable version of aquamacs
00:14joshua-choiThere's a Cocoa version of Emacs?
00:14rickmodeAquamacs is built on top of Emacs
00:15rickmodethere's a couple... aquamacs seems the most user-friendly (to me at least)
01:00DeusExPikachujoshua-choi, I use emacs/slime but I use a repl only for really short one liners. Stuart Halloway's trick of having a temp buffer and just evaluating stuff from there is soo much better then trying to navigate the history of the repl. Also the keybindings are different in the slime-repl rather then a full blown slime / clojure-mode / paredit buffer
01:03DeusExPikachuthink of emacs as firefox with a bunch of tabs, but to switch between the tabs, use the key sequence C-x b. Most of emac's behavior is nondestructive, just switch back to the old buffer, nothing happened to your data
03:02robinkIs it possible to have a JVM run quickly on a machine without hardware float?
03:06TheBusbyor a broader question, does the JVM run quickly on any machine that isn't a desktop PC or server? Based on experiences with Android I wouldn't say it was very quick on an embedded device...
03:07hiredmanwell, android isn't a jvm
03:07Fossido you really mean a jvm on android?
03:07TheBusbyit's a platform partially built on top of a jvm
03:08Fossiit's got it's own vm, dex
03:08Fossiand it's gc sucks ;D
03:08Fossiespecially for clojure ;)
03:09TheBusbysorry, I consider a virtual machine that runs Java to be a JVM
03:12hiredmanTheBusby: it doesn't even use java bytecode
03:12TheBusbyand a turing machine doesn't use electricity
03:12hiredmanwe aren't talking turing machines
03:13TheBusbyI was hoping you'd see the connection
03:13TheBusbyjvm's don't necessarily have to use bytecodes, or be stack based
03:13TheBusbyI guess sun may have a different definition for their trademark though
03:13hiredmanTheBusby: the jvm spec says different
03:14TheBusbyand xerox says that only machines made by them can be called "xerox machines", same with cleanex
03:14hiredmanwell, it at least says it has to implement bytecodes that operate on a stack
03:15hiredmanTheBusby: the jvm is not just a brand, it has a spec, which is what allows others to make jvms
03:15TheBusbyI understand your point hiredman, and I know what you're trying to say
03:15TheBusbyI just don't agree
03:16hiredmanyou seem to be confusing java the language with the jvm
03:17hiredmancalling the dalvik vm a jvm is like calling an arm cpu a x86 because if you run an x86 binary through the right translation programming it will run on an arm machine
03:17TheBusbyno I just think than JVM is the acronym for any java virtual machine, and that one of those is the branded "jvm" we all know and love
03:18hiredmanthere are others too
03:18TheBusbyhence "one of those"
03:18hiredmanbut the dalvik vm is not one of those
03:18hiredmanit's not a matter of branding
03:19hiredmanthe architecture is completely different from any jvms
03:19TheBusbycorrect
03:19TheBusbyI was simply saying that I consider the term JVM to encompass all java virtual machines, not just the ones that meet the sun VM spec. I realize there can be significant differences
03:20hiredmanas I said, that is ridiculous
03:20hiredmanlike saying an arm cpu is a x86
03:20gregha VM that doesn't meet the Sun JVM spec is simply *not* a JVM
03:20TheBusbyso you call it a "java virtual machine", but you can't use the acronym?
03:21adityohey did you guys read this http://bit.ly/d040Aw, and who is codemonkey
03:21hiredmanno
03:21hiredmanit's not a java virtual machine
03:21TheBusbywhat would you call it then?
03:22hiredmana dalvik virtual machine
03:22TheBusbyI think that's fine too
03:23TheBusbythis is all semantics really
03:23TheBusbyand I realize my use of JVM is unclear
03:23hiredmanis an x86 a jvm? I mean you could translate java bytecode into machine code (this is exactly what the jit does)
03:23TheBusbyI understand your point, which is why I mentioned turing machines earlier
03:24hiredmanyes
03:24hiredmanyou obviously don't understand my point
03:24TheBusbyit's all semantics and depends on how detailed you want to be
03:24greghand how easily you need to communicate with other developers
03:24greghit's not "just semantics"
03:25TheBusbyyou're right in that it does depend entirely on your audience
03:25hiredmanto run Java The Language on a dalvik vm, you have to compile to java bytecode and run a translation tool that turns it into dex bytecode
03:26hiredmanto say that the dalvik vm is a jvm is equivalent to calling an arm cpu a x86
03:27TheBusbyI understand what you're saying, I wish you'd believe that
03:27hiredmanthis is totally isomorphic, I demand that if you are going to call dalvik a jvm that from now on you call arm cpus x86 cpus
03:30TheBusbyso to return the core topic, can you get great performance on embedded platforms?
03:30hiredmanI doubt it
03:30TheBusbyignoring android for the moment, I haven't seen any good examples in the cellphone market in the past 10 years. I haven't been looking too closely either though
03:31hiredmanthe delbik vm doesn't have a good gc regardless
03:31hiredmandalvik
03:31TheBusbyI know for a lot of embedded applications they require taking advantage of CPU specific calls to handle different things
03:31greghsome arm cpus can run jvm bytecodes directly, they're probably better placed to be faster than an interpreter
03:31hiredmanyou might be able to find some kind of openjdk build, but you might be stuck with something like jamvm, which also is not a huge performer
03:31TheBusbyI can't imagine that's well suited for something like a vm
03:32hiredmanjazelle?
03:32hiredmanTheBusby: depends
03:32hiredmanthere is jni "stuff"
03:32TheBusbyhiredman: it certainly depends because you see such a huge variation in platform characteristics across the market
03:32greghyeah, jazelle is what I'm thinking of
03:33TheBusbyfor example, two different platfroms using the same CPU can have wildly different performance relating to memory access
03:33hiredmanthe idea of a jvm in hardware is very interesting
03:34TheBusbydidn't sun try that 10-15 years back?
03:34hiredmanazul does it now
03:34hiredmanand jazelle is some kind of hybrid if I recall
03:36TheBusbyIn regards to universal compatibiltiy, I haven't seen anything comparable to pure old C with all the types/calls abstracted out to #defines
03:37TheBusbyI'm waiting for the day that isn't true... :)
04:30Licenser_greetings parenthethie friends
04:46timothypratleycan someone help me out (brain not working): http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/Query.FilterOperator.html
04:46timothypratleyHow do I reference EQUAL from there?
04:47timothypratleylike com.google.appengine.api.datastore.Query.FilterOperator.EQUAL but with $ and or / in there or something.
04:49esjhey Licenser_
04:51timothypratleyah nm I remember now.... com.google.appengine.api.datastore.Query$FilterOperator/EQUAL
04:52esjreally rolls off the fingertips
04:52timothypratley:)
05:09Licenser_hi esj :)
06:31powr-tocI'm using leiningen, and have just updated and lein installed swank-clojure... However changing the dev-dependency to 1.2.0-SNAPSHOT attempts (and fails) to download it; despite the fact that it's already installed locally... any ideas?
06:36robinkI'm not sure I'd want something handled with c-type #defines.
06:40powr-tocdoh... I'm mixing up swank-clojure and lein-swank!
07:00mattcClojure and Java newbie question: how can I call a Java constructor with variadic args from Clojure?
07:00mattcI've tried just passing args, passing them as a vector, a list, a seq constructed from a vector... all give errors e.g. ClassCastException
07:01esjapply ?
07:01esjthat's just a guess
07:01mattcapply: "java.lang.IllegalArgumentException: No matching ctor found for class ..."
07:02rhickey_mattc: Java doesn't have real variadics. just language sugar for array creation. To use from Clojure. you need to pass the array. you can make the array with into-array or to-array
07:02esjdunno, not done much java interop
07:02mattcok I'll give that a go, thanks!
07:02the-kennyIs there something like when-comp? Like comp, but with nil-checking
07:03the-kenny(I know this is a maybe-monad... but I think c.c.monad is too much for this)
07:03mattcyou seem to know a bit about clojure ;-) that worked perfectly, thanks Rich.
07:04the-kennymattc: No... rhickey_ is a total newbie in clojure.... ;)
07:04mattc"(LocalServiceTestHelper. (into-array [(LocalDatastoreServiceTestConfig.)]))"
07:04mattc:-)
09:24powr-tocDoes anyone know how to get leiningen to AOT compile your source? It keeps saying "No namespaces listed for compilation in project.clj"
09:25bsteuberlein compile does the job for me
09:25sparievpowr-toc: you should add :namespaces - a list of namespaces on which to perform AOT-compilation
09:26sparievsee README at http://github.com/technomancy/leiningen
09:26bsteuberspariev: is that specific to the new leiningen version?
09:26sparievyep, I believe it's specific for 1.1.0
09:27bsteuberic
09:27sparievs/for/to/
09:28sparievmust improve my English :)
09:32powr-tocspariev: I have that
09:32powr-tocspariev: and it still reports the error
09:34powr-tocOk, it means a literal list... it doesn't work for a vector... should that really be the case?
09:36sparievnot sure, http://github.com/technomancy/leiningen/blob/master/src/leiningen/compile.clj#L16 yere it just checks if it's collection
09:36sparievtry :namespaces :all
09:41jcromartieI almost took this Compojure app and said "screw it" and did it in Rails, but then I realized that my data validation rules were way more powerful than they'd ever be in Rails
09:43powr-tocspariev: cheers... it seems to work... but now I have some horrible exceptions... I wish clojure's stacktraces were a little easier to debug
09:44sparievnp, glad I could help
09:45powr-tocit's odd... my program seems to run ok... but compiling it causes it to barf
09:45powr-toc(during compilation I mean)
10:06tjghi there! i'm listed as a clojure contributor but my membership on the clojure-dev forum is pending, though i applied a couple times... is this expected, or am i supposed to do something else like email a moderator? (i don't mean to rush anyone, just curious.)
10:08chousertjg: how did you apply?
10:09rhickeytjg: you should be all set now
10:09tjgrhickey: Thanks!
10:10tjgchouser: I just pushed the googlegroups button to apply, wrote a little note and.. waited. ;)
10:10chouserrhickey: is that all you need in general?
10:10rhickeytjg: sorry, I had neglected the PO box for a bit, just added a bunch of contributors
10:11tjgchouser: oh yeah, and of course snailmailed in the CA to pleasantville. ;)
10:11rhickeychouser: yeah, CA, and the apply button asks people to state they've submitted a CA. I still get a lot of applications from people who haven't, dunno what they expect
10:12tjgrhickey: yeah, my last PO box was terminated because it overfilled since i neglected to check it. ;) good thing I wasn't using it for anything important...
10:12Licenser_clojure really really takes advantage of the high number of cores it's incredible
10:13rhickeytjg: it would be nice if they didn't put junk/bulk mail in PO boxes - what's the point? My post office has a stack of circulars taken out of PO boxes - such waste
10:14wthidden,(apply (first '(+ 10 10)) nil (rest '(+ 10 10)))
10:14clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: Symbol
10:14wthiddenso what am i missing?
10:15zmilawthidden - paren just after '
10:15zmilaopen paren
10:15rhickeywthidden: the symbol '+ is not the function +
10:15wthiddenfhrump.
10:16wthiddeni was hoping that was not the case. thanks
10:18zmilasorry, i'm wrong about paren
10:20wthidden,(apply (resolve (first '(+ 10 10))) (rest '(+ 10 10)))
10:20clojurebot20
10:20wthiddenzmila: np.
10:26powr-tocHow do people structure clojure.test unit tests with leiningen?
10:27powr-toc(or more generally clojure.test) ... Presumably the test namespaces and filenames mirror those defined in src/
10:28joshua-choiIt was always kind of weird
10:28joshua-choiOn the one hand, clojure.test tests seem to be intended to be integrated in vars' metadata
10:28joshua-choiBut a lot of people put tests in separate vars in src/test/ directories
10:29joshua-choiI think Leiningen goes for the latter...I think.
10:29joshua-choiOh, wait; "lein test [TESTS] # run the tests in the TESTS namespaces, or all tests", according to its readme.
10:30powr-tocyeah... looking at lein's test source code, they pull in the namespace to test with :use
10:31joshua-choiReally? That seems a little fragile, but maybe there's a reason
10:31powr-tocjoshua-choi: yeah... it does... also I can't get lein's tests to run at all
10:32powr-tocoh no... It just has...
10:32powr-toclooks like it failed though :-\
10:38sparievjoshua-choi: just wanted to say "thank you" for FnParse
10:38joshua-choiOh, no problem
10:38sparievjoshua-choi: it's awesome
10:38joshua-choiI'm still writing FnParse 3 though, and it looks quite different
10:38joshua-choiBut FnParse 2 is fine too
10:39joshua-choiJust warning you though :P
10:42sparievcan't believe FnParse could be made even better :)
10:44chouserrhickey: would it be better for deftype to catch when you define `valAt instead of 'valAt (for example), and not generate conflicting definitions?
10:44joshua-choispariev: If you have questions on it in the future, feel free to message me on GitHub or something
10:44rhickeychouser: I'm working on a non-magic solution to that stuff right now
10:45rhickeysomething like :mixin [(impl-X ...) (impl-Y ...)]
10:45chouserrhickey: ok
10:45chouserah! sounds nice
10:45sparievjoshua-choi: oh, thanks
10:45rhickeywhere impl-X and impl-Y generate forms for use in body, that get spliced in
10:46rhickeycan be passed names of fields
10:46rhickeyor anything else they need
10:46rhickeyjust trying to figure out how to make the basic cases small, also how to avoid lots of repetition of field list
10:47rhickeysince many mixins will need it, also the class name or some recipe for self-construction
10:49rhickeyall without replacing one set of magic with another :)
10:49chouserheh, right.
12:18wthiddencan an un-interned symbol have meta data?
12:19hiredmansymbols are not interned
12:20hiredman,(identical? 'a 'a)
12:20clojurebotfalse
12:22wthiddenso symbol 'silly can't have any meta data associated with it, correct?
12:22hiredmanwhy not?
12:23wthiddenthen how?
12:23hiredmanhow do you normally attach metadate to something?
12:24wthiddennot very well it seems at the momement.. would like to do it.. but need to go get lunch first.. be back in 30 min or so.
12:31drewr,(meta (with-meta 'foo {:really 'bar}))
12:31clojurebot{:really bar}
12:39duncanmis there a variant of str so that (str-varient 1 2 3) => "1 2 3" ?
12:39duncanmcuz (str 1 2 3) => "123"
12:40chouserpr-str
12:40duncanmthanks
12:40rseniorI'm having some difficulty using clojure.contrib.sql to do an insert into a column that does not have a standard integer or character value
12:40rseniorit's a special oracle data type called "SDO_RDF_TRIPLE_S"
12:41rseniorI've been able to do inserts using jdbc, but not clojure.contrib.sql
13:04MononcQcI'm thinking of picking up clojure, coming from Erlang (and some scheme) without any java experience. Is Stuart Halloway's book something I should seek out?
13:06dakroneMononcQc: I found his book very informative and useful
13:06dakroneand I still refer to it occasionally
13:07MononcQcI had heard that clojure changed quite a while since it got out and otherwise it seemed to be very focused for people using Java
13:08MononcQcin fact it's pretty much as if every tutorial out there assumes the programmer has Java experience
13:08stuartsierrathat's true
13:08stuartsierraClojure integrates tightly with Java.
13:09stuartsierraIt is not really intended to stand on its own.
13:09stuartsierraAt the very least, you'll need to be familiar with standard JDK libraries.
13:09dakronein my opinion, learning Java from Clojure inter-op is easier than learning Java from Java
13:09MononcQcegh, that's a bt annoying then. I wouldn't really feel like learning Java just to learn clojure
13:09nDuffeasier environment for experimentation
13:10nDuffMononcQc, Java-the-library is not nearly as annoying to learn as Java-the-language.
13:10dakroneyou're not really "learning" it so much as leveraging a really bit library base
13:10dakrone*big
13:10technomancyMononcQc: it's true to a degree; the example project in Programming Clojure doesn't make a lot of sense without prior experience on Java
13:10MononcQcyeah. I guess knowing the libs will be useful for whenever I do have to learn the language itself
13:10technomancybut I found the rest of the book to be helpful even with zero Java experience
13:10hiredmanit's not like java is hard to pick up
13:11chouserI had barely ever used java before I started learning clojure.
13:11dakroneit's possible to avoid Java almost entirely with Clojure, but you'd be missing out on a lot of well-done stdlib sort of functions
13:11MononcQcOh, I'm just relatively busy writing my own book about stuff, so I try to save time where I can ;)
13:11MononcQcdoesn't mean I won't try and go around that
13:11dakronewhat are you writing about?
13:11MononcQchttp://learnyousomeerlang.com
13:12dakronecool
13:13rickmodeI have a simple question related to this paste: http://paste.lisp.org/display/95972
13:13MononcQcI was mainly thinking of learning clojure to see the concepts and then probably work with incanter (I plan on buffing up on stats and whatnot) and Erlang's pretty bad at that.
13:13MononcQcBut I don't know, I'm kind of thinking R would be fine for the stats too
13:13defnClojure *can* be done without knowing any java, but in the end you'll need Java. The most important thing is to just be able to read javadocs.
13:13rickmodeSeems like I should using a closure around the sever returned by run-server rather than a global
13:13defnIf you can do that you'll be able to do most of what you need to do in Clojure.
13:13rickmodethoughs?
13:14nDufffor my purposes, R's library is more complete than what's available for Incanter presently
13:14MononcQcdefn, I'm usually alright with reading docs, so it'd not be too bad
13:14MononcQcI like docs.
13:15MononcQcalso the GUI programming seems to be pretty interesting with Clojure, rather than Erlang's WX drivers
13:17MononcQcI guess I'll get Stuart's book. Any other interesting guide?
13:19dakronethe video presentations by rhickey on blip.tv would be good
13:19rickmodeI agree - the videos on clojure.blip.tv were great - especially the first two
13:20technomancythere's also the peepcode video, which doesn't assume any Java experience
13:20technomancy(disclosure: I wrote it)
13:20nDuffthere are a few books in the MEAP program from Manning Publications, but they're unfinished as of yet, so not so good for anyone in a hurry.
13:20Raynestechnomancy: No vested interests here. ;)
13:20MononcQctechnomancy, that would be interesting to me
13:21dakronetechnomancy: peepcode charges for those, right?
13:21MononcQcwell I'm alright with people linking to their own stuff given I linked to my own in Erlang :B
13:21technomancyyes, it's $9 for an hour-long video
13:21dakronetechnomancy: I'm curious, do you get a pretty good % of the proceeds for that?
13:21technomancydakrone: yes, peepcode is very generous as a publisher.
13:21dakronethat's good to know
13:22technomancythe video from around the clojure 1.0 days, but the only thing that is obsolete is the segment on building your project.
13:22MononcQcuh, that sounds important
13:22technomancyyeah, but there's a good video on Full Disclojure that does a good job of explaining the up-to-date way to do it.
13:22technomancyand it's free
13:23MononcQcI see.
13:23rickmode$ lein new my-project
13:23technomancyhttp://vimeo.com/8934942
13:23dakroneoh yea, the full disclojure series is good: http://vimeo.com/channels/fulldisclojure
13:23technomancy+1
13:23Raynes+2
13:24MononcQcah that looks good
13:25powr-tocI know you guys are probably gonna beat me up for this... but is there a way to reload namespace from a file? i.e. I want to ship a product with some default configs in a namespace foo.config, but if the user includes a config.clj in that defines a namespace called foo.config, I want to allow the redefinition of the specified vars
13:25dakroneand free :)
13:25chouserreloading namespaces is nothing to be ashamed of
13:26pdkwe won't tell your parents
13:26powr-tocpdk: lol
13:26chouserI think 'load' is what you want, or perhaps 'load-file'
13:26powr-tocchouser: ok... how do I stop it bitching about the vars being already defined?
13:26powr-tocchouser: I'm using load-file right now
13:26chouserhm... something's not right.
13:27chouserwhat's the error?
13:28powr-tocchouser: "Name conflict, can't def *foobar* because namespace: foo.main refers to:#'foo.config/*foobar*
13:29rickmodeAny takers on my global question? http://vimeo.com/channels/fulldisclojure
13:29powr-tocessentially I want to provide the option of overriding a few configuration constants... And I want to refer to those constants in other namespaces
13:29rickmodesorry http://paste.lisp.org/display/95972
13:29chouserpowr-toc: oh, that's something else...
13:30rickmodeI'm wondering if there's a more idiomatic way to capture the result of an expression between two function calls
13:30chouserhm... hmm... try: (binding [*ns* (find-ns 'foo.config)] (load-file ...))
13:30MononcQcthanks for the help.
13:31chouserrickmode: yeah, don't use 'def' inside a function like that. Best would be to have whoever calls jstart store the value and pass it to jstop
13:32chouserbut if you're really sure you'll only ever have one *server* per JVM and don't want to make your user do that, you could have *server* be an atom or ref.
13:32chouserlunch. bbl.
13:32rickmodechouser: the use of *server* should be internal something only jstart and jstop care about
13:33rickmodeI'm trying to break out my OO thinking....
13:34powr-tocchouser: ahh it's ok... I think it works... During refactoring I'd forgot to remove some symbol definitions from my foo.main namespace
13:34powr-tocthey were clashing
13:34dakronerickmode: I annotated it with a suggestion, but I don't know about the correctness of it
13:34dakroneit's kind of a weird way to do it
13:37rickmodedakrone: I was wondering if there was something like (let [foo nl] (defn func1 [] (set! foo "a")) (defn func2 [] (printf foo)))... basically use a closure of some sort to capture something in func1 to be used later by func2. In my case (the compojure case) there is very likely only one *thing* at any one point.
13:37powr-tocchouser: is that kinda namespace/config overriding bad style?
13:38powr-tocchouser: It's pretty much the first thing that my code does...
13:39dakronerickmode: I was trying to avoid mutating any kind of state in my example
13:43rickmodedakrone: well I dont' really need mutable state. what i need is to use the output of one later in another... *and* hold this expression within a file. The alternative would be to force the caller of jstart to do something like (def *server* (jstart)) then later (jstop *server*).
13:44dakroneI'm afraid I don't understand, you need the server declared in jstart as well as what else?
13:47rickmodereally I just want to hold some state internal to one namespace
13:47rickmodeprivate global state ... such that use of jstart and jstop does not expose this internal state
13:48rickmodeand it seemed like the use of a global, while possible, might not be the best approach
13:48dakroneso, the example I annotated keeps the server between the jstart and jstop functions, but doesn't expose it as a global
13:49rickmodedakrone; looking (attempting to grok...)
13:55dakronerickmode: off to lunch, hopefully the annotation is self-explanatory
14:02jcromartieOK so one of the best selling games on Steam is Java...
14:02nteonhow can I check out the Java code gen-class is producing?
14:02jcromartiethat should be inspiring to anybody wanting to try games in Clojure
14:04hiredmannteon: it doesn't produce java code, it generates bytecode
14:04hoecknteon: use sth. like http://java.decompiler.free.fr/ on the generated .class files
14:13jcromartiewhere's somnium when you need him
14:15rickmodedakrone: i see where you solution is going, however evaluating your version of jstop causes the server to start since it defines itself as the evaluation of jstart
14:24nteonhiredman, hoeck: thanks, that of course makes sense. I suppose my problem is that I want to make the equivalent of a static method in clojure which I can call from java
14:28hiredmansure
14:29hiredmanyou just add :static true to the metadata of the method signature in the gen-class form
14:32hoecknteon: maybe this helps too: http://berlinbrowndev.blogspot.com/2009/03/java-clojure-interoperability-calling.html
14:50konrI've got a (defn play-mp3 [file]). How can I call it to play an mp3 file inside the jar, and how can I include such mp3 file?
14:51jcromartiekonr: just include it in the jar, and use resource loaders to find i
14:51jcromartieit
14:53konrjcromartie: hmm, but how can I include it using lein, for example?
14:53tomojlein will automatically include everything in resources/
14:54jcromartieresources
14:54jcromartie^what tomoj said
14:54jcromartiestandard java junkz
14:55jcromartieclasses and resources
14:55tomojthen you can use (.getResourceAsStream (clojure.lang.RT/baseLoader) "filename")
14:55jcromartiehm, maybe a (resource name) function could make it into clojure core at some point
14:56tomojat least contrib
14:56konrthanks, guys!
14:57tomoja function for serving up resources from a root based on a path and not allowing functions outside the root would be nice too
14:57tomojer
14:57tomojnot allowing resources outside the root to be returned, I mean
15:03joshua-choiThat's weird
15:03joshua-choiAccording to clojure.org/reader, symbols "can contain alphanumeric characters and *, +, !, -, _, and ?".
15:03joshua-choiBut what about -> and ->>?
15:05hiredman,(let [♥ 1] ♥)
15:05clojurebot1
15:05chouserand > < >= <= = == / ?
15:07hiredman,(let [x 1 x
15:07clojurebotEOF while reading
15:07hiredmaner
15:07hiredman,(let [x 1 x′ (inc x)] x′)
15:07clojurebot2
15:12joshua-choihiredman: Yeah, I know that currently all non-indicator Unicode characters are allowed in symbols
15:13joshua-choiBut it seems that Rich Hickey made an informal limitation on symbol characters in clojure.org/reader
15:13joshua-choiBut that rule doesn't allow -> and ->>, which is weird
15:14joshua-choiI needed to know if < and > are allowed in symbols or not; since -> and ->> exist, I guess they are, and there's no danger of < and > becoming indicator characters in the future
15:15hiredmanjoshua-choi: indicator?
15:16joshua-choiLike (, [, ^, #, etc.
15:16joshua-choiReader macro characters
15:16hiredmanreader macro I understand
15:16joshua-choiI suppose http://clojure.org/reader just needs to be updated
15:17joshua-choiTo allow < and > in symbols too
15:18joshua-choiI'm planning to use <foo> in my parser's rules
15:19joshua-choiBy the way, how do you do that IRC thing? "hiredman
15:19joshua-choilikes to use <foo> for structs".
15:19hiredman/me
15:20joshua-choiCool
16:38jcromartieonly the best languages can claim an IRC bot that speaks that channel's topic language :)
16:39jcromartieIn fact that's pretty much my main criteria for choosing a new language to leanr.
16:39jcromartie(joking)
16:49the-kennyjcromartie: Then you should choose clojure. It's the language of the future - When clojurebot became skynet
16:49the-kennyclojurebot: skynet
16:49clojurebotI will become skynet. Mark my words.
16:50jcromartieOH GOD NO
16:50jcromartieI'm kind of surprised there's no equivalent bot in #ruby
17:01radsis there a way to prevent the REPL from printing a line?
17:02Raynes(remove #(= \n) s) ;p
17:02radsI mean if I'm evaluating a form and I don't want it to be printed out in the REPL
17:03bsteuber,(do 42 nil)
17:03clojurebotnil
17:03radsbsteuber: that works, thanks
17:20derefeddoes clojure have something similar to python properties?
17:21hiredmanwhat are those?
17:23derefedsomething like accessor methods
17:23derefedlike
17:23derefedI want to be able to retrieve a piece of data from a clojure struct
17:23jcromartieyou can use keywords
17:23hiredmanstructs are just maps
17:24jcromartie,(:foo {:foo "bar"})
17:24clojurebot"bar"
17:24the-kenny,(get {:foo "bar"} :foo)
17:24clojurebot"bar"
17:24the-kenny,({:foo "bar"} :foo)
17:24clojurebot"bar"
17:24derefedbut later on, if I decide that the implementation of getting a particular value from the struct should change, I don't want to have to change all the calling code
17:24the-kennyThree ways to access the data :)
17:24jcromartie,(-> {:foo {:bar "bat"}} :foo :bar)
17:24clojurebot"bat"
17:24derefedyeah I know
17:24derefedI wasn't finished ;)
17:24hiredmanderefed: then write a function
17:24derefedright but
17:24hiredmanbut what?
17:24derefednot finished
17:25derefedgimme a minute lol
17:25derefedI don't want it to devolve into making an accessor function for everything like in java
17:25hiredmanjava has methods not functions
17:26derefedyou're splitting hairs
17:26hiredmanI am not trying to be pedantic there, it is a reminder that clojure is not java
17:26derefedI mean in clojure, writing accessor functions
17:27derefedwhat I want is the power of accessors without the ceremony of typing each and every one out like in java
17:27derefeddoes clojure have something like that?
17:27dakroneisn't that what doing (:foo {:foo "bar"}) is?
17:27derefedno
17:28derefedwith a bare accessor, yes
17:28hiredmandakrone: he wants an additional layer of indirection in case he desides to change the name of the :foo key
17:28derefedbut later on I may decide to add logic to the retrieval
17:28hiredmanlisppaste8: url?
17:28hiredmannuts
17:28dakroneI'm not familiar enough with python, how does python do it without writing a method?
17:28derefednot because I want to change the name, but the logic in the retrieval
17:29derefedwell
17:29hiredmanderefed: logic should be in functions
17:29derefedyou still have to write a method
17:29dakroneso what's wrong with (defn get-foo [m] (:foo m)) then?
17:29derefedbut callers don't have to change their code to call that method if they were just grabbing the value originally
17:29derefedhiredman: right I'm not arguing with that
17:30derefedfor instance
17:30hiredmanderefed: then go forth and write functions
17:30jcromartieI can't seem to serve up a PNG image from compojure
17:30derefedin python, say you had a class Foo
17:30hiredmanjcromartie: are you using the correct mime-type
17:30jcromartieI set the Content-Type header but the browser interprets it as a document
17:30derefedand an object of Foo, f
17:30derefedand it had a member variable bar
17:30jcromartieit looks like a charset is getting tacked on
17:30hiredmanderefed: no classes, no objects
17:30hiredmana struct is a map
17:30derefedhiredman: I'm talking about python
17:30jcromartie:headers {"Content-Type" "image/png"}
17:31derefedhiredman: I'm explaining it to dakrone
17:31derefedin python you could say f.bar = 100
17:31derefedand it would just set bar
17:31derefedbut later on, you could add a property, or accessor method
17:31derefedlet's say the new setter just adds 10 to the incoming argument before setting bar
17:32derefedso I write the method to perform the + 10
17:32derefedbut instead of having to change the caller to this: f.setBar(100)
17:32derefedI can leave it like this: f.bar = 100
17:32jcromartie(defn assoc-bar [x bar] (assoc x :bar (+ 10 x)))
17:33konrIs it particularly bad to slurp a 10-100MB file? Should I use open it as a Stream?
17:33jcromartiebecause you don't really set, unless it's a ref/var/atom
17:34derefedright but what I'm getting at here is that I can go from directly accessing the value to providing a layer of logic WITHOUT having to change what the caller does
17:34jcromartiehiredman: I'm getting this header in the actual response: Content-Type:image/png; charset=UTF-8
17:34radsderefed: you just use a function
17:34dakroneso it sounds like syntactic sugar for doing something like (defn get-foo ...), correct?
17:35derefedno
17:35hiredmanjcromartie: what makes you think the charset bit is the problem?
17:35jcromartiehiredman: because I get the right data back, but the browser/curl interprets it as utf
17:35derefedjoshua-choi: yeah I think that's what it'd have to be... overridable keyword functions
17:35dakronehow is it not? behind the scenes it's doing the same thing calling a function before setting the value
17:36radsderefed: (defn get-foo [m] (:foo m)) / if you want to change the logic, you just change the function
17:37radsyou could write a macro to define it for you but you don't end up needing it too much
17:37joshua-choiThe problem is, that's not the default
17:37rhickeykeyword accessors explicitly say - the data is the interface. If you want something else to be the interface, write functions or use a protocol in the first place. If you always want the flexibility to change things, always use functions
17:37derefeddakrone: it's not that it makes the programmer avoid typing out the (defn), it's that it makes the caller avoid changing how he retrieves values
17:37hiredmanif you want a function, write one, maps(structs) are datastructures(containers) meant to be operated on by functions
17:37derefeddakrone: it is syntactic sugar, but not for defn I guess is what I mean
17:38dakroneokay, so in that case, you're going to end up having to create a function for it
17:38derefedrhickey: so there's no sort of shortcut like python does with properties?
17:38dakroneI don't think that (having the suger) fits into the kind of paradigm Clojure promotes for that datatype
17:39derefedprobably not
17:39derefedI'm still trying to figure out how to do the things I do in clojureworld ;)
17:39bsteuberdefered: I think you're trying to do what everyone else here does - try to map the clojure world to the concepts you know
17:40derefedtrue
17:40bsteuberbut actually there is not always a mapping, and in fact you don't need it, because clojure solves the deeper problem differently
17:40derefedI guess I just don't know any other way
17:40jcromartieso is there a way to NOT set the charset in Compojure?
17:40jcromartiebecause I think it's kinda messing me up here
17:40hiredmanderefed: a few people have told you to write functions
17:41hiredmanover and over
17:41derefedright but in my eyes that isn't solving the problem
17:41derefedI'm interested in seeing how clojure does it differently
17:41rhickeyfor public interfaces, using keywords might not be a good idea. Just because they are there doesn't make them the right thing in all cases. In practice, properties/getters are rarely redefined, but if you do that often you might want a protocol for the outer interface
17:41derefedbut until a few minutes ago I felt like you guys didn't understand what I meant so I kept going
17:42bsteubermaybe you should give us some more details about the problem you actually want to solve using accessors
17:42bsteuberI mean, you can give some code snippets or stuff
17:42derefedthere is no concrete problem
17:42derefedI'm trying to figure it out before I go in coding
17:43hiredmanbsteuber: it doesn't reall matter, the answer is write functions
17:43rhickeyone thing about morphing keywords into getter fns is whether or not the entire map interface morphs as well, e.g. contains?, dissoc etc
17:43derefedI just know that I use interfaces a lot and find it convenient to be able to change the logic in the interface
17:43hiredmanyou want to reach into a datastructure and pull out data, write functions
17:43bsteuberhiredman: yeah, I think you're right
17:44bsteuberbut I think for most cases, directly using a keyword is
17:44bsteuberfine
17:44dnolenderefed: also I wrote this, http://github.com/swannodette/accessors
17:45rads_derefed: (defn foo [m] (:foo m)) is equivalent to an accessor with no logic. if you do this a lot, a macro for defining them would be pretty trivial
17:45dnolenderefed: however nobody seems interested in this functionality
17:45dnolenit's automatically generates setters and getters.
17:45dnolenyou can free provide your implementation for a particular property to override the default
17:45bsteuberI'd probably just start with trivial functions and refactor if I happen to change implementation somehow
17:46derefeddnolen: yeah, that's basically what I was looking for
17:46bsteuberI mean, just use the data structures clojure gives you and don't think of replacing them unless needed
17:47derefedbsteuber: right, but I'm just afraid about what will happen when I do need to replace them
17:47bsteuberbut will you?
17:47rads_in practice you don't have to replace them too often
17:47derefedand all the code previously written depends on the old stuff
17:47bsteuberalso, there's refactoring
17:48derefedI don't know I've run into it before... I guess it doesn't happen often but it happens
17:48bsteuberyeah, but are you really calling this from a hundret places?
17:48derefedno but still
17:49derefedeven if you have to change ten places
17:49derefeddoesn't that go against The Right Way?
17:49derefedseems like it goes against everything I've learned about lispy programming
17:50rads_if you expect the interface to change you should use a function, not the keyword, like rich said
17:50derefedI agree
17:50derefedI was just wondering if there was a shortcut like properties
17:50derefeddnolen's library looks like the answer
17:50derefedI guess now I'm wondering what you guys do
17:50hiredmanI write functions
17:51dnolenand my accessors library writes those functions for you, it's really a matter of style
17:51bsteuberand I don't care unless I'm sure I'll want change it
17:51hiredmanupon functions, ye until seven orders of functions
17:51dakroneit seems like one of those trying design before you have a problem things
17:51bsteuberand have unit tests that save my ass in that case :)
17:52hiredmandnolen:
17:52rads_if you don't need the flexibility of dnolen's library, writing a macro to generate getter functions is pretty trivial
17:52hiredmansure
17:52derefedhiredman: so do you have to write out get-foo, get-bar, etc. etc. for all the data structure interfaces?
17:52derefedrads_: I suppose I could do that too
17:53hiredmanderefed: depends, I think mostly I use keywords
17:54derefedhave you ever run into a situation where you had to change from keyword access to function access?
17:54jcromartiehiredman: looks like it was a deficiency in my understanding of curl, after all :P
17:55hiredmanderefed: there have been times when I have written functions instead of using keywords
17:56hiredmanI think the key point here is clojure datastructures don't have behaviour outside of their datastructuryness
17:56derefedgood point
17:56hiredmanyour data just flows in and out of them, manipulated by functions
17:57hiredmandon't expect the datastructures to do stuff
17:57derefedwell I think you guys have given me some good stuff to think about... thanks for all your help
17:58rads_I do usually write a setter function for changing mutable data
17:58rads_but since you don't have too much mutable data in clojure you don't need those setter functions often
17:59rads_and if for example you wanted to add 10 every time you accessed a field, you would just add 10 when you create the data structure
18:01dakronederefed: good luck with your clojure projects, hope you stick with it :)
18:02derefedthank you -- oops he left
18:06bsteuberbtw. is there any way to attach hooks to refs?
18:06bsteuberso that thay do something I specify when they change
18:06bsteuberI mean obviously I can def my own dosync-with-hook-xy
18:06bsteuberbut I wondered if there's something builtin
18:08hiredman,(doc add-watch)
18:08clojurebot"([reference key fn]); Experimental. Adds a watch function to an agent/atom/var/ref reference. The watch fn must be a fn of 4 args: a key, the reference, its old-state, its new-state. Whenever the reference's state might have been changed, any registered watches will have their functions called. The watch fn will be called synchronously, on the agent's thread if an agent, before any pending sends if agent or ref. Note that
18:10bsteuberthx
18:21hiredmanlast I checked it didn't need building
18:21hiredmanyou can just jar up the source
18:21hiredmanyou can also just grap the jar from clojars and forget about it
18:22robinkHeh, OK
18:22robinkI'd like to try to build the jar.
18:22robinkIt's good practice (I run Gentoo)
18:23hiredmanthat's too bad :)
18:23hiredmananyway, I think the guy who wrote it uses netbean's build stuff
18:23hiredmanso the best bet is for you to go compile netbeans :)
18:23robinkHeh, hm
18:24robinkI could try
18:25hiredmanrobink: I'm telling you, jar -cvf fnparse.jar -C src/ . is all you need
18:25hiredmanthis could all be over, and you could quit shaving yaks right now
18:26robinkmust...shave...yaks!
18:39hiredmanrobink: what benefit do you think you are going to get compiling vs. just jaring up the source? or even just grabing a jar from clojars?
18:45robinkhiredman: Compiling a jar would make it faster than just bundling the source. Grabbing a jar from clojars would work just as well but then I'd be stuck the next time I needed to build a Clojure app with ant.
18:46hiredmanrobink: the speed difference is almost nothing
18:46hiredmanand only at load time
18:46robinkhiredman: It may end up running on embedded hardware.
18:46robinkhiredman: Load time is still a small factor.
18:46hiredmanfnparse's ant setup is very different
18:46robinkOh, OK
18:46robinkhm
18:47hiredmanit is basically a bunch of ant xml generated by netbeans as far as I know
18:47hiredmanI don't know of any other clojure project that uses that
18:48robinkhiredman: Ah, OK
18:48hiredmanalmost everything is using lein these days except for some larger older projects
18:48rickmodelein is mean
18:49robinkI don't like Maven
18:49hiredmanjoshua-choi: you can namespace stuff you upload to clojars so it is possible to publish a jar there even if you aren't the maintainer
18:49robinkI've been trying to wrestle with it to only use distro-installed dependencies.
18:49joshua-choiJust wondering, what version of FnParse did you build?
18:49robinkgit trunk
18:50hiredmanjoshua-choi: it claims to be 2.2.4
18:50joshua-choiOkay
18:50hiredmanI try not to think about it :)
18:51hiredmanhttp://clojars.org/org.clojars.hiredman/fnparse
18:51joshua-choiI see; that's nice
18:51joshua-choiI'm worried though that I'll cause some confusion when I wrap up FnParse 3
18:52joshua-choiOh well
18:52hiredmanwell the version number is right there
18:52joshua-choiOh, right, it is :P
18:52hiredmanand you could push a cannonical fnparse to clojars
18:52joshua-choiHow does that work? Canonical libraries on Clojars
18:53hiredmanthey aren't namespaced
18:53hiredmanhttp://clojars.org/lein-gae
18:54robinkThere we go
18:54joshua-choiOh, I see
18:54robinkCompiled
18:55robinkInstalled
18:56hiredmanactually, fnparse is leiniszed these days, so "lein jar" will build and jar it
18:56robinkAh, OK
18:59nteonheh, leiniszed
19:01robinkI met the guy who wrote leiningen
19:01hiredmanI was there :P
19:02robinkhiredman: Oh! Hi!
19:03hiredmanI was the one in green
19:03hiredmanon the otherside of the guy with the n900
19:04robinkhiredman: Right. Well immediately opposite the guy with the N900 was Phil, right?
19:04robinkWere you to Phil's right?
19:04technomancyrobink: hi. =)
19:04robink!
19:04technomancy<= phil
19:04robinkHi :-)
19:04robinkWow, this is cool
19:04hiredmanno no
19:04robinktechnomancy: Yeah, I know.
19:04robinkhiredman: OK, I think I remember you now.
19:05hiredmannot on the otherside of the table
19:05robinkOh, gotcha
19:05robinkYeah, OK
19:05technomancyascii-art diagram?
19:05hiredmanrobink | n900 | hiredman
19:05robinkhehe
19:05robinkI get it
19:06robinkand then opposite going the same direction (N, not R) was Brian, technomancy, guy-whose-name-i-can't-remember
19:06robinkand then the guy who showed up later.
19:07hiredmanthe shaver
19:07robinkNo, he was to Brian's...wait, oops
19:08robinkOK, towards the back of the coffee shop is N, right?
19:09robinkOops, that's S
19:09hiredmanoh, right, the other guy who came later
19:09robinkYeah.
19:10robinkAwesome, lein errored on me.
19:10robinkMaven just sucks in a dependency if it thinks you don't have it.
19:11robinklein is doing exactly what I want it to do. Not sure why the clojure POM file is missing.
19:12robinkOh, huh, it's a Maven thing
19:12robinkStill, leiningen is behaving more like what I want.
19:13robinkWhich is to never (ever) pull in a dep
19:13technomancydeps only get pulled in if you explicitly ask for them or if the lib/ dir is empty IIRC
19:14technomancyso you don't have to always remind it to stay offline like you do with mvn
19:14robinkOh, good
19:14robinkNot sure where I get a Clojure POM file.
19:14technomancylein pom
19:14robinkHah
19:14technomancywhat do you need it for?
19:14robinkAwesome
19:15robinkWhen I do 'lein jar' on fnparse, it says it needs the Clojure POM file.
19:15robinkClojure was installed by MacPorts, not Maven.
19:15robinkSame POM error
19:17robinkCould be an issue with the way fnparse's project.clj is written.
19:18robinkAh, fixed
19:18robinkAck!
19:18robinkIt's trying to install Clojure!
19:18hiredmansure
19:18hiredmanif it depends on it, it will grab it
19:18technomancyclojure dependencies aren't system-wide like rubygems or apt-get
19:19robinkI thought it would check the root fs and classpath for something ...oh
19:19robinkThat's...bothersome
19:19robinkIt's going to make writing an ebuild tricky.
19:20technomancyyeah, debian builds of JVM tools are notorious for that reason.
19:20robinkOf course I can just use ant with fnparse, but Compojure is all Maven-based, and Maven definitely wants to pull something in if it thinks it's missing.
19:22robinkThe Java-hosted languages are new to Portage, generally, so there's not a whole lot of infrastructure to support them.
19:23robinkI imagine eventually it might be possible to have a 'baselayout' or -common ebuild for these guys so that you could hint Maven to where things truly were.
19:23robinkMaybe folded into the main ebuilds themselves, I'm not sure.
19:23hiredmanuh, unless it changed very recently compojure is not maven based
19:24robinkhiredman: No, it's not, but Maven doesn't think it exists.
19:24robinkhiredman: There has to be a way to tell Maven "Compojure is here!"
19:24robinkhiredman: Without installing another concurrent copy.
19:25hiredmanrobink: that has nothing to do with maven
19:25robinkhiredman: Well, no, but it has to do with the build process that ultimately involves Maven.
19:25hiredmanI think you are conflating lein and maven because lein uses some of mavens machinery
19:26robinkhiredman: No, I see that Lein is better.
19:26hiredmanbut they are not the same thing
19:26technomancysome of the leiningen output makes it looks like it's coming from maven. that should be cleaned up.
19:27robinktechnomancy: OK
19:28hugodtechnomancy: I have a prev/next problem implementation for clojure test mode, and a working run test at point
19:29technomancyhugod: nice! I will pull tonight.
19:29hugodok, I'll fork and push to a branch
19:30technomancyif you would rather just mail a patch that's fine too
19:30hugodok, can do
19:47nteoncan anyone suggest a more lispy form for this function? http://fpaste.org/9Y7i/
19:50nteonah! ->
19:50hiredman,(assoc {} :a 1 :b 2)
19:50clojurebot{:b 2, :a 1}
19:50_atonteon: assoc can take many arguments
19:51nteon_ato, yes but in my silly example i need to refer to the value of :time-step in d to generate e.
19:56_atoI'd probably just do: http://gist.github.com/323376
19:59_atooh wait, are you trying to set the save-step to the previous time-step?
19:59_ato(in which case your code has a bug)
19:59nteon_ato: no, not the the previous
20:01nteon_ato: I think I like what you outlined in that gist, thanks
20:52defn_ato!
20:52defnYou're back!
20:53defnI have a question-- I'm pulling tweets from the "firehose" and I'm wondering if it's possible to conditionally return items during the execution of a function
20:54defnin english: im consuming some massive sequence, is it possible to return items which match a condition, and still continue consuming the sequence? how do you do that?
20:55technomancyif you return a lazy sequence, the caller of your function can read the first few elements of the seq while later elements are still being processed
20:55technomancyis that what you mean?
20:56defnmaybe... im trying to understand what you're saying there
20:57defnokay, yeah that sounds kind of like what im thinking
20:57defnI was just sort of imagining a console where this sequence is being consumed, and whenver it finds something that matches X, it returns that match, and continues to consume
20:57defnwhat you're saying makes sense
20:58technomancyif "consuming" has side-effects then you probably don't want to mix it with laziness though
20:58defnyes i was just considering that :)
20:58technomancywhat about sending matching elements to an agent instead of returning them?
20:58defnthat's a great idea
20:58defnthanks technomancy
20:58technomancynp
21:03nathanmarzanyone know if "fine-grained locals clearing" is available in 1.1? (http://groups.google.com/group/clojure/msg/9b4e268b85c20cd6)
21:05technomancynathanmarz: pretty sure it's not.
21:07nathanmarzis the plan to get that into 1.2?
21:07technomancyit's in the 1.2 snapshot, yeah
21:07nathanmarzcool
21:07nathanmarzgratzi
21:22konrIs there a function that prints a number like 1234567.89 as 1,234,567.89?
21:23hiredman,(doc pprint)
21:23clojurebot"([object] [object writer]); Pretty print object to the optional output writer. If the writer is not provided, print the object to the currently bound value of *out*."
21:25konrhmm, cl-format does the trick too... should have checked before: (cl-format nil "~:d" 1234567.89)
21:53tomojsuppose you inherit a bunch of clojure code that's written with variable names in some foreign language
21:54defnsuppose the internet has translators available
21:55tomojcan you automatically correctly rename them? not doing automatic machine translation, but just prompting you for a translation once per unique name needing to be translated?
21:55defni highly doubt it
21:55defnconsider rand vs random
21:55tomojhow is that a problem
21:55defnrand-var vs random-variable
21:55tomojI still don't understand how that is a problem :(
21:56defnrand isnt a word in either language?
21:56tomojyeah, so what
21:56defnso how do you automatically rename that
21:56tomojif "splurgenfrach" means "random" and they just write "splurg", that's ok
21:56hiredmanI don't think you understood what he said
21:56tomojI don't think so either
21:56hiredmanhe wants a refactoring tool
21:57tomojI mean, now I can't really think of any big problems
21:57tomojbut I feel like there would be tricky issues
21:57defn80/20
21:58hiredmanit woudl be tempting to read in the code as a datastructure and manipulate symbols
21:58hiredmanbut you would lose formating when printing it back out
21:58defnim going to be the naysayer and say that it's completely impossible to write a good tool for that
21:58tomojhmm
21:58tomojI think losing formatting might be OK
21:58defnthe edge cases will continue to erupt
21:58hiredmandefn: I think you could write a tool that did a decent job
21:59tomojas long as you can walk the data structure and the raw code in parallel
21:59defnmaybe...
21:59tomojneed a new reader to do that?
21:59hiredman:D
21:59hiredmanI happen to have a read written in clojure
21:59hiredmanreader
21:59defni just have a hard time imagining a tool which could accurately refactor within a single lnaguage (english) let alone 10 of them
21:59defnit would be a mess
22:00tomojthe only thing you'd need to match with the raw code is the positions of the symbols
22:00tomojso you could stick that in the metadata maybe?
22:00DuneManFairly basic question (starting out with clojure today). I have a lein project.clj defined that includes clojure-1.1.0-master-SNAPSHOT and clojure-contrib-1.1.0-master-SNAPSHOT.
22:00DuneManwhen I do lein "deps" the correct libraries are copied from my maven dir (~/.m2) into my project's lib.
22:00hiredmandefn: you are getting to hung up on the "different language" thing
22:00DuneManHowever, when I bring up a repl and do (System/getProperty "java.class.path") both the clojure and clojure contrib jars show up in my classpath. However, doing a (require clojure.contrib.str-utils2) fails (or any other namespace that's supposed to be in clojure contrib).
22:01tomojdefn: it's really just variable renaming
22:01hiredmanyou want to rename all instances of symbol X in scope Y to W
22:01tomojbut doing it over and over again once per unique symbol
22:01tomojacross a list of source files
22:01DuneMan(bringing up a repl using lein repl, to make sure the class path is correct)
22:01tomojwithout changing the program
22:01hiredmanI no stuartsierra really wants a namespace renaming tool
22:01DuneManthis also fails in VimClojure+Nailgun
22:01tomojDuneMan: lein repl uses the clojure that leiningen has
22:02tomoj~/.swank-clojure I think
22:02clojurebotThat is the one thing Clojure can not do.
22:02hiredmanDuneMan: what version of contrib?
22:02DuneMan1.1.0-master-SNAPSHOT
22:02hiredmanin master a lot of stuff got renamed
22:02DuneMansame as the version of clojure
22:02DuneManI've also tried it with 1.1.0, and 1.2.0
22:02tomojdo you even need to maniplate symbols?
22:02DuneMan(1.2.0 seems to make Vimclojure + nailgun not work at all)
22:02tomojor can you just have something which scans the raw code looking for symbols
22:02DuneMan(\sr just stops doing anything)
22:03DuneManoh, I'm also on MacOS.
22:03tomojhmm, no, if you change a name, you must change it in every other file that references the symbol
22:03tomoj"The repl task will use the version of Clojure and Contrib that Leiningen uses, not the one specified by your project."
22:04tomojI dunno if that's your problem, but
22:04DuneManhm... that is interesting.
22:04DuneManWhere was that in the docs?
22:04tomojon http://github.com/technomancy/leiningen
22:04defnDuneMan: change your includes to clojure "1.1.0"
22:04tomoj"known issues"
22:04DuneMan(one would think that the nailgun task would use the correct version)
22:04defnand clojure-contrib "1.1.0"
22:04tomojone would indeed
22:05tomojlein-swank does
22:05DuneMandefn: That's what I had it as before, and had the same problem. I'll try again.
22:05defnthose are a better bet than what you're using
22:05tomojI think there are pretty difficult problems in that area of lein
22:05defnAFAIK no one has been using those snapshots for awhile
22:05tomojsubclassloaders oslt
22:06tomojyet lein new still generates a project.clj with them, correct?
22:06defndepends on what version of lein
22:06tomojoh, I see, no
22:06tomoj"1.1.0"
22:06tomojnice
22:07DuneManyes, it generates them with 1.1.0
22:07DuneManand yeah, same problem. Start nailgun, open vim, and get a huge slew of errors about not being able to find seq-utils
22:07tomojDuneMan: how does it fail? pastie the error
22:07tomojand, which jar for contrib do you see in the classpath?
22:08tomoj(the one in your project's lib/?)
22:08DuneManlib/clojure-contrib-1.1.0.jar from my project's lib
22:08DuneMan#<CompilerException java.lang.Exception: No such namespace: seq-utils (parsers.clj:9)>
22:08DuneManwhen doing \ef
22:09DuneManEven though seq-utils is in the 1.1.x branch docs on github...
22:09tomojhow many contrib jars do you see in your lib dir
22:09DuneManjust that one. I blasted lib/
22:09tomojwell shit
22:10DuneManit just makes no sense.
22:10tomojoh
22:10tomojhehe
22:10tomojpaste the exact code that's failing
22:10DuneManI've been complaining about clojure all day because of this ;-) (stupid jvm)
22:10tomoj(require clojure.contrib.str-utils) ?
22:10defndoes nailgun f--- with the classpath at all?
22:10DuneMan(ns beansprout.parsers
22:10DuneMan (:import java.util.Date
22:10DuneMan java.text.DateFormat)
22:10DuneMan (:require [clojure.contrib.str-utils2 :as string]
22:10DuneMan [clojure.contrib.seq-utils]))
22:11slyphonDuneMan: uh, pastebin?
22:11DuneMandefn: If it did one would think that doing (System/getProperty ...) within the nailgun repl would be getting the right classpath from the urrent jvm instance
22:11tomojwell, the contrib jar is on the classpath when he checks from the repl, yes?
22:11tomojyeah, exactly
22:11tomojDuneMan: it blows up on seq-utils?
22:11DuneManslyphon: woop, sorry.
22:12DuneMantomoj: yes. But if I'm in the repl and do a simple (require clojure.contrib.seq-utils) it also fails, also with (require clojure.contrib.str-utils2)
22:12tomojthose would naturally fail
22:12DuneManwhy naturally?
22:13tomojin (require clojure.contrib.seq-utils), the "clojure.contrib.seq-utils" is evaluated as a var
22:13DuneManaha
22:13tomojnot sure I'm using the right words there
22:13tomojbut, you need to quote when using require et al manually rather than through the ns macro
22:13tomojso (require 'clojure.contrib.seq-utils)
22:15tomojhowever
22:16tomojputting that code in src/beansprout/parsers.clj, it works fine for me
22:16tomojand I can see the functions that were pulled in
22:16DuneManhuh.
22:17tomojcan you pastebin/gist/whatever 1) the error you get when you try to load the code with the ns macro 2) the error you get when you (require 'clojure.contrib.seq-utils) ?
22:17DuneManmaybe my jvm install is screwed somehow
22:17tomojare they the same?
22:17DuneManWhen I do the latter I don't get an error, it returns nil (which I think means success?)
22:18DuneManbut then it says it can't resolve the symbol, e.g. flatten
22:19DuneManah...
22:19tomojbrandonw: hey
22:19tomojmaybe you can help DuneMan :)
22:19DuneManI have to fully qualify that.
22:19tomojDuneMan: yes
22:19tomojand (require '[clojure.contrib.str-utils2 :as string])
22:19hiredmanrequire doesn't make alias in the current namespace
22:20DuneManyeah, already did that with :as string...
22:20tomojthen you should be able to (string/whatever)
22:20tomojuse use if you want to just pull in all the functions
22:20tomoj(but I don't like doing this)
22:20tomojexcept like (use '[foo.bar :only (baz bim bang)])
22:20tomojwhich will pull in baz, bim, and bang from foo.bar
22:21DuneManAha, so it was all because I wasn't FULLY qualifying that.
22:21tomojlein-nailgun and/or vimclojure must be screwing up
22:21tomojbut, you still get the error trying to load that file, right?
22:21DuneMan... no.
22:22DuneMan*looks back at his old errors*
22:22tomojoh, the error was only that you were referring to the functions incorrectly after loading the file?
22:22DuneManNo, the error I was getting was about not being able to find the seq-utils class file
22:23DuneManBut now... it appears to work magically?
22:23tomojhah
22:23tomojwell, grats
22:23DuneManThanks :-)
22:23tomojyou might feel the need to meditate deeply on the docs for ns, use, require, etc
22:24tomojthey confused me when I was new to clojure
22:24DuneManI've read them a few times now but I'm still very confused by them.
22:25DuneManThe language that is used to talk about these things are unfamiliar to me.
22:25dnolenDuneMan do you know Python?
22:25DuneManyes.
22:25dnolenuse -> import *
22:26dnolenrequire -> import foo.bar
22:27DuneManAh, okay. And :import ~> from foo import bar (but only for java classes)
22:27rickmodeduneman i've hit a similar thing with these... the language is correct but unfamiliar. A laymans writeup would definitely help. Something giving the "why" along with canonical / idiomatic usage to go along with the theory
22:28DuneManMight be good to write up a blog post about it or somesuch, after wrestling with it for a day
22:28DuneMantook me forever to get lein working
22:28tomojI plan to do that but with a focus on emacs
22:29rickmodeI would like to see a unification of the java things with the clojure things so there isn't as much of a difference
22:29rickmodethings like import and the extra dot notation are a bit odd and smell like a hack. I could be wrong though.
22:30tomojI kind of like the extra dot
22:30tomojbecause it shows clearly when you are using a function and when you are using some java method
22:30rickmodeas far as the differences between ns, in-ns, use, requrire and refer, I am getting a feel for them after a few days
22:31DuneManI think a lot of this is just normal stumbling through a new set of tools
22:31tomojjava methods will rarely (but maybe increasingly more often with 1.2.0 features?) behave in ways that make me want to think of them as functions
22:31DuneManbut it's particularly frustrating because its new language foo + the awful mess that working with the jvm always is.
22:32tomojyeah :/
22:32tomojI think the jvm is overall a good thing though once you stumble through it
22:32tomojfor clojure, I mean
22:32DuneManOh, it's a wonderful product, hotspot rocks, etc. Using it is... a pain, though.
22:32tomojyeah
22:33DuneMananyway, I think you helped me stumble into something that works...
22:33tomojI think without an easy-to-interop-with host, clojure would suffer
22:33rickmodePart of the attraction of a lisp dialect and clojure specifically is the lack of unneeded syntax. Something like this: (.getCanonicalPath (File. "public" "main.css")) just feels odd in a lisp. How can I anticipate where the dots go?
22:34tomojby understanding the interop syntax, I guess :(
22:34rickmodebut it's a small thing... I am *totally* digging this language
22:34tomojI think it's worth it, though, because I don't want jvm interop to look like clojure code
22:34tomojit should look different because it will likely not behave in clojure-ish ways
22:34rickmodetomaj: ah.. you are totally right... if it's different , emphasis the difference
22:34tomojyour clojure wrapper can still look clojure-ish
22:35tomojbut when you are doing things that could be Evil, I think a different syntax is good
22:35tomojbut the ability to do Evil is a great boon to clojure :)
22:36rickmodewell so long as it doesn't reintroduce mutable collections... ;)
22:37tomojthat's the thing
22:37tomojall of the available options with good library support are Evil, I think
22:38tomojso unless you want to write everything from scratch, you're going to have to do interop with stuff that uses mutable collections or whatever
22:38tomojand as long as you're doing that, better to have a slighly different syntax for that stuff
22:39hiredman,(macroexpand '(.foo bar))
22:39clojurebot(. bar foo)
22:39hiredman,(macroexpand '(foo. bar))
22:39clojurebot(new foo bar)
22:44DuneManbtw, vimclojure = ghetto
22:45DuneManvim is not meant to host a repl... and it works like it
22:45DuneManheh
22:47rickmodethanks, hiredman... i honestly hadn't quote got the classname. syntax
22:48rickmodeer... quite got...
22:51tomojDuneMan: slime... :P
22:51DuneManYeah... I don't know emacs... will probably need to learn it if I ever actually want to code in this.
22:51tomojI think a lot of people use vim with success
22:52tomoj(but personally I love slime/clojure-mode/lein-swank)
22:52rshis there a good way to include free variables in macroexpansions w/o getting "can't use qualified name as a parameter" exception?
22:53rshan intentional free variable, so a gensym will not work
22:53tomojcan you show what you're trying to do?
22:53DuneMantomoj: Using the repl is painful... you have a vim buffer so doing movement expressions moves you within the buffer instead of doing readliney stuff
22:54tomojah, slime takes care of the readliney stuff very nicely in my opinion
22:54DuneManyeah, emacs is good for this... it was designed for this
22:54rshtomoj: is there a better way to show you a code snippit than pasting it directly in here?
22:55tomojrsh: yes, any pasting service will do
22:55tomojgist, pastebin, whatever
22:55tomojI think the bot can help but I don't know how to ask it
22:55tomojclojurebot: paste?
22:55clojurebotlisppaste8, url
22:56tomojrsh: anyway, I think I might understand your problem
22:56tomojconsider this macro
22:56rshtomoj: http://pastebin.com/5M7Cz1Q5
22:56tomoj(defmacro with-foo [& body] `(let [~'foo 3] ~@body))
22:56tomoj(with-foo foo) macroexpands to (clojure.core/let [foo 3] foo)
22:57rshyeah that is the same concept
22:57tomojyou need to syntax-quote the body of the macro
22:57tomojcontinuation framework?
22:57rshyep!
22:57rshthanks for your help
22:57rickmodeI used http://paste.lisp.org/new/clojure earlier .. but you need to mention the URL here
22:57tomojsounds interesting
22:58tomojtell us if you share it
22:58dnolenthere's also clj-cont, http://github.com/swannodette/clj-cont, my port of the CL continuation library :)
22:58dnolennever had a reason to use it yet tho :P
22:59rshI saw that actually. Will probably take a look at it later after I play around with it some on my own to learn a little
23:00dnolenrsh: feedback appreciated. continuations are fun.
23:00hiredmanlisppaste8 needs to be voiced
23:02rshcan someone explain to me or point me to some further reading why clojure has this issue with macroexpanding free variables into ns qualified names but common lisp macros do not have problems doing this?
23:02DuneManokay, so... when I do (string/partition "a b c" #"\s")) I get: "java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number"
23:03DuneMan.... anyone have a clue why that would occur? partition takes 2 arguments, a string and a pattern.
23:03DuneManaccording to all the web pages and (doc ...) [which, I'll note has a broken example]
23:04dnolenrsh: Clojure rules simply prevent you from shooting yourself in the foot. You can however accomplish what you want.
23:05rshI see
23:07tomojrsh: is ~' really so bad?
23:08tomojI quite like it, it makes unhygienic macros a bit harder to write
23:08tomojand the auto-gensyming makes up for it by making hygenienic macros easier to write
23:08rshwhat would be the consequences of actually having a namespace qualified function parameter (if it were allowed)?
23:08tomojs/hygen/hyg/
23:09dnolenrsh: it wouldn't make any sense.
23:09tomojI don't even know what that means :(
23:10dnolena namespaced qualifier would usually refer to some definition in a namespace, using that as a fn parameter name doesn't make sense.
23:10tomojDuneMan: hmm
23:10tomojthe example in the docs works for me
23:10dnolenwhat you want for =defn is (defn ~f [~'*cont* ~@parms] ~@body)
23:10tomoj(clojure.contrib.str-utils2/partition "abc123def" #"[a-z]+") returns exactly what the docs say
23:10DuneManheh. The stars are not aligning says my coworker bob.
23:10dnolenrsh: I actually did PG cont stuff in Clojure as well.
23:11tomojDuneMan: just wait a bit longer!
23:11tomojthe stars will align after a while, I predict
23:11rshdnolen: how did it work out?
23:12DuneManhaha. if I cut-n-paste the line that you just pasted, I get a classnotfound exception
23:12DuneManwonderful
23:12tomojDuneMan: yes
23:12tomojpaste the whole file?
23:12tomojat least the ns declaration and the call to partition
23:12dnolenrsh: small tweaks here and there. had to use ~'. And you need to use an atom since you need *saved* to mutate.
23:12tomojby paste I mean on some pastie webapp, of course
23:13DuneManah, I know what was wrong. I did :as string when I import str-utils2
23:13tomojthat's fine
23:13DuneManand that... somehow messed up something in the namespace. if I require it as str-utils2
23:14tomojyou should then be able to string/partition
23:14DuneManthen the partition works right
23:14tomojI get an IllegalArgument exception when I try to call clojure.core/partition with those arguments
23:15DuneManyeah, as would be expected.
23:15DuneMansince core/partition is different.
23:15tomojthe problem might be that str-utils2 also uses this name, and that you were accidentally calling clojure.core/partition?
23:15tomojor not?
23:15DuneManI was actually calling string/partition
23:15DuneManexplicitly.
23:15tomojand you're sure string was clojure.contrib.str-utils2 then?
23:15tomojthat should work fine
23:16tomojI just did it myself with the ns macro you pasted earlier
23:16DuneManYeah, it should work fine. But it didn't. And after I killed my repl and did the require again and used the fully qualified name it works
23:16DuneManand now my original source works.
23:16DuneMan*shrugs*
23:16tomojI blame vimclojure and/or lein-nailgun
23:16DuneManThat was actually just happening in a normal command line repl
23:16tomojthese kinds of problems don't happen to me
23:16DuneMan:-)
23:16tomojwell, shit
23:17DuneManthat I've been cutting and pasting into
23:17tomojit may just be easier to stay sane about the repl's state when using slime?
23:17DuneManyeah, who knows. thanks again
23:17tomojnot to imply that you screwed up, but maybe it's a possibility? I can't think of any way that could happen
23:19DuneManNo, I'm certain I'm screwing up somehow, I just can't figure out *how*
23:19DuneManThe toolset, when not using slime, at least, is... confusing.
23:21DuneManIs there a better way to test this stuff in the repl than using load-file and then requiring the namespace?
23:21DuneManI just did (eval (read-line (slurp "filename"))) so that it doesn't pop me out of the namespace
23:22DuneMansuppose you could load-file and then (ns ...) to put myslf in that namespace?
23:28tomojDuneMan: yes
23:28tomojload-file, then use in-ns
23:28tomoj(doc in-ns)
23:28clojurebot"([name]); Sets *ns* to the namespace named by the symbol, creating it if needed."
23:29tomojthen the repl will be in that namespace
23:32tomojDuneMan: slime looks like this http://tomojack.com/stuff/sshots/slime.png
23:32tomojyou can see that the repl prompt changes when I switch to working on namespace/examples.clj
23:33DuneManyeah, suppose I could learn emacs :-)
23:33tomojyou can C-c C-k when editing a clj file to compile and load that file into the repl
23:33DuneManGo play with a symbolics machine...
23:33tomojthen there is a slime command which changes the repl's current namespace
23:34tomojI have C-c n look at the current source file's path, figure out the clojure namespace from that, and then switch to it in the repl
23:34tomojalso C-c C-n looks at the source file's path and inserts a skeleton ns declaration with the appropriate namespace
23:34tomoj(for lein-style projects only)
23:34tomojbut that is ok because everything I work on is a lein project
23:35tomojplus, it works with 1.2.0
23:35tomojand if you learn emacs lisp (heh) the sky's the limit
23:35DuneManYeah, we'll see if use clojure long enough to make it worthwhile.