#clojure logs

2010-05-18

00:12jColeChangedHow would I create a function which would return 1 the first time it was called, 2 the second time, 3 the third ect
00:14ravajcolchanged: just have the function increment a counter var
00:20turbofailjcolchanged: what you may really want is an infinite stream that counts upwards
00:21turbofailbut if it's not then do what rava said
00:22jColeChangedI'm actually confused as to how to persist assignment between function calls.
00:23TheBusby(def current-count (ref 0)) then, (defn inc-count [] (dosync (ref-set current-count (inc @current-count))))
00:24jColeChangedThanks.
00:26ravaor use alter
00:58mmarczykon 1.2, (deftype Counter [^{:volatile-mutable true} cnt] clojure.lang.IFn (invoke [this] (set! cnt (inc cnt)))) is also a possibility
01:29kanakHi, in Programming Clojure's chapter on refs, the following snippet is called "bad idea":
01:29kanak
01:29kanak ; bad idea
01:29kanak(defn naive-add-message [msg]
01:29kanak(dosync (ref-set messages (cons msg @messages))))
01:29kanakis it a bad idea because accessing and updating are not a single step?
01:36ravaEssentially, yes. or at least that's how I understand it. If there's no need to deref the var first, like in the example where you don't care about the contents..you're just appending, it doesn't make sense to have to deref and re-set the ref.
01:36ChousukeI suppose it's a bad idea because you could just use alter or commute (if order doesn't matter)
01:47joshua-choiclojure.contrib.seq/separate is ostensibly useful, but I find that in all cases that I want to use it, I should use (map #(if ...) s) instead. Also, it crawls twice.
01:54G0SUBChousuke, ping
01:56LauJensenMorning all
01:56mmarczykhi Lau
01:56mmarczyknice work on the site -- and the blog post :-)
01:56G0SUBLauJensen
01:56LauJensenThanks a lot mmarczyk !
01:56mmarczyk(and btw, thanks for the corrected classpath-building script :-))
01:57LauJensennp - it went into my 'deploy' script which converts the old site, builds the new and rsyncs it to the server
01:57mmarczykcool :-)
01:57G0SUBLauJensen, something is wrong with your feed URLs. they are going to the CSS file.
01:58LauJensenG0SUB: Im on that right now actually
01:58LauJensenThe way I inject CSS matches <link rel="atom" as well - gimme a couple of minz :)
01:58rdsrjoshua-choi: how is (split with #(...) s) different from separate?
01:58G0SUBLauJensen, sure. I was surprised because your posts are not appearing on Planet Clojure.
01:59LauJensenI appologize for the inconvinience
01:59joshua-choirdsr: You mean, in traversing the sequence twice? I'm not quite sure. :|
01:59G0SUBLauJensen, no problem man :) take your time.
02:00rdsrjoshua-choi: in terms of functionality, maybe I can't think of any good examples
02:00rdsra little thick headed today I guess :(
02:00ravagreetings all
02:02ravaLauJensen: really dig the blog
02:02LauJensenrava: the blog as in content or the design?
02:02ravaLauJensen: both :)
02:02LauJensenrava: great, cool, thanks :)
02:03ravaLauJensen: http://www.bestinclass.dk/index.clj/blog.html that link goes to 404
02:03rdsroh sorry, just realized my mistake
02:03LauJensenrava: true, there's no file there
02:04ravaLauJensen: its all sorts of helpful to have some well written code + commentary to read through as i'm teaching myself clj. the hardest part for me learning clj is wrapping my head around the idioms of functional programming.
02:04G0SUBhmm... Apress vs. Manning vs. Packt
02:04G0SUBargh!
02:05LauJensenrava: yes that is a painful but worthwhile experience :)
02:07alexykmmarczyk: so every?-based version is much slower than a loop one: http://paste.pocoo.org/show/215132/
02:07alexyksometimes FP is pretty but slow, even though it allows for pmap!
02:08LauJensenCould somebody do me a favor and try to and leave a comment on my site please
02:08G0SUBLauJensen, yeah
02:08LauJensenthanks
02:09G0SUBLauJensen, done.
02:09LauJensenthanks
02:12LauJensenG0SUB: Got it thanks
02:17mmarczykalexyk: could you please use some line breaks in there... but anyway, as far as I can see (without the line breaks!), the loop-based version doesn't include pmap, while the every?-based version does
02:19mmarczykum, whoops, next time...
02:19turbofail,(doc ->>)
02:19clojurebot"([x form] [x form & more]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."
02:23LauJensenG0SUB: moderated
02:24LauJensenmmarczyk: if thats a performance enhanced loop, I'd expect to see some hinted ints and transients? :)
02:28turbofailhm... that difference in performance is a little surprising
02:35mmarczykLauJensen: not my loop, I only provided a few ideas :-)
02:35LauJensenaha - so you're the mastermind :)
02:36mmarczykwell, hardly -- I haven't managed to effect a nested ifs -> cond switch ;-)
02:37Chousukehow many dreps are there?
02:39turbofaildunno... the guy left
02:39mmarczykno idea, you'll need to ask alexyk next time
02:39Chousukethe pmap overhead might be killing it if the day seqs are short but there are many dreps :/
02:40Chousukealso laziness does add its own overhead even if it didn't use pmap, but it shouldn't be that bad.
02:46Chousuke(every? true (map >= s (cons (first s) s)))) wonder if this could be replaced with (apply <= s)
02:46turbofailprobably can
02:47mmarczykhah, right :-)
02:47G0SUBChousuke, can I PM you? something OT to discuss.
02:48Chousukesure.
02:48G0SUBthanks
02:50ravaLauJensen: I can't seem to find your blog's feed url on your site
02:51johnmn3hello
02:51G0SUBchouser, ping
02:51ravagreetings johnmn3
02:52johnmn3I'm toying around with a rudimentary clojure code editor. I'm thinking about putting some kind of inspector on the left side
02:53johnmn3what do you guys think the most useful inspector would look like?
02:53johnmn3I'm thinking something akin to Rich Hickey's inspect-tree
02:54johnmn3but where you can drill down into an object... perhaps do a macro expand? or maybe collapsed nodes showed a short string from it's docstring
02:55johnmn3I'm not really sure though.
02:58johnmn3I really like eclipse's class inspector.. where you can drill down, then you find an object in there you'd like to explore and open it in another window
02:58johnmn3and look at all the fields and methods.
03:01johnmn3anybody have any preferrences?
03:01johnmn3or any preferences?
03:18G0SUBwhat is the difference between dev-dependencies and dependencies in lein?
03:18G0SUBwhy does swank-clojure have clojure 1.2.x as a dev-dependency? does it affect projects using clojure 1.1.0 ?
03:20ravaLauJensen: on your web scraper blog entry, what ns contains that get-page function?
03:20lancepantz_G0SUB: dev-dependencies are not transitive
03:21lancepantz_G0SUB: in other words, if a project you depend on has a dev-dep, when you do deps it will not get pulled down
03:26G0SUBlancepantz_, OK. so swank-clojure 1.2.1 should work fine with clojure 1.1.0, right?
03:27lancepantz_i'm not sure
03:27lancepantz_i think so though
03:37G0SUBok
03:38kris928Is anyone here familiar with vimclojure?
03:40ravai used it for a spell, what's up?
03:42kris928rava: I'm not sure how to get a new repl from within vim. Non of the default keybindings appear to work for me although I don't know if I am getting my Localleader correct.
03:42LauJensenrava: sec
03:44ravakris928: i could never get the nailgun repl thing to work in vimclojure, and your local leader is usually defaulted to ','
03:44ravai ended up using slime.vim before just going back to emacs+slime
03:44LauJensenrava: That post has been a headache to me, because the html and regexes escaped Wordpress and mangled the post
03:44kris928rava: I think that is what mine is too, but it never does anything when I type "sr" s always triggers edit mode.
03:45LauJensenrava: but the text says "if search results contains the raw html output", so get-page would nowadays be called clojure.contrib.io.slurp*
03:45ravakris928: yup, what i ran into aswell. never found a satisfactory answer to fixing it.
03:45kris928rava: thanks
03:45ravakris928: if you're set on using vim, check out slime.vim
03:46ravavery simple extension that just copies the marked region and outputs it to a screen session running the repl
03:46kris928rava: nice, I'll try that
03:47ravaat the same time you'll keep vimclojure's documentation reflection
03:48ravakris928: i found it most useful to run vim, open a terminal and start screen, create the project with lein, hop into the proj dir and run lein repl
03:48ravakris928: <3 lein repl for handling all the classpath crud
03:48ravaLauJensen: cool beans, thanks
03:48kris928yeah I like lein, but I need clojure 1.2.0 right now and lein doesn't like that
03:49ravakris928: why do you need 1.2?
03:49kris928rava: I guess I just want it. Hit a few functions that are in 1.2.0 and not earlier
03:50ravakris928: ah. i'm still learning a ton and haven't done anything worth while so haven't looked at 1.2 beyond protocols
03:52kris928rava: thanks for help. night!
03:52ravakris928: np, rest easy
05:44liwpis swank-clojure supposed to load ~/.clojure/user.clj?
05:46liwpI can see in swank-clojure.el that all the jars in ~/.clojure are added to the classpath, but I can't see .clojure being added or user.clj being explicitly loaded into the repl
05:51hiredmanliwp: user.clj is loaded from the classpath by clojure
05:51liwphiredman: yeah, I know that, and that works fine for me
05:52liwphiredman: I just see all these posts on the web implying that user.clj gets loaded automatically for them by slime/swank-clojure/lein-swank
05:52hiredmanliwp: oh, right
05:52liwpe.g. here http://stackoverflow.com/questions/2854618/using-clojure-contrib-functions-in-slime-repl
05:52sexpbot"Using clojure.contrib functions in slime REPL - Stack Overflow"
05:53hiredmanpeople making stuff up on the internet
05:53liwpand I can't make it work...
05:53liwphiredman: yeah that's right :)
05:53hiredmanmake what work?
05:54liwphiredman: ~/.clojure/user.clj doesn't get loaded when I run slime
05:54hiredmanis ~/.clojure on the classpath?
05:56liwphiredman: probably not. The point is that it seems that other people have ~/.clojure on their classpath automatically when using slime, but I don't. So I'm trying to figure out why not.
05:56liwpso I'm wondering whether it's something that should work automatically or whether I need to configure something differently
05:56liwphiredman: you don't use slime, do you?
05:57hiredmanI do
05:57hiredmanI've never used user.clj
05:57liwpfair enough
05:58ravathe most use so far i've found from a user.clj file is to autoload clojure.contrib.repl-utils
05:58liwpI just realised that there's all these contrib goodies that are useful in the repl and I'm not using them since I can't be bothered to (use) them every time I run the repl
05:58liwprava: yeah, that's what I'm looking for ;)
05:58hiredman*shrug*
05:59ravaliwp: just add "~/.clojure" to your swank-clojure-extra-classpaths
06:00ravaliwp: one thing i've found useful is to add "." "./src" "./classes" "./jars" to that aswell
06:00liwprava: ok. I'm just wondering whether all this should work out of the box or not
06:01ravaliwp: If it is then I've been doing it wrong :) . Even in clojurebox (emacs+slime bundle for windows) i had to manually add ~/.clojure to my classpath
06:02liwprava: ok, thanks
06:03ravaall and all, its still the jvm, so classpath munging doesn't go away
06:03ravaand by default clojure/-main isn't going to add ~/.clojure to your class path
06:06liwprava: no, but I was hoping that either swank-clojure (it adds ~/.clojure/*.jar to your classpath automatically) or lein-swank would do it for me
06:06ravai've tried it with lein-repl/swank and swank-clojure. I've not had any of them do it. I could be missing something though :)
06:45bsteuberhow can I check if something implements a certain interface? not isa?, I suppose
06:45cemerickinstance?
06:45bsteuberthx
06:48bsteuber,(instance? clojure.lang.ISeq (into-array [1 2 3]))
06:48clojurebotfalse
06:48bsteuberwhat's wring here?
06:48cemerickarrays aren't seqs
06:48bsteuberwrong
06:48bsteuberso what are they, then, to have first work on them?
06:48cemerick,(instance? clojure.lang.ISeq (seq (into-array [1 2 3])))
06:48clojurebottrue
06:48cemerickbut you can just do...
06:49cemerick,(seq? (seq (into-array [1 2 3])))
06:49clojurebottrue
06:49cemerickif you only care about ISeq
06:49bsteuberso how can I ask if seq works on something, then?
06:49bsteuberor is there no such general method?
06:49cemerick,(doc seqable?)
06:49clojurebot"clojure.contrib.core/seqable?;[[x]]; Returns true if (seq x) will succeed, false otherwise."
06:49bsteuber(ah, nice
06:53patrkristhis should be a simple question: which function do I use to append an element to the end of a sequence? I could use concat and wrap the element in a vector, but there's gotta be another way?
06:54bsteuber,(doc cons)
06:54clojurebot"([x seq]); Returns a new seq where x is the first element and seq is the rest."
06:54bsteuber,(doc conj)
06:54clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
06:55patrkrisyes, but how to *always* add to the end of a seq? if conj is used on a seq besides a vector, the element gets inserted as the first element
06:56cemerickpatrkris: ensure you're using vectors if you must add to the end of the collection
06:56bsteuberah, sorry
06:57cemerickotherwise, *always* adding to the end of a sequence is likely to be inefficient
06:58patrkriscemerick: yes - but in this case, it doesn't matter much because the collection wont contain many elements. I was just looking for a shortcut for adding an element to any seq. In which case I could 'vectorize' my seq or use concat by wrapping the element in a collection.
06:59cemerickpatrkris: the latter is more idiomatic and efficient
06:59patrkris(I meant *appending* to a seq - i.e. at the end.)
06:59patrkriscemerick: ok, thanks
06:59cemerickAsking to be able to append to any sequence is sort of like asking for a sorted collection without the cost associated with sorting.
07:00Chousukeclojure doesn't provide functions for silly operations :)
07:00patrkriswell, if you have the ability to use concat to concatenate two seqs, wouldn't it be easy (and efficient) to create a function to append an element on top of concat?
07:01Chousukeso appending to a sequence has to be done in a roundabout way
07:01Chousukeit would be easy, but it's silly, so it won't be provided for you
07:01patrkrisheh alright :)
07:01cemerickhi Chousuke, how goes it?
07:02ChousukeI think the point of Clojure is to be the right tool for you, not a too :P
07:02Chousuketool*
07:04Chousukecemerick: (Silly English, what's the "it"? :P) Just fine I think. I'm going to get some food right now. :)
07:05lpetitHello, what problem exactly does the recent commit "hotfix for classloading, force new loader in all cases" solve ?
07:06lpetitI'm asking because we have a bug in ccw involving class files being "still held" by something and maybe (maybe) it was related.
07:06lpetitrhickey: hello, ^^^
07:07rhickeylpetit: If you have a reproducible test case for your bug, please try it with the latest
07:08rhickeylpetit: the fix solves a problem with :reload-all and its ilk, but in general it uses finer granularity classloaders
07:08lpetitrhickey: that's what I intend to do (hopefully) tonight.
07:08lpetitrhickey: oh, so maybe not related. I'll check.
07:08rhickeylpetit: great! let me know how it works out
07:09cemericklpetit: is there a mailing list or google group, etc. for CCW?
07:10lpetitcemerick: yes, listed in the homepage of ccw
07:10lpetit~ccw
07:10clojurebotccw is http://github.com/laurentpetit/ccw
07:10lpetitsh***t
07:10lpetit~counterclockwise
07:10clojurebotCounterclockwise aka ccw at http://code.google.com/p/counterclockwise/
07:10lpetitso ccw for github, counterclockwise for google code, isn't that logic, heh ? :-)
07:11cemerickah, I didn't put 2 & 2 together re: "Groups:"
07:11lpetitcemerick: in practice, I use both mls for annoucing new versions. But both are low traffic.
07:12lpetitcemerick: why ?
07:13cemericklpetit: no particular reason -- just want to keep on top of things. I think CCW has a good deal of potential. What's coming in e4 may be a great set of raw materials a clojure env could do a lot with.
07:14lpetitcemerick: it's possible you're more informed than me concerning e4. What particular feature(s) are you thinking about ?
07:15cemericklpetit: I'm not particularly well-informed either :-) IIUC, the entire UI will be accessible through a DOM-like model, making it far easier to modify/generate UI elements at runtime. Components can be styled with CSS. Take those, mix in a clojure frontend for it, and it seems a lot of things become possible.
07:18lpetitcemerick:I was aware of the UI being created via EMF models. What I didn't catch is the "dynamic part" of it. Seems interesting, indeed.
07:19lpetitI want clojure on my client side GWT application !
07:19cemerickheh
07:20cemericklpetit: I think we'll all be flogging chouser to resurrect clojurescript soon enough. :-)
07:21lpetitcemerick: I didn't check #clojure as "well" as usual. What are the current informal plans for say the next 2-3 months ?
07:22cemericklpetit: you mean release-wise?
07:23lpetitcemerick: I know about 1.2, just wondering what were the current research, if the focus remains on working on things related to make cinc become a reality (aka in the following of protocols) or more "exploratory" stuff (aka cells) ?
07:26cemericklpetit: I think only rhickey knows that for sure. My impression is that cells has been shelved for a bit. There's a number of open issues w.r.t. types and protocols that I'd think would be fairly high on the list, which would likely get us closer to cinc (definable factory fns for types, maybe multiprotocols, etc). I remember seeing rhickey talking about/tinkering with readers impl'd in clojure a few weeks ago. *shrug*
07:28lpetitany news on the "problem" spotted by cgrand concerning extending protocols on existing types and concurrency ?
07:28cemericklpetit: you'll have to remind me about that -- link?
07:29lpetitrhickey: ^^^ (protocols & concurrency) ?
07:30lpetitcemerick: http://groups.google.com/group/clojure-dev/browse_thread/thread/59d2f3a1703cc09
07:32cemericklpetit: yeah, I've no info on that.
07:52AWizzArdrhickey: the DynamicClassLoader that Clojure uses... do you think you can make it one day inherit the rights of its parent ClassLoader?
07:53AWizzArdThis would be very nice for Applets and Web Start applications. Currently it is a complex thing to get Web Start running all Clojure code.
07:54AWizzArdI managed to do so, and am thinking about writing a How-To for that. But the thing is: if the Clojure ClassLoader could inherit the rights of its parent, then the How-To could be greatly simplified.
07:58rhickeyAWizzArd: what do you mean by inherit the rights?
07:58AWizzArdTrying to check what rights the parent has and then setting the own rights to those.
07:59AWizzArdCurrently the default situation is that the Web Start class loader has its own rights, which can mean "all-permissions", while the Clojure ClassLoader still runs in the sandbox with only very few rights.
07:59AWizzArdI managed to give Clojure also full rights, so I can run anything now via Web Start (or in an applet) easily, but getting there was a long quest.
08:01AWizzArdIf Clojure would "copy" the rights of its parent, then everybody could get started with Web Start (or applets) within 1-2 hours, without Clojure-specific tutorials. With tutorial it is a thing of 10-30 minutes.
08:03AWizzArdIt is a quite intruiging idea to write web applications in 100% Clojure, and this is really possible :)
08:13rhickeylpetit: http://groups.google.com/group/clojure-dev/msg/4522fe2e4fa21f63
08:18lpetitrhickey: thank s!
08:18zakwilson_http://github.com/zakwilson/zutil-clj/blob/master/map.clj <-- request for optimization - can this be made faster?
08:19rhickeyAWizzArd: how about suggesting a patch?
08:30AWizzArdrhickey: oki thanks, I will add an issue then
08:30rhickeyAWizzArd: I don't want an issue without a patch, please
08:30cemerickrhickey: A couple of times last week I bumped into some odd behaviour at the REPL, where an instance of a defrecord Foo would no longer be (instance? Foo obj) after reloading the file that contained the defrecord delcaration. In those cases, (= Foo (class obj)) was no longer true. Is this expected?
08:31cemerick(I can imagine the old class was being GC'd, but I'd hope the instance? check would still work as I'd intuitively expect.)
08:31AWizzArdrhickey: I could give you patch, but currently I have no CA. Do you accept them also via fax? :)
08:32rhickeycemerick: the classes may be new ones with the same name. If you are keeping an older Foo class instance around, it need not be the same
08:32rhickeycemerick: I try to reuse the class if the definition hasn't changed, but that is an optimization, not a promise
08:35cemerickhrm, OK. That almost makes me want to put together a quickie defrecord-once. Very rarely am I reloading a file to change a record's slots, and I'd very much like to not have instance? checks fail in odd ways.
08:35rhickeycemerick: can you construct a reproducible test case?
08:36cemerickrhickey: I'll see what I can do.
08:37rhickeycemerick: the existing logic *should* handle the simple reload case, as obviously there is no change
08:41cemerickrhickey: The defrecord spec and the object were actually defined in two different namespaces (reloaded in that order). I wonder if Namespace.referenceClass was simply continuing to get the old Class?
08:43rhickeycemerick: but the caching should make new-class identical-to old-class
09:24yonatan_hello
09:25yonatan_i think i just ran into a bug in clojure's RegexReader
09:25yonatan_it seems to choke on #"\Q"\E"
09:25yonatan_#"\Q\"\E" works, but matches \" rather than "
09:26yonatan_(re-pattern "\\Q\"\\E") works as expected (matches ")
09:26yonatan_is this a bug or am i missing something?
09:27hiredmanwhat string are you trying to match?
09:27yonatan_"
09:28yonatan_a double quote char. (re-find (re-pattern "\\Q\"\\E") "\"") works.
09:30yonatan_RegexReader interprets a double-quote inside a \Q...\E sequence as the end of the regexp.
09:30yonatan_is this the expected behaviour?
09:30chouserI think so. That's not really what \Q...\E means
09:30chouser#"\"" should work
09:31hiredmanwell, \ "quotes"
09:31hiredmanand so does \Q \E, yes?
09:31chouser\Q is about making chunks of strings act as strings instead of regex metachars
09:32yonatan_i thought \Q...\E is supposed to treat everything in between as a literal
09:32chouserso if you want . to mean a period instead of "any char", you can wrap it in \Q...\E
09:33chouserbut if you want a literal " you need to use \"
09:34yonatan_but you can't do that inside a \Q...\E sequens?
09:34chouser, #"\Q\"\E"
09:34clojurebot#"\Q\"\E"
09:34yonatan_nope
09:34yonatan_it matches \" not "
09:35chouserah
09:35chouserhm
09:35yonatan_i ran into it trying to port your patch to las3r
09:35yonatan_(the clojure in flash thingie)
09:36yonatan_i don't know if it's a clojure issue or a jdk issue
09:37yonatan_but since (re-find (re-pattern "\\Q\"\\E") "\"") works i'm thinking maybe it's a bug
09:37yonatan_wanted to make sure before i try to fix it
09:40chouserwell, I guess it's a soft spot in the definition. How do we want it to behave?
09:41chouserwhy do you want #"\Q\"\E" to match " instead of \" ?
09:50yonatan_dunno, it seems like the right thing to do. i mean, \Q'\E matches ', \Q\\E matches \, \Q.\E matches . why should " be any different?
09:51yonatan_that's how it works in actionscript, and http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html says that's how it should work in java (although i didn't check if it really does).
09:51sexpbot"Pattern (Java 2 Platform SE v1.4.2)"
09:58yonatan_although Regular Expressions Cookbok says "If you omit the \E, all characters after the \Q until the end of the regex are treated as literals."
10:03yonatan_which implies that the regexp can end without an \E. so no need to fix anything i guess :)
10:07patrkrisrhickey: what exactly from the Ennals paper convinced you that Clojure's STM should not be obstruction-free? I can't connect the ends.
10:27_na_ka_na_hi
10:27_na_ka_na_when im doing (defrecord A [i j]) .. it gives a reflection warning ..Reflection warning, NO_SOURCE_PATH:4 - call to contains can't be resolved.
10:28_na_ka_na_using the latest snapshot for 1.2
10:28_na_ka_na_clojure-1.2.0-master-20100518.110252-71.jar
10:29_na_ka_na_is this as expected? or am i doing something wrong?
10:32_na_ka_na_helloooo anyone?
10:35AWizzArd,(read-string "{:a 1, :b}")
10:35clojurebot3
10:35AWizzArd:)
10:35AWizzArdThe Exception is a bit misleading.
10:37_na_ka_na_, (defrecord A [i j])
10:37clojurebotDENIED
10:37_na_ka_na_,(defrecord A [i j])
10:37clojurebotDENIED
10:39Borkdude,(letfn [foo #("umbrella")] (foo)
10:39clojurebotEOF while reading
10:39_na_ka_na_,*clojure-version*
10:39clojurebot{:interim true, :major 1, :minor 2, :incremental 0, :qualifier "master"}
10:39Borkdude,(letfn [foo #("umbrella")] (foo))
10:39clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
10:39Borkdudeo yeh, never mind
10:48hoeck_na_ka_na_: I guess thats a bug, the values method in the defrecord expansion probably needs a typehint
10:50hoeck_na_ka_na_: but the defrecord will work regardless of the reflection warning, it just uses reflection to compute .containsValues
10:50_na_ka_na_hmm .. even this gives the same warning (defrecord A [^int i ^int j]) .. never mind
10:50LicenserHmm anyone around who used ring and sessions before?
10:51hoeck_na_ka_na_: its not related to hinting the records fields
10:51_na_ka_na_hoeck: got it .. thx
10:51cemerickrhickey: that defrecord/type class change issue is reproducible, but only sporadically, and does appear to be related to the namespace import mechanism. Gotta run for a bit, but I'll bear down on it later.
10:52AWizzArdHow can I catch read-time exceptions?
10:52AWizzArd,(try (read-string "{[]}") (catch Exception e (println "Hi")))
10:52clojurebotAWizzArd: Pardon?
10:52AWizzArdOn my system this throws an Exception and does not enter the catch block.
10:53gfodorare there any known issues with anonymous closures leaking? I have been load testing a service written in clojure and after taking a heap dump after a night of testing, there are thousands of what look to be anonymous function closures stuck in RAM
10:53chouserAWizzArd: your exception is coming during printing, not during reading.
10:53chouserit is read without error, which is a bit startling to be sure.
10:54AWizzArd,{[]}
10:54clojurebotjava.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1
10:54chouser,(class {[]})
10:54clojurebot1
10:54AWizzArdchouser: to what does this eval for you? (try {[]} (catch Exception e (println "Hi")))
10:54chouser,(class (read-string "{[]}"))
10:54clojurebotclojure.lang.PersistentArrayMap
10:54Licensermight it be a lazyness problem?
10:55hoecklaziness
10:55ChousukeI thought that was a know issue?
10:55chouserno, it's just that the reader creates a map that can't print itself.
10:55chousernot about lazy seqs.
10:55Chousukeyou get weird behaviour with illegal literals.
10:55Chousuke,`{~@[1]}
10:55clojurebot1
10:55Chousuke,`{~@[1 2]}
10:55clojurebot1
10:56AWizzArd,(with-out-str (read-string "{[]}"))
10:56clojurebot""
10:56Chousukehm, the latter has worked for me before :P
10:57Licenseris the ring developper in the channel every now and then? Everyone an idea?
10:59AWizzArdSo, currently, if I want to check if some expression is valid I will have to do (try (print (read-string s)) (catch Exception e "not valid"))
10:59cemerickLicenser: try #compojure?
10:59Licensercemerick: thanks!
10:59AWizzArdputting read-string into try does not do the trick, I also have to print it
11:01AWizzArdah okay, this is it then: (try (with-out-str (print (read-string "{[]}"))) (catch ...))
11:02Licenserhttp://grab.by/4rce it worked!
11:05tcrayfordchouser: ended up giving up on the whole compiler/analyze thing, it wasn't that useful in the end
11:07Licensertcrayford: did you look in the analyzing methods the sandbox provides? they can be 'abused' for quite some funny things
11:08tcrayfordLicenser: not yet
11:08Licenser*nods*
11:08tcrayfordI found that repetition is almost better done without looking at just the variables in each specific function
11:08tcrayfordand more looking at the length/layout of sexps
11:08Licenser*nods*
11:09tcrayfordit points out things that should obviously be functions/macros pretty well now that I've made that change
11:11tcrayfordthe next thing to do: code generation for proxy (ala cmerick's article)
11:12tcrayfordLicenser: is there a type in the docstring for add-reader-to-sandbox? I've never seen the word 'conuse' before
11:12tcrayford*typo
11:12Licensertcrayford: I've never seen it before either :P
11:13tcrayford:)
11:20AWizzArdWhat is a meaningful Exception for wrong entries in a config file?
11:23MrHusHi I came across The Clojure Library Coding Standards, and saw the following rule:
11:23MrHusUnroll optional named arguments. Callers should not have to wrap optional named arguments in a map literal:
11:24MrHusBut how do you get the [& args] in a map
11:24MrHusAn example from the page: (release-sharks 2 :laser-beams true) ; good (release-sharks 2 {:laser-beams true}) ; bad
11:26Licenserquestion: I have this code:
11:26Licenser(. clojure.lang.LockingTransaction (clojure.core/runInTransaction (clojure.core/fn [] (alte r y inc)))) (it is a dosync)
11:26ChousukeMrHus: on 1.1, (apply hash-map args)
11:26Licenserwhat is happening here? clojure.lang.LockingTransaction is a class, but there seems to be no function called o.O
11:26hoeckMrHus: (defn foo [n & {:keys [laser-beams, other-key]})
11:26ChousukeMrHus: and 1.2 has a new destructuring syntax, so you can do ... that.
11:26Licenseris it the same as new?
11:27ChousukeLicenser: note the . special form
11:27AWizzArd,(Exception. "hi")
11:27clojurebot#<Exception java.lang.Exception: hi>
11:27Chousukeit
11:27AWizzArd,(throw (Exception. "hi"))
11:27LicenserChousuke: yap
11:27clojurebotjava.lang.Exception: hi
11:28AWizzArd,(throw (proxy [Throwable] [] (getMessage [] "hi")))
11:28clojurebotjava.lang.IllegalStateException: Var null/null is unbound.
11:28AWizzArdhiredman: uh oh
11:28Chousukeit's calling the runInTransaction method of the LockingTransaction class.
11:28LicenserThe question is the . special form takes a class a member and parameters right? but I don't see a member or parameters in this call
11:28Chousukeit works for static methods too.
11:28Licenserbut why the () there?
11:29Chousukethe static method takes parameters :)
11:29Chousuke(. class (staticmethod args))
11:29Chousuke(. obj (instancemethod args))
11:29Licenseroh I thought it was like (. class method args)
11:29Licenserdarn it ^^
11:29AWizzArdAnyway: is there a name to give my proxied Throwable a custom name? Something different from #<Throwable$0 my.companies.ns.proxy$java.lang.Throwable$0>?
11:30LicenserChousuke: thanks for the update :) I'll work this out!
11:30ChousukeAWizzArd: not the class.
11:30AWizzArd,(proxy [Throwable] [])
11:30clojurebotjava.lang.IllegalStateException: Var null/null is unbound.
11:30AWizzArdChousuke: ok
11:32ChousukeLicenser: note that the syntax means that if you want to call a method on an instance of Class, you need to do eg. (. (identity String) newInstance) :)
11:32ChousukeLicenser: but this is usually not a problem
11:32MrHusChousuke so you can't destructure the argument in a map in 1.1?
11:32ChousukeMrHus: correct. it's a new feature.
11:33LicenserChousuke: it is for clj-sandbox to allow dosync ;)
11:33ChousukeLicenser: usually the difference is determined from the sugared form
11:33joshua-choiQuestion: when protocols were first introduced (http://www.assembla.com/wiki/show/clojure/Protocols), I got the impression that you named them "ASomething" by convention. Is this really true though?
11:33sexpbot"Show | Clojure | Assembla"
11:33Chousukeie. (.foo bar) is always an instance method call
11:33Chousukejoshua-choi: nah.
11:34joshua-choiEh.
11:34Chousukejoshua-choi: I think the convention is just to call them Something :P
11:34Chousukejoshua-choi: though that might change.
11:34MrHusChousuke What's the syntax in 1.2?
11:34Chousukejoshua-choi: PSomething is not a bad choice either.
11:34joshua-choiChousuke: Oh oh. Well, I'll get rid of my "A"s.
11:35joshua-choiWhat's up with APersistentList, etc., though
11:35ChousukeMrHus: just map destructuring after the &, borrowing hoeck's example (defn foo [n & {:keys [laser-beams, other-key]})
11:36Chousukejoshua-choi: they're abstract base classes
11:36joshua-choiAh
11:36joshua-choiBetter not conflate protocols with them then
11:36joshua-choiNomenclature-wise
11:36Chousukeyeah.
11:40hamzaguys how can i access a filed in a proxy? such as extended class has a filed called someObject and i need to invoke a function on this object?
11:41hamza* field
11:42Chousuke'this is bound to the proxy instance within its methods
11:44hamzaChousuke: (.someObject 'this) is this the correct usage?
11:44Chousukeno, that would be calling the method on the symbol :P
11:44Chousukelose the quote :)
11:45AWizzArdBetter test than (or (true? b) (false? b))
11:45hamzakk, thanks alot.
11:46AWizzArdah (instance? Boolean b)
11:46Chousukeheh, that is indeed a confusing test :P
12:04rseniorlpetit: thanks for the blog comment, do you have some info on the -?> operator you mentioned? I couldn't find it in the docs...
12:06lpetitlook in clojure.contrib.core
12:06lpetit,(doc -?>)
12:06clojurebot"clojure.contrib.core/-?>;[[x form] [x form & forms]]; Same as clojure.core/-> but returns nil as soon as the threaded value is nil itself (thus short-circuiting any pending computation). Examples : (-?> \"foo\" .toUpperCase (.substring 1)) returns \"OO\" (-?> nil .toUpperCase (.substring 1)) returns nil "
12:06lpetitrsenior: ^^^
12:07rseniorlpetit: ah, in contrib, thanks
12:08lpetitrsenior: I know the -?> operator quite well (wrote it, my only contribution AFAIK :) )
12:09lpetitmust leave, cu
12:09rseniorlpetit: does just what I need, I also didn't know that -> works on java methods, I thought it was just for clojure functions
12:10lpetitrsenior: np, clojure changes are not always well propagated, and the most stuff I know has been gathered on the ml and this channel
12:10lpetit(I mean, once I had read the clojure.org site from a to z, of course)
12:20arkahndo the macros #^ and ^ have anything to do with each other, or is #^ still current and ^ just being deprecated and forgotten?
12:21chouserin git master, #^ and ^ mean the same
12:22arkahnchouser: is that 1.2/1.3?
12:23arkahnchouser: 1.1 gives deprecation warnings on ^
12:25hamzais not permitted to access protected objects in a class? when i do (.someObject (proxyed-class)) gives field not found exception..
12:25chouserarkahn: right, in 1.1 ^foo expanded to (meta foo), with deprecation warning.
12:26chouserin 1.2 ^ will mean the same as #^
12:26arkahnchouser: thank you
12:27arkahnand I think google needs to learn how to search on things like #^ ; )
13:10LauJensenhttp://dorophone.blogspot.com/2008/03/common-lisp-reader-macros-simple.html
13:10sexpbot"Dorophone: Common Lisp Reader Macros: A Simple Introduction"
13:10LauJensen:)~
13:13KirinDaveReader macros are beautiful
13:13KirinDaveI miss them badly
13:16etateLauJensen: your new blog is awesome man... this is the best use of clojure on the web i've seen so far - very professional
13:16etateLauJensen: congrats
13:16LauJensenetate: wow, thanks man :)
13:16KirinDaveLauJensen: url plz?
13:16LauJensenbtw, Ive been looking for you, where's that bright theme? :)
13:16technomancyI was wondering how long it would take before the ".php" in the URL would be too much for Lau to take. =)
13:16LauJensenKirinDave: http://www.bestinclass.dk/blog.html
13:16sexpbot"Best In Class - Software Innovator"
13:16LauJensentechnomancy: yea, it was killing me :)
13:17KirinDaveLauJensen: So this is in clojure?
13:17LauJensenyep
13:17etateLauJensen: :) Im in process of changing it i'll paste it a bit later for you
13:17KirinDaveFun
13:17KirinDaveIs it on GAE?
13:17LauJensenNope, just a Linux/NGINX combo
13:18LauJensenetate: great, and if Im not here feel very free to send me an email :)
13:18etateLauJensen: will do, I really love your new logo
13:18LauJensenetate: Im very glad - though its about to get tweaked a little
13:19LauJensen(I think)
13:19LauJensenIm not sure I can ever be happy with a website that doesn't have the Knight Rider scroller and theme song in flash
13:19etateLauJensen: yeah it could use some polish for some of the UI elements but the direction is great, I mean it looks great as it is - and its a good example of how clojure can compete in this domain
13:20LauJensenYea, I hope you guys can verify that the site as a whole is much more responsive now, even in peak periods
13:21etateLauJensen: yeah, that was a noticeable difference
13:21LauJensengreat; I gotta duck out. etate you got my email right?
13:21Borkdudeetate: LauJensen: agreed about the competition. I just discussed functional programming today with a colleague, that we should promote it at our work, but he said, it's still just an academic thing (he is into Haskell). So I explained him that serious nice things happen these days in Clojure, people translate their blogs into it ;)
13:21LauJensenhehe
13:21etateLauJensen: Its on your site right? :) So cool that you included enlive tips in your post too :)
13:22LauJensenetate: yea it is. And more Enlive tips to come when I realise the code
13:22LauJensenAnyway - I gotta duck out
13:22KirinDaveI went all the way down the rabbit hole of compiling enlive transforms on templates into actual functions before I realized it couldn't work.
13:22KirinDaveI was pretty bummed out with that.
13:22BorkdudeLauJensen: bye
13:23etateKirinDave: why couldn't it work?
13:23KirinDaveetate: Because inserting new markup would require a rescan of the whole tree.
13:23KirinDaveIf you are a good boy and your selectors don't overlap in any way, it's MUCH faster.
13:23KirinDaveOtherwise it reduces to the same thing
13:24etateKirinDave: can you not memoize or something? (naive suggestion warning)
13:24KirinDaveetate: Imagine two xforms on a tree
13:25KirinDaveOne inserts a series of <article> tags.
13:25KirinDaveThe other decorates article tags.
13:25KirinDaveIf the information for generating those article tags is dynamic, it's very difficult to fold the two together.
13:27etateKirinDave: so what are you using as an alternative to this?
13:27etateor what did you decide on doing in the end :)
13:32cgrandKirinDave: can't you decorate the articles as you insert them?
13:36KirinDavecgrand: I dunno what that'd be like
13:37etatecgrand: by the looks of it this was LauJensens approach in his blog, "baking" the post into html
13:37KirinDavecgrand: I just am bummed because I wrote a bunch of code without thinking about it. ;)
13:37etateKirinDave: check http://www.bestinclass.dk/index.clj/2010/05/refresh-your-cache--best-in-class-has-been-baked.html
13:37sexpbot"Best In Class: Refresh your cache - Best In Class has been baked"
13:38KirinDavecgrand: It's possible that for a limited class of selectors I could make it work
13:38KirinDavecgrand: But if people get exotic about the boundaries of things, it'd be difficult to get a correct result.
13:42cgrandI'm not sure to understand what you want: did you want a sort of pipeline (-> html-tree xform1 xform2 render)?
13:43cgrandI see you are speaking about non-overlapping selectors, in enlive you can now specify sets of indepedent transforms, thus they are applied in one pass
13:43KirinDavecgrand: I tried to take the template and the xforms and precompile it into a function that just patches wholes in the template.
13:43KirinDavecgrand: Basically xform to a ` macro.
13:43KirinDavecgrand: I was trying to get enlive generated pages to exceed 2k r/s
13:44KirinDaveAnd it works, but not if the selectors overlap.
13:44KirinDaveAt least not yet
13:45cgrandvery interesting, are your experiments public?
13:45KirinDavecgrand: Sadly, no. It's a microsoft deal.
13:45KirinDaveBut I will recreate at home once I am out from under their cruel yolk
13:45KirinDavecgrand: Some common lisp systems do it this way tho.
13:45technomancyKirinDave: how much longer?
13:45KirinDavetechnomancy: Sept 1 unless I get a good offer.
13:46technomancynice
13:46KirinDavetechnomancy: A mutual acquaintance of ours has expressed interest in pulling me away. I'm considering it strongly
14:18ArkRost Hi! I find a strange thing: ('a 1 2) return 2. Why does it happens?
14:19chouserArkRost: symbols used as functions expect their first arg to be a map, and look themselves up in it.
14:19chouser('a {'c 1, 'b 2, 'a 3})
14:19chouser,('a {'c 1, 'b 2, 'a 3})
14:19clojurebot3
14:20chouserthey accept a second arg which is returned if the key is not found
14:20chouser,('z {'c 1, 'b 2, 'a 3} :missing)
14:20clojurebot:missing
14:20chouserthat second arg is also returned if the first arg isn't a map
14:20chouser,('z 1 :missing)
14:20clojurebot:missing
14:20chouser,('z 1 2)
14:20clojurebot2
14:20chouser,('a 1 2)
14:20clojurebot2
14:22ArkRostok. Another question: how can I shadow special forms(def, do and ect)?
14:22technomancyArkRost: if you have to ask ... you should probably think twice before doing it. =)
14:23technomancythere's probably a better way to do what you're thinking of
14:23technomancysorry to sound like a smartass
14:24chouserI actually think it may be impossible
14:24ArkRostoh no.. I don't want to use it in code. Just curious
14:24chouser,(let [def 5] def)
14:24clojurebotDENIED
14:24chouserbah
14:24chouser,(let [do 5] (do do))
14:24clojurebot5
14:25chouser,(let [do (fn [] 7)] (do))
14:25clojurebotnil
14:25chouseryeah, don't do it. Even if it's possible in some cases, such as above, I very much doubt it's supported and could quit working at any time.
14:26ArkRostok. Thanks
14:27Borkdude('fibnext 0 1)
14:27Borkdude,('fibnext 0 1)
14:27clojurebot1
14:27Borkdudedamn it works! ;)
14:28Borkdude('add 0 1)
14:28Borkdude,('add 0 1)
14:28clojurebot1
14:28Borkdudeyup perfect.
14:30Borkdudewhat is so graceful about symbols accepting everything, instead of throwing actually?
14:31lancepantzBorkdude: i like the behavior, but the powers have be said not to rely on it and they may change it at any point in time
14:31lancepantz*that be
14:31chouserwhat? symbols as functions are fully supported, afaik.
14:31chouserjust like keywords
14:31lancepantzi thought he was referring to the alphanumeric requirement
14:32chouseroh
14:32lancepantzi may have misunderstood
14:32Borkdudechouser: I mean, you gave the example of the MapKey throwing an exception instead of nil
14:32Borkdudewhy is returning nil better, errors may be hard to find
14:32lancepantzyep
14:33Borkdudeand the same goes for ('foo 'dont-care-what-is-here 'i-just-return-this)
14:34Borkdude,('foo 'dont-care-what-is-here 'i-just-return-this)
14:34clojureboti-just-return-this
14:34chouserIf any sort of reasonable default behavior can be provided, I genearlly prefer that over exceptions.
14:35chouserleads to cleaner simpler code, rather than try/catches and if's all over the place.
14:35Borkdudeso exceptions aren't considered helpful in Clojure?
14:36ChousukeI'd say they're a last resort thing
14:36chouserI'm not setting clojure policy here, just voicing my agreement with some specific decisions.
14:36Chousukewhen something is obviously wrong
14:36technomancyChousuke: dare we say ... exceptional?
14:36Chousuketechnomancy: perhaps.
14:37Chousuketechnomancy: though what qualifies as exceptional is open to discussion
14:37chouserif there is a reasonable and/or obvious default, why not provide that instead of forcing the code to be explicit.
14:37chouser(meta nil) could throw, but I'm happy it just returns nil
14:37BorkdudeI would say an empty map is ok, but when would it be good to give a non-map to a symbol?
14:37ChousukeBorkdude: maybe you have some generic lookup code
14:38ChousukeBorkdude: that could take any collection and just return nil if the item is not there
14:38Chousukeor if it's not a collection
14:38Chousukeso you can do stuff like (if ('something foo) (dostuff) (fail))
14:39Chousukeor just (dostuff ('something foo 'default))
14:40chouserhey look, you eliminated an 'if'! congrats!
14:40BorkdudeI guess you can always check yourself if a map has been provided, if it's really important to you
14:41Chousukeif you want an exception you can always do the lookup as (foo 'something) :(
14:41Chousuke:) I mean :P
14:41Borkdude,({:a "dude"} :b)
14:41clojurebotnil
14:41Borkdude?
14:41chouser,(nil :b)
14:41clojurebotjava.lang.IllegalArgumentException: Can't call nil
14:42chouser,(1 :b)
14:42clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
14:42Borkdudeah ok
14:43BorkdudeI guess there are always ways to get what you want out of Clojure ;)
14:44Borkdude,nil
14:44clojurebotDENIED
15:02LauJensenetate: progress? :)
15:02arohneris there any way to specify the startup arguments to the JVM using lein / maven?
15:02arohneror any other tool? I dislike writing my clojure startup script in bash, because that's the only way I know of right now
15:03tcrayfordlein is just a bash script
15:03tcrayfordso if you want to, you could copy the lein bash script to your project, then modify it
15:04arohnertcrayford: I would like to define my startup script in something lein-y, that would go in the project.clj
15:04tcrayfordarohner: there's no decent way to do that now (as far as I know)
15:04tcrayfordthe jvm has to start before lein can process project.clj
15:05arohnerhrm, looks like maven exec might do it
15:06LauJensenchouser: when do we get reader macros in clojure?
15:06chouserLauJensen: never
15:06RaynesEver ever.
15:07chouserLauJensen: of course you can write your own reader and/or fork clojure, but don't expect many people to use your new language. :-)
15:08LauJensenchouser: Why not ?
15:08arohnerLauJensen: reader macros don't compose
15:09etateLauJensen: almost there :)
15:10LauJensenetate: cool
15:10LauJensenarohner: But I just dont see us ever accomplishing the goal of being Lisp-Perl without them :(
15:10arohnerthat's a goal?
15:11LauJensenIm kidding of course
15:11chouserbecause you'll have to convince each potential clojure user to trust your judgement over rhickey's. tough.
15:11kotarakIsn't @#^foo perly enough?
15:12LauJensenchouser: so... no real arguments, its just a matter of taste?
15:12chouserwhat? how'd you get that?
15:13LauJensenchouser: I just didn't see a real argument. Reader macros doesn't imply a transfer of trust anymore than regular macros and they can be used in some restricted sense
15:13kotarakLauJensen: this was discussed several times, with lots of reasoning in all directions. Check the group archives.
15:14chouserI wasn't arguing about reader macros, it's just the challenge that any functionality-fork of clojure would face. You failed to convince rhickey or you wouldn't have forked.
15:14LauJensenoh, I wouldn't fork :)
15:14chouserah
15:14LauJensenI was just thinking of implementing them in Clojure
15:14LauJensenBut I'll take kotaraks advice and check the group
15:15chouserI think the composability of reader macros is actually a red herring. I mean it's part of the problem, but I actually proposed a feature that would address a subset of reasons people want reader macros that was fully namespaceable, and rhickey smiled politely and said "I don't like it".
15:16LauJensenWell, at least he was polite :)
15:16chouserthey are very rarely necessary and carry a burden for anyone trying to parse or read a clojure file.
15:16LauJensenBut ok, I guess in all honesty I do actually get along very well without them
15:17chouserright now, untrusted clojure can be read. with reader macros this would be impossible
15:17chouseruntrusted clojure code
15:17LauJensendepending a little on how you implement them
15:17chouserthat is a clojure reader doesn't need to be able to eval -- this has benefits for editors, syntax highlighter, code analyzers, etc.
15:18chouserreade macros by definition eliminate all that.
15:18chouserand to what benefit? I have a DSL here that needs to support x.y.z field-lookup syntax, with non-standard rules for the resolution of x.
15:18LauJensenstrong point
15:19chouserwrap it in a (--> x.y.z) or something, and a regular macro does just fine.
15:19etateLauJensen: http://paste.lisp.org/display/99418
15:19LauJensenchouser: , the thing is, I really want 5**2 instead of (Math/pow 5 2) :)
15:19etateLauJensen: thats a rough draft of what i'm working on - trying to get rid of the purple
15:19ChousukeI think a reader library might be useful though
15:19chouserLauJensen: no you really don't.
15:19etateLauJensen: I have to head out so i'll send you an updated version some other time :)
15:19chouserthough apparently Incanter provides that now.
15:20Chousukeso people can write their own readers when they need to :)
15:20kotarakLauJensen: (def ** #(Math/pow %1 %2))
15:20LauJensencool, thanks etata
15:20chouserwell, provides 5 ** 2
15:20LauJensenchouser: I dont ?
15:21chouserrhickey worked so hard to talk us out of including an infix example in the book, and then Leibke goes and puts one in his hugely popular library.
15:21Borkdudehehe
15:21tcrayfordchouser: what did rhickey argue against infix stuff with?
15:21Chousukewell, in their defense it does more than just infix math
15:21Chousukeand it is a math library :P
15:22chousertcrayford: he was afraid people would actually use it, which was never our point.
15:22Chousukeyou can just think of it as a dsl for matrix/vector (oh, and scalar) manipulation
15:22tcrayfordchouser: makes sense
15:23chouserour point was to show that clojure could do infix just fine -- the reason it doesn't is because it's undesriable (in clojure) not because it's impossible.
15:23tcrayfordand demonstrating macros as well
15:24chouserI don't think it was a macro. Just a function.
15:24tcrayfordnice then
15:24ChousukeI don't think most people will suffer incanter as a dependency just to get infix math
15:25chouserno, but lots of people use incanter. I'm sure I'll end up debugging somebody's infix math code at some point now.
15:25Chousukeand I think most math in clojure consists of (apply + ...) or somesuch
15:26Borkdude(import-static java.lang.Math pow pow), is this considered normal practice in Clojure?
15:26ChousukeBorkdude: you should just use Math/pow I think
15:26kotarakno, at least on on my side
15:26Chousukeit's not that much longer, is it? :P
15:31cemerickarohner: not sure if you've settled anywhere, but look @ clojure-maven-plugin
15:33arohnercemerick: interesting. The primary thing I'm looking for is setting JAVA_ARGS
15:35cemerickarohner: Sure. That's done via the clojureOptions in the plugin config. i.e. <clojureOptions>-Xmx512m -Djava.awt.headless=true -XX:MaxPermSize=256m</clojureOptions>
15:36lancepantzi don't know what to search for, so i'll just ask- how do i jump to the closing parent for one my cursor is in in emacs?
15:36lancepantzlike % in vim
15:36tcrayfordI've never found something that works well for that in vanilla emacs
15:36arohnerlancepantz: C-M-f, if you're running paredit
15:36lancepantzs/parent/paren
15:36arohnercemerick: cool, thanks
15:36lancepantzthat works, thanks arohner
15:37tcrayfordlancepantz: note that works for going forwards
15:37tcrayfordyou need C-M-b for backwards
15:37lancepantzjust realized that :)
15:37lancepantzthansk
15:45joshua-choiuestion. I used to do (isa? (type obj) t) whenever I was checking if an object was a certain type. With the advent of records, should I use (= (class obj) t) instead, if I'm *not* using a protocol?
15:46Chousukeyou can use instance?
15:46Chousukethough I think checking for an interface is better.
15:46Chousukethe class can freely change then
15:47joshua-choiI'm not using a protocol or interface; there's only one type of record to check for. But I suppose that whenever I need to check a type, I should consider using a protocol instead...
15:48Chousukeperhaps.
15:48joshua-choiI totally didn't know about instance?, though
15:48Chousukea protocol function should be interchangeable with a normal function in the best case.
15:48Borkdudechouser: does TjOC treat defrecord, protocol and the like somewhere?
15:49chouserBorkdude: ch8, not released yet
15:49Chousukeso if protocols don't work for you, you can replace it with a normal function with an instance check.
15:49chouserit was mostly done before defrecord was invented, so we need to revise...
15:49joshua-choiChousuke: When would you want to do that?
15:49Borkdudechouser: ah good to know that will come up
15:50Chousukejoshua-choi: dunno. I suppose replacing a protocol function with a multimethod is more plausible
15:50Borkdudechouser: is middleware also a topic that belongs in there, or is that a compjore specific thing?
15:50Chousukejoshua-choi: but the point remains that they're all just functions
15:51joshua-choiDoes anyone use (type ...) nowadays?
15:51chouserBorkdude: we won't be dealing with specific library features like that.
15:51chouserwe're way over our target pagecount already
15:51Borkdudechouser: I just wondered if that term was a general thing in Clojure
15:52chouserBorkdude: it's not
15:52kotarakjoshua-choi: yes, why not?
15:52Borkdudek
15:52joshua-choikotarak: (type obj) is (or (:type (meta obj)) (class obj)). I'm wondering if using :type in metadata is still idiomatic at all
15:53joshua-choiI myself use it, but I'm wondering if I should change it...
15:53joshua-choiSame goes for isa? in the context of object type hierarchies
15:54kotarakbtw, what do I use to test for a deftype? Is its type still ::SomeType? Or do I test for a class?
15:55AWizzArdkotarak: (type yourRecord) ==> ou
15:55AWizzArdkotarak: (type yourRecord) ==> your.ns.recordName
15:55kotarakAWizzArd: so I test with (instance? your.ns.recordName x)?
15:55AWizzArdexactly
15:56AWizzArdif you use Protocolls this test will be done automatically for you
15:56kotarakAWizzArd: Except when I don't use a protocol function and want to test for the type explicitely.
15:56AWizzArdpositive
15:59_na_ka_na_hi , i want to create a doubly linked list .. a node looks like (defstruct node :data :next :prev) .. so first i cr8 a list of nodes and then try to link them up .. is there a way to do it w/o creating each node as an atom/ref .. i ask coz after i create the list i'm not going to mutate it ..
15:59_na_ka_na_whats the most idiomatic clojure way to do this
15:59chouser_na_ka_na_: why do you want a doubly linked list?
16:00ChousukeI don't think there is a way to do that with immutable thigns
16:00_na_ka_na_i actually want to create a graph data structure .. where nodes are connected to other nodes via 2-3 different kinds of edges ...
16:01_na_ka_na_i thot ask abt doubly linked list would be easier
16:01Chousukemaybe you should use a set or a map of edges then
16:01_na_ka_na_hmm ya thats an option ..
16:01Chousukefor doubly linked lists you'd need mutual references, which are impossible with persistent things.
16:02_na_ka_na_so i create a list of nodes + a map of sets (key=node, value=set of connected edges) ?
16:02_na_ka_na_oh i meant set of connected nodes
16:03Chousukesomething like that I guess.
16:03chousera common solution is a map of ids to nodes, with each node refering to its neighbors by id
16:04_na_ka_na_hmm .. that looks good ..
16:05_na_ka_na_but .. how do these two solutions compare .. i mean where i have nodes as atoms v/s persistent maps ..
16:05_na_ka_na_the first one makes a more intuitive picture in my head ..
16:06_na_ka_na_is the only concern perf?
16:06alexykwhich predicate do you give to every? to check none of a seq's elements is nil?
16:07_na_ka_na_(comp not nil?)
16:07alexykshorter!
16:07chouser(not (some nil? ...))
16:07Borkdude(complement nil?) ?
16:08Chousukeidentity
16:08chouser(every? identity ...)
16:08Chousukefails on false though.
16:08chouseris the seq produced by 'map' perchance?
16:08alexykhmm... let's call it meaty?
16:08alexykevery? meaty?
16:09alexykbut it should be in core! not-nil?
16:09alexyknot= is there
16:09alexyksome useless when-not is there!
16:09alexykalmost-useless
16:09ninjuddwhen-not isn't useless
16:09lancepantzruh roh
16:09alexykninjudd: it was an overstatement :)
16:10Borkdudeisn't there a macro that can define the complement each thing in core and append -not to it's name ;)
16:10chouseralexyk: you need to differentiate between nil and false?
16:10alexykhope not, but am afraid
16:11alexykI'll defn ismeat? as not nil?
16:11alexykis? <-- cute
16:11alexykevery? is?
16:11_na_ka_na_is what?
16:11alexykexists?
16:11Borkdudenil exists
16:12alexykit *is*
16:12alexykBorkdude: but things which are nil don't
16:12_na_ka_na_but how to ppl looking at your code understand *is* ..?
16:12Borkdudeyes, they do, because they ARE nil
16:13alexykdoes a key exist in a map if lookup is nil?
16:13Borkdudedoes the lookup return the key?
16:14alexykdoes a value for the key exist?
16:14Borkdudeit's a default value for non-mapped keys
16:14tcrayford,({:a nil} :a)
16:14clojurebotnil
16:15_na_ka_na_better to use contains
16:15_na_ka_na_,(contains? {:a nil} :a)
16:15clojurebottrue
16:15BorkdudeI think not nil? is the best description you can get ;)
16:15tcrayfordalexyk: you want "untruthy"
16:16tcrayfordor perhaps not-truthy?
16:16alexykBorkdude: alas
16:17_na_ka_na_i use not nil quite often so i've just put (defn not-nil? (comp not nil?)) at the top ..
16:17remleduffvici?
16:19_na_ka_na_hey guys how abt the graph ds .. how do the atoms v/s maps solution compare ..
16:21chouser_na_ka_na_: don't use atoms for this
16:22_na_ka_na_chouser but why? .. just want to understand ..
16:22chouserit's not about performance -- I'm not sure which would be faster, actually.
16:23alexykhow do you assert something is a number?
16:23_na_ka_na_why does your gut feeling say no to atoms? :)
16:23chouserrather it's sort of an abuse of an atom to have it sitting there able to change with a vague promise that you won't.
16:23_na_ka_na_hmm ya ..
16:24chouserif you can do something more like transients, where you can "lock it" when you're done building it, that would be something else.
16:24Borkdude,(number? "foo")
16:24clojurebotfalse
16:24Chousuke_na_ka_na_: it would be just emulating traditional mutability, which is not maintainable :/
16:24Borkdude,(assert (number? "foo"))
16:24clojurebotjava.lang.AssertionError: Assert failed: (number? "foo")
16:25Chousukeyou don't want your core data structure to have anything to do with state :P
16:25alexykBorkdude: thx! that's my not-nil :)
16:25_na_ka_na_Chousuke: i think every one agrees on that .. thats why we are here :D ..
16:26Borkdudealexyk: =)
16:28_na_ka_na_but that is an issue only if someone *actually changes* the ds after building it .. if this graph of mine is a "private" ds which i don't expose in my API .. and i know that i'll never mutate it ..
16:28tcrayfordwell if you're never going to mutate it, why do you need an atom?
16:29_na_ka_na_its not like i favor the atoms .. i'm just trying to put arguments both ways
16:29Chousuke_na_ka_na_: in this case, there isn't much of a case to be made in favour of the atoms :)
16:30Chousukepeople will think it's unidiomatic, ugly and stupid :P
16:30_na_ka_na_the graph data structure represented with atoms is more intuitive no? .. anyone who sees it will understand at the first glance?
16:30Chousukeeven if it works.
16:30chouseris the graph a value or not? if it's a value in the way other complex nested map/vector things are, then you get all the same benefits: keep old version, build using 'reduce', etc.
16:30_na_ka_na_hehe ya thats one more point against :)
16:30Chousuke_na_ka_na_: no, a person used to clojure will go "what?"
16:30chouserbut as soon as there's an atom in there, it's a stateful thing and you can have only the one.
16:31chousergotta go
16:31Chousuke_na_ka_na_: while they might understand mutability, atoms are meant to address mutability in a very different way from what you're suggesting, so they would be confused.
16:32_na_ka_na_yes I agree with that point .. its not idiomatic Clojure at all ..
16:32Chousukeactually, s/mutability/state/g
16:34Chousukedoing things "the right way" might be difficult at first but this gets easier with experience.
16:34Chousukeand it's never too early to start experiencing :P
16:34_na_ka_na_now that seems like the best argument to me :P ..
16:35Borkdudeatoms are there, but never use them!
16:35Borkdudeheh ;)
16:35_na_ka_na_hehe ..
16:36Chousuketry the approach using maps of ids -> node where node = some stuff + set of edges which are pairs of [edge-type, node-id] (you had several kinds of edges, right?)
16:36Chousukealso, starting advice: don't be tempted to use struct maps
16:37Chousukethey're not real types, and you won't need them until you know you need them :P
16:37_na_ka_na_ya i have several kinds of edges ...
16:38_na_ka_na_ya if im not using atoms .. then no need of structmap i guess ..
16:38Chousukestruct maps are just an optimisation of regular maps
16:38BorkdudeWhat would be a good example of import-static?
16:38_na_ka_na_Math/PI ?
16:39Chousukeif you feel you need the memory benefit, it should be pretty easy to convert code using plain maps to struct maps
16:39tcrayfordstruct-maps are confusing when you're starting out. The first major thing I wrote in clojure used struct maps, and I look back on it now with annoyance
16:39tcrayfordthey look so like classes :/
16:39technomancystruct-maps are a tank trap
16:39Chousuketcrayford: yeah, I think the first reaction from people new to clojure must be something like "ooh, structs, I know those"
16:40_na_ka_na_but I just treat them as regular maps ..? only its named and little more optimized
16:40Chousukethen they go and use struct maps. no real harm there, but it's often unnecessary ceremony.
16:40tcrayfordtechnomancy: looking at the swank-clojure source, it says M-TAB to complete symbol, wheras slime says C-c TAB
16:40AWizzArdIsn’t completion on just <Tab> only?
16:40technomancytcrayford: they both work, but in most WMs C-c TAB is easier to invoke.
16:40tcrayfords/source/README
16:40technomancyI'll change the readme; thanks.
16:41Chousuke_na_ka_na_: the optimisation won't matter unless you have many "instances" of the base map (in the order of several thousand)
16:41tcrayfordAWizzArd: that's slime specific completion
16:41AWizzArdtcrayford: which one? With tab or C-c Tab?
16:41tcrayfordC-c TAB
16:41_na_ka_na_Chousuke: I have around 100,000 nodes .. so isn't struct-map better
16:41technomancyAWizzArd: bare tab is usually bound to indentation
16:41technomancyunless you're in the repl
16:41AWizzArdtechnomancy: yes, in the repl i mean
16:41Chousukenathanmarz: will your node be a map?
16:41tcrayfordor using smart-tab-mode or summat
16:41Chousukeoops
16:41AWizzArdindentation and completion
16:42tcrayforddoes bare tab work in the repl for completion?
16:42Chousuke_na_ka_na_: couldn't the node be just a pair?
16:42Chousukenathanmarz: no keys, just [stuff, set-of-edges]
16:42AWizzArdM-Tab would not be so nice for Windows users - it switches out of Emacs to the next application.
16:42tcrayfordsame for osx :/
16:43AWizzArdI put fuzzy-completion on C-Tab
16:43Borkdudetechnomancy: maybe a dumb question, but why would I upgrade to swank-clojure 1.2?
16:43technomancyBorkdude: all the cool kids are doing it.
16:43Chousukenathanmarz: I suppose a struct-map could be useful too
16:43Borkdudetechnomancy: I noticed, that's why I ask ;)
16:43technomancyBorkdude: here's the list of new features: http://github.com/technomancy/swank-clojure/blob/master/NEWS
16:43AWizzArdtechnomancy: btw, is the freshest swank-clojure + clojure-mode working with the freshest slime?
16:44Borkdudetechnomancy: tnx
16:44technomancyBorkdude: who-calls and swank-break are pretty awesome
16:44Chousukenathanmarz: just don't think it's anything more than a regular map; that's a common mistake.
16:44_na_ka_na_Chousuke: yup .. it can be for the moment.. but later i'll need to introduce several kinds of attributes with the nodes (like {:id :data :attr1 :attr2 ..}) .. i could use several maps for this .. one for data, one for attr1 .. but isn't that overkill ?
16:44technomancyAWizzArd: swank-clojure.el or swank-clojure clojure server?
16:45Chousuke_na_ka_na_: well, the nodes will be just maps so you can just assoc the keys.
16:45Chousuke_na_ka_na_: in that regard it doesn't matter what you put in there.
16:45Borkdudetechnomancy: ok, sounds good. Now I have to find out how I do it using ELPA, can I just overwrite it or smth?
16:46Borkdudesorry, I'm still an Emacs n00b
16:46AWizzArdtechnomancy: I was not aware of those two so far. I still have a very old installation where I just do M-x Clojure to get a repl and Clojure-Mode. I typically did not start a swank server to which I then connected on port 4005 or something like that.
16:46Chousuke_na_ka_na_: so maybe using a map as a node is a good idea. try and experiment with a small prototype first
16:46technomancyBorkdude: the readme now shows a more foolproof method of using it. basically you don't need the elisp for swank-clojure anymore. on the Emacs side just get slime-repl and clojure-mode, and launch your swank server from the command-line
16:46_na_ka_na_Chousuke: yes, but the question is maps v/s struct-maps (v/s defrecord ?) .. coz I'm not going to dynamically add keys .. well maybe if my app runs for weeks along :D
16:47tcrayford_na_ka_na_: read steve yegge's article about systems that never stop
16:47Chousuke_na_ka_na_: well, a struct-map will be okay.
16:47Borkdudetechnomancy: and if I don't want to use the command line?
16:47technomancyAWizzArd: I'm using a relatively recent slime (two or three weeks old) with lein swank. I quit using M-x swank-clojure-project, but I think it still works
16:47Chousuke_na_ka_na_: though records are better.
16:47technomancyBorkdude: then it's more manual, but you can use this: http://p.hagelb.org/swank-launchers.html
16:47sexpbot"programming.el"
16:47AWizzArdtechnomancy: do you now always start a jvm with a swank-server listening and do slime-connect them from emacs?
16:48technomancyAWizzArd: that's what I do now, yes. it's much more foolproof; M-x swank-clojure-project had several nasty edge cases that confused a lot of people
16:48Chousuke_na_ka_na_: if you're using 1.2 and need the memory savings, you can use defrecord and then treat it as if it were a regular map I suppose :)
16:48_na_ka_na_tcrayford: link pls .. and ur is hard to see at first :) i wrote tracyford :P .. hope u dont mind
16:49_na_ka_na_Chousuke: exactly what i was thinking after i learnt protocols, datatypes today itself!
16:49tcrayfordtechnomancy/AWizzArd: though swank-clojure-project lets you customize the jvm startup better than you can with lein atm
16:49tcrayford_na_ka_na_: http://steve-yegge.blogspot.com/2007/01/pinocchio-problem.html
16:49sexpbot"Stevey's Blog Rants: The Pinocchio Problem"
16:50tcrayfordwarning: Steve Yegge post, ie really really long
16:50Chousuke_na_ka_na_: the important thing in the beginning is not to marry yourself to a certain approach. programming to generic interfaces (ie. thinking of your data as just maps of stuff) often helps.
16:50Chousukeespecially if you have a background in OOP :/
16:51Borkdudetechnomancy: maybe it's more foolproof, it's not n00bproof
16:52_na_ka_na_Chousuke: thats right, my background is OOP .. but the more I did it the more I felt this is wrong, we are just writing variables too much .. then I came across Clojure :D
16:55_na_ka_na_the sad thing now that I look back is we were thought not even one functional language in school, not even the topic of functional programming, immutability came across in so many "programming courses"
16:55_na_ka_na_first Java then C then Perl, Python ..
16:56Borkdude_na_ka_na_: what school was that
16:56Borkdude_na_ka_na_: I mean, what kind
16:56Borkdude_na_ka_na_: not that it sounds ridiculous, just curious
16:58LauJensenetate: ping
16:59_na_ka_na_Borkdude: not giving away the names .. but it was the... institute of technology
16:59Borkdude_na_ka_na_: only a few options then
17:00_na_ka_na_Borkdude: lets not name the options :P
17:01Borkdude_na_ka_na_: I'm just asking because I work at a 'school' as well
17:01_na_ka_na_Borkdude: Hmm, you teach or just work?
17:02BorkdudeI teach
17:02_na_ka_na_Oh wow thats nice to hear, what subject(s) if you don't mind?
17:02Borkdude_na_ka_na_: I just started since March 1
17:04Borkdude_na_ka_na_: as of now, I teach things like Google Web Toolkit, a project using that and Object Oriented Design, some course around Oracle JDeveloper
17:04_na_ka_na_Borkdude: I like teachers :), wish you a rewarding career!
17:04BorkdudeI hope to sneak in some Clojure somewhere sometime ;)
17:05_na_ka_na_Hehe ;) not let them know
17:05AWizzArdtechnomancy: what is swank.core/break doing?
17:05Borkdude_na_ka_na_: tnx
17:06technomancyAWizzArd: http://hugoduncan.org/post/2010/swank_clojure_gets_a_break_with_the_local_environment.xhtml
17:06sexpbot"Hugo Duncan : Swank Clojure gets a Break with the Local Environment"
17:06technomancyspoiler alert: it's awesome
17:06_na_ka_na_Chousuke: thanks for discussion, I'm off to test some of the ideas discussed.
17:06tcrayfordtechnomancy: I've never had break succesfully work for me
17:10tcrayforddoes it only work from the repl?
17:10alexykninjudd: you know what a cool sideeffect of jiraph format is?
17:10tcrayfordtechnomancy: (ie won't work using C-x C-e)
17:10ninjuddalexyk: what?
17:11technomancytcrayford: it should work that way, but I usually invoke it via tests
17:11alexykninjudd: it's language-independent! you can read it from Scala presumably, or even from Python or C++
17:11alexykwhatever supports TC and protobuffers
17:12joshua-choiQuestion: In Clojure, in order to have two mutually recursive functions, must you use two vars? Is it impossible to create them in a let binding?
17:12mmarczykjoshua-choi: see letfn
17:12ninjuddalexyk: good point. didn't even think of that. i was just going for speed
17:12joshua-choimmarczyk: Can letfn create mutually recursive functions?
17:12mmarczykjoshua-choi: that's its entire point :-)
17:13alexykninjudd: yeah, OTOH, compiling a proto is annoying, but you get portability too
17:13ninjuddalexyk: i'm working on lein tasks for compiling protobufs right now
17:13alexykI'm sick of NPEs and will try Scala on a jiraph soon :)
17:13joshua-choimmarczyk: Oh, I've been using it since it's cooler than (let [a (fn ...)] ...). That's cool. But only letfn can do that?
17:13ninjuddshould make it easier
17:14mmarczykjoshua-choi: well you could conceivably use let with atoms (not sure why you'd want to, though)
17:14alexykninjudd: cool! as I understand, if you add a proto/ directory to classpath of a repl, you can keep compiling protos there without reloading repls, right?
17:14mmarczykjoshua-choi: anyway, letfn is there precisely for this purpose
17:15mmarczyk,(letfn [(ev? [n] (if (zero? n) true (od? (dec n)))) (od? [n] (if (zero? n) false (ev? (dec n))))] (ev? 10))
17:15clojurebottrue
17:15joshua-choimmarczyk: No, I don't want to use mutable structures. I have a problem with recursive nested functions that I've been using solving with vars, but now I've come up against a wall with them: namely, metadata.
17:15alexykpost-NPE-debugging stress disorder
17:16joshua-choiOh dear, letfn seems to use a special form "letfn*".
17:16joshua-choi,`letfn*
17:16clojurebotletfn*
17:16mmarczykjoshua-choi: yeah, and let uses a special form "let*", loop uses "loop*" and fn uses "fn*"
17:16mmarczykdon't worry about it
17:16ninjuddalexyk: no, you'll still have to do 'lein proto' to recompile your proto files
17:16joshua-choimmarczyk: I was hoping that I could utilize letfn's source code for my own parser library
17:17joshua-choiI am having to deal with recursive rules, and I don't want to use var-quoting anymore
17:17alexykninjudd: true, but I can do it from another dir and laod into a running repl by defining protobuffer there with just a class name
17:17mmarczykjoshua-choi: perhaps you can utilise letfn itself for your library? :-)
17:17alexykclojurebot: take your NPE and shove it!
17:17clojurebotexcusez-moi
17:17mmarczykjoshua-choi: note that there's no way around the lack of TCE for non-self-calls
17:19joshua-choimmarczyk: Yes; I can unfortunately do little about that, I think; I can just hope that the stack stays small
17:19mmarczykI guess so
17:19joshua-choiI thought that I could wrap all my rules in zero-argument functions, and that would fix it
17:19mmarczykor maintain your own CPS stack, or use trampoline
17:19joshua-choiThe mutual recursion reference problem I mean
17:19mmarczykyup
17:20joshua-choiYeah, no way I can use trampoline, I think; there's always many functions in between the mutually recursive functions
17:20mmarczykthat doesn't necessarily mean that you can't trampoline
17:21mmarczykas long as you can wrap up all info on how the computation is to continue in a thunk, you can
17:22joshua-choiReally? I'll have to think hard about that
17:22joshua-choiGee, it looks like I won't be done with FnParse 3 for a while again
17:22mmarczykoh, this is about FnParse 3? cool :-)
17:22joshua-choiYes. I'm trying to solve the problem of mutually recursive rules.
17:22mmarczykdo you have a public scratchpad somewhere...?
17:23joshua-choiUp to today it's been solved by var-quoting: #'
17:23mmarczykjust asking cause I'd be curious to have a look
17:23joshua-choiNo, I don't
17:23mmarczykoh well.
17:24joshua-choiVar-quoting isn't adequate, though: it introduces dependencies on mutable objects (the vars), it complicates validation (the vars can't be evaluated until...I don't even understand this part, actually), and it makes it impossible to use in a let form.
17:24technomancyclojurebot: swank-break is http://hugoduncan.org/post/2010/swank_clojure_gets_a_break_with_the_local_environment.xhtml
17:24clojurebotIk begrijp
17:24sexpbot"Hugo Duncan : Swank Clojure gets a Break with the Local Environment"
17:25joshua-choimmarczyk: What's a public scratchpad, by the way?
17:25joshua-choiLike a wiki?
17:27mmarczykjoshua-choi: well, I'm not sure myself :-)
17:27mmarczyka wiki, a set of gists etc.
17:27tcrayfordor just a TODO.txt on github
17:27mmarczykyou've got your 3.alpha.x tags on github
17:27mmarczykso I guess I'll have a look at what you've committed lately
17:27joshua-choiThose aren't updated often. It'd be better to pay attention to my commits
17:27mmarczykright.
17:27joshua-choiYes. I also update a news page on my wiki from time to time
17:28joshua-choiI was waiting for Clojure 1.2 to release so Autodoc could work again, but I think I'll do one more revamp :)
17:28mmarczyk:-)
17:28mmarczykum, sorry, I need to be off for now; bbl
17:29joshua-choiTalk to you later.
17:33joshua-choiQuestion. If a future JVM implements good tail-call optimization, would trampoline become obsolete?
17:45neotykHi *
17:46neotykcan someone explain why if I: (set! *print-length* 1) and than do (str '(1 2 3)) I will get (1 ...) I just can't see where it is happening in str function
17:49_na_ka_na_neotyk: Don't think its in the str function, has to be the print function ..
17:49Borkdudeneotyk: maybe it's not happening in the str function
17:50neotykat REPL than?
17:50neotykbut look: user> (str '(1 2 3))
17:50neotyk"(1 ...)"
17:51neotykI get that one: user> '(1 2 3)
17:51neotyk(1 ...)
17:53Borkdudeneotyk: I see what you mean
17:55neotyk~str
17:55clojurebotdestructuring is http://clojure.org/special_forms#let
17:55neotyksource str
17:56neotykhttp://github.com/tomfaulhaber/clojure/blob/7b4b8e18c0d28e03e7c66f54bc441ef355ceb5ed/src/clj/clojure/core.clj#L401
17:56neotykwhere is this magic cut off happening ?
17:58neotykjust checked that it is not just emacs, normal repl does the same
18:01arohneranyone have experience with clj-cont?
18:02tcrayfordno, but I think I understand continuations
18:02tcrayford(if I was going to use continuations in clojure, I'd probably use the cont-m monad from c.c.monads)
18:02arohnerI think I understand continuations, I'm wondering how reliable clj-cont is compared to say, scheme. Any weird gotchas?
18:03_na_ka_na_neotyk: maybe the .toString method?
18:03tcrayfordno idea on that count then
18:04neotyk_na_ka_na_: but .toString is called on each element of list, not on a list
18:07arkahnneotyk: set! is often used for Java interop - I would think it's setting something in java.lang.String
18:09arkahnneotyk: printf related? I'm probably grasping ...
18:11neotykarkahn: I have no idea, str source doesn't indicate this kind of behavior at all
18:11neotykI'm trying to find usages of *print-length*
18:11arkahnneotyk: nvm, I was wrong. *print-length* is located in core_print.clj in the actual clojure source
18:12LaPingvinoHello hubert :)
18:12LaPingvinoJoop here
18:12neotykLaPingvino: Hello
18:12LaPingvinohow are you?
18:12neotykgoed, en jij
18:12LaPingvinoI am playing a bit with the newest compojure... it did change enough to make me search a lot to get it all running :S
18:13LaPingvinomet mij ook :)
18:13kotarak(doc number?)
18:13clojurebot"([x]); Returns true if x is a Number"
18:13arkahnneotyk: (doc *print-length*) <- have you tried that? Hopefully I'm helping what you're asking.
18:13LaPingvinoyou know how to do a serve-file now?
18:13LaPingvinoI will put the question in #compojure as well :)
18:14kotarak,(some number? [nil nil nil 5 nil nil])
18:14clojurebottrue
18:15kotarak,(some #(and (number? %) %) [nil nil nil 5 nil nil])
18:15clojurebot5
18:15neotykarkahn: yes, though didn't help :(
18:15LaPingvinoneotyk: any idea?
18:15neotykLaPingvino: no idea, I'm serving files via apache
18:16LaPingvinoah okay
18:17arkahnneotyk: the doc on *print-length* looks like it totally explains the behavior. Can you re-state what you're asking?
18:18neotykwhy (str '(1 2 3)) gives "(1 ...)" if (set! *print-length* 1)
18:20arkahnto what I'm understanding, *print-length* set to 1 will only print the first item of a collection, with all remaining items represented by the ellipsis
18:20arkahn,(do (set! *print-length* 1) (str '(1 2 3)))
18:20clojurebotjava.lang.IllegalStateException: Can't change/establish root binding of: *print-length* with set
18:21_na_ka_na_,(let [s (str '(1 2 3)) s1 (binding [*print-length* 1] (str '(1 2 3))) s2 (binding [*print-length* 2] (str '(1 2 3)))] [s s1 s2])
18:21clojurebot["(1 2 3)" "(1 ...)" "(1 2 ...)"]
18:21alexykI get a StackOverflow, and printStackTrace shows a huge block of internal things, like clojure.lang.LazySeq.sval/seq/RT.seq, and none of my files' lines. How do I debug it?
18:21arkahnand then if you set *print-length* to logical false it'll print the whole collection
18:23_na_ka_na_and this will prove that its not just repl printing thats using *print-length* ..
18:23_na_ka_na_,(let [s (str '(1 2 3)) s1 (binding [*print-length* 1] (str '(1 2 3))) s2 (binding [*print-length* 2] (str '(1 2 3)))] [(count s) (count s1) (count s2)])
18:23clojurebot[7 7 9]
18:24alexykcan apply cause StackOverflow?
18:25alexykwith a very long arg list?
18:25tcrayfordI think clojure arg lists fail somewhere around 40
18:25alexyklooks like it
18:25alexykstrangely no source line, apparently it overflown the said stack
18:26tcrayford,(apply + (repeat 100 10))
18:26clojurebot1000
18:26arohnerclojure functions can take an infinite number of arguments
18:26alexykso that's not it
18:26tcrayfordnope
18:26arohneralexyk: my guess is the function being applied has a 'normal' stack overflow
18:27alexykarohner: why would it? is apply nesting?
18:28arohneralexyk: no, I was saying that I doubt apply is causing a stack overflow. it's more likely either the function being applied, or the seq that is passed to apply
18:28alexyk,(apply max (range 1000000))
18:28clojurebot999999
18:29arohneralexyk: apply has been known to cause heap overflows. some kind of head-holding going on in some circumstances
18:29_na_ka_na_neotyk: found anything?
18:29neotyk_na_ka_na_: still nothing
18:30neotykI know that print-method multimethod does this limiting tirck
18:30neotykbut can't find a link between str and print-method
18:31neotyks/tirck/trick/
18:31sexpbotbut can't find a link between str and print-method
18:32arohnerneotyk: the repl prints the return values of expressions
18:32arohnerit's the P in Read Eval Print
18:32neotyk,(binding [*print-length* 1] (str '(1 2)))
18:32clojurebot"(1 ...)"
18:33_na_ka_na_neotyk: yup i'm stuck thr too
18:33_na_ka_na_neotyk: esp. see this ..
18:34_na_ka_na_,(let [s (str '(1 2 3)) s1 (binding [*print-length* 1] (str '(1 2 3))) s2 (binding [*print-length* 2] (str '(1 2 3)))] [(count s) (count s1) (count s2)])
18:34clojurebot[7 7 9]
18:34arohnerneotyk: I don't understand what's wrong with that example
18:34_na_ka_na_arohner: can you see the above example?
18:34neotykarohner: look at source of str
18:35neotykand please do tell why it prints "(1 ...)"
18:35alexyk is there a simple way to find a max of a list without (apply max that-list)?
18:35neotykI think key here is '('
18:37neotykI don't see anything in str source that would make it print '('
18:37arohnerneotyk: ok, now I understand what you mean
18:38_na_ka_na_alexyk: whats wrong with apply max?
18:38neotykI should *not* be saying print, when we talk about str fn
18:38alexyk_na_ka_na_: I'm not sure what causes StackOverflow
18:38_na_ka_na_yup thats why i printed counts
18:39ipostelniklooks like clojure.lang.PersistentList#toString respect *print-length*
18:39_na_ka_na_,(apply max (into [] (range 100000000)))
18:39clojurebotExecution Timed Out
18:39alexykI am thinking of apply; I don't have any recursion, and trace shows LazySeq.sval=>seq=>RT.seq ad infinitum
18:40neotykI think I got it: IPeristentList has it's own .toString that delegate to print-method
18:40_na_ka_na_but its a PersistentList right?
18:40_na_ka_na_,(class '(1 2 3))
18:40clojurebotclojure.lang.PersistentList
18:42remleduff,(RT/printString '(1 2 3))
18:42clojurebotjava.lang.Exception: No such namespace: RT
18:42remleduff,(clojure.lang.RT/printString '(1 2 3))
18:42clojurebot"(1 2 3)"
18:43arkahnI wonder if all/most collection .toString's delegate to print-method
18:43_na_ka_na_it looks that way, but the question is how?
18:43_na_ka_na_can you point out in the source?
18:43remleduffASeq is the abstract base of most of the collections, its toString calls RT.printString which is where the magic happens
18:44_na_ka_na_ya ..
18:44_na_ka_na_,(binding [*print-length* 1] (clojure.lang.RT/printString '(1 2 3)))
18:44clojurebot"(1 ...)"
18:45_na_ka_na_remleduff: but can you point out in the source? i'm unable to see
18:45remleduffYou mean point out the delegation or what does the cut-off?
18:45neotykASeq has toString that calls RT/printString
18:46neotykPersistentList extends ASeq
18:46neotykso in str it is arity 1 case
18:46_na_ka_na_yup it is ..
18:47neotykthough I would have though that is is last case
18:47_na_ka_na_remleduff: i mean point out where exactly the magic is happening in RT.printString
18:48LaPingvinoneotyk: found it :)
18:48neotykit must be calling print-method multimethod
18:48arkahnthat's what I see, too (the print-method multimethod)
18:49_na_ka_na_but the question is how does it reach thr?
18:49arkahnwhat is RT ?
18:50_na_ka_na_its a class in the Clojure java source
18:51alexykthis fragment of a let causes stack overflow: http://paste.pocoo.org/show/215514/ -- why?
18:52neotykRT.printString -> print -> printInnerSeq
18:52neotykand I'm still missing link to print-method
18:52neotykLaPingvino: so how do you serve-file?
18:52alexykI've tried to stick a doall at random. Googling for StackOverflow shows notions of filters closing over locals as culprits; I do have locals in the map's fn. The list it works on is about 300,000 long
18:53_na_ka_na_i see it!
18:54alexyk_na_ka_na_: what is it you see?
18:54_na_ka_na_neotyk: if you are looking the source of clojure.lang.RT/printString .. see the lines ..PR_ON.invoke(x, w);
18:55islondefmethod body has an implicit do?
18:55neotykoh yeah, it even has a comment on top saying "//call multimethod"
18:56islonthanks
18:56_na_ka_na_oh i just glossed all over that comment :(
18:57_na_ka_na_its 2 light
18:57neotykrest of this method is commented out
18:57remleduffAll of the multimethod implementations that get called for the core datastructers are defined in clojure/lang/core_print.clj, specifically the one that looks like (defmethod print-method clojure.lang.ISeq ...)
18:57neotyksyntax highlighting borked
18:57_na_ka_na_nope its not commented out is it?
18:58remleduffI think everything except for the multimethod invocation is just there for bootstrapping/debugging
18:58neotykislon: I did *not* answer your question
18:59_na_ka_na_atleast its not commented out in the main .. //* .. //*/
19:00_na_ka_na_remleduff: can you explain how does in help in bootstrapping/debugging
19:00neotykoh my so evil
19:00neotykit is not commented out
19:00neotyk/* is not multiline comment in java
19:00neotyk///*
19:00neotyk/
19:01neotykthe one in the source
19:01alexykhmm -- I traced the overflow to let: ustats (into {} ustats) where ustats is computed above now as a huge vector. Possible?
19:01islonneotyk, i tested in the repl
19:01remleduffI imagine it just lets rich debug stuff until the actual print-method multimethods get defined by clojure/core_print.clj. Once the pr-on var is defined in core.clj, none of that method gets called except for the very first multimethod invocation.
19:01_na_ka_na_neotyk: well we solved one mystery today .. but the point is that the str docs should say so!
19:03neotyk_na_ka_na_: did we? I still don't get why arity 1 is used
19:03alexykactually, wrong -- a doall on the vector forces overflow
19:03_na_ka_na_remleduff: I see ..
19:03_na_ka_na_neotyk: Oh thats easy
19:04neotykdo tell
19:04_na_ka_na_,(str [1 2 3])
19:04clojurebot"[1 2 3]"
19:04_na_ka_na_[1 2 3] is one object ...
19:04neotyk,(str '(1 2 3) [1 2 3])
19:04_na_ka_na_where as
19:04clojurebot"(1 2 3)[1 2 3]"
19:04_na_ka_na_,(apply str [1 2 3])
19:04clojurebot"123"
19:04_na_ka_na_,(str 1 2 3)
19:04clojurebot"123"
19:05neotykgot it
19:05_na_ka_na_are both same, multiple arity
19:05neotykwe did solve one mystery
19:05_na_ka_na_neotyk: I guess you should notify the developers involved
19:05neotyk_na_ka_na_: that it works?
19:06_na_ka_na_neotyk: that the doc of str should reflect the *print-length* thingy
19:06remleduffHere's a question for you, now that we think we know how the printing works, is ASeq.toString actually being called?
19:07_na_ka_na_thats how it reaches RT.printString right?
19:08_na_ka_na_str -> ASeq.toString -> RT.printString -> print-method -> print-sequential
19:08remleduffI don't think so ;)
19:08_na_ka_na_then?
19:09remleduffclojure.main/repl evaluates your form then calls "print" on it, which by default is the method "prn"
19:09remleduffprn uses the pr-on multimethod
19:10remleduffSorry, pr-on isn't a multimethod, but that calls the print-method multimethod
19:10neotykremleduff: str fn
19:10alexykcan something like let ... stats (assoc :key val) in a nested fn of a long map cause overflow?
19:10_na_ka_na_remleduff: but i'm not even calling the print
19:10remleduffOh, bah! :)
19:11remleduffYeah, you're right
19:11neotykremleduff: arity 1 case
19:11neotykcalles toString on PertistentList
19:11ninjuddalexyk: StackOverflow usually means infinite loop
19:11neotykthat takes impl from ASeq
19:11alexykninjudd: I don't get it on a shorter data
19:11remleduffYeah, didn't realize you were calling str, thought you were just printing it at the repl
19:12alexykI only get it if I add a doall to a map
19:12ninjuddhmm. let me look at your code fragment
19:12_na_ka_na_that's why the docs of str should reflect *print-length*
19:12alexykthe doall there causes overflow
19:12_na_ka_na_can anyone chk in 1.1 ?
19:12alexykhttp://paste.pocoo.org/show/215514/
19:13ninjuddalexyk: is this inside a loop?
19:13arkahn_na_ka_na_: check for what ?
19:14ninjuddor are you using recursion?
19:14remleduffstr docs just say it calls toString, and toString has always been super-loosely defined
19:14alexykninjudd: no, it's a piece of let which explicitly iterates over days. it fails on the very first one
19:14arkahnoh .. yeah
19:15alexykustats is a map with 300,000 structs
19:15remleduffWhenever you call toString in java, you should assume that eventually you're going to run across a programmer who was hungry and just decided to make his class print, "I like pie" ;0
19:16_na_ka_na_neotyk: i guess thats fine then .. but I'm sure there would have been / will be many fellows who'll just find the hard way
19:16arkahnhaving *print-length* affect str is bad - seems like it should be more than documented, it should be changed
19:17arkahnit was fun trying to keep up with you guys, though ... I learned along the way ; )
19:17remleduffWhat do you expect str to do if you do (str (range)) ?
19:17neotykarkahn: I'm fine with it doing so, or at least to have a variant that has this cut off behavior, but docs should reflect it
19:19alexykninjudd: in fact, forget it, it may be above it... am doalling it
19:20alexykI had an init-less reduce which suddenly barfed on count'ing its result
19:20_na_ka_na_,((fn [n] (when (pos? n) (x (dec n)) (nil? nil))) 6280)
19:20clojurebotjava.lang.Exception: Unable to resolve symbol: x in this context
19:20_na_ka_na_blah
19:20remleduffOh, fortunately, LazySeq doesn't delegate
19:21remleduffMaybe ASeq should bind *print-length* to nil before calling printString
19:21ninjuddalexyk: so you figured it out?
19:21alexykor it's a nested remove... man, lazy bastartds are tricky!
19:21alexykninjudd: not yet
19:22alexykmy graphs are huge
19:22ninjuddhehe
19:22_na_ka_na_,(letfn [(x [n] (when (pos? n) (x (dec n)) (nil? nil)))] (x 6280))
19:22clojurebotjava.lang.StackOverflowError
19:22alexykI got more Twitter user than you mormons :)
19:22ninjuddhuh?
19:22alexykninjudd: in your genealogy :)
19:22_na_ka_na_wierd for me 6280 works and 6281 fails
19:23ninjuddoh, we do genealogy way better than the mormons
19:23ninjuddthey're genealogy 1.0
19:23ninjuddplus we don't baptize our users
19:23_na_ka_na_How do I easily figure out at what point my stack will blow off?
19:23alexykI may be dense today, but this seems the line du jour candidate for overflow: (reduce (fn [sums terms] (map + sums terms)) (remove nil? sum-terms)) ; why?
19:24lancepantzwe do tell them they're going to hell if they quit using our site though
19:24alexykdoall'ing remove didn't save it
19:24tomoj_na_ka_na_: why not just stop blowing the stack?
19:24alexykadding [0 0 0] init doesn't save it either. Each element of sum-terms is a tuple of 3 numbers
19:25_na_ka_na_tomoj: well thats ideal :) but say just for fun / knowing it
19:25alexykI simply compute all 3 sums in one pass, for each position
19:25ninjuddlancepantz: isn't that standard practice with all internet companies?
19:25tomojah, I dunno
19:25tomojI think it probably depends on how big the stack frames are
19:25alexykor, will nested (map + sums terms) lazily sit there??
19:26ninjuddalexyk: can you update the code snippet with the reduce?
19:26lancepantzthat's why facebook doesn't let users quit, just trying to protect them from going to hell
19:26tomoje.g. if the functions close over more variables, you'll run out sooner, I'd think?
19:26_na_ka_na_hmm that sounds an idea, i'll quickly test it
19:27_na_ka_na_yup you're right
19:27_na_ka_na_so is there a way to how the size of stack frames?
19:27_na_ka_na_know* the size
19:28alexykyes! that nested (map + sums terms) had to be doall'ed into submission, like 3 mormonic wives who don't use geni.com! :)
19:28remleduffalexyk: Every map returns a LazySeq, so you end up with (+ LazySeq (+ LazySeq (+ LazySeq...)))) in pseudo-stack notation
19:28alexykmap is lazy and dangerous -- my new motto
19:28remleduffnm, you got it
19:29alexykremleduff: thx, too! this was evil and took long on a huge graph to locate
19:29neotykthanks _na_ka_na_ remleduff for helping in figuring str out
19:30remleduffI run into laziness problems with map all the time still
19:30alexyknew Clojure T-shirt: doall
19:30remleduffI mean self-imposed laziness problems
19:30alexykdid you doall your nested map today?
19:31alexykfor every lazy map, there's a doall
19:35islondoes this works: (defn foo [{bar :bar :as stuff}] bar)?
19:36tcrayford,(let [{bar :bar :as stuff} {:bar 1 :foo 2} ] stuff)
19:36clojurebot{:bar 1, :foo 2}
19:37remleduff stuff is extraneous there, but yeah
19:37tcrayfordyeah, but shows that the destructuring works like that
19:37remleduffCould also use (defn [{:keys [bar]}] bar)
19:38remleduffToo many bars
19:38isloni was just asking if :as worked with maps, thanks =)
19:41alexyk"just doall it" <-- my final slogan for today
19:42tcrayfordI need to get a t-shirt with "unqualified lisp chainsaw operator" at some point
19:44remleduff(let [{:keys [a] :syms [b] :strs [c] :as foo} {:a 1 'b 2 "c" 3}] [a b c foo])
19:45remleduff(-> it doall)
19:45mario-goulartHi. I'm trying to execute a clojure script from java. The clojure script access java methods. I'm getting some errors.
19:45mario-goulartHere's what I'm trying: http://paste.lisp.org/display/99436
19:47remleduffWhy do you think (. bar baz a b) should work? What are bar and baz?
19:48mario-goulartremleduff: that's my interpretation from I read at http://clojure.org/java_interop
19:48mario-goulartI'm new to clojure, BTW.
19:48remleduffYou need to add a "bar" parameter to your function in clojure, and then pass "this" when you call the function
19:50remleduffOr, since your Bar class is static, you could actually do (. Bar baz 1 2), but note that this is kind of old style and it's bad because your Bar is in the default package, so I don't think it is doing what you think it's doing.
19:51mario-goulartremleduff: thanks. What'd be the proper way for doing that?
19:51remleduffAlternatively, (Bar/baz 1 2) is the way to do it nowadays. But Bar should really be in a package
19:51remleduffThen it would be (import package.Bar) (Bar/baz 1 2)
19:52MadWombatstupid question, what is a simple method of removing last character from a string?
19:52mario-goulartremleduff: thanks for the tips. I'm gonna try that.
19:54MadWombatchop seems to work, anyone using enlive? is there a way to avoid constructs like (chop (chop (first (:content (first (select item *store-name-selector*))))))
19:54remleduffOr make baz not a static method, and pass an object to invoke named "object" ... (defn foo [object a b] (.baz object a b)). In that case, you'd use the this pointer from java
19:54tcrayford,(reduce str (drop-last "foo"))
19:54clojurebot"fo"
19:54remleduffMadWombat: (apply str (drop-last "Hello"))
19:54mario-goulartremleduff: one more thing: is it a problem is the package Bar loads the clojure script and the script imports Bar? Should I make the Bar package something isolated from the script loader?
19:55mario-goulartproblem if*
19:55MadWombatremleduff: yes, chop from str-utils2 seems to work as well
19:55remleduffWonder if there's a reason to prefer reduce or apply
19:55tcrayfordreduce is often faster
19:55tcrayfordespecially with + (iirc)
19:57remleduffmario-goulart: I don't think so, just don't think that they get any special access to each other because of that
19:57mario-goulartremleduff: right. Thanks.
20:00RaynesJust a bit of an announcement: I've put out a new version of http://www.try-clojure.org/. Thanks to some work by Licenser, def has been allowed. There is an also short, totally incomplete first-cut of a tutorial that I threw up in about an hour. More serious work on that will start tomorrow.
20:00sexpbot"TryClojure"
20:00RaynesGood night, friends. <3
20:01tcrayfordRaynes:
20:01tcrayfordunless you've gone
20:02tcrayfordyou've misplaced a "they're" on that page, should be "their"
20:05ninjuddRaynes: nice! how about an iphone version of the site?
20:05Raynestcrayford: I'll fix that in a moment. I've not gone yet. Feeding my snake.
20:05remleduffRaynes: Is it intentionaly that I can't copy or paste?
20:05Raynesninjudd: I don't have an iphone to test that on.
20:06tcrayfordneat then
20:06Raynesremleduff: It uses jquery-console. There doesn't seem to be a way to allow copypasta.
20:06tcrayfordI added a github issue in case you had gone
20:07Raynestcrayford: Thanks for the catch.
20:07Raynesremleduff: Note that none of the trylanguage sites allow copypasta.
20:07RaynesIt's helpful for learning, but not so much for practicality.
20:07ninjuddRaynes: oh, the source is on github. sweet!
20:08RaynesIndeed.
20:08ninjuddi guess jQuery console is where the work would need to be done to get it working on iphone
20:13Raynestcrayford: Fixed.
20:14tcrayfordRaynes: good to hear
20:14tcrayfordnight all
20:15RaynesNight here as well. <3
20:21RaynesActually, ninjudd: I was just thinking, and it would be possible to somewhere down the line support a more HTML-based REPL or something. Kind of like what I had originally. I can just add another interface over it and call it m.try-clojure.org. :p
20:22tomojwhat, like page reload per form eval'd?
20:22tomojs/re//
20:22sexpbotwhat, like page load per form eval'd?
20:22mario-goulartHmmm. Still no luck: http://paste.lisp.org/display/99436#1
20:22Raynestomoj: If necessary.
20:22Raynestomoj: Whatever it takes.
20:23tcrayfordRaynes: for an iphone app you wouldn't need that
20:24RaynesAnyway, I'll point out that try-clojure has an API in there too. http://www.try-clojure.org/magics?code=urlencodedcode, so anybody could write their own interface around that for whatever they want.
20:24ninjuddRaynes: that would be nice
20:24tcrayford/s/a/at a
20:24RaynesI'd be tickled if someone wrote an IPhone app using try-clojure.
20:25RaynesAnyway, I'm off to sleep. For real this time. ;)
20:25tcrayfordheh
20:25tcrayfordI should go as well
20:25tomojtyping clojure on the iphone sounds painful
20:25ninjuddRaynes: hmm, can't get the API to load
20:25tomojunless the app has some tricked out editing interface
20:25ninjuddRaynes: java.lang.Exception: Unable to resolve symbol: urlencodedcode in this context
20:26tomojwhat would paredit be in multitouch? :D
20:26Raynesninjudd: It tried to execute that code. Try it with actual code, silly.
20:26ninjuddtomoj: wouldn't be as bad with gestures for parens, brackets etc
20:26tomojand completion
20:26ninjuddRaynes: heh
20:30Ploujdoes anyone knelse have problems with readLine in slime/swank/eclipse?
20:31Ploujs/eclipse/emacs/
20:31sexpbotdoes anyone knelse have problems with readLine in slime/swank/emacs?
20:33Plouj:)
20:33Ploujs/knelse/else/
20:33sexpbot:)
20:35Ploujonce readLine is called, i can't get back to the prompt in *slime-repl clojure*
20:38lancepantz:)
20:38lancepantzs/)/(/
20:38sexpbotIncorrectly formatted regular expression: )
20:38ninjuddfoo bar
20:38ninjudds/foo/bar/
20:38sexpbotbar bar
20:38lancepantzs/\)/\(/
20:38sexpbots/foo/bar/
20:38ninjudds/bar/baz/
20:38sexpbots/\)/\(/
20:38lancepantz:)
20:39lancepantzs/\)/\(/
20:39sexpbot:(
20:39ninjuddfoo bar
20:39ninjudds/foo/bar/
20:39sexpbotbar bar
20:39ninjudds/bar/baz/
20:39sexpbots/foo/baz/
20:39lancepantzthat's awesome
20:43remleduffmario-goulart: I think your problem is that class Bar isn't in directory "bar" which java expects for packages. Also, you need to change your main class to "bar.Bar" on your java invocation line.
20:43tomojs.awesome.annoying.
20:43tomojcool, it doesn't pick up on other delimeters :)
20:45remleduffmario-goulart: Also, your foo.clj lost its namespace
20:46mario-goulartremleduff: you mean the (ns user) declaration?
20:46remleduffmario-goulart: Yeah, in the paste at least. That will make RT.var("user", "foo") not find anything
20:48mario-goulartremleduff: Thanks a lot. The directory structure and (ns user) make it work. I can get 6 as output. :-)
20:49remleduffCool, good luck :)
20:49mario-goulartThank you. :-)
20:55MadWombathmm... seems like enlive encodes non-breaking space into some sort of strange character... wonder how to remove it
21:11SynrGwin 18
21:11SynrGbluh
21:20maxhodakis it possible to destructure a list into a list-of-lists?
21:20maxhodaki.e.,
21:21maxhodak("foo" for 1 at 3214 where "bar")
21:21maxhodakinto something like
21:21maxhodak[myvar [[key value]]] ?
21:21maxhodak([for 1] [at 3214] [where "bar"])
21:22tomojI don't think that's possible, but maybe something like this?
21:23dnolen,(partition 2 (for 1 at 3214 where "bar"))
21:23clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args passed to: core$for
21:23tomoj,(for [[k v] (partition 2 '(for 1 at 3214 where "bar"))] [k v])
21:23clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args passed to: core$for
21:23tomojwhoops
21:23dnolen,(partition 2 '(for 1 at 3214 where "bar"))
21:23clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args passed to: core$for
21:23tomoj,3
21:23clojurebot3
21:23tomojweird
21:24tomoj$(for [[k v] (partition 2 '(for 1 at 3214 where "bar"))] [k v])
21:24sexpbotWrong number of args passed to: core$for
21:24dnolen,(partition 2 '(for-blah 1 at 3214 where "bar"))
21:24clojurebot((for-blah 1) (at 3214) (where "bar"))
21:24tomojI'm confused
21:25maxhodakhmm
21:26tomojwhy are sexpbot and clojurebot both broken?
21:26tomoj$(partition 2 '(for 1 at 3214 where "bar"))
21:26sexpbotWrong number of args passed to: core$for
21:27tomojor maybe they're using a different version of partition?
21:27tomoj,(doc partition)
21:27clojurebot"([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items."
21:27tomojlooks ok to me, very strange
21:27tomojLicenser_: ping
21:27maxhodakit works for me in repl so
22:55johnmn3_test
22:56johnmn3how do you do the opposite of (str .. ?
22:56johnmn3like, return the contents of "(pr \"hi\")"
22:56johnmn3though I don't want them evaluated by the reader.
22:56johnmn3which read-string seems to be doing
22:57johnmn3print, maybe
23:00johnmn3no, read-string should work
23:00johnmn3,(let [s (read-string "2")] (pr (str "1 " s)))
23:00clojurebot"1 2"
23:01johnmn3,(let [s (read-string "2")] (pr (+ 1 s)))
23:01clojurebot3
23:01johnmn3rather
23:12johnmn3I'm getting a java.lang.Exception: EOF while reading
23:12dakronejohnmn3: did you close all your parens?
23:12johnmn3last call was clojure.lang.LispReader.read
23:13johnmn3while doing a read-string
23:13johnmn3yea, I did. strangely, it's like read-string is sending the data into a reader
23:14dakronewhat string are you reading?
23:15johnmn3and I'm getting an EOF on the data I'm sending into read-string to send a treemodel the datastructure to be displayed.
23:17johnmn3I mean, read-string is un-stringifying strings pulled from a gui component and feeding them to a clojure.inspector/tree-model, which is in turn sent to a JTree.
23:17dakronedo you know the actual text of the string being passed to read-string?
23:18johnmn3I guess I should verify
23:18johnmn3should be whatever it scrapes from the textarea, like "(println \"hi")"
23:18johnmn3should be whatever it scrapes from the textarea, like "(println \"hi\")"
23:24johnmn3meh, theres got to be a missing parens in my code somewhere
23:24dakroneanyone know why I'm having problems with variable-arity protocols? http://gist.github.com/405912
23:40brweber2If I have a seq and I want to get the items (but not in a seq) what function should I use? ie I want to go from ((+ 2 3) \a) to (+ 2 3) \a
23:40tomojfunctions can't return multiple values
23:41tomoj,(let [[a b] [(+ 2 3) \a]] [a b])
23:41clojurebot[5 \a]
23:42tomoj,(let [s [(+ 2 3) \a]] [(first s) (second s)])
23:42clojurebot[5 \a]
23:42brweber2I just want to "unroll" a sequence. tomoj so de-structuring won't work if I don't know the size of the seq will it?
23:42tomojcorrect
23:42tomojunrolling a sequence of an unknown size doesn't really make any sense
23:43tomojassuming you're not willing to drop some off the end
23:43tomojmaybe just explain what you're actually trying to do
23:44tomojis it a string you want in the end? like (your-fn [(+ 2 3) \a]) == "5 \a" ?
23:45brweber2tomoj no, more like I want to do (list fun-name ... ) in a macro
23:46brweber2but the ... is a lazy seq
23:46brweber2and I just want the values of the seq
23:46tomoj,`(list ~@[(+ 1 2) \a])
23:46clojurebot(clojure.core/list 3 \a)
23:47tomoj,`(list ~@`[(+ 1 2) \a])
23:47clojurebot(clojure.core/list (clojure.core/+ 1 2) \a)
23:48johnmn3,(map read-string '("1" ""))
23:48clojurebotjava.lang.RuntimeException: java.lang.Exception: EOF while reading
23:49johnmn3that's my problem right there
23:49brweber2tomoj thanks!
23:49johnmn3,(map read-string '("1" "2" "hi"))
23:49clojurebot(1 2 hi)
23:50johnmn3,(map read-string '("1" "2" "hi" ""))
23:50clojurebotjava.lang.RuntimeException: java.lang.Exception: EOF while reading
23:50tomoj,(read-string "")
23:50clojurebotjava.lang.RuntimeException: java.lang.Exception: EOF while reading
23:50johnmn3hmm, it's the empty quotes
23:50johnmn3so filter ""
23:53johnmn3,(map read-string (remove #(= "" %) '("1" "" "hi")))
23:53clojurebot(1 hi)
23:54tomoj,(map read-string (remove #{""} '("1" "" "hi")))
23:54clojurebot(1 hi)