#clojure logs

2012-01-19

00:04clj_newbThe answer to this is probably "n00bs should not be doing this"; but anyways: is there a way to ahve a defrecord behave like a function? i.e. I want to be able to do something like (defrecord Foo ...) (def foo (Foo. ...)) ... (foo 1 2 3) <-- now foo is behaving as a function
00:06bobhopeclj_newb, try (defrecord Foo [] IFn (invoke [this a b c] ...code))
00:06bobhopeIFn is the interface for things you can call
00:06clj_newbbobhope: nice; thanks
00:20seancorfieldRaynes: what do you want to know about cat shows?
00:21Raynesseancorfield: Well, I didn't know of their existence. Now I'm interested in the popularity of such events and how many cats your wife has.
00:24gf3is it possible to use (read-string) to read *all* expressions from a string, and not simply the first?
00:24seancorfieldwe've been breeding and showing for about 15 years - my wife's a cat show judge and gets to go all over the world
00:25seancorfieldwe're off to australia in august and then england and russia in september
00:25seancorfieldwe breed Bengal cats - hybrids with an Asian Leopard Cat
00:27seancorfield,(doc read-string)
00:27clojurebot"([s]); Reads one object from the string s"
00:27seancorfield,(apropos "read")
00:27clojurebot(read-line pop-thread-bindings thread-bound? read *read-eval* ...)
00:27seancorfieldhmm, that wasn't much help
00:28seancorfieldRaynes: as for "how many"... quite a few :)
00:28RaynesHuh. Well, I have one cat.
00:28gf3e.g.:
00:28gf3,(read-string "(prn 9) (prn 11)")
00:28clojurebot(prn 9)
00:28RaynesNo clue what breed she is. She lived under our houre.
00:28gf3:(
00:28Rayneshouse*
00:28Raynes&(doc read)
00:28lazybot⇒ "([] [stream] [stream eof-error? eof-value] [stream eof-error? eof-value recursive?]); Reads the next object from stream, which must be an instance of java.io.PushbackReader or some derivee. stream defaults to the current value of *in* ."
00:28Raynesgf3: ^
00:29RaynesYou'll want to create a pushbackreader out of your code and then read from it until it is depleted. This will involve a loop.
00:29RaynesOr recursion, or something.
00:30gf3Raynes: thanks
00:31JanxSpiritthe REPL doesn't do up-arrow history?
00:31RaynesJanxSpirit: The default Clojure repl? No. You want to rlwrap that.
00:31RaynesOr better yet, use Leiningen.
00:31RaynesOr at least reply.
00:31RaynesBut you probably want Leiningen.
00:31JanxSpirityeah I was wondering if Leiningen was the answer
00:32JanxSpiritit's *the way*? :)
00:32JanxSpiritI'll give it a go - how does it compare to SBT?
00:33RaynesLeiningen is our religious text.
00:33RaynesNot sure what 'SBT' is.
00:33JanxSpiritsorry it's the Scala "Simple Build Tool"
00:34JanxSpiritnot that simple though
00:34RaynesOh. Never used Scala.
00:34RaynesLeiningen is pretty simple.
00:34gf3JanxSpirit: http://trac.macports.org/browser/trunk/dports/lang/clojure/files/clj-rlwrap.sh?format=txt
00:34RaynesPlease don't install Clojure stuff via package managers.
00:34RaynesIt's just going to give you a headache in the end.
00:35JanxSpiritpackage managers like RPM or APT and whatnot?
00:35RaynesLike anything.
00:35JanxSpiritI just downloaded and unzipped so far
00:35RaynesInstalling Leiningen via a package manager is an okay way to get it as long as it has the latest version.
00:36RaynesAnd installing Leiningen is generally the equivalent of installing Clojure.
00:36JanxSpiritthanks gf3
00:36gf3np
00:36JanxSpiritOK - gonna install it
00:37JanxSpirithey how do I exit the regular REPL? Feels like the first time I used vi ;)
00:37gf3⌃D
00:37Raynesctrl+d should work.
00:37JanxSpiritcool thanks again
00:39JanxSpiritlein certainly seems straightforward
00:39JanxSpiritI think aptitude would have been slower ;)
00:44seancorfieldwith clojure you don't really need what sbt brings to the table (the watching and compiling) since clojure can be treated like a scripting language and just reloaded when it changes - and it compiles on the fly
00:44JanxSpiritcool - up arrow history achieved
00:44JanxSpiritlein does dependency management too?
00:44seancorfieldwith clojurescript it's worth having a watcher that does compilation (to javascript)
00:44seancorfieldyes, lein handles dependencies - like maven only done right :)
00:45seancorfieldlein can do everything - with a plugin :)
00:45RaynesExcept it actually uses maven behind the scenes.
00:45JanxSpiritbetter than Ivy behind the scenes I think
00:46JanxSpiritSBT uses Ivy
00:46seancorfieldwell, it doesn't really use maven per se, but it can use maven repos
00:46JanxSpiritnice - yeah you need that
00:46JanxSpiritis there a "Clojure central" type repo?
00:46JanxSpiritBTW - I'm sure I can go read about this - just playing around and curious - ignore me all you want :)
00:47seancorfieldclojars.org
00:48seancorfieldlein checks maven central and clojars (and probably a few other places?) and you can tell it to check any other repos you want
00:49Raynesseancorfield: No, I'm pretty sure it uses maven. Maven is implemented as libraries on the backend, which Leiningen uses.
00:49RaynesTurtles all the way down.
00:54amalloyyes, lein bundles itself a copy of maven
00:57seancorfieldi sit corrected Raynes amalloy - i thought it used a different library for that
00:57JanxSpiritmaven has always worked better at dep management than Ivy in my experience
00:57JanxSpiritok Clojars registered
00:57seancorfieldstill, the lein experience is way better than the maven experience
00:57amalloyseancorfield: he'd like it to
00:57JanxSpiritlooks good
00:57JanxSpiritseancorfield: good ;)
00:57JanxSpiritwhat is lein telling me to do:
00:58seancorfieldthat's the downside of maintaining a contrib library - those use maven directly
00:58JanxSpiritUsing JLine for console I/O; install rlwrap for optimum experience.
00:58seancorfieldit's saying the UX is better if you have rlwrap installed and on your path
00:59seancorfieldJLine is a fallback
00:59JanxSpiritdig
00:59seancorfield:)
00:59RaynesJLine is going to be removed as a fallback in 2.0, IIRC.
00:59seancorfieldgood to know
00:59vreskcinwriting a blog post now on my re-purposing of noir-blog to build an an editable website for my dad's website on his book.
01:00vreskcinhttp://qftk.herokuapp.com
01:01vreskcinto get to the backend: http://qftk.herokuapp.com/admin
01:02gf3JLine was really bad last I tried it
01:02vreskcinusername guest password guest
01:02JanxSpiritis compojure the go-to REST framework?
01:02vreskcinit's not pretty, but it got the job done
01:03vreskcinJLine gets the job done too ;)
01:04gf3JanxSpirit: Noir (based on compojure) is nice
01:05brehautJanxSpirit: theres a few different REST specific libs around (not that i can remember the names off the top of my head) but i dont think any one would be described as 'go to'
01:05mrevilim using noir for that purpose
01:05brehautcompojure, moustache and noir are all entirely capable for doing REST APIs easily
01:06vreskcinmrevil: for restful framework, or to make a regular site, like the one I made?
01:07gf3JanxSpirit: be sure to check out Hiccup and CSSGEN
01:11seancorfieldi'm biased but i'll vote for fw/1 :)
01:11seancorfieldi need to port the routes logic across to clojure before it's really good for REST
01:12Raynesseancorfield: I've been meaning to ask you, since I'm not using google in protest of SOPA, why would one use FW/1? Or anything based on something from Coldfusion, for that matter.
01:13seancorfieldit's been around for over two years, in production, hundreds of users on the mailing list, about 10,000 downloads
01:14seancorfieldsome parts of the clojure version are cleaner / simpler than the cfml version, some not as much
01:14JanxSpirithttp://stopsoap.com/
01:14seancorfieldand i prefer CFML - to include the free open source engines - rather than just ColdFusion which is Adobe's proprietary offering
01:15seancorfield:)
01:17seancorfieldi'm trying to figure out how to use domina (from clojurescript:one) in another project... i thought i could just drop the lib folder into my project... and it seems to compile a :use or :require ok... but none of my cljs code works once i do that :(
01:18seancorfieldi'm using lein-cljsbuild for compilation
01:22vreskcinyea, I thought that the selenium-like features in clojurescript one was pretty neat
01:26seancorfieldvreskcin: yeah, cljs1 looks very impressive but i'd be happier if it was modular and could easily be used with other code
01:28vreskcinwell, there was some inhibitions about letting it be a framework. Maybe they weren't completely confident it was the best workflow
01:29vreskcinand cljs doesn't do runtime compilation right? because then the compiler would have to be loaded in the browser...
01:31vreskcinI wonder how difficult it would be a worthwhile experiment to try though.
01:31seancorfieldthere's a cljs repl tho'...
01:32vreskcinright, I just thought it'd be need to have a repl and IDE in my browser.
01:32seancorfieldhmm, maybe i just put the domina stuff in the wrong folder... i just moved my own dom functions to a new ns and was able to use that
01:32seancorfieldvreskcin: have you watched the cljs1 video?
01:33seancorfieldit's impressive - shows working with a live app in the browser, from a repl using cljs
01:33kwertiiAre there any interesting solutions for managing the evolution over time of a relational database schema with Clojure?
01:34clj_newb(1) go to http://paste.lisp.org/display/127163 (2) this is a minimal test case trying to make a defrecord behave like a function. Why does it fail?
01:34seancorfieldkwertii: lobos?
01:34seancorfieldit does migrations
01:34vreskcinseancorfield: Yup. It's pretty neat. I mean an actual repl/ide and the cljs environment all in the browser.
01:35clj_newbWizards of Clojure-land; I call upon thee. Slay this dragon: http://paste.lisp.org/display/127163 .
01:35kwertiiseancorfield: looking at Lobos, not sure what it does beyond providing a thin S-expression mapping over the SQL commands
01:35vreskcinI suppose you could hook up a web ide/repl to talk back to the java repl, which in turn points back to the browser
01:35brehautclj_newb: what dragon?
01:35seancorfieldvreskcin: well, you need two windows regardles - one for the app, one for the repl - so why does it matter that one of them is in the browser and one in your ide?
01:36clj_newbbrehaut: http://paste.lisp.org/display/127163 <-- why does this defrecord not behave like a function?
01:36kwertiiseancorfield: there's also drift, and clj-liquibase
01:36seancorfieldkwertii: hmm, then i'm not sure what you're looking for
01:37JanxSpiritkwertii: not clojure but in my relational days I used liquibase - uses XML to manage schema changes
01:37brehautclj_newb: looks like your method signature for invoke is wrong
01:37kwertiiseancorfield: ideally, I wouldn't have to maintain a huge chain of migrations. I'd just have a schema definition, and the lib could inspect the database state and figure out itself what needs to be done to make the DB look like the schema, warning about destructive actions..
01:38JanxSpirit+1
01:38brehautclj_newb: (invoke [this args] …)
01:38emezeskeHmm, is there any simple way to truncate a string? All I can come up with is (take n "thestring"), but that doesn't return a string
01:38clj_newbbrehaut: testing
01:38clj_newbbrehaut: it worked
01:38clj_newbbrehaut: can you explain to me: ... why can't I have the & like in normal functions?
01:38Raynesemezeske: ##(apply str (take 3 "abcdefg"))
01:38clj_newbthis baffles me
01:38lazybot⇒ "abc"
01:39emezeskeRaynes: Thanks. It seems like Clojure's string manip libraries are fairly... lacking
01:39RaynesProtocols compile to interfaces.
01:39kwertiiJanxSpirit: looking at clj-liquibase now. getting nightmarish flashbacks of J2EE and XML config files that are longer than the code
01:39brehautclj_newb: because the interface for ifn has an object array as its argument. var args are a myth in java. clojure is able to maintain that myth, but when you step down to the interop level you have to deal with it yourself
01:39Raynesemezeske: That's because you can treat strings like sequences. Also, clojure.string.
01:40Rayneshttp://clojure.github.com/clojure/clojure.string-api.html
01:40clj_newbbrehaut , Raynes : noted, thanks.
01:40vreskcinseancorfield: because it would be neat. Imagine being able to go to any given site and open a repl in it. have access to the running javascript through cljs
01:40brehautclj_newb: actually. i think i lied about the object array.
01:40brehautclj_newb: thats a related but different issue
01:40clj_newbbrehaut: from testing; it seems like I have to specify the # of args
01:40emezeskeRaynes: Yeah, clojure.string is really piddly
01:40clj_newbi.e. if my defrecord says invoke [this a]; I can't call it with 5 args
01:40clj_newbhowever; this does not bother me; I accept it
01:40Raynesemezeske: What isn't there that you wish were there?
01:40brehautclj_newb: off course: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/IFn.java
01:41emezeskeRaynes: Compare your truncate solution with Python, e.g. "abcdef"[:3]
01:41RaynesThat's a syntactical trick.
01:41emezeskeRaynes: For instance, all of the trim functions don't accept a "what to trim" arg
01:41clj_newbbrehaut: hmm; nice ot see they can go up to 20 args
01:41emezeskeRaynes: Most string libs accept that
01:42RaynesAlso, I understand my solution -- the python one makes no sense to me.
01:42emezeskeRaynes: Sure, a very very convenient trick.
01:42emezeskeRaynes: Well, then, that's because you don't know Python :P
01:42RaynesConvenient and disgusting.
01:42clj_newbhere's the notion
01:42RaynesI was writing Python 4 days ago.
01:42clj_newbif you like syntax, go perl
01:42RaynesI actually used that syntax, but I don't know what the colon means.
01:42clj_newbclojure, iirc, != perl :-)
01:42brehaut,(subs "abcdef" 3)
01:42emezeskeRegardless of using a syntactical trick, things like that come up often enough that one would think the main string manip library would help
01:42clojurebot"def"
01:43RaynesIt looks to me like that syntax is overloaded to do a thousand different things.
01:43seancorfield,(doc subs)
01:43clojurebot"([s start] [s start end]); Returns the substring of s beginning at start inclusive, and ending at end (defaults to length of string), exclusive."
01:43emezeske,(subs "abcdef" 0 3)
01:43clojurebot"abc"
01:43seancorfieldbeat me to it :)
01:43emezeskeThere we go! thank you brehaut, seancorfield
01:44seancorfield,(defn truncate [s n] (subs s 0 n))
01:44clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
01:44emezeskeI'm glad there's a non-ridiculous way to do it
01:44brehaut(.substring "abcdef" 0 3)
01:44seancorfieldSANBOX?
01:44RaynesI don't see how my example was ridiculus.
01:44brehautthats pretty nonrediculous
01:45RaynesStrings are seqable -- using seq functions with them is perfectly acceptable.
01:45emezeskeAcceptable != fun
01:45seancorfield,(let [truncate #(subs %1 0 %2)] (truncate "some string" 4))
01:45clojurebot"some"
01:46emezeskeI've come to expect a certain set of basic string operations that are available in every language ever
01:46emezeskeThankfully, clojure does have "subs", which is one of them
01:46RaynesActually, Java has subs.
01:46Raynessubs is just a wrapper.
01:46seancorfieldand there's always the underlying Java String stuff
01:46brehautand clojure.string
01:46emezeskeSure, sure, but (subs ...) is prettier than (.substring)
01:47brehautpersonally im willing to loose a few 'simple' string ops if i can have nice parser combinators
01:47emezeskeI care 0% about how it's implemented
01:47emezeskeI just don't want to have to implement it myself if it already exists.
01:47brehauts/loose/lose/
01:47seancorfieldjava exists *zen* :)
01:47Raynesemezeske: Anyways, Java Strings are immutable so anything http://docs.oracle.com/javase/6/docs/api/java/lang/String.html is fine to use from Clojure.
01:48RaynesIf you don't mind typing a dot.
01:48RaynesOr two. :)
01:48brehautRaynes: my keyboard has a tax on dot characters
01:48brehautthats why i love semicolons and lisp so much
01:48seancorfieldsemicolons? *spit* :)
01:49brehautseancorfield: semicolons for english ;)
01:49gf3bah, is it possible to use try/catch with loop/recur where recur is in the tail position?
01:49gf3sans-finally
01:50seancorfieldyou can't recur across try/catch, eh?
01:51gf3across?
01:52seancorfieldright, you can't have recur inside try/catch in 1.3.0
01:52seancorfieldthe ticket that changed the behavior explains why... i read it once and went "oh yeah that makes sense" but can't remember now
01:53gf3you don't have a link, do you?
01:53gf3(btw, thx seancorfield)
01:56seancorfieldi'll see if i can find it
01:58seancorfieldthis is one ticket http://dev.clojure.org/jira/browse/CLJ-31 (but it's not very informative)
02:00seancorfieldso there may have been a mailing list discussion around it too...
02:01gf3seancorfield: thank you
02:06gf3seancorfield: do you know if there is a idiomatic solution to this issue? I'm sure it's quite common when interfacing with Java
02:19gf3or anyone? ↑
02:19seancorfieldthe try/catch issue? i'm not even quite sure where it comes up...
02:20amalloygf3: what is your broken code shaped like?
02:21gf3amalloy: https://gist.github.com/c3e80e85e2072962c8d6
02:22gf3amalloy: reading a stream until the EOF exception is thrown
02:23amalloygfredericks: well (a), you can't do that because recur is supposed to be a simple "jump" instruction, but here in order to recur you have to teardown the try/catch context
02:23seancorfieldso only the (read r) can throw an exception?
02:24amalloybut (b) this is really better as a lazy-seq anyway
02:24gf3seancorfield
02:24gf3yes
02:24amalloyoh, and (c) you should be asking read to not throw an exception, then you don't have this issue at all
02:24seancorfieldalso your initial (read r) could throw an exception
02:25gf3amalloy: ahh perhaps I have missed it, is there a way to convert a stream to a lazy seq?
02:25gf3seancorfield: true enough
02:25amalloywell, yes, but my point is instead of loop/recur you would probably be happier using lazyseq
02:26amalloy&(doc read)
02:26lazybot⇒ "([] [stream] [stream eof-error? eof-value] [stream eof-error? eof-value recursive?]); Reads the next object from stream, which must be an instance of java.io.PushbackReader or some derivee. stream defaults to the current value of *in* ."
02:27amalloyset eof-error to false, and just wait for the sentinel value
02:30gf3amalloy: awesome, thank you
02:30amalloythat said, this has been implemented a lot of times already
02:31gf3amalloy: is there something better I should be using/doing?
02:31amalloywell, i thought it was in clojail so i was going to point you there, but apparently not
02:32gf3amalloy: I'm actually using this with clojail
02:32amalloyright, but you could use clojail's impl, either by depending or copy/paste
02:33amalloyhere's one of the implementations i've written: https://gist.github.com/1638602
02:35gf3thank you
02:40vreskcinhttp://sexp.posterous.com/another-clojure-noir-site-on-heroku
02:51tavis`how do I get lazybot to give me a list of its available commands?
02:53seancorfieldmostly it just evaluates clojure code...
02:53seancorfieldtavis`: i guess you could go look at the source on github?
02:54tavis`ok, thanks. I'm doing that now already.
02:54seancorfieldg'nite
02:55amalloythe wiki has a not-very-complete list of commands, but if you search the source for defplugin you'll at least see which ones are available (they're not all enabled on the lazybot in here)
02:56tavis`ah, no wonder I couldn't find the right docs - mistook it for clojurebot
03:38Blktgood morning everyone
03:39gf3good morning
03:39gunthahello
03:42gensymmoinsen
03:43mduerksenmoin :)
04:12tufflaxHm, what's the reason that :test is in the metadata of a fn, but pre and postconditions are not? Aren't those the same kind of thing?
04:39emezeskeAnyone else having issues pushing jars to clojars?
04:39clgvemezeske: in general or via the lein plugin?
04:40emezeskeclgv: in general
04:40emezeskeclgv: my scp command seems to be hanging
04:41clgvemezeske: you got you public ssh-key added overthere?
04:41emezeskeclgv: yeah, I have pushed a number of jars before (including just about an hour ago)
04:42clgvemezeske: oh ok. maybe temporary service failure then. I got nothing to try it here.
04:42emezeskeclgv: thanks anyway!
04:42emezeskeclgv: yeah, I ran scp -vvv and it's authenticating, but the command it's exec'ing is hanging
04:42emezeskedoes appear to be a clojars problem
04:43clgvI see your clojurescript stuff was the last.
04:44emezeskehah, maybe I broke it ^_^
04:49clgvbad boy ;)
04:50lpetithi there
04:52clgvlpetit: hey. hows your favorite project coming along?
04:53lpetithey. Quite good. I see 2012 being a veery good year for CCW develoment
04:54lpetitclgv: Sorry, but I don't remember who's behind clgv nickname?
04:54clgvthats good to hear.
04:54clgvlpetit: no one famous ;)
04:54lpetitclgv: c'mon !
04:55clgvjust a ccw user that took the chance to ask you how ccw is getting along
04:56lpetitclgv: thanks for asking, then
04:57clgvlpetit: the funny thing is that I checked on ccw status minutes before you showed up here.
04:57lpetitclgv: a 0.6.0 beta will be released today
04:57clgvlpetit: oh nice.
04:58clgvlpetit: what are the big changes?
04:58clgvs/big/mayor/
04:59lpetitclgv: there http://code.google.com/p/counterclockwise/issues/list?q=label:next
05:01clgvlpetit: ah mostly bugfixes. and the one cemerick submitted for me :)
05:02lpetitclgv: bug fixes, use of Clojure 1.3 internally, steps towards simplification of ccw hacking/building, smart paste in string literals when in editor strict mode (paste a bunch of XML content, get the double quotes automatically escaped), automatically send repl content if cursor at the end of the repl input editor, *and* its content is well formed clojure
05:04clgvlpetit: I would love to be able to use the repl view standalone in my project (keyword: gui repl) some time. as far as cemerick told me thats not easily possible right now
05:04lpetitclgv: ?
05:06clgvlpetit: I mean including it for usage in my running application outside of eclipse. last time I mentioned that to cemerick I was told that could be difficult to modularity issues. is that wrong?
05:06clgv*due to
05:08lpetitclgv: for one, your app should be using the SWT graphic library. And also, the REPL view in its current form is indeed very tied to the Eclipse framework: ViewParts, etc.
05:08lpetitclgv: so Chas was right.
05:09clgvlpetit: ok. using SWT was obvious. so I would need to build an Eclipse RCP project to be able to use it?
05:10lpetitclgv: to say the least
05:11clgvlpetit: ok, so we can agree on it's still not easy? ;)
05:11lpetitclgv: yes, as I said ^^^, Chas was right, and it's not easy right now
05:11lpetitclgv: :/
05:13clgvlpetit: ah one thing about the repl view history - I can step through it backwards - but is it searchable with prefix-strings like the linux bash with page-up/-down=
05:13lpetitclgv: not yet, nope
05:14lpetitclgv: what was the bug you reported to Chas, you're waiting for correction of ?
05:15clgvlpetit: that one "Unwanted linebreak inserted when typing ' in default editing mode" which seems included in 0.6.0
05:15lpetitclgv: yeah, this was is very annoying.
05:19clgvlpetit: I love the syntax highlighting in repl view. I always miss that when running my jars remotely within rlwrap...
05:20lpetitclgv: you know you can have a repl view point to any server on any port. (and with the help of some ssh tunneling, not compromising security altogether) ?
05:20lpetitclgv: of course, you'll need the nrepl server started somehow in your remote jvm
05:21clgvlpetit: humm, is there some information on the ssh tunneling part?
05:22lpetitclgv: that part is really just plain old ssh tunneling, nothing specific to us. I must admit I don't have to use it so I don't know the details, but my bet is it's dead easy once you know the ssh command options
05:22clgvlpetit: ah ok. so gotta check the ssh docs. thanks for that hint
05:23lpetitclgv: basically, you use ssh on a linux/mac terminal, or the equivalent with putty on Windows, to create the tunnel, and then instead of trying to connect to the remote server, you connect to the specific port on localhost which will be bound to the remote port on the server
05:25lpetitclgv: plus, the beta I'll soon release (when I stop chatting ;) ) will include nrepl hyperlinks: you just put text like nrepl://127.0.0.1:9032 (or whatever) in your clojure source file, and then when hovering onto it with the Ctrl/Cmd key pressed, you're a click away from having a REPL View opening and trying to connect via this url
05:26clgvlpetit: cool
05:26raekssh -L 1234:some.host:4568 will cause the remote side to connect to some.host:4568 whenever someone connects to localhost:1234 on the local side (and the data will be tunneled)
05:26clgvraek: thx. gotta paste that in my notes.
05:27raeksorry, "ssh -L 1234:some.host:4568 remote.host"
05:27lpetitraek: thanks
05:36clj_newbI realize this question is off topic; but I'm asking it since I respect people here's opinions: has anyone found a decent GTD style app for the ipad? I want something simple (i.e. like vim, clojure) rather than feature-full, like omnifocus/things
06:11wiseenis there a nicer way to write (or (instance? Foo x) (instance? Bar x) (instance? Blah x)) ?
06:17lucianwilfredh: i think (any (partial instance? x) [Foo Bar Blah]), but i'm not sure
06:19wiseenlucian, #(instance? % x) instead of (partial instance x) ? cool tnx.
06:19lucianor that. i'm not even sure clojure has any, really :)
06:20lpetit,(let [x "yo"] (some #(instance? % x) [Integer String Long])
06:21clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
06:21lpetit,(let [x "yo"] (some #(instance? % x) [Integer String Long]))
06:21clojurebottrue
06:21lpetit,(let [x "yo"] (some #(instance? % x) [Integer Long]))
06:21clojurebotnil
06:21lucianlpetit: ah, so it's called some
06:22lpetitbe aware that some returns the result of the predicate, not the element for which the predicate worked
06:22lpetitif you want the former, you'll need (first (filter ...))
06:23LeNsTRHello guys! Can you explain me why this code does work without stack overflow? http://pastie.org/3212832
06:28lucianLeNsTR: because it's lazy, pretty much
06:28wiseenLeNsTR, because it's not recursive or lazy-seq ?
06:29wiseenLeNsTR, replace line 4 with (cons a (lazy-seq (fib-seq b (+' a b))))))
06:30wiseen*tail recursive
06:31LeNsTRI'm bit confused, because function calls yourself without 'recur'
06:32lucianLeNsTR: with lazy-cons, fib-seq isn't actually recursive
06:32lucianif you think about it, when you ask for 2, it gets called twice
06:32lucianit doesn't keep recurring
06:33lucianso there aren't any nested calls
06:34wiseenit uses a closure instead of the stack ?
06:39LeNsTRah! lazy-seq calling internal clojure.lang.LazySeq which takes the body
06:39LeNsTRand working without tail calls
06:41LeNsTRthank you for the explanation
06:44LeNsTRs/tail calls/recursion
07:05lpetitclgv: still there ?
07:15phaoHey, does clojure support continuations?
07:18lpetitphao: no
07:27clgvlpetit: now again
07:28lpetitclgv: would you have the opportunity to beta test the future version 0.6.0 ? In that case I can send you the update site for the betas versions I've just created
07:30clgvlpetit: I can have a look at it in my free time: tonight or this weekend. at work it's "stable only" ;)
07:31lpetitclgv: okay, so no hurry, I'll make an announce on the mailing list in a few hours
08:23lpetithttp://groups.google.com/group/clojure/browse_thread/thread/8cb9162117c62621
08:23lpetitAwesome! @thinkrelevance sponsorship for #Counterclockwise development! Many thx to @muness , @redinger et al. #Clojure
08:24clgvlpetit: wow. great! that'll speed up development I guess =)
08:24Licenserlpetit :D :D :D
08:24lpetitHope so, that the whole point ! :-D
08:51chouserlpetit: amazing! congrats!
08:52lpetitchouser: thanks
08:59cemericklpetit: same, congratulations :-)
08:59lpetitcemerick: :-D
09:05lpetitBeta version of Counterclockwise sent in the wild: http://ccw.cgrand.net/updatesite-betas/
10:41BorkdudeIs there something like arrow up to get the last expression in CounterClockWise?
10:45TimMcTry M-p (maybe it will work)
10:45TimMcBorkdude: If all else fails, check the keybindings in Eclipse's preferences
10:47cemerickBorkdude: Ctrl- or Alt-up, usually
10:47cemerick*unless* you're on OS X and use spaces, in which case spaces is eating that keystroke; the workaround is to either change the keybindings for spaces, or the keybinding for previous REPL command.
10:47Borkdudeah Cmd-up on my Mac, tnx :)
11:15BorkdudeWhat is the way to create an interactive application in Eclipse+CCW ? read / readline doesn't work, maybe create a JFrame + txtfield?
11:27cemerickBorkdude: what sort of inputs are you expecting?
11:27Borkdudecemerick: I'm just brainstorming about an exercise I can let students do, like programming tic tac toe for exaple
11:27Borkdudeexample
11:28cemerickJOptionPane/showInputDialog is probably as low-ceremony as you can get
11:30Borkdudecemerick: ah, that is usable
11:30Borkdude:-)
11:31BorkdudeI can skip the entire GUI this way
11:37BorkdudeWhat is the "best" way to concat two vectors? Using into or concat?
11:38llasramDepends on why you want to concatenate them...
11:40TimMcBorkdude: Do you want a lazy seq or a vector of the first type as your result?
11:41BorkdudeTimMc: I actually didn't think about it. I am putting together some slides on clojure datastructues like lists and vectors and how to manipulate them
11:44Null-AIs there something I can call that will return java.lang.Integer? (class (int 3)) ?
11:44Null-Ainstead of java.lang.Long
11:44Null-AI tried .getClass
11:44gfredericksNull-A: does the symbol java.lang.Integer not work for you?
11:44Borkdude,(type 1)
11:44clojurebotjava.lang.Long
11:44Borkdudehmm
11:44Null-A,(type (int 1))
11:44clojurebotjava.lang.Long
11:44TimMcNull-A: ##(class (Integer. 5))
11:44lazybot⇒ java.lang.Integer
11:45Null-Aah I see I need to box it
11:45Borkdudeis this different in clojure 1.3? in my 1.2 repl I get an Integer
11:45Null-Agfredericks: it's a convenience thing, my code will be less verbose ,i'm writing a DSL
11:45Null-Ayes Borkdude
11:45TimMcBorkdude: Yeah.
11:45TimMcIt's one of the breaking changes.
11:45Null-Athanks TimMc
11:45tufflaxWhat's the reason that :test is in the metadata of a fn, but pre and postconditions are not? Aren't those the same kind of thing?
11:46TimMctufflax: :pre and :post are actually part of the function proper -- they affect how it runs
11:46tufflaxoh
11:46tufflaxi see
11:48tufflaxthanks
12:49technomancyTimMc: that doesn't preclude using metadata though
12:50TimMchrm?
12:51technomancyI mean the function could check its own metadata and run :pre/:post from there
12:51gfredericksis there some kind of guidelines/heuristics about what metadata is for? I know for data structures it's supposed to not effect the equality semantics, but that doesn't really apply to functions does it?
12:53TimMctechnomancy: :pre and :post don't work as literals -- they need some macro assistance
12:53TimMc% and all
12:53technomancyoh yeah; that makes sense.
12:54iceyAnyone here use elastic beanstalk as their production environment? Or evaluated it and disliked it strongly for some reason?
13:19lpetittechnomancy: starting next thursday, I'll start work on lein support in CCW. At first, only support for automatically updating project's class path settings from project.clj. As seen with Chas, I intend to use leiningen-core to do so.
13:19lpetittechnomancy: just to keep you informed.
13:20technomancylpetit: great; I will definitely be interested in feedback on how that works out for you
13:20lpetittechnomancy: I for sure will give you feedback as I go
13:21technomancythat will only give compatibility for lein 2.x though, so I guess we better press on and have a usable release soon. =)
13:22_carlos_hi!
13:23lpetittechnomancy: yeah. Anyway there's no support for lein1 in CCW, so that is not an issue.
13:25lpetitwhy do I always think about ANTLR when LeNsTR enters/quits the room ? :)
13:25technomancythere will be a large level of compatibility between 1.x and 2.x anyway; mostly it's :dev-dependencies getting ignored that people will notice
13:27_carlos_it is beyond me why removing some parentheses from: "(import '(java.util Calendar TimeZone)) (. (. (Calendar/getInstance) (getTimeZone)) (getDisplayName))" is not possible
13:28lpetittechnomancy: I'll use leiningen-core only for CCW's needs, independently of what leon version the user is expecting.
13:28antares_technomancy: :dev-dependencies will be completely ignored? or only in some cases (like dev dependencies of dependencies)
13:28lpetitMust go, see you
13:29LeNsTRlpetit: sure, why? :D
13:29_carlos_I would take parentheses from: (Calendar/getInstance), (getTimeZone), and (getDisplayName) . it seems that, if I use the form at the top level, I can remove them though
13:29Bronsa,(.. (java.util.Calendar/getInstance) getTimeZone getDisplayName)
13:29clojurebot"Pacific Standard Time"
13:30Bronsaor even
13:30Bronsa,(.. java.util.Calendar getInstance getTimeZone getDisplayName)
13:30clojurebot"Pacific Standard Time"
13:31_carlos_Bronsa: ha! I was going to get to the .. part in the next page. anyways, it still doesn't anwser the question, why is it calling from inside other macros change the parentheses requirements?
13:32TimMcOh man, I totally forgot about ..
13:34Bronsa,(. (. (java.util.Calendar/getInstance) getTimeZone) getDisplayName)
13:34clojurebot"Pacific Standard Time"
13:34Bronsayou can avoid parenthesis here too
13:34_carlos_Bronsa: please forget this issue I am still having. I think maybe I misunderstood something. I will investigate further
13:35Bronsanp :)
13:35technomancy.. is deprecated in favour of ->
13:36technomancyantares_: :dev-dependencies will be deprecated in favour of profiles, which are much more flexible
13:36antares_technomancy: ok
13:37technomancyit's explained under "Profiles" but I should probably add a more concrete example involving dev-deps: https://github.com/technomancy/leiningen/blob/master/README.md
13:39_carlos_technomancy: yeah! good idea -> "->"
13:46cemericktechnomancy: Just to clarify re: lein-core, it should be v1 and v2 capable as long as we're not attempting to run any tasks right?
13:46cemerickI think all we need for a first cut is :deps and :repos.
13:46technomancycemerick: it will read :deps and :repos from project.clj files; sure.
13:46cemerick(really not much more than (read-string (slurp "project.clj"))
13:46cemerickok
13:46technomancypeople just might expect it to honor :dev-deps too
13:47cemerickwell, I (and I think lpetit as well) am happy enough to let ccw drive lein2 adoption ;-)
13:47technomancyworks for me =)
13:47technomancy:plugins is backported to lein 1.7.0 anyway
13:51_carlos_technomancy: wouldn't ".." be deprecated in favor of "->>" instead of "->"? I was just building the previous using that macro: http://pastebin.com/DGZ48PEQ
13:52dnolen_carlos_: ->> is for operating on sequences
13:52TimMcwhat
13:52TimMc&(doc ->>)
13:52lazybot⇒ "Macro ([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."
13:52tmciverI think either would work in this case.
13:53TimMc_carlos_: If you're dealing with a bunch of nllary Java methods, it doesn't matter which you use.
13:53TimMc*nullary
13:53tmciverbecause the second and last form are one in the same here.
13:54llasram_carlos_: The difference is that `->' threads the forms as the first argument to each subsequent form, while `->>' threads as the last. So interop foo usually requires `->' and sequence functions `->>'
13:54_carlos_TimMc: "nullary"? what does it mean such a fashionable term?
13:56TimMc_carlos_: nullary = 0 args, unary = 1 arg, binary = 2 args...
13:56_carlos_thanks dnolen, llasram, TimMc
13:57TimMc-> is specifically used in interop when you keep calling methods on the return value of the previous calls
13:57joegalloisn't .. better for that?
13:58TimMcjoegallo: -> is the replacement for .., apparently
13:58TimMc&(doc ..)
13:58lazybot⇒ "Macro ([x form] [x form & more]); form => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first member on the first argument, followed by the next member on the result, etc. For instance: (.. System (getProperties) (get ... https://refheap.com/paste/356
13:58joegallohuh, today-i-learned
13:58_carlos_TimMc: so I guess "->" is more generic since it applies both for nullary and non-nullary methods in interop, making it therefore more idiomatic
13:59TimMc_carlos_: .. can be used for n-ary methods
13:59technomancy-> is preferred because it works for functions as well as interop
13:59TimMc-> applies to both methods and function...
13:59TimMcyeah, sniped
14:01cemerick.. remains handy for static method calls
14:02TimMcHow so?
14:04TimMc&(-> 10 Integer. (Integer/toString 16))
14:04lazybot⇒ "a"
14:04technomancyhttp://lispcabinet.sourceforge.net/ o_O
14:05TimMcsweet
14:05TimMcSomeone try it out.
14:05technomancyis this a reasonable thing to point windows users to?
14:06technomancyincluding a bunch of CLs and racket seems weird
14:07lrennbest way to remove the first, and only the first occurance of something in a sec?
14:09technomancyplus now we have yet another clojurescript redistributor.
14:11llasramlrenn: Not sure that's a super-common case. You can probably work something up using `split-with', but you're probably better off doing a recursive function with `lazy-seq' (unless `split-with' is actually what you need)
14:11llasramtechnomancy: Oh, who?
14:12technomancyllasram: this lisp cabinet thing appears to redistribute clojurescript
14:12llasramOh, nm. Didn't noticed it was included in "Lisp Cabinet"
14:12llasramContext!
14:12raeklrenn: one way is to roll your own lazy seq: (defn without-first [item coll] (lazy-seq (when (seq coll) (if (= (first coll) item) (rest coll) (cons item (without-first item (rest coll)))))
14:12lrennllasram: yeah, that's what i was doing, but seemed...wrong. Simple case really, person has a hand of cards, message comes in to play one, now i need to remove it from their hand.
14:13technomancya guy on the leiningen mailing list apparently finds it very useful
14:13technomancyexcept for the fact that the bundled lein wasn't honoring his swank version
14:13llasramI should subscribe to that newsletter...
14:13raeklrenn: if there can be no duplicates, consider using a set instead
14:13lrennraek: there can be duplicates :)
14:14joegallo,(let [[a b] (split-with (partial not= 5) (range 0 50))] (concat a (rest b)))
14:14clojurebot(0 1 2 3 4 ...)
14:14joegallo(let [[a b] (split-with (partial not= 3) (range 0 5))] (concat a (rest b)))
14:15joegallo,(let [[a b] (split-with (partial not= 3) (range 0 5))] (concat a (rest b)))
14:15clojurebot(0 1 2 4)
14:15joegallostill seems gross, though
14:15technomancy(let [found? (atom false)] (remove #(or @found? (and (= % thingy) (swap! found? not))) my-seq))
14:15technomancyoh, that's not any shorter; boo
14:15llasramAnd walks the whole seq. And uses mutable state! Heretic!
14:16TimMcEh, the atom doesn't escape.
14:16llasramEvery time you use an atom, rhickey kills a kitten
14:17TimMcWhat's wrong with atoms?
14:17technomancyif a tree falls in the forest, &c
14:17llasramNothing -- I'm just punchy :-)
14:17amalloyi prefer to think that happens when you could use an atom but use a ref instead because you're too lazy to work it all into a swap!
14:18amalloy&(let [[xs [y & ys]] (split-with (complement #{3}) (range 0 5))] `(~@xs ~@ys))
14:18lazybot⇒ (0 1 2 4)
14:18joegalloooh, nice work with the y & ys
14:18joegalloclever
14:19technomancyamalloy has lots of practice golfing from 4clojure =)
14:19amalloywell, i don't think using complement made it shorter
14:19technomancy(comp not x) is shorter by chars but not tokens
14:34VinzentHello. I wonder why when-let can take only one binding\test pair. It cause me to write nested when-let\let
14:35amalloybasically: it's not obvious what additional bindings would do. test them all, or not? either is reasonable, but either could lead to some confusion if you expect the other
14:36amalloyand if it bothers you, it takes just two minutes to write your own when-let that behaves the way you want
14:36llasramVinzent: If you want something like a flattened version of nesting multiple when-lets, check out maybe-m in algo.monads
14:38Vinzenthm, I thought it's natural to expect that all bindings would be tested (lazily, with and).
14:38Vinzentllasram, thanks, I'll check it
14:39Vinzentamalloy, I'm afraid my own when-let version would just make more confusion in future
14:40amalloyVinzent: https://gist.github.com/1642108, for what it's worth
14:42llasramOooh. I like the use of `reduce' instead of making the macro explicitly recursive
14:42amalloyllasram: i have to imagine the clojure.core versions would have done that, except that reduce isn't available when they're defined
14:44llasramSeems plausible. Def has some nice properties
14:45Vinzentthe other way is https://gist.github.com/1642131
14:48Vinzentbut anyway, I don't think it's a good idea to write your own generic macros, cause it leads to many different, incompatible "helper" libs written by nearly every programmer
14:49amalloyVinzent: your macro actually is wrong in a number of ways
14:49llasramVinzent: 100% disagreed. As long as the language has good namespace support, what's the problem?
14:50Vinzentso e.g. if someone wants to contribute to your open source project, he have to learn your helper lib first (although, maybe it's not a big deal in this particular case, cause "when-lets" is pretty self-explaining)
14:51Vinzentamalloy, can you please explain what's exactly is wrong?
14:51Chousukeif you do when-lets often then it makes sense to provide one
14:51amalloyVinzent: would he rather slog through a five-line macro and three one-line use-cases, or three five-line use-cases?
14:51amalloyeg, try (when-lets [x nil, y (.length x)] y)
14:51amalloyor (when-lets [[x & xs] (seq coll), y (count xs)] y)
14:53Vinzentamalloy, ah, right, I haven't thought about that not only body, but bindings too must not be evaluated when something is falsey (in my case inner let was just for some helper function)
14:54magnarsLooking for idiomatic clojure: I would like to replace parts of a string, calculated from the match. Let me try to explain: (re-replace "123" #"\d" #(+ 1 %)) => "234" ... I'm rather new to clojure, and I don't want to brute force out a solution. What would be an idiomatic way of attacking this problem?
14:54amalloymy point, and i'm sorta tired of making it so this is the last you'll hear from me, is that if you choose not to create abstractions because other people might not write them, you're stuck writing to the lowest basic level that the language comes with. the same argument applies to functions as well as macros, but you don't hear someone saying "oh, i won't write a function for this; i'll just write its body all over the place". the whole point
14:54Vinzentamalloy, well, this three five-line use-cases would be clear and perfectly readable, aren't they?
14:55hiredmanamalloy: who are you talking to?
14:55amalloyhiredman: Vinzent mostly
14:56hiredmanah
14:56emezeskeVinzent: so with the macro, it'd be 8 lines total, and without, 15 lines total?
14:56emezeskeVinzent: I believe several studies have shown that bugs are extremely well correlated with number of lines of code
14:57emezeskeVinzent: like, regardless of language, tools, etc, less lines of code just means less bugs in general
14:58Vinzentamalloy, I think that you should not create abstraction only to reduce number of lines e.g. from 5 to 3. Sometimes it's better to have a little longer code, but the one which consist of familiar, standard constructions
14:58amalloyright. every time you write those five lines you have to get them right. and the person reading it has to make sure all the details match up without (for example) off-by-one errors. that's one reason sequence operations are much less error-prone than the java: for (i = 0; i < foo.size(); i++) {doStuff(foo.get(i));}
14:59Vinzentemezeske, I think what actually matters is not number of lines, but number of concepts, complexity of the code, etc
14:59emezeskeVinzent: yep, but you're wrong. I know it's not intuitive. I'll try to dig up some of the papers.
15:00emezeskeVinzent: I think this blog post points at the paper I'm thinking of: http://blog.vivekhaldar.com/post/10669678292/size-is-the-best-predictor-of-code-quality
15:00hiredmanit should ne intuitive to anyone with experience coding
15:00sritchiehey all, is it possible to proxy a protocol, not just an interface?
15:00amalloysritchie: reify, not proxy
15:00hiredmanprotocols actually generate an interface of the same name
15:01hiredmanbut yes, you should prefer reify
15:01sritchieI've got to proxy an existing class, unfortunately
15:01hiredmanalso there is a definterface
15:01hiredmanthat looks sort of like defprotocol
15:02sritchielike this: https://gist.github.com/1642241
15:02hiredmanproxy may try and proxy the generated interface for the protocol, which will have mangled names
15:03hiredmanso if the above doesn't work try changing the protocol to have java legal names for the methods
15:03sritchieah, got it
15:04magnarsAny pointers at all in trying to get to (re-replace "A1 B2 C3" #"\d" inc) => "A2 B3 C4" ? Any way of getting it nice? Whenever I start out with re-find or re-matcher I end up with some rather unpleasant code. :-/
15:04amalloyye cannae inc a character
15:05hiredmanwell
15:05amalloy(or a string. parse/cast it to an int instead)
15:05Vinzentemezeske, a little silly example: (fn [very-self-explanatory-name] \newline ...) is 2 times more lines than #(...), but it's better in many cases. Or very smart, short and "hacky" function might be worse than longer, but more obvious and simple one. Let me read your link...
15:07sritchiehiredman: this is interesting, it looks like I can't proxy an interface and a protocol together
15:07emezeskeVinzent: I'm not advocating playing code golf all the time. But if a simple abstraction can decrease the total lines, that's a good thing, even if it forces you to use a language feature you are not yet comfortable with.
15:07sritchieImplementing class
15:07sritchie [Thrown class java.lang.IncompatibleClassChangeError]
15:07magnarsI'm basically looking for some way of doing (.replace "haystack" "needle" "replacement") but with a function in place of the replacement, that can decide per match what to replace with. Increasing a char is the least of my problems. :-)
15:07sritchiethat happens if I list the protocol first; listing the class first compiles fine, but none of the protocol methods work
15:07amalloymagnars: clojure.string/replace does that already. increasing a char is your only problem
15:08cemericksritchie: gist?
15:08hiredmansritchie: maybe try definterface
15:08sritchiecemerick: sure, one sec
15:08magnarsamalloy: that is most excellent, thank you. Just the answer I was looking for. :-)
15:08hiredmanor, actually, try the.ns.name.TheProtocol instead of just TheProtocol
15:11sritchiehiredman: that's what I was doing
15:11sritchieI'm definitely misunderstanding something, as I can't seem to come up with a good proxy example:
15:11sritchie(proxy [java.util.HashMap] [] (toString [_] "I am."))
15:12sritchieis that valid?
15:12sritchieI'm getting Wrong number of args (1) passed to: user$eval1796$fn
15:12cemericksritchie: proxy method bodies have an implicit `this`
15:12cemerick,(str (proxy [java.util.HashMap] [] (toString [] "I am.")))
15:12clojurebot"I am."
15:12Vinzentemezeske, come on, I'm comfortable with macros :) I'm just afraid that such approach can lead to something we can see in Common Lisp now: many different external libs providing basic, core functionality (of course it's caused also by a number of reasons unrelated to our discussion), which is very uncomfortable for those who want to learn the language, because they have to learn this libs in addition to the language library
15:13cemericksritchie: i.e. "old world" style :-)
15:13sritchieaha! unhygienic!
15:13emezeskeVinzent: c'est la lisp :)
15:14Vinzentemezeske, hah, yeah :) but it doesn't have to be as complex as CL is
15:16emezeskeVinzent: maybe text-editor support for macroexpand would help with that? if you really don't want to remember what some crazy macro does, tell your editor to just always show it expanded (maybe in a special color to indicate this)
15:16sritchiecemerick: https://gist.github.com/1642325
15:16sritchiehiredman: here's the error, where ordering within proxy is important (on Clojure 1.3.0)
15:16emezeskeVinzent: but I do agree with you in the sense that macros can be arbitrarily hard to understand
15:18hiredmansritchie: oh, well that is the same as classes and interfaces, the class has to go before the interfaces
15:18hiredman(and infact user.Connected is the interface generated by your defprotocol)
15:18sritchieah, okay, got it
15:19hiredmanConnected is a var with some special stuff to make it a protocol, but user.Connected bypasses the resolution via *ns*
15:19cemericksritchie: what hiredman says; class first is in the proxy doc FWIW ;-)
15:20amalloyneither of those is a concrete class though, right? i mean, obviously Object is, but i thought it was a special exception and "treated" like an interface by proxy/reify
15:21Vinzentemezeske, actually I'm talking about this stuff in general, not particulary about macros
15:22hiredmanamalloy: for reify, sure
15:22cemerickI never quite grokked that; sorting the classname vector as needed is easy enough.
15:22cemerick,(sort-by #(.isInterface %) [java.util.List Object])
15:22clojurebot(java.lang.Object java.util.List)
15:22cemerickanyway
15:23hiredman,(proxy [clojure.lang.AFn Object] [] (toString [] "Foo"))
15:23clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.IncompatibleClassChangeError: Implementing class>
15:23hiredman,(proxy [clojure.lang.AFn] [] (toString [] "Foo"))
15:23clojurebot#<AFn$0 Foo>
15:24sritchieI can only get everything passing by using camelCase in my defprotocol
15:24hiredmanright
15:24sritchieis_connected [Thrown class java.lang.UnsupportedOperationException], for example
15:24hiredmanyou are not actually using the protocol
15:24sritchieyeah, the interface it generates
15:24sritchiebut shouldn't is_connected be legal?
15:25Vinzentemezeske, so the point is that sometimes it's better to write more lines of code and make less abstractions if it makes code more clear and improves readabilty
15:25hiredmanhard to say
15:26noidihas anyone else had problems in emacs with winner-mode and slime?
15:26Raynes$google winner-mode emacs
15:27lazybot[EmacsWiki: Winner Mode] http://www.emacswiki.org/emacs/WinnerMode
15:27emezeskeVinzent: we may have to just disagree on that point. :)
15:27RaynesHuh. Never heard of that one.
15:27noidifor some reason winner-undo doesn't properly undo the changes that slime commands (such as slime-compile-and-load-file) make to the window configuration
15:28sritchiehiredman: it'd be interesting to wrap existing interfaces in corresponding protocols
15:28noidiI suspect the problem isn't even in winner-mode but it's a bug in slime
15:28sritchiethen you could extend the generated protocol and be effectively extending the interface, right?
15:28llasramOh, god, SLIME's window-destruction is awful
15:28sritchie(extend-type MyType GeneratedProtocol (mirroredMethod1 …))
15:28noidibecause pressing 'q' in the windows that it pops up doesn't restore the window configuration either
15:28sritchieand all calls to the protocol would pass directly through
15:29noidillasram, have you experienced this problem as well?
15:29Vinzentemezeske, oh, sure. It may be just my lack of experience.
15:30llasramnoidi: Not the particular problem, but just that the SLIME windows don't obey normal emacs temp buffer rules (or use the standard functions). I've got a bunch of advice defined to make them act more like I want
15:30llasramI'll put them in a paste -- might provide a starting place for you to tweak the behavior to the way you want it
15:31noidillasram, appreciated!
15:31hiredmansritchie: I think you could write a similar macro on top of multimethods pretty easily, I don't see much benefit for it
15:31noidicurrently every time I compile a file my window configuration is messed up, essentially forcing me to only use a single window when working on clojure code
15:32hiredmanwell, I dunno
15:32llasramnoidi: https://refheap.com/paste/357
15:32sritchiehiredman: I've got a database type that I want to be able to extend to a number of Thrift server interfaces
15:32hiredmansritchie: but protocols are not interfaces
15:32noidillasram, thank you!
15:34sritchiehiredman: you'd have to generate both a wrapping protocol and a function that took an instance of the type you were extending and returned a reified instance of the interface
15:34hiredmansritchie: :(
15:34hiredmanyou can't reify types, only interfaces and protocols
15:35hiredmanand proxy is much slower than reify
15:35sritchie(defn wrapper [some-type] (reify SomeInterface (methodOne [this x] (protocolMethodOne this x)) …))
15:36sritchieso the wrapper reifies the interface, and all calls pass through to the generated protocol
15:36sritchiewhich the type has extended
15:36hiredmansritchie: you don't use some-type there
15:36sritchiewhoops, sorry: (defn wrapper [some-type] (reify SomeInterface (methodOne [this x] (protocolMethodOne some-type x)) …))
15:37sritchiehere's where this comes into play: https://github.com/nathanmarz/elephantdb/blob/develop/src/clj/elephantdb/keyval/core.clj#L111
15:37hiredmanwhy not just extend th protocol to some-type?
15:37sritchiethis is meant to be a trick for letting the type extend an interface
15:38hiredmanbut it doesn't
15:38hiredmansometype still doesn't extend the interface
15:38hiredmanit just generates a wrapper that does
15:38hiredmanwhich is meh
15:38sritchiesorry, from the beginning -- I'm thinking of a macro that takes an interface and generates a complementary protocol in addition to this wrapper function
15:39sritchieyeah, it still sucks, but check out what I have to do currently
15:39sritchieall the functionality at the bottom is shared: https://github.com/nathanmarz/elephantdb/blob/develop/src/clj/elephantdb/keyval/core.clj#L111
15:39sritchiegetStatus, update, etc
15:39sritchiethe idea is for users to be able to extend the database type to something, and create a function like kv-service for them
15:40sritchieto get rid of all of this pass-through boilerplate
15:40hiredmandatabase should be a type, it should be a protocol
15:41sritchieshould or shouldn't be a type?
15:41hiredmanshouldn't be
15:41sritchiehere's where I define it
15:41sritchiehttps://github.com/nathanmarz/elephantdb/blob/develop/src/clj/elephantdb/common/database.clj#L96
15:41hiredman:(
15:42hiredmanif it's a tpye you control you should have the interface inline
15:42hiredman(deftype Foo [] ISomething (doSomething [...] ...)) etc
15:43sritchiethis is meant to be a library others can use to write their own databases
15:43hiredmanreifying a wrapper of an interface over a deftype is horrible
15:43hiredmansritchie: right, so provide protocols and interfaces they can extend with their own types
15:43hiredmandon't provide types
15:45hiredmantypes are not an extension point, multimethods, protocols, and interfaces are
15:45sritchiethat makes sense,
15:46sritchiehmm, I was using a type so I could provide implementations for most things
15:46hiredmanyou can provide default via functions
15:47sritchiehttps://github.com/nathanmarz/elephantdb/blob/develop/src/clj/elephantdb/common/domain.clj#L269
15:47sritchieI see
15:47sritchieso for something like this type,
15:47sritchiewell, this one actually might make sense as a type, since everything about a domain is generic
15:48sritchiethanks for the the advice here, btw, this is my first big dive into records & protocols
15:49hiredmansure
15:49hiredmandon't provide types (as an extension point)
15:50sritchiehiredman: I still don't see how to avoid a whole set of repeated methods like isUpdating, isFullyLoaded, etc -- these are all part of the thrift interface, but since I can't do
15:50sritchie(extend MyType SomeInterface {:isUpdating (fn ….)})
15:51sritchiewith a map of implementations, I'm not sure how to go about supplying such a big set of defaults
15:51sritchiedefault interface implementation
15:51sritchies
15:54hiredmansritchie: there are a few possiblities
15:57sritchiethis one uses the lein-newnew project, it's pretty cool
15:58hiredmanit actually would be fairly easy to (def thrift-impl '(SomeInterface (method [...] ...))) and have a macro ontop of deftype or defrecord that would be able to pull those in
15:59sritchiehiredman: that sounds like a good lead
15:59sritchierather than building my proxy business, build a macro like "extend" that can build these thrift interfaces
16:00sritchieletting the user construct his own type
16:00sritchiethat's good, I see what you mean
16:01hiredmanit is unfortunate that macros aren't more composable
16:02romain_pHi everyone, quick question (clojure, linux): why does (slurp "/proc/cpuinfo") fail on my machine ?
16:02bhenryhey guys. who can provide a less roundabout way of this https://gist.github.com/663d0d5cdf150b7be3d5
16:03bhenryneed to turn integers of seconds into date objects
16:04hiredman,(java.sql.Timestamp. 10000)
16:04hiredmanuh
16:04clojurebot#<Timestamp 1969-12-31 16:00:10.0>
16:04hiredmanthat is horrible, why don't you just pass them to the Date constructor?
16:04hiredman,(Date. (* 100 100))
16:04clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: Date, compiling:(NO_SOURCE_PATH:0)>
16:04hiredman,(java.util.Date. (* 100 100))
16:04clojurebot#<Date Wed Dec 31 16:00:10 PST 1969>
16:05hiredman,(supers java.sql.Timestamp) ;for grins
16:05clojurebot#{java.util.Date java.io.Serializable java.lang.Comparable java.lang.Cloneable java.lang.Object}
16:05romain_p,(slurp "/proc/cpuinfo")
16:05clojurebot#<AccessControlException java.security.AccessControlException: access denied (java.io.FilePermission /proc/cpuinfo read)>
16:06romain_pOn my machine, this fails with an IOException ("invalid argument")
16:06gtrak`&(slurp "/proc/cpuinfo")
16:06lazybotjava.security.AccessControlException: access denied (java.io.FilePermission /proc/cpuinfo read)
16:06hiredmanyou are doing it wrong
16:07VinzentWhy (meta ^{:a "1"} []) works, since (meta ^{:a "1"} 'x) returns nil?
16:08Vinzentah, got it
16:08gtrak`Vinzent: curious, what's the answer?
16:08Vinzenthm, no, not got it
16:09gtrak`i think you have to use with-meta to add metadata
16:11amalloy^ is for reader metadata, which mostly is consumed by the compiler. if you want metadata on your runtime values, use with-meta
16:11amalloy&(meta ' ^{:a "1"} x) probably works, but is still wrong
16:11lazybot⇒ {:a "1"}
16:13gtrak`so the reader macro is only for constants really?
16:14amalloyi think that's an accurate statement, but no guarantees
16:14Vinzentgtrak`, I use it just to have nice syntax in my macro, like (defentity foo [^:flag x y]), and wonder why such syntax not working in the repl
16:14Vinzentamalloy, hm, thank you
16:17narsilouHi, there do you think with clojurescript and compojure someone could build a website that is either entirely server-side, or entirely client-side or anywhere in-between (meaning part of the functions are runned by the server, the rest by the client through javascript) with the samecodebase ?
16:18brehautnarsilou: have you looked at clojurescript one yet?
16:19narsilouYes I have.
16:19emezeskenarsilou: lein-cljsbuild has some provisions for sharing code between clj and cljs
16:20emezeskenarsilou: You have to be careful in code that's used in both environments, though
16:20pjstadig~suddenly
16:20clojurebotBOT FIGHT!!!!!111
16:20pjstadigwut?!
16:20pjstadig~suddenly
16:20clojurebotCLABANGO!
16:21emezeskenarsilou: But if you keep I/O-type stuff out of the shared code, and keep it as pure as possible, I think you could have a great deal of code work either on the client or server
16:23narsilouThx for lein-cljsbuild, but actually I was thinking at having only clj files, with a macro like (client `(do (cool stuff) ~(server stuff))) and it would automatically compile js (the ~stuff being ran by the server), and serve it.
16:24narsilouOf course this leaves out I/O which stays on the server
16:24narsilouAnd DOM manipulation should stay at the client too
16:24emezeskeAh, I see. If you are going down that road, you will want to aggressively memoize your cljs compilation, it is not fast.
16:25narsilouYep, I actually have a test stuff (to freshen up my clojure)
16:25narsilouCaching the js is OK
16:25narsilouBut I am still wondering if it could be more than a pet project
16:25emezeskeI originally went that direction, but I'm working on a google appengine project, and the cljs compiler requires temporary files (which GAE does not allow)
16:26emezeskeSo I had to switch to doing all cljs compilation up front
16:26hiredmanhugod: from the reflector?
16:26narsilouYep I'm using tmp files too.
16:26hugodhiredman: yes, via core/load
16:26hiredman:(
16:27narsilouDo you actually know why cljsc requires a file ?
16:27hiredmanhugod: there is a thread on the mailing list about it, maybe chime in (let clojure/core feel your pain)
16:27emezeskenarsilou: I think it builds the basic JS on-disk, and then passes the JS files to the google closure optimizer as its inputs
16:27emezeskenarsilou: But don't quote me on that
16:27hiredmanhugod: or even look over the issue in jira
16:28hugodhiredman: I had been sort of following the issue, but now I have first hand experience...
16:28cemerickThe last time I looked at it, the gclosure compiler API wasn't super-friendly
16:28cemerickThey really want you to just use the command-line entry point.
16:29hiredmanhugod: it is pretty lame
16:29narsilouOw probably it. This sucks.
16:31narsilouemezeske: Anyway, do you have some code for when you tried ? It took me a lot of time to realise `(fn ~(something)) was what I wanted for client/server mixed behavior)
16:32emezeskenarsilou: I might be able to dig it up. It was a hairy nightmare, particularly when you needed to access cljs namespaces from the code
16:33semperoslet's say I have several `deftest` forms which I want to define in a macro, because I need to execute the same set of tests with different application contexts
16:33narsilouOw, yes, namespaces might be a problem
16:33semperosif I just do `(deftest ~'name-of-test ...), then names collide and only one set of tests is run
16:34hiredmanyou can put (is ...) forms in regular functions and call them inside a deftest
16:34technomancyoh, beat me to it
16:34hiredmanor just use doseq or something
16:34technomancyyeah, do what hiredman said
16:34semperosalrighty
16:34narsilouBut doesn't cljsc handles namespaces ?
16:34hiredman(doseq [test-data some-test-data] (is (do-stuff test-data)))
16:34hiredmanetc
16:35emezeskenarsilou: The (ns ...) form HAS to be the first form the compiler encounters in a compilation unit
16:35semperoshiredman: thanks, I'll go that route
16:35TimMcnarsilou: Not exactly.
16:35emezeskenarsilou: So your code has to aggregate things into the (ns) form and make sure to prepend that to whatever code you're slinging at it
16:36narsilouMeaning cljs can't import for other cljs ? They have to be standalone ?
16:37emezeskenarsilou: They can import.
16:37TimMcromain_p: Read slurp's doc -- it needs a file or stream or something, not the name of a file.
16:37emezeskenarsilou: It's just really, really tricky to do at runtime like you're proposing
16:38narsilouTricky and possible, or tricky and probably impossible ?
16:38TimMcromain_p: Cancel that, it should take a string...
16:38simonadameithi
16:38simonadameitregarding build tools, is cake or leiningen the thing to use?
16:38TimMcsimonadameit: Lein
16:38narsilouLein
16:39TimMcCake dev has stopped, the devs are contributing to leiningen now.
16:39simonadameitah ok, thats good!
16:39simonadameitleiningen is so slow in startup… :(
16:39TimMcThat's the JVM.
16:39simonadameityes, but on the cake site it says they have solved that problem
16:39TimMcsimonadameit: Are you on 64-bit Linux by any chance?
16:39technomancysimonadameit: two things: use a client JVM and try the interactive task.
16:39cemerickhopefully we can get jark to solve the startup issue permanently
16:40technomancyyeah I saw jark had some activity yesterday
16:40simonadameitTimMc: 64bit macosx
16:41TimMcsimonadameit: Does java -version show "Server VM"?
16:41technomancyI have no idea how to get a client JVM on a mac =(
16:41technomancyif someone figures it out please document it on the wiki
16:41cemericktechnomancy: I think they're blocking on me a bit at this point :-/
16:41technomancycemerick: blocking nrepl work?
16:42simonadameiti have a server jvm
16:42TimMcYeah, those apparently have slow startup.
16:42cemericktechnomancy: no, repl work is blocking jark (maybe).
16:42cemerickThat'll not be the case in a couple of days.
16:42technomancyoic
16:45romain_pTimMc: I am told that it is because a DataInputStream cannot be created for a /proc file. Now why would slurp need a DataInputStream when it just returns a String (without any parsing AFAIK)... ?
16:47TimMcromain_p: I get a different error: IOException Invalid argument java.io.FileInputStream.available (FileInputStream.java:-2)
16:48TimMcromain_p: But this works fine: (with-open [f (java.io.FileReader. "/proc/cpuinfo")] (slurp f))
16:48romain_pTimMc: ah, thanks for the tip !
16:49TimMcBut that does seem like a bug.
16:49emezeskenarsilou: Tricky and possible, I think.
16:49technomancysimonadameit: actually try "export LEIN_JVM_OPTS=-XX:+TieredCompilation"
16:49romain_pTimMc: well I can always paste the code on the clojure bug tracker if I can find it
16:50technomancythat may get you client-jvm-level startup times without having to hunt down a new JVM
16:50emezeskenarsilou: But I had to dip way down into the compiler code to do it; you have to largely reimplement the 'build' function yourself
16:50technomancywhat build of hotspot do macs ship with anyway?
16:51technomancyI think you need at least 20
16:51theignoratithe 32bit version is client
16:51brehauttechnomancy: java version "1.6.0_29" \n Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11M3527) \n Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
16:52brehauttechnomancy: thats whatever lion has out of the box
16:52technomancyis lion the latest?
16:52brehauttechnomancy: yes
16:52clojurebotCool story bro.
16:53brehauttechnomancy: i think you can download a non-apple openjdk that is newer?
16:53technomancybrehaut: can you tell if exporting that LEIN_JVM_OPTS var speeds up "time lein versin"?
16:54brehauttechnomancy: is there an example in the readme or something?
16:54brehautoh. its above
16:54technomancybrehaut: it's built-in to bin/lein in 1.7.0-SNAPSHOT and 2.0.0-SNAPSHOT; I just found out about it 2 days ago
16:55brehautok, i'll get myself up to date and run that for you
16:55tavis`you can also do export LEIN_JAVA_CMD=<path-to-32-bit-java> once you have it installed. That allows you to run lein's commands in 32 bit while still using the 64bit jvm for anything lein launches as a subproc
16:55technomancybrehaut: no need to update
16:55technomancyif you export that env var it works in older versions
16:55brehautoh right
16:56technomancytavis`: yeah, but from what I can tell it's hard to find 32-bit binaries
16:56tavis`http://stackoverflow.com/questions/6942063/how-to-run-32-bit-java-on-mac-osx-10-7-lion
16:56technomancyaha
16:56tavis`looks like -d32 does it
16:57brehauttechnomancy: prior to export … its ~1.2 seconds total
16:57brehauttechnomancy: after, its ~0.95
16:58brehautwait, im reading the wrong column
16:58raekwow. 3.8 secs before and 1.0 secs after!
16:59brehaut1.6 before, 1.9 after
16:59technomancyo_O
17:00raekthis one goes straight to my ~/.path_and_stuff file
17:01semperostechnomancy: going back to putting (is) forms in functions and using (doseq) to run through them multiple times, would your robert-hooke be a good replacement for (use-fixture :each) support?
17:01semperosotherwise you do lose the clojure.test fixture support, if you're not running defining all test cases in individual deftest's
17:01narsilouemezke: Do cljs devs know about this ?
17:02technomancysemperos: I don't recommend using hooke to extend functions you control
17:02semperosthat's true
17:02technomancyI'd just call the defn from three separate deftests if you need :each fixtures
17:03semperosdon't think I understand what you mean
17:04semperosin my specific case, I have global instances of web browsers I'm controlling from Clojure
17:04semperosfor performance reasons, I don't open/close the browser instance each time, so instead, I use an :each fixture to bring my test application back to the same URL
17:04semperosfor the beginning of each deftest
17:05technomancy(defn my-check [x] (is (good? x))) (deftest check-ff (my-check :firefox)) (deftest check-chromium (my-check :chromium)) (deftest check-w3m (my-check :w3m))
17:07TimMctechnomancy: I don't know how to read the output of time, but "real" goes down slightly on average, and "user" goes up by 50%.
17:07semperostechnomancy: going one step further: https://gist.github.com/1643192
17:07semperosbetween calls to my-check and another-check within a single deftest, I need to ensure that the browser is back to the same URL
17:08semperosnot seeing how that works without, now, adding that to the beginning of each function; not end of world, just looking to keep things DRY-ish
17:09technomancyTimMc: cool
17:10technomancysemperos: ok, maybe that won't work then
17:11semperoscool, just wanted to make sure I wasn't missing something obvious
17:11tavis`can anyone see any issues with this patch to defmethod I'd like to propose https://gist.github.com/1643214
17:12tavis`it adds metadata so swank and other tools can find the source location of entry in (methods a-multifn) without resorting to hacks
17:13hiredmantavis`: doesn't seem very useful
17:13hiredmanI guess it could be
17:13tavis`slime-who-specializes
17:13hiredmanright
17:13technomancytavis`: interesting; there's all this CL functionality just waiting to be wired up =)
17:13hiredmanI was thinking you couldn't use it for M-.
17:13tavis`I implemented that in swank-clojure last night but had to resort to an ugly hack
17:14hiredmantavis`: how ugly?
17:14llasramsemperos: remember that functions are data too: https://gist.github.com/1643212
17:14tavis`regexes
17:14hiredmantavis`: you might be able to pull that info from the fn's class
17:14semperosllasram: there we go, that's the simple tactic I was missing
17:15semperosthanks
17:15tavis`I went fishing for it there, but couldn't see it
17:16hiredmanhmm, yeah, too bad Class doesn't expose that info, because it is definitely there
17:17hiredmantavis`: if you call some method on the function badly you'll get an exception you call pull that information from
17:18simonadameittechnomancy: again thanks, for looking into it
17:18simonadameittechnomancy: I now found the magic option to make jvm startup super fast :)
17:18tavis`hiredman: not sure I understand
17:18simonadameitunfortunately it doesnt seem to work...
17:19tavis`hiredman: oh, I see what you mean
17:19hiredman,(apply (fn [x y z] x) (map (fn [_] (throw (Exception.))) (range 5)))
17:19clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.Exception>
17:19hiredman,(take 3 (.getStacktrace (apply (fn [x y z] x) (map (fn [_] (throw (Exception.))) (range 5)))))
17:19clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.Exception>
17:19hiredmanbleh
17:20hiredmanOh
17:20hiredmanAFn has a public thorwArity method
17:20hiredmanPerfect
17:20hiredman,(.throwArity (fn [] ) 1)
17:20clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox$eval87$fn>
17:22tavis`(.throwArity (:cdt (methods swank.core.debugger-backends/debugger-exception?)) 1)
17:22hiredmansomething like that
17:22tavis`the stacktrace doesn't show the source
17:24tavis`(.throwArity identity 1) doesn't either
17:24simonadameittechnomancy: -d32 does improve it somewhat though...
17:25tavis`hiredman: anyway, I figured adding the metadata would be the most straightforward longterm
17:25hiredmantravis`: if you are doing this at the slime repl you need to call getCause
17:27tavis`even then I'm just seeing some reflection and eval
17:27hiredmanOh, of course, it just shows you clojure.lang.AFn as the classname
17:28hiredman(because thats where the code that throws the exception is from)
17:28hiredmantoo bad
17:28tavis`right
17:30tavis`hiredman: the only way I could trace the method back to the source was via its name
17:30hiredman:/
17:31tavis`hence the regex hack
17:32chojeendoes the map function interfere with dynamic binding somehow, e.g. http://pastebin.com/iBPyiW2C
17:33hiredman~map
17:33clojurebotmap and the other sequence functions used to be lazy, but with the advent of chunked sequences, may or may not be lazy, consult your local ouija board
17:33hiredman~map
17:33clojurebotmap is laziness
17:33hiredman~map
17:33clojurebotmap is *LAZY*
17:34chojeenokay...
17:38Rayneschojeen: Laziness means that nothing is evaluated until you use it. If you use map to map over a dynamically rebound value, nothing actually happens until you try to use map's return value. However, by time you actually do that, you've left the scope of the dynamic rebinding and thus your var is set back to what it was before, resulting in boogs.
17:39chojeenah, very helpful
17:40TimMcSome lazy-ish things copy dynamic bindings, lazy-seqs do not.
17:42chojeenit looks as though judicious use of doall helps, thanks
17:44amalloyTimMc: example?
17:47Rayneschojeen: Yeah, that's what doall is for. Also, doseq if you're only mapping for side effects.
17:51TimMcamalloy: @(binding [*print-readably* 5] (future *print-readably*))
17:51TimMcI think that illustrates it...
17:51TimMcOK, "lazy-ish" is maybe a bad term...
17:52amalloyyeah, future seems unrelated to laziness
17:52chojeenhas anybody read 'Clojure in Action'? is it worth the purchase?
17:53TimMcamalloy: dynamic-scope-escaping-things
17:53tmciverchojeen: I've been reading it. It's OK, imo. Not as good as JoC.
17:53chojeenI've got JoC; it's good, but it leans towards the theoretical
17:54llasramchojeen: I haven't read it in-depth. It's got some good walkthroughs of doing some practical Java interop stuff, but for general language knowledge and application it seems relatively weak
17:54tmciverI've definitely learned some things (granted I'm still a noob) so it was worth it to me.
17:57gtrak`future does abstract computation from synchronous execution, like laziness
18:15TimMcWith futures and promises you *intend* to use the value.
18:19gtrak`i guess we have delay and force
18:26_carlos_hi!
18:26alex_baranoskyhi!
18:27_carlos_why doesn't doc say ".." is somewhat deprecated in favour of "->"?
18:30_carlos_by the way, is "doto" called that way because someone thought about using japanese english for "dot"? ドト〜
18:30amalloydo to
18:30_carlos_ha.
18:35_carlos_amalloy: btw, isn't it better to just use also "->" instead of "doto"?
18:59TimMc_carlos_: They're different.
19:01TimMc_carlos_: ##(* (doto 4 (println "is the inner value.")) 3)
19:01lazybot⇒ 4 is the inner value. 12
19:02bitopsTimMc: hey, you were helping me with my hl-line-mode problem yesterday I think it was. I found the solution.
19:02TimMcbitops: Probably wasn't me, but go ahead!
19:03bitopsTimMc: to turn off hl-line-mode globally, put this in init.el:
19:03bitops(remove-hook 'prog-mode-hook 'esk-turn-on-hl-line-mode)
19:03TimMcI wonder if that was tmciver.
19:03bitopsoh actually you're right...d'oh. it was kodein, but you *did* try to help me.
19:03bitopsso...uh...now you know.
19:03bitops:)
19:04TimMcGlad it's fixed!
19:04TimMc_carlos_: doto takes the value and runs a bunch of side-effecty things on it, discarding the return value of each, then returns that initial value.
19:06TimMc(doto (Constructor. 5) (.setFoo 6) (.setBar 13) (.init)) => returns the object, not the result of .init
19:06clj_newbwhat does agent failed mean ? can it only be triggered if a (send _agent _fn) has _fn throw an exception, or does a watcher throwing an exception also trigger an agent failing?
19:06clj_newbn00bish minds want to know
19:10TimMctry it and see
19:10neddoes clojure have something like macro-expand-1
19:11nedand unwind-protect signaling/restart
19:11hiredmanlike macroexpand-1?
19:11hiredman,(doc macroexpand-1)
19:11clojurebot"([form]); If form represents a macro form, returns its expansion, else returns form."
19:11TimMcclj_newb: Actually, the docs imply that they're treated the same way.
19:11nedoh, rad.
19:11clj_newbTimMc: which docs are you referring to?
19:11TimMcclj_newb: (doc agent) and (doc set-error-handler!), which the first refers you to.
19:12hiredmanno signaling, just java style exceptions, but some people have written some libraries to try and provide things like conditions on top of exceptions
19:12clj_newb(sorry about these dumb questions; I feel like I'm in the area between "doing simple things that are obvious" vs "understnding details of clojure")
19:12nedhiredman: is there a lib that's advanced enough to be placed into something that's not-mission-critical-but-still-might-be-important
19:12nedor should i stick to just try/finally
19:12hiredmandunno, I've never used any of them
19:13bitops,(doc doc)
19:13clojurebot"([name]); Prints documentation for a var or special form given its name"
19:13ned,(doc 'doc)
19:13clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol>
19:13bitopsned: naughty
19:13bitops,(.toUpperCase "very naughty")
19:13clojurebot"VERY NAUGHTY"
19:14bitopsthat is fantastic
19:14TimMcdoc is a macro that reads a symbol
19:14clj_newb:error-mode :continue looks cool
19:14bitopshmm...I'm about to get in trouble here, but...
19:14bitops,(source map)
19:14clojurebotSource not found
19:14bitopsaw
19:14hiredman~def map
19:15bitops,(def foo 12)
19:15clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
19:15TimMc&(source flatten)
19:15lazybotjava.lang.RuntimeException: Unable to resolve symbol: source in this context
19:15bitopshahahaha
19:15bitops,(str (map .toUpperCase '("that" "is" "just" "craziness")))
19:15clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: .toUpperCase in this context, compiling:(NO_SOURCE_PATH:0)>
19:15bitopshuh.
19:16bitopsdid I mess something up?
19:16TimMcyep
19:16TimMcbitops: .foo is a method, not a function
19:16tavis`,(str (map #(.toUpperCase %) '("that" "is" "just" "craziness")))
19:16clojurebot"clojure.lang.LazySeq@fec989f0"
19:16hiredmanfeel to get your own repl or interact via private message
19:16bitopsTimMc: d'oh, got it
19:16_carlos_TimMc: about "doto", I understand the usage. the book I am reading, "clojure in action", uses a not so happy example because I can implement the same result with much less clutter and using "->"
19:16tavis`,(apply str (map #(.toUpperCase %) '("that" "is" "just" "craziness")))
19:16clojurebot"THATISJUSTCRAZINESS"
19:16bitopshiredman: no worries, just goofing around a bit.
19:17TimMcYou'd want to interpose \space, but I think that's enough...
19:17bitopsTimMc: yeah I'm already getting in trouble. :)
19:17TimMc_carlos_: Is the example short enough to paste? 'Cause I'm doubtful.
19:18nedwiat what does the % char do
19:19TimMcned: It's used by the anon fn literal #()
19:19brehautned:its the first argment to an anon function defined using the #( … ) shorthand
19:20dgrnbrgIf I have a function that is amenable to the early-return/guard-style coding, how do I write it in idiomatic clojure?
19:20tavis`ned: see row 2 of this http://clojure.org/other_functions table
19:21hiredmanearly returns :(
19:21amalloyTimMc, tavis`: every time someone uses (apply str (interpose x ys)) i cry
19:21amalloy(clojure.string/join x ys)
19:21_carlos_TimMc: sure, http://pastebin.com/dA28QrWz
19:21clj_newb,(apply str (interpose "," ["a", "b", "c"]))
19:21clojurebot"a,b,c"
19:22tavis`amalloy: hehe, just completing the code he already had
19:22_carlos_TimMc: this is the import, sorry: (import '(java.util Calendar))
19:22clj_newb,(join "," ["a", "b", "c"])
19:22clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: join in this context, compiling:(NO_SOURCE_PATH:0)>
19:22brehautdgrnbrg: early returns arent that common in clojure code
19:23brehautdgrnbrg: but if you want something like haskells guards / case, then cond, condp and case might be appropriate
19:23amalloy_carlos_: http://stackoverflow.com/q/8821751/625403 is relevant here
19:23hiredmanor the pattern matching library
19:23amalloy$javadoc java.util.Calendar
19:23lazybothttp://download.oracle.com/javase/6/docs/api/java/util/Calendar.html
19:23brehautclj_newb: clojure.string/join
19:23dgrnbrgbrehaut, thanks
19:24amalloyand also, _carlos_, it looks from the javadocs like your assertion that -> would work as well as doto seems completely bogus
19:25dgrnbrgwhat's the difference between extends? and satisfies?
19:25tavis`does anyone here have experience using clj-webdriver in the way semperos was describing before? i.e. keeping one browser instance open in a repl coding/testing session rather than restarting it for each test run
19:25brehautdgrnbrg: one works on types, one on instances
19:25tavis`(at least I think he meant that)
19:26dgrnbrgbrehaut, thanks again!
19:26TimMc_carlos_: Ah, I see -- the result of the doto is discarded.
19:27TimMcBut have you tried running your impl? I doubt it works...
19:27_carlos_TimMc: yes, in the example from the book it is discarded
19:27_carlos_TimMc: I don't know about the existence of impl, but I ran it on repl
19:28_carlos_TimMc: ok, probably my last answers seems hilarious. did you mean "sample code" by "impl"?
19:29TimMc_carlos_: "implementation" :-)
19:30clj_newbis there a short hand for: (with-meta (agent "") {:name "foo"}) ? i.e. something involving charaters # and ^ ?
19:30_carlos_amalloy: I have to read that post carefully. about "doto" "seems completely bogus", I don't understand, is it also related to that link?
19:31TimMc,(import java.util.Calendar)
19:31clojurebotjava.util.Calendar
19:31TimMc,(-> (Calendar/getInstance) (.set Calendar/HOUR 0) (.set Calendar/MINUTE 0) (.getTime)) ; _carlos_
19:31clojurebot#<NullPointerException java.lang.NullPointerException>
19:37TimMc_carlos_: Calendar's setters are pretty standard as Java goes in that they have void returns -- you can't stitch them together with ->.
19:45_carlos_TimMc: I will get back to you in a second. thank you
20:00_carlos_TimMc: yes, java methods would return void in many cases, which would make most implementations with "->" useless. I now understand the use case for "doto", which would be of much use for java functions. it is quite strange, though, that clojurebot returned nullpointerexception, because I ran my code without problems in the repl. did you try the entire sample on the repl?
20:02_carlos_TimMc: its not relevant if it doesn't throw an exception of course. thank you for pointing the usage of doto
20:04_carlos_TimMc: and clojure in action is right all along, being doto an idiomatic way of handling java methods
20:05TimMc_carlos_: I did not run your sample then, but I have now -- same exception.
20:06TimMcTheir names are the same in the paste you linked, so I assume you called the wrong one while testing. :-)
20:07_carlos_TimMc: weirdest thing ever. I imported the java lib. then ran the code from pastebin in repl again just now. it doesn't throw any exception o.O
20:08_carlos_TimMc: did you paste the second example?
20:08TimMcyep
20:08_carlos_TimMc: please notice this doesn't mean to prove anything. I am just curious why we are getting different results
20:09TimMcme too
20:09_carlos_TimMc: the second example starts in line 14
20:09TimMcright
20:10TimMcTry just pasting the *inside* of the second example: (-> ...)
20:10TimMcinto your REPL
20:11_carlos_TimMc: this is my input/ouput from repl: http://pastebin.com/jjAuPgzA
20:11_carlos_TimMc: ha! inside
20:11TimMc_carlos_: Umm, what happens if you *run* the function?
20:12_carlos_TimMc: gotcha. sorry, this was pretty lame haha
20:12amalloy(defn make-the-magic [] (-> Calendar/getInstance (.dosomestufftothething 10 20 30))) will compile too, but that doesn't mean it works :P
20:13_carlos_can someone please remove the last logs from #clojure??
20:13lazybot_carlos_: What are you, crazy? Of course not!
20:14_carlos_uau.. smart
20:17TimMc_carlos_: You'll sometimes see "fluent" Java interfaces where the setters return the object you called them on, in which case -> could be used.
20:17TimMcThat's what amalloy's link was about.
20:17alex_baranoskyaka chained method calls
20:19hiredman~search for sender:_carlos_
20:19clojurebot<#clojure:_carlos_> uau.. smart
20:19clojurebot<#clojure:_carlos_> can someone please remove the last logs from #clojure??
20:19lazybotclojurebot: Uh, no. Why would you even ask?
20:19clojurebot<#clojure:_carlos_> TimMc: gotcha. sorry, this was pretty lame haha
20:19clojurebot<#clojure:_carlos_> TimMc: ha! inside
20:19clojurebotTitim gan éirí ort.
20:20TimMcWhat was the point of that, O Unseeing One?
20:21_carlos_TimMc: is the object in doto mutable?
20:22TimMc_carlos_: Depends on the object!
20:23TimMcdoto is often used to initialize a mutable Java object, but you might also see it used to send off I/O actions or hammer on mutable Clojure stuff too.
20:24TimMcI'd say doto always means "side-effects and/or mutation"
20:25_carlos_TimMc: of course! I see, what it means. it just uses the object as parameter of successive calls inside doto, instead of using the last return of expression as parameter for the next expression, regardless of what kind of object the symbol binded to at that moment
20:29_carlos_TimMc: no, sorry for the rush conclusion. I am wrong. there is no way for doto to guess at some time, the method at the moment returned something useful, and rebind it to the initial symbol. so, the object may change it's state and/or produce some side effect(s)
20:29_carlos_sorry for the grammar, I hope though its somehow clear
20:31_carlos_TimMc: so, if so method returns a new object, and that was supposed to be the new value to bound to, one would have to use "->". if there were some methods returning a new object, and others just changing the state of the object, it would produce code with "doto" and "->" in clojure
20:34mindbenderplease how do I control which directories clojure-jack-in includes in the classpath?
20:36technomancymindbender: it's just using leiningen; what do you need?
20:38mindbendertechnomancy: I'm working on the clojurescript-one project and I need the cljs and cljs-macro dir included
20:38TimMc_carlos_: right
20:38_carlos_TimMc: I read the stackoverflow post. it quite covers our whole discussion. I am clear about this stuff. thanks
20:38TimMcyay!
20:38technomancymindbender: maybe :extra-classpath-dirs
20:38technomancymindbender: but yeah, clojurescript-one is really ridiculous in that regard
20:38technomancyyou should probably open a bug report
20:39mindbendertechnomancy: yes it is.. I have had to make a number of such corrections.. I'll consider reporting
20:41technomancymindbender: you could try this: http://p.hagelb.org/lein-cljs-swank.html
20:41technomancyput it in src/leiningen/cljs_swank.clj and try "lein cljs-swank"
20:41technomancyit should open a cljs repl on stdin and a swank server on port 4005
20:41technomancyit's gross though
20:42mindbendertechnomancy: thanks.. I'll definitely try it out
20:44mindbendertechnomancy: but for clojure-jack-in it's still going to pick up the :extra-classpath-dirs, right?
20:44technomancyI'm starting to think lein2 is going to have to have first-class cljs support
20:44technomancymindbender: right; if you jack in it will have to go in project.clj
20:45mindbenderok, I prefer clojure-jack-in for some reasons
20:46technomancyyeah, in most cases I do to, but I suspect here having two repls at once is beneficial
20:46technomancyand jack-in doesn't make it convenient to use stdout
20:46technomancystdin/out
20:48technomancybut then again I've spent a total of maybe half an hour using clojurescript (minus fighting build insanity) so what do I know.
20:59uvtcHi. I'm trying to modify a top-level dynamic var (or, what I *think* is a dynamic var) inside a `binding` block, but it's not working.
20:59uvtchttp://paste.pocoo.org/show/537560/
21:00uvtcI get "Warning: "*factor* not declared dynamic and thus is not dynamically
21:00uvtc;; > rebindable, but its name suggests otherwise."
21:00brehautuvtc: clj 1.2 or 1.3 ?
21:00uvtc1.3
21:00brehaut(def ^:dynamic *factor* 10)
21:00uvtcbrehaut: Hm. I'd thought that `def` makes dynamic variables. Is that not the case?
21:01brehautuvtc: it was the case up to 1.2.1
21:01uvtc(by default, that is)
21:01uvtcDoes `def` now make lexicals by default?
21:01brehaut1.3 onward default to static vars
21:01uvtc"static" == "lexical", correct?
21:01brehauterr…
21:02brehautyou'd need to ask someone who knows the internals better
21:02brehautbut im sure theres subtle distinctions
21:02uvtcInteresting. I'd always thought they were synonyms. Thanks, brehaut.
21:03brehautuvtc: well, one example is that you can ns-unmap a static var, but you cant do so with a lexically scoped var
21:03uvtcbrehaut, btw, the code correction you gave worked. Thanks.
21:04uvtcMy understanding of the terminology is that "static" means that scope is determined "statically" -- that is, by just looking at blocks/parens.
21:05uvtcIs a "global" simply a var defined at the top-level?
21:05brehautuvtc: any def is global to a namespace, nomatter where it occurs
21:05uvtcbrehaut: Thank you.
21:06brehaut(let [n 1] (def foo n)) foo ;=> 1
21:07brehautuvtc: clojures vars, namespaces and defs occupy a more complicated space than just their scoping rules. 'static' vs 'dynamic' here is to do with when they are resolved, rather than how the scoping works.
21:08brehautuvtc: unfortunately, im right on the edge of my knowledge
21:09uvtcbrehaut, re. `(let [n 1] (def foo n)) foo ;=> 1`, That's interesting --- at first I'd expect foo to not be visible outside the `let`,
21:09brehautuvtc: if you have a scheme background its very surprising.
21:10uvtcbrehaut: I learned a little Scheme before coming to Clojure. Everything being lexical is pretty nice and simple.
21:10brehautbut it illustrates the two different axis that they operate on
21:10uvtcyes.
21:11uvtcbrehaut, thanks again.
21:14TimMcbrehaut: Are you teaching nonsense again? :-P
21:14TimMcEveryone knows vars are just magic.
21:14brehautTimMc: lol
21:16brehautThe secret life of vars is a blog post waiting to be written
21:17brehaut(by someone who understand what the hell is going on)
21:17TimMcI think it's fair to say that vars are globally-available bindings attached to namespaces, and that they can opt into dynamic scoping.
21:17brehautTimMc: that works :)
21:17TimMc(not globally-*visible*, mind you)
21:17brehautalthough i would like to understand more about them under the hood
21:28uvtcNot requesting this, but is there a public log of this channel anywhere?
21:29brehautclojure-log.n01se.net
21:29brehaut(for one example)
21:30uvtcThanks!
21:39uvtcbrehaut, the docs at http://clojure.org/vars don't mention ^:dynamic. Those docs are still for Clojure 1.2?
21:40brehautclojure.org needs an update :/
21:41uvtcAh. Thanks. Hate to be a hit-n-run IRC user, but family calls. :) bye again.
22:11metajackany idea how to fix this when trying swank.cdt? warning: unabled to add tools.jar to classpath. This may cause CDT initialization to fail.
22:13tmcivermetajack: at least one solution is to make a symbolic link to tools.jar in your .lein directory.
22:14clj_newbI want to overwrite .equals for a defrecord. Here is a minimal failing example: http://paste.lisp.org/display/127181 . What am I doing wrong?
22:15amalloywithout looking at your example, i'd say what you're doing wrong is trying to override .equals on a record
22:15clj_newbah; I can only do it to a deftype
22:15clj_newbI'm an idiot
22:16clj_newbamalloy: is there anyway to make it work with defrecord; or am I forced to use deftype?
22:17amalloyi doubt it, and if you succeed then anyone who uses your record will want to murder you, so...
22:17brehautdoes creating a with-db middleware for my ring (moustache) app make sense?
22:17amalloybrehaut: i think so
22:17brehautamalloy: thanks
22:18clj_newbamalloy: great; given I need to release this code GPL; makeing it hard to read is all good
22:18technomancymetajack: that warning is not always fatal
22:18metajacktmciver: If I knew what tools.jar was or where I was supposed to get it, that might be helpful. Is it some standard thing?
22:18metajacktechnomancy: Indeed, CDT appears to work fine. I just figured I might as well make it happy if I can.
22:18technomancymetajack: it's just a bug in cdt that it emits spurious warnings
22:19technomancydon't waste your time on it unless you are actually interested in fixing it in cdt itself
22:19metajackfair enough.
22:20technomancywould be great if you could patch it of course =)
22:21metajackI may look at it later. It's on my list to dig around in a little in this stuff.
22:21metajackFor example, I still haven't gotten the colored stacktraces working :)
22:22technomancythat needs tweaking on the elisp side
22:22tavis`metajack: are you using clojure-jack-in?
22:22metajackYes
22:23ferdtechnomancy: metajack: I've seen multiple options for debuggers on Clojure. Is swank+CDT currently the best option on Emacs ?
22:23metajackferd: (swank.core/break) will work without any extra setup, but CDT seems the nicest that I've seen
22:23tavis`ferd: I think so but you need to use swank-clojure 1.4.0-SNAPSHOT
22:24technomancyferd: if you need stepping I think cdt is the best. if you just need locals and a breakpoint then yeah, it's hard to beat swank.core/break
22:24technomancythere is also ritz, which I haven't tried
22:24metajacktechnomancy: I've been resisting the urge so far to dive into some of the smaller issues I have. Like why the repl buffer is sometimes called *slime-repl nil* and sometimes *slime-repl clojure* etc.
22:25tavis`I've got a hackish patch for locals in cdt
22:25technomancymetajack: that's been driving me nuts for a while
22:25metajackoh good. it's not just me :)
22:25technomancywell, abstractly driving me nuts
22:25technomancyit doesn't bother me apart from not knowing why it happens
22:25metajacksame here.
22:26ferdthanks everybody
22:26tavis`I've also got a patch in progress for jack-in on the el side that fixes that *slime-repl nil* issue
22:26ferdAre you all using Emacs 24 ?
22:26metajackI'm on Emacs 24.
22:26tavis`same
22:27ferdI'm still on 23 and wondering if it's worth the upgrade before it's "officially stable"
22:27tavis`if you change the slime-connect line in jack-in to this:
22:27tavis` (with-current-buffer
22:27tavis` (or
22:27tavis` (get-buffer "*slime-repl clojure*")
22:27tavis` (get-buffer "*slime-repl nil*")
22:27tavis` (current-buffer))
22:27tavis` (slime-connect hostname port)
22:27tavis`
22:27metajackDo you guys use clojure-jack-in repeated to swtich between projects? Or do you run multiple repls?
22:27technomancyferd: it's unofficially extremely stable
22:27tavis`it should prevent the nil version from being created
22:27technomancymore stable than 23 in my experience
22:27technomancymetajack: multiple emacs instances
22:27metajackferd: I've had zero problems and the new theming is better too.
22:28technomancytavis`: also: stick with gists for multiline pastes next time?
22:28tavis`sorry
22:28tavis`lazy
22:29metajacktechnomancy: Hadn't thought of that. I've been jacking in back and for, but I did get multiple repls going once with slime-connect and lein swank.
22:29technomancymetajack: I'm an oddball; not many people like multiple instances
22:29technomancybut it works great for me
22:29technomancyseparate color themes keep work distinct from play, etc.
22:29metajackI suppose a nice patch might be to make prefixed clojure-jack-in launch a second repl :)
22:29brandelwhere did the nomenclature jack-in come from - some kind of cyberpunk homage?
22:29technomancyslime's support for multiple connections is kind of crappy
22:30brandelah :)
22:30technomancyhttps://github.com/technomancy/slamhound <- exhibit B
22:30brandelI've been meaning to read some of his newer work.. I think Idoru was the last thing I read
22:30metajackAnd just to make sure, I have to re-jack-in if I want to see new deps right?
22:31technomancymetajack: aye, or you could try your luck with pomegranate
22:31technomancybrandel: it's good but not excellent.
22:32brandelI thought it was interesting that he no longer considers himself a sci-fi novelist in that the future he wanted to write about is mostly a reality now, or elements of it
22:33technomancyactually I like the third trilogy better than the second. but neither come close to the energy and pace of the sprawl trilogy
22:33metajackpomegranate looks nice. I'll give that a whirl.
22:34tmcivermetajack: my apologies for being terse. I just ran find on my system to find tools.jar. On my Ubuntu system it's somewhere in /usr/lib/jvm/...
22:35metajacktmciver: no worries. I just had no idea what it was, and it didn't show up in ~/.m2 or ~/.lein or anywhere.
22:36tavis`If anyone is interested in playing with locals in CDT/swank stackframes here's a patch for it https://gist.github.com/1644817
22:37metajacktavis`: does that make them show up? I seem to be able to eval them fine in each frame.
22:37tavis`you already can eval them
22:38tavis`this makes a string version of them show up in the locals part of the sldb buffer
22:38tavis`I can't figure out how to avoid serializing to strings though
22:41tavis`1.4.0-snapshot with cdt enabled already allows you to eval locals with 'e' in sldb or by putting your cursor on a sexp in the source for the frame and hitting some magic key sequence I can't remember
22:41metajackC-c C-x C-p :)
22:41tavis`metajack: oh, sorry misread your last line though you said you couldn't eval
22:42metajackI'll give your patch a try a little later and let you know how it works.
23:01PaulIIIIIIIIhi
23:01PaulIIIIIIIIhow are you
23:04notsonerdysunnyIs there a way to see the actual sql command it is generating/using when I do a clojure.java.jdbc/insert-record ?
23:04PaulIIIIIIIIi dont know
23:05PaulIIIIIIIIsome microproccessor command maybe
23:06PaulIIIIIIIIif you send some stack to the lan card, and its activates from proccessor secret code, what can hack your windows
23:06PaulIIIIIIIIbut then you must been at least microproccessor archidect
23:20tmcivertechnomancy: I see that swank-clojure depends on clj-stacktrace. If I run 'lein swank' in a project that does not depend on clj-stacktrace (and therefore does not have the jar in /lib) I get a FileNotFoundException.
23:20technomancyit should be on the classpath regardless, either in lib/dev or as part of the plugin uberjar in ~/.lein/plugins
23:24tmcivertechnomancy: Ahh, I created a swank-clojure jar from a fresh clone of the repo. I think my problem is the swank-clojure shell script set up the class path for my old 1.3.4 swank-clojure jar.
23:32tavis`technomancy: I've just about got jack-in working with tramp, but I'm not sure how to handle the remote filenames for the payload .el files. Any thoughts?