#clojure logs

2013-01-23

00:07FrozenlockAhhh lazyness... you hurt me once more.
00:55brainproxyi'm comfortable prog'ing with clojure, javascript, some python and ruby, shell... i need to whip something together in C# (maybe toss in some clojurecljr), but I feel lost don't even know where to start
00:56brainproxyanyone have a favorite .net/c# crash course w/ some examples of how to just start doing some basic things?
00:57brainproxyI'm just not even sure how to layout a project, compile or whatever, etc.
00:57xumingmingvHave you ever used Java?
00:57xumingmingvThey are similar
00:58brainproxytbh, not really, i got into clojure from working w/ other dynamic languages
00:58brainproxyand have been learning little bits of java as i go along
00:58brainproxyI have absolutely no idea what I'm doing with eclipse, netbeans, etc. when I fire those up and tinker w/ stuff
00:58brainproxythough I have managed to get java classes to compile and run as application
00:59brehautbrainproxy: personally id skip C# and go straight to F#
00:59brehautits got a better non-visual studio experience
00:59brainproxybrehaut: can't do it ... it really needs to be c#
00:59brehautthats unfortunate
01:00brainproxyi'm a quick study, and have been looking at c# code and get the basic ideas, I just feel totally lost with the tooling
01:00brehautbrainproxy: the tooling basically all asumes visual studio and msbuild fiels (managed by VS)
01:01RaynesVisual Studio is a raging heap of steaming cow dung just for the installation procedure.
01:01brainproxyyeah, well I can get the 30-day version of VS, should be enough to get done what I need to get done
01:01brehautbrainproxy: or perhaps monodevelop
01:01brehautthough i have no idea what state its C# support is at
01:02brehaut(version number wise)
01:02brainproxybrehaut: thanks! that might do the trick
01:02brainproxythere are some get-up-and-running examples on the site
01:02brehautsweet
01:03Raynesbrehaut: We should write something in F# together.
01:03RaynesMaybe a Lisp.
01:03Raynes;)
01:03brehautlols
01:03brehauti do quite like F#
01:03brehautand mono 3 supports F#3
01:08brehautbrainproxy: keep in mind the version of C# any tutorial talks about BTW; C#4 is drastically different to C#2
01:11brehaut(local type inference, lambdas and block lambdas, linq (which is not just an SQL thing), covariance and contravariance, async…)
01:20tomojhmm, ring.util.codec uses URLEncoder
01:20tomojI mean, ring.util.codec/form-encode
01:20tomojwhich it also uses for cookies
01:21tomojbut that encodes spaces as +
01:21tomojwhere javascript's urldecoding wants %20
01:22amalloythen, uh, javascript's url decoder is no good? last i checked both of those are allowed
01:22tomojhttp://stackoverflow.com/questions/2678551/when-to-encode-space-to-plus-and-when-to-20
01:23tomojhmm
01:23brainproxybrehaut: thanks for the tip
01:24Raynesamalloy: In my experience, most URL encoder/decoders are wrong. I went through 4 different Erlang libs before just writing that URI lib in Elixir.
01:24bbloomamalloy: javascript is doing url encoding which is different (but similar to) form encoding
01:24Raynesamalloy: The thing that most people don't account for are unicode characters. They encode a single byte.
01:25bbloomthere's also URI "component" encoding
01:25tomojand angular.js and ring BOTH make that choice deep inside
01:25tomojoi
01:25tomojincompatible choices I mean :)
01:26bbloomthe web is broken.
01:26brehautderp
01:26amalloytomoj: that seems like an unambiguously correct choice for ring.util.codec/form, since it's presumably being used to encode forms, not uri path components, although making the other choice would also have been fine.
01:26bbloomit's impossible complex, but b/c it's all plain text, it works out more or less right modulo some major security bugs
01:27bbloomthat's the unix way!
01:27tomojamalloy: and wrap-cookies too?
01:27brehautbbloom: nothing some more poorly considered regexen wont solve!
01:27Raynesamalloy: https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/uri.ex The URL decoding stuff wasn't me, but the encoding stuff is. Lots of blame in that file now, since people have mucked with it over time.
01:28bbloomform encoding makes sense as the default for post data, but i'm pretty sure cookies are supposed to be URL encoding, not form encoded
01:28bbloomtomoj: so that might be a bug in ring, but it would be backwards incompatible to fix... however, you may want to report it anyway
01:28amalloytomoj: cookie values don't have to be url encoded at all
01:29tomojthen ring should let you choose?
01:29amalloyi think so
01:29bbloomyes
01:29bbloomurl-encoding is just the most common choice
01:30tomojhow the heck do you even do url-encoding on the jvm if URLEncoder does form encoding?
01:30bbloomspec says: The VALUE is opaque to the user agent and may be anything the
01:30bbloom origin server chooses to send, possibly in a server-selected
01:30bbloom printable ASCII encoding.
01:30bbloomso it has to be printable ASCII
01:30amalloybbloom: your summary is the exact opposite of what you're summarizing
01:31bbloomand since javascript makes urlEncode readily available (but oddly, no way to get form encoding) most client side code uses url encoding
01:31amalloythe value may be anything; the server may, if it chooses, encode it some way into ascii
01:31cbp`hello
01:31bbloomamalloy: yes, but in practice, browsers suck lol
01:31cbp`for a friend just starting out what would be the best way
01:31cbp`with like no programming experience
01:32bbloomamalloy: http://stackoverflow.com/questions/1969232/allowed-characters-in-cookies
01:32bbloomthe money shot: "so in practice you cannot use non-ASCII characters in cookies at all. "
01:32tomojI guess I can with-redefs ring.middleware.cookies for now
01:32bbloom"Most popular is UTF-8-inside-URL-encoding (as produced by JavaScript's encodeURIComponent)."
01:33tomojthat or make another copy of a bunch of middleware-related code :(
01:33bbloomtomoj: i think you should report a bug in ring if it's using form encoding
01:33bbloomit should, at minimum, be pluggable
01:33tomojwill do, but I also want to make it work tonight
01:34bbloomfor sure :-)
01:34bbloompoint to http://stackoverflow.com/questions/1969232/allowed-characters-in-cookies
01:36tomojok, alter-var-root time
01:37cbp`anyone used catnip? :P
01:37cbp`seems like newbie friendly
01:42tomojoh, ring.util.codec has url-encode too, didn't notice
01:43tomoj(->> (.getBytes unencoded (or encoding "UTF-8")) (map (partial format "%%%02X")) (str/join))
01:46amalloyhah, the least efficient way imaginable
01:47bbloomsurprising that they wouldn't delegate to some well tested and performing apache module...
01:50tomojespecially since that ns imports base64 from commons-codec
01:51bbloomtomoj: lol
01:51bbloomi guess base-64 is a bit trickier
01:52bbloomprobably implemetned url encoding & then was like "oh, shit." and went to find commons-codec
02:14mich2Hi there! I'm new to clojure and now using data.xml to process some XML data, I have a problem though
02:15mich2The data.xml API gives you the content of an XML element with :content , this returns a l: LayzSeq but I want a string
02:15mich2So how do I convert a lazySeq to a string?
02:15bbloommich2: what's it a lazy seq of? (take 5 the-seq)
02:16bbloomor even just (first the-seq)
02:16mich2(Str lazySeq) seem not to work
02:16bbloomtry (apply str the-seq)
02:16mich2First or take, hmm
02:16mich2Apply! Ok I try that thanks!
02:17jballanchmm...so apparantly recur doesn't work with apply :(
02:17Raynesjballanc: apply only works with functions.
02:18jballancwhat do I do, then, if I have a func that returns an array of two items, and I want to recur while "exploding" the array
02:18Raynesrecur isn't even a macro, much less a function.
02:18jballancyeah, I'm not surprised it didn't work
02:18jballancjust not sure what to do...
02:18bbloomjballanc: use a vector or a seq
02:18bbloomif you need to alter the signature you want to recur to, use a loop
02:18RaynesDon't explode the 'array', probably.
02:19jballancah
02:19bbloomit's very common to see (fn [...] (loop [...] ... (recur ...)))
02:19RaynesIt's hard to answer specifically without code to look at.
02:19jballancok...one sec
02:22jballancthis is a trivial example: https://gist.github.com/4602823
02:22SegFaultAXIs it common to have a server like nginx or apache serve static content directly instead of letting tomcat or whatever serve it in the Java world?
02:22amalloyjballanc: just call foo
02:22bbloomSegFaultAX: i put nginx in front of everything as a matter of principle
02:22jballancyeah, that's what I was going to do...
02:22amalloyand don't wrap it in []s
02:23jballancright
02:23jballancwell, the [] is coming from another function
02:23SegFaultAXjballanc: You can't recur across function clauses like that.
02:23bbloomjballanc: i assume you know the number of elements in the vector? use a let to destructure right before your loop
02:23bbloomor, just change the loop target to take the vector itself
02:24SegFaultAXbbloom: I'm really shaky on how to actually deploy Clojure web applications in a production environment. I haven't found many tutorials on the subject, either.
02:24SegFaultAXbbloom: And how to handle things like redeploys, etc.
02:25bbloomSegFaultAX: i've never done it, but my assumption is that you just use the ring jetty container and do exactly like you would do for any other java app
02:26ro_stwe have a ring app in production on ec2
02:26jballancbbloom: ah, yeah...that's not a bad idea :)
02:27SegFaultAXro_st: Can you tell me a little about your stack?
02:28michaelr525hello
02:28ro_stwe use "lein trampoline run" to start our server, and use apache to proxy to it (and take care of stuff like mime types, cache + expiry, etc)
02:28SegFaultAXro_st: What application server do you use?
02:28tomojring-refresh checks for "Content-Type" specifically :)
02:28tomojclj-http downcases all headers due to the ring spec
02:29ro_stjetty, i believe
02:30ro_stfor deploys, we rsync from our build vps, which only happens once our build vps has done a 'lein check' and run the tests
02:30SegFaultAXro_st: Do you use jetty to serve static content?
02:30ro_stno. S3
02:30tomojrelatedly, I kind of expect (re-find #"foo" nil) to be nil
02:30SegFaultAXro_st: But aren't static resources in the webapp tree?
02:31ro_stactually, i might be wrong about that. we serve our content from s3, and our static assets (js, css, ui stuff) from jetty
02:32tomojweird
02:32ro_stthe intent is to move everything to s3, though
02:32SegFaultAXro_st: I see. So is jetty a pretty capable web server, then? I've been using nginx as a proxy for my application servers for so long, /not/ using it feels wrong.
02:32ro_styou could still use nginx
02:33ro_stjetty is perfectly capable. it's just that you don't want your contended app server process serving something that S3 or the proxying webserver can serve instead. prefer 100% of jetty's requests to be dynamic
02:34amalloySegFaultAX: nginx in front of jetty is pretty popular for clojure
02:34SegFaultAXIs there a tutorial or blog post on this?
02:34ro_stwe went with apache because of all the goodness the html5boilerplate .htaccess gives us
02:34SegFaultAXI've never really deployed a Java application into production.
02:34SegFaultAXOnly local development stuff. Toys, really.
02:34bbloomSegFaultAX: just leave "clojure" out of your searches
02:34ro_stSegFaultAX: our production server does exactly the same thing that our dev server does
02:34ro_st"lein run"
02:35ro_stwe use env vars to configure the process
02:35ro_stso if you can start a jetty server and proxy to it from nginx locally, you have your solution
02:36SegFaultAXro_st: Do you use the auto-generated web.xml?
02:36ro_stwe don't use jars or wars
02:37ro_stwe rsync the loose clj files over from the build box (which gets it from github) once it's been checked and tested
02:37ro_stthat way, when we connect to our nrepl server in production, we can reload files from disk if need be
02:38SegFaultAXro_st: That sounds awesome. I wish I knew how to set all that up. :/
02:38ro_stfeel free to PM me and ask more :-)
02:38amalloyit's a lot easier to set up than anything involving web.xml files
02:38ro_styep
02:39ro_stapache vhost proxies to localhost:9991. configure ring server to start on port 9991. lein run. done
02:39SegFaultAXro_st: Does deploying a new version require downtime for your site?
02:39ro_styes, about a minute's worth, at this point
02:39amalloyi hope you don't mind my poking a bit of fun, but asking if he uses the autogenerated web.xml after hearing he just does lein run made me think of the introduction of cars: "a horseless carriage!" "sounds great, what kind of horse feed do i have to buy for it?"
02:40ro_stas our startup does several important things; connect to datomic, transact datomic schema, connect to rabbitmq, connect to memcached
02:40SegFaultAXamalloy: I don't. But like I said, I don't really have much experience deploying production Java applications and all the tutorials I've found start with configuring the web.xml file.
02:41SegFaultAXro_st: Does the long pause between versions dissuade you from deploying very often?
02:41ro_stas we're using ec2, we won't bother trying to shorten that time. once we have load, we'll add another ec2 web node and lean on the the load balancer to direct traffic properly while we cycle each node one at a time
02:42ro_styes. it does cause us to think carefully about whether we need or want to deploy the changes we have
02:42SegFaultAXBummer.
02:42ro_stonce we have two nodes, though, we'll deploy as much as we like, because then we'll always be up
02:43SegFaultAXTrue.
02:43amalloyif two nodes is really all it would take, you could just run two of them on the same machine with a load balancer or something in between
02:43SegFaultAXro_st: Are you using pallet for automation? Cap? Fab? Other?
02:43ro_stthanks to memcached, rabbitmq, and datomic, the web processes don't have any state to shepherd. so we don't lose sessions or datomic peer cache
02:43ro_stpallet
02:44ro_stamalloy: true. but we'd be trading a day's developer time to get that working robustly just to throw it away in a couple weeks. we can live with a minute's downtime for now
02:44SegFaultAXro_st: A day? nginx can load balance in 1 line ;)
02:44ro_st-grin-
02:45ro_stwe use upstart for our java process management
02:45ro_stit's a tradeoff, we've chosen to wait out the short-term niggle, keep complexity down and get some features built instead :-)
02:47ro_styou could probably do a loadbalanced solution on a single server, and keep jumping back and forth between two jvms every time you deploy
02:47ro_stwe also have to factor in the fact that we have a limited number of datomic processes available
02:48amalloyi'm not saying you're wrong and should spend time on no-downtime deploys, just saying it's silly to blame it on having only one node
02:49ro_stsure
02:57SegFaultAXro_st: PM?
02:59SegFaultAXamalloy: You mentioned earlier that nginx -> jetty is a pretty common configuration for clojure. Are you aware of any sample apps I can take a look at?
03:01amalloysure, 4clojure is open source, and the nginx configuration is just https://gist.github.com/02f0ccf609e8d3d5db34
03:03SegFaultAXamalloy: Does 4clojure also use lein run? Or wars?
03:03amalloylein run
03:05michaelr525cljs-kickoff is great, now how can I clojurescript to an existing compojure site?
03:06michaelr525add cs
03:06ro_stfrom the perspective of a compojure site, the output of the cljsbuild is is just a static js file
03:06ro_sttreat it accordingly :-)
03:07ro_stour cljs app is in a separate git repo to our server code. we use symlinks between the two in development to test the one on the other, and deployment copies the js etc into place for production
03:09michaelr525ro_st: why do you separate the projects?
03:10ro_stso that we can build the cljs and deploy it without also causing a server reboot
03:11michaelr525ok
03:11michaelr525ro_st: what's your startup?
03:11michaelr525btw
03:11ro_stwww.cognician.com
03:11yunfanso how to use regex for replacing? i can only found those funcs for finding/matching
03:11ro_stclojure.string/replace
03:12yunfanit support regex?
03:12ro_st(doc clojure.string/replace)
03:12clojurebot"([s match replacement]); Replaces all instance of match with replacement in s. match/replacement can be: string / string char / char pattern / (string or function of match). See also replace-first."
03:13yunfanit didnt said it support regex. is char pattern the alias of regex?
03:14ro_stmatch is a regex or a string
03:15michaelr525ro_st: how do you access the web services?
03:15ro_st,(clojure.string/replace "aBc" #"[A-Z]" "!")
03:15clojurebot"a!c"
03:15ro_stmichaelr525: we don't currently have content for the general public to use, sorry. we only went live last week :-)
03:16yunfanro_st: ok thanks
03:16michaelr525ro_st: heh, sorry. I was asking using what method do you call the web services from clojurescript code.. :)
03:16ro_stohh :-)
03:16ro_stwe use shoreleave-remote
03:17ro_stand shoreleave-remote-noir
03:17ro_stcljs/clj respectively
03:17michaelr525clojure datastructures over the wire or json?
03:18ro_stedn :-)
03:18michaelr525cool
03:18yunfanwhy not just push clojure express as a alternative for jsonp?
03:18ro_stnever heard of that before
03:19yunfani know some one agree that using s-exp to instead json
03:19SegFaultAXedn is probably best if you're a) using datomic and b) using clojure throughout your entire stack.
03:19ro_stcheck, check.
03:19SegFaultAXyunfan: We've been doing it for years, it's called XML.
03:19yunfanSegFaultAX: oops, hell xml
03:21yunfanSegFaultAX: how much cost of you using datomic per month?
03:23SegFaultAXyunfan: ro_st uses datomic, ask him.
03:24yunfanro_st: ?
03:24ro_styunfan: we have 8 processes. we use a normal m1.medium with postgres for storage, right now
03:24spjtFinally finished my first clojure program? a prime number generator.
03:24yunfani am also want to use clojure for my website idea, but i am worry about the cost
03:25spjtGenerates all prime numbers between 2 and 10^7 in 120ms.
03:25yunfanro_st: how many PV per page of your site?
03:25ro_stdatomic is expensive, but in our particular case, it's saved us many hours of development time, and, going forward, code maintenance time
03:26ro_styunfan: sorry, not sure what that means
03:26yunfanro_st: how many page view of your website in a day?
03:26yunfanin average
03:28ro_stin the hundreds. when we switch off our old stack in feb, in the thousands
03:28ro_stcan't wait for that day. no more php!
03:29yunfanoop, that must be horrible while you using php
03:29ro_stnot long now.
03:29yunfani have those experience in the earlytime
03:29yunfannow i live on python, less horrible but still have
03:30ro_stpy is far better'n php, i believe. can't say personally, never used py.
03:31yunfani have a question, if i made a rss subscribe service like GR but with more customizing services , and need you pay $5 per month, would it be expensive?
03:32ro_stanother great thing is no more IE8-
03:32p_lro_st: lucky you
03:33ro_stour rationale is, install one of the other 4, or install google chromeframe
03:33ro_stwhich can be done sans admin rights
03:34ro_stMUCH rather put that time into feature dev
03:34ro_stwe even have some folks carrying Chrome Portable to use on university networks
03:36yunfanro_st: can i have a look of your site?
03:36ro_stwww.cognician.com
03:36yunfanok
03:37p_lro_st: and our requirements were written few years ago and can't be changed. Fun.
03:38ro_sti feel for you. not fun
03:45ro_stp_l: that must be a big project
03:52p_lit is
03:52p_land it was done by foreign company first and we were supposed ony to integrate
03:54yunfanforeign company , is it indian one or a chinese company in shenyang :]
03:56p_lyunfan: worse - american
04:07cinvokecan someone point me to a good source that would help me decide the benefits of clojure vs nodejs?
04:10ChongLicinvoke: with clojurescript you don't have to choose
04:10cinvokeChongLi: but they would run on 2 diff platforms correct? jre vs v8?
04:11ChongLicinvoke: clojurescript compiles to javascript so it'd be running on v8
04:16amalloydon't run cljs on node
04:16ChongLiwhy not?
04:18cinvokeso no benefit to use one over the other ChongLi?
04:18amalloyit's a mess, and even if it worked you might as well use the well-tested, performant clojure environment. cljs is (and this part is just my opinion) for letting you write clojure on the client; if you're on the server you get to choose, and there's no reason to do all the extra hoops to get cljs->node interaction going
04:18cinvokejust lang flow?
04:19ChongLicinvoke: I didn't say that
04:19ChongLicinvoke: clojure (and clojurescript) has many advantages
04:20ChongLiit's an extremely beautiful language with some really nice abstractions
04:20ChongLiso much of it was designed based on a ton of experience and it shows
04:21ChongLijavascript, on the other hand, is the result of a rushjob with many deep flaws
04:21cinvokeok so more zen, more principle..
04:22ChongLijavascript makes it easy to do the wrong thing; it has quite a few language features that experts would recommend you never use
04:23ChongLiclojure's language features make it easier to write better code
04:23ChongLiwith persistent data structures and clean abstractions
04:23cinvokelike eval :)
04:24augustlChongLi: out of curiousity, since you can choose VM on the server, why choose V8/Node, instead of the JVM?
04:24ChongLiaugustl: no idea, I'm not all that familiar with node
04:25augustlah, cinvoke was the one asking
04:26cinvokebut i would have access to most java libs on jvm, and wouldnt it also be more stable, application-wise?
04:27ChongLicinvoke: in jvm you have access to java libs
04:27cinvokenice
04:27ChongLion v8 you have access to js libs
04:28ChongLiclojure (and its variants) aim to nestle themselves within their host platform
04:28ChongLiso interop syntax is very simple
05:09Bodilcinvoke: The biggest problem with Cljs on Node is that you can't use any Clojure libraries - you're limited to what's been ported to Cljs, which on the server side is practically nothing.
05:10cinvokeBodil: makes sense. i didnt see the point in cljs unless i just wanted that lang flow.
05:11noidiand with CLJS you also get all the JavaScript's problematic semantics
05:11noidi(defn foo [x] x) (foo no such symbols defined in this ns)
05:11noidiwill work
05:12noidipassing extra arguments to a function is fine in JS, and undefined names evaluate to, well, undefined :P
05:12noidion the JVM both are errors caught at runtime
05:16clgvnoidi: no the unknown symbols are detected on compile time
05:17noidioh?
05:17clgvnoidi: wrong function arity will throw at runtime
05:17noidithat wasn't the case when I last used CLJS
05:17clgvnoidi: oh, I picked up your last sentence, so on the JVM I meant
05:20clgv&(do something with unknown symbols)
05:20lazybotjava.lang.RuntimeException: Unable to resolve symbol: something in this context
05:20bozhidarBodil: the availability of libraries on node is problematic even if you're using JS :-). The platform is simply too young at this point...
05:44AWizzArdIs Java’s „Sizeof.FLOAT” in Clojure „Float/SIZE”?
05:48bozhidarAWizzArd: Java's Sizeof.FLOAT? I don't recall the existance of such a class
05:50AWizzArdbozhidar: good, thanks for the info. Then this is a JCuda class.
05:50AWizzArdThat guy imported jcuda.* and so I wasn’t sure if Sizeof is Java or JCuda. Thanks :)
05:50bozhidarAWizzArd: You're welcome.
06:00clgv&Float/SIZE
06:00lazybot⇒ 32
06:07AWizzArd,(.clone (float-array 5))
06:07clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: clone for class [F>
06:07AWizzArdBut I found this Java code: float h_C[] = createRandomFloatData(10); float h_C_ref[] = h_C.clone();
06:07AWizzArdcreateRandomFloatData obviously returns a float array.
06:14xumingmingvAWizzArd: you wonder why the IllegalArgumentException is thrown?
06:15AWizzArdYes.
06:16AWizzArdTo me it seems from that Java code that .close can be called on float arrays.
06:16AWizzArdclone even
06:17xumingmingvjava.lang.Object.clone is a protected method
06:18xumingmingvIt is only callable in Java class's definition file itself. (Unless you define your clone public clone method)
06:20xumingmingv&(.clone (java.util.Date.))
06:20lazybot⇒ #inst "2013-01-23T11:20:22.952-00:00"
06:20xumingmingvjava.util.Date defines its public clone method
06:28clgvAWizzArd: you probably have to use reflection for that since arrays are no objects on JVM level
06:31clgvAWizzArd: try java.util.Arrays/copyOf like ##(java.util.Arrays/copyOf (float 5) 5)
06:31lazybotjava.lang.IllegalArgumentException: No matching method found: copyOf
06:31clgv&(java.util.Arrays/copyOf (float-array 5) 5)
06:31lazybot⇒ #<float[] [F@a494b>
06:32AWizzArdclgv: yes, I already use that.
06:32clgvgood :)
06:34AWizzArdVery nice performance difference. Two 800x800 matrices multiplied in Clojure with quad core at 100%: 25000 msecs. The same task on my Nvidia: 63 msecs. Holy goodness :)
06:34clgvyeah thats what these GPUs are good at ^^
06:34AWizzArdNice that 98% of my program runtime is about exactly this :)
06:52noidiAWizzArd, cool :)
07:12fantasticsidas
07:52mattywin core.logic I'm trying to say something should be in list a but not in list b. Seems like I need (membero q vec-A) (not-membero q vec-B) but there doesn't seem to be an official implementation of not-membero.
08:14clgvmattyw: you can look up the source of `membero` and implement `not-membero` analogous
08:14mattywclgv, just started looking into that
08:17Morgawrquestion time... I am using ClojureScript to output to javascript into a web page, it's some small silly javascript game (just for the hell of it) and the game runs starting from an "init()" function called from the html page.. using the :advanced flag for the clo_s_ure compiler it doesn't detect such function called from my html hence it prunes everything and removes it
08:17Morgawrhow can I specify which functions I want to stay in my code even when using :advanced?
08:25no7hingshouldn't ^export do the trick?
08:25no7hing^:export
08:26Morgawrdoesn't seem to be working
08:26ChongLisometimes you need to do a clean and recompile
08:28Morgawrokay... looks like I was wrong, the problem isn't with the init() function
08:28MorgawrI call it with "testjs.core.init();" in my html code (inside a <script>)
08:28Morgawrand it says "referenceerror testjs is not defined"
08:28Morgawrin advanced mode
08:28Morgawrtestjs is the name of my namespace
08:28Morgawrin simple mode it works
08:29ChongLitry searching for testjs in the text of the advanced output
08:30Morgawrthere's a few instances
08:30ChongLihmm
08:30Morgawrstuff like
08:30Morgawr("testjs.core.init",function()..
08:30Morgawretc tec
08:30Morgawralso the output says "TypeError: jQuery.Uf is not a function" maybe that's related?
08:30ChongLiis there any reason you need to put the init call inline in the html file?
08:30Morgawrno real reason, I am just trying it out and it made sense, what other option do I have?
08:31ChongLijust put (init) at the bottom of your source file
08:31Morgawrmmm yes that might work, lemme try
08:32Morgawrokay, reference error is gone, now I get a jQuery error so I guess that makes for half of the problem solved
08:33ChongLihave you read up on calling externs from google closure?
08:33ChongLihttps://developers.google.com/closure/compiler/docs/api-tutorial3#externs
08:34MorgawrI'll give it a read
08:34ChongLiwhy are you using jquery btw?
08:34ChongLias far as I know it doesn't work too well with the closure compiler
08:35ChongLiand a lot of its functionality already exists in the closure library
08:35ChongLiI take it you're probably experienced with jquery
08:35Morgawrbecause I was following (and translating along the way) a jQuery javascript tutorial and wanted to see how it worked with clojurescript
08:35clgvChongLi: huh? it should. there is the jayq lib
08:35MorgawrI don't really know much about jQuery, I don't care which library I use
08:35Morgawrand yeah, jayq is working fine with jquery
08:35ChongLiah ok
08:36ChongLithe core idea of advanced mode compilation is to get rid extra scripts so you can take advantage of whole program optimization
08:36Morgawrhttp://corfield.org/blog/post.cfm/getting-started-with-clojurescript-and-jquery-and-fw-1 reding from this
08:37ChongLiif you're also loading jquery on the side you're losing a lot of the benefit
08:37Morgawrreading*
08:37Morgawrit seems I need ":externs ["externs/jquery.js"]" in my project.clj
08:37Morgawrlet's try
08:37Morgawrbut yeah, I'm just using jquery now because I'm following this example tutorial (in javascript), I'll move on to better stuff after I'm done
08:38MorgawrI'm satisfied I managed to learn how to do all this stuff and properly translate clojure code into javascript
08:38ChongLihere's a tutorial on clojurescript
08:38ChongLihttps://github.com/magomimmo/modern-cljs
08:38ChongLiit uses the domina library
08:38Morgawryeah, I saw that
08:39ChongLiit's a native library which is functional and idiomatic clojure
08:39MorgawrI read the basics from that but I was more curious on working out some game programming in html5 so I read a tutorial related to that and translated it to clojurescript
08:39Morgawrbut that tutorial used jquery so that's why
08:39Morgawrnot a big deal either way, I'm learning how it works :)
08:39ChongLithe real key is to learn the underlying ideas
08:39ChongLiof what you want to do with the dom
08:39ChongLithen you can use any library to get the job done
08:40Morgawryeah exactly
08:40Morgawranyhow, thanks for the help, gotta go now :)
08:40ChongLigood luck :)
08:46michaelr525Ctrl-C'ing 'lein run' on cygwin windows leaves a java process still running in the background.. is this a known problem?
09:10no7hingif i'am not mistaken, adding "-Djava.awt.headless=true" to the :jvm-opts in your project file should solve the issue
09:11no7hingone of my deps had a dependency on AWT...
09:11no7hingcan't write proper sentences today apparently
09:12no7hingcan't read them properly either, as i replaced process with window in my head
09:13rasputnikis there some trick to accessing a var in another namespace?
09:13michaelr525no7hing: you're writing to me?
09:13rasputnikhave an atom in one namespace, just want to read it from another
09:14no7hingyes, but i gave you the wrong answer
09:14michaelr525rasputnik: you can use the fully qualified name i think, like this my-namespace.myatom
09:14rasputnikrephrase that: functions via (defn….) and vars (def….) defined in a namespace thingy.whatever should both be accessible as thingy.whatever/name right?
09:15michaelr525i think so
09:15rasputnikprobably a brain fart this end
09:16michaelr525you can also (:require ... :refer...
09:16rasputnikdo i need a require to be able to see the namespace at all?
09:16clgvrasputnik: you need to require the other namespace at least
09:17rasputnikclgv: there we are, that's my problem. I'll do the require/refer bit to limit the exposure
09:17clgvrasputnik: yes, require does load the namespace
09:17rasputnikthanks both
09:17Thallasios_Xelonhello :))
09:17clgvrasputnik: you can use :require :as
09:17clgvand should^^
09:18rasputnikthis would be easier but I'm building an uberjar so have to go round the houses to get an error
09:18Thallasios_Xelon (let [f1 lazyseq1
09:18Thallasios_Xelon f2 (fun f1) ]
09:18Thallasios_Xelonthis will work?
09:18rasputnikclgv: actually I just want to reach this one atom, and it's only at atom because I need somewhere to keep a config map for the app
09:19clgvrasputnik: hmm for encapsulation you should not expose that atom. expose operations on the atom as functions
09:21rasputnikclgv: it's a read-once , "turn this configfile into a map" kind affair. [-main] needs to set it up as it's a command line argument, but it's used later to wire up connection pools
09:21rasputnikprobably doesn't even need to be an atom, a 'global' would do. and i'd rather it were immutable
09:22rasputnikshared state bad, i know :)
09:22rasputniks/shared//
09:22clgvrasputnik: functions might prove more handy. since the using namespaces do not need to know how the configuration is organized. so changes to that affect only that one namepsace
09:23rasputnikclgv: point taken. one of those situations where im' balancing the Right Way with Pragmatism
09:26rasputnikno shit
09:26clgvrasputnik: what does it save you to expose the global and have every consumer knowing how to access it? I'd say just using the function that gives me the desired result and encapsulates the config access is the pragmatic one^^
09:26rasputnikit's just a map of JDBC setup info
09:27rasputniksorry, the 'no shit' was to my mate in another window
09:27clgvhow many namespaces use that map`
09:27rasputnikhe lives in the welsh mountains and says it's snowy :)
09:28rasputnikclgv: 3, one where main lives (reads the jetty port) , one for the DB layer (reads the jdbc bits), one for the utility function that turns the config.clj into a map
09:28firefuxis clojure better than java?
09:29ro_stYES
09:29ohpauleezthat was an easy answer
09:29tiledwhy does this not work? it always returns nil (http://pastebin.com/HnmSdCfA)
09:32clgvrasputnik: well thats 3 namespaces that are affected with changes when you change the config organization^^
09:32ro_stohpauleez: :-)
09:32bprtiled: i'm not sure what (to-vect ...) actually returns, but you may want to try (flatten (to-vect ...))
09:32rasputnikclgv: seriously, this is around 30 lines of clojure code total and I'm replacing 500+ of Dropwizard with it. :)
09:33bprtiled: that will find the 2 if (to-vect ...) returns a vector of vectors
09:33rasputnikclgv: if it gets any bigger i'll refactor but seems like overkill for something so teeny
09:35clgvrasputnik: your choice after all. but I did not see the tradeoff from your arguments, thats why I asked^^
09:35rasputnikclgv: hey i come here for the voice of experience, thanks for the advice.
09:35bprtiled: oh.. i read that wrong, you are doing nested iteration on that.
09:37tiledbut i guess it is easier to use flatten?
09:37bprwell, i believe flatten is eager, so you'll loose the benefits of lasziness
09:38rasputnikarg, require loop : [ /tyrekick/core ]->/tyrekick/db->[ /tyrekick/core ]
09:39firefuxrasputnik: dropwizard, the java web framework?
09:40rasputnikfirefux: yup
09:40rasputnikcan I use refer inside a (ns … ) ? or a let binding ?
09:41bprrefer needs to be in a require form
09:41Thallasios_Xelon(let [f1 (parse_replace '(=> a (<=> b c)) () del=>)
09:41Thallasios_Xelon f2 (parse_replace f1 () del<=>)]
09:41Thallasios_Xelon f2)
09:41Thallasios_Xelonparse_replace return a lazyseq
09:42Thallasios_Xelondo you know why only f1 is evaluated?
09:42rasputnikbpr: you sure? the samples on http://clojuredocs.org/clojure_core/clojure.core/refer don't make it look that way
09:42rasputnikmaybe that's a repl thing?
09:42bprrasputnik: lol. nope that's new to me
09:42bprrasputnik: (nope, i'm not sure)
09:43firefuxrasputnik: do you use dropwizard-views?
09:46rasputnikfirefux: no
09:47rasputnikhum, bit stuck here now then. wanted to set a 'global' config map, but can't see it from other namespaces (since can't require them to reach it).
09:47rasputnik*that feeling when you're fighting the language*
09:48Thallasios_Xelonis there a way to make a clojure.lang.lazyseq to sequence?
09:49rasputnikThallasios_Xelon: do you mean like (doall ...)
09:49Thallasios_Xelonmaybe i got stuck...
09:49augustlweavejester: hey, I'm using clout outside of ring, in fact outside of http in general. Using message queues to do RPC, and the commands are HTTP-like, but not HTTP. Does it make sense to decomplect clout from ring, you think?
09:50Thallasios_Xelon(let [f1 (parse_replace f () del=>)
09:50Thallasios_Xelon f2 (parse_replace f1 () del<=>)] f2 ) ; parse return lazyseq,f2 is never calculated dont know why
09:50augustlI currently have to construct a ring-like request even though I'm not in ring or http
09:50weavejesteraugustl: You should be able to use strings too.
09:51Thallasios_Xelonis there anything to think before you pass a lazyseq as argument?
09:51weavejesteraugustl: Oh, wait, my mistake - I think it needs to be a request.
09:52rasputnikis there any way to let 2 namespaces access things in each other without causing a require loop then?
09:53weavejesteraugustl: I think it would be hard to pull the HTTP out of Clout. It's designed to match against HTTP, with information spread throughout the request map.
09:54jballancstyle question..."if" with "do" clauses: ugly? or acceptable?
09:54jballancfor example: https://gist.github.com/4607286
09:55jballancalternatively, what would be a good way to branch, but also report based on which side of the branch is taken?
09:55augustlweavejester: I guess there's not much point in splitting it
09:55weavejesterjballanc: Sometimes necessary, but to be avoided in favor of more functional code when possible.
09:55jballancweavejester: yeah, that's what I was thinking
09:55augustlweavejester: perhaps it would make sense if it took strings, though
09:57jballancin this case, I have 3 methods that are all returning bools, and I'm using an "and" clause to report their collective success/failure
09:57augustlweavejester: but passing {:path-info "/my-path"} works fine :)
09:57jballancbut for one method, I'd like to have a guard, and report + return false if the gaurd fails
09:58clgvrasputnik: no. you cannot make circle-require-statements.
09:59clgvrasputnik: usually you have to extract those functions both namespaces want to use in a third which does not depend on the other too
10:00xumingmi`A question about Clojure CA: http://clojure.org/file/view/ca.pdf
10:04xumingmingvA question about Clojure CA: http://clojure.org/file/view/ca.pdf
10:05xumingmingvIt asks me which projects I'd want to contribute
10:05xumingmingvIs it enough to just put Clojure(https://github.com/clojure/clojure) in it?
10:07gfredericksxumingmingv: I've never heard that field mentioned
10:08hyPiRionxumingmingv: I added Clojure core and Clojure contrib
10:08hyPiRionI think that should cover all of it
10:08xumingmingvgfredericks: So I dont need to fill in that field, only Contact information is Ok?
10:09TimMcWell, put Clojure in, for sure.
10:09TimMcAll they ever care about is "did you sign the CA?"
10:10xumingmingvok, thanks you guys
10:13ohpauleezRaynes: ping
10:16AnderkentIs it possible to make dosync *always* start a new transaction, even if it's already contained in one?
10:16rasputnikclgv: good call, i'll merge the tyrekick.config and tyrekick.utils and keep the atom in there
10:17TimMcAnderkent: Why?
10:17hyPiRionAnderkent: Doesn't sound like you want transactions then.
10:18AnderkentIt's more that I don't control whether my transaction is nested in one or not, but I want to persist the result if my transaction succeeds
10:18hyPiRionIf you start a new transaction, then that transaction may run multiple times.
10:18Anderkentthat's fine, it's idempotent
10:18Anderkentbasically I have a code coverage 'store' that keeps track whether a form was executed
10:18Anderkentsince I may have multiple threads executing I update it in a transaction
10:19hyPiRionAnderkent: The thing is, (dosync (dosync (commute a + 10)) (commute a + 20)) may increment a by more than 30
10:19hyPiRion*IF* the inner dosync started a new transaction
10:19Anderkentright, I'm not saying it should be the default, I'm just asking whether there is a way to do it
10:19Anderkentthink like this: (dosync (dosync (mark-visited :here)) (throw Exception.))
10:20AnderkentI want the coverage state to be updated even if the outer transaction fails
10:20Anderkenthm. I suppose I want an atom instead?
10:21clgvAnderkent: huh. I thought (dosync (dosync ...)) would result in only one transaction
10:21hyPiRionclgv: It does
10:21Anderkentclgv: it does. That's exactly the opposite of what I want
10:21Anderkentand I undestand why it does
10:22hyPiRionAnderkent: So you want to know how far into a transaction you get before it errors out?
10:22clgvah ok. I inspected the code once, and saw a check for the enclosing transaction...
10:22AnderkenthyPiRion: something like that. It's a code coverage library.
10:23Anderkentcurrently I can't properly cover transactions that fail
10:23Anderkentbecause it rolls back my 'forms that were visited' store
10:23Anderkentare atoms also reverted if an outer transaction fails?
10:24hyPiRionAnderkent: Try it out
10:25clgvAnderkent: no atoms take no part in transactions
10:25gfrederickshow do protocols enable dynamicity but still stay low-level enough to be fast? e.g., what happens when you (extend-protocol ...)?
10:26hiredmangfredericks: inline callsite caching is the big one, outside of extending the protocol directly when you create the type
10:27Anderkentokay. That sounds like a solution here, but it means I have to change some other code.. Anyway, thanks
10:27gfrederickshiredman: so is extending protocols to existing types always a bit slower?
10:27TimMcAnderkent: You can *prevent* your code from running inside a transaction. :-)
10:27hiredmangfredericks: I cannot see how it would not be
10:27AnderkentTimMc: that doesn't help - I want to be able to cover transaction expressions, just breaking would be worse than current state :P
10:28gfrederickshiredman: okay, that's what I suspected
10:28TimMcAnderkent: Oh, I see -- this is code you're injecting into the code to be analyzed.
10:28Anderkentyes
10:28TimMcEw, tricky.
10:28Anderkent:P
10:28gfrederickshiredman: is it better than doing a long list of type-checks?
10:28gfredericksor maybe a map of classes to functions...
10:29TimMcYeah, tell an atom. It's an idempotent action, yeah?
10:29hiredmangfredericks: I think inline caching should be, yes
10:29Anderkentyes, that's what I'm changing it to
10:29Anderkenthave to update some initialization code, but it shouldnt be that hard
10:30gfredericksI need some reason to dig into the compiler details :/
10:31hiredmangfredericks: pjstadig has a library that pulls out the protocol dispatching code out in to a regular function (no protocol grouping functions), I doubt it has the inline caching that protocols have, so comparing the two would be one way to isolate performance
10:32hiredmanhttps://github.com/pjstadig/polyfn
10:33gfrederickshiredman: cool, thanks
10:35hiredmanthe callsite caching and constant pool entry kind of stuff would be interesting to expose to macros somehow
10:37hiredmane.g. so a macro could tell the compile that then function it emits needs an extra callsite cache or constant pool entry that the macro will futz with
10:37hiredmannot sure how that would work though
10:47tiledhow can I test whether two floats have the same value? since its value varies (0.2 becomes 0.20000000298023224)
10:48firefuxthat's why you don't test them
10:48bprtiled: define an acceptable epsilon and see if they are within epsilon of each other: (< (- float1 float2) epsilon)
10:49hyPiRionWeren't there an approx= in numeric-tower?
10:49hiteki`bpr .. some abs is missing I guess
10:49bprtiled: well, you'd want to wrap that subtraction in a Math/abs
10:49bprhiteki`: yup
10:50TimMc,(< (Math/abs (- 0.1 (/ 10.0))) 1e6)
10:50clojurebottrue
10:50TimMc,(< (Math/abs (- 0.1 (/ 10.0))) 1e-6) ; rather
10:50clojurebottrue
10:51bprTimMc: I was like, "Wow! He must be doing cosmology... or economics"
10:51bpr:-p
10:51TimMc:-)
10:51tiledok thank you
10:53TimMcbpr: What's a few orders of magnitude among friends, anyway.
10:54hyPiRionAs long the sign is correct
10:55hyPiRionlet epsilon be less than zero
10:56gfredericksemacs' trailing whitespace removal feature is quite annoying when editing other peoples' projects :/
10:57minimal134gfredericks: use ethan whitespace
10:57hyPiRionturn it off then
10:57gfredericksbut I wants it on otherwise :/
10:58hyPiRionI'm sure there's a hook which enable features based on what the git's origin links to
10:58minimal134ehan-wspace only auto cleans files that were opened clean
11:00gfredericksminimal134: that does sound useful.
11:00yediis the clojure log at n01se relatively complete?
11:01yedior a better q, does it tend to miss messages at all / often
11:02gfrederickswhoever suggested ethan, thanks for the tip; I just borked my irssi and lost the history :/
11:03hyPiRiongfredericks: that would be minimal134.
11:04gfredericksminimal134: thanks
11:04gfrederickshyPiRion: thanks
11:04gfredericks(inc everybody)
11:04lazybot⇒ 1
11:04minimal134gfredericks: thanks. blame ethan
11:06gfredericksit's weird that extending a protocol to Object doesn't cover the nil case
11:06gfredericksis that a jvm detail or a clojure detail?
11:07hyPiRiongfredericks: nil/null isn't an object
11:07hyPiRionnull instanceof Object returns false
11:07gfrederickswat
11:07gfredericksmy whole world is falling apart
11:07gfredericksI guess this makes sense
11:07creesegfredericks: re: whitespace: because you can't find the changes you actually made?
11:07gfrederickscreese: I can it just takes lots of paging
11:07hyPiRiongfredericks: how can nothing me something? :)
11:08creesegfredericks: in a diff?
11:08gfrederickshyPiRion: I was thinking of the fact that in java "int x = null;" is bad but "Integer x = null;" is okay
11:08creesegfredericks: seems like there ought to be a way to tell git to ignore whitespace changes
11:08gfredericksthat fact mislead my expectations
11:08gfrederickscreese: in `git add -p`
11:08yaziriangit diff --ignore-space-at-eol
11:08hyPiRiongfredericks: oh right.
11:09gfredericksso at compile time null is an Object; but I can see why instanceof would disagree
11:11hyPiRiongfredericks: null is only void, null is just the lack of an Object
11:12hyPiRionBut I agree that it is strange
11:12hyPiRionJust like you'd think "((Math)null).abs(1+2);" would fail, yet it compiles and runs perfectly.
11:12gfredericksO_O
11:13gfrederickswhat the hell is that
11:13hyPiRionMakes sense compile-wise
11:13gfredericksit looks like an instance method call though
11:14hyPiRiongfredericks: static method, can be inferred that it's just a call to that method
11:14hyPiRionNo need for the object to find the specified method
11:14gfredericksoh you can call static methods on objects
11:14gfredericksI forgot that weird little flexibility
11:15gfredericksokay; now it makes sense
11:16hyPiRionThis one has always bothered me though: https://www.refheap.com/paste/8894
11:17hyPiRionMan, those edge cases
11:17hyPiRionWell, "always bothered" is a bit of a stretch, but it's gotten to me once.
11:17gfredericksdoes it crash?
11:17gfredericksis that an implicit cast?
11:18hyPiRionIt crashes with an arraystore exception
11:19gfrederickswould the equivalent code with generics do the same thing?
11:19hyPiRionAnd yeah, since String isa Object, casting an array to Object[] is valid somehow.
11:20hyPiRiongfredericks: List<Object> x = (Some List of String) fails
11:22yediif clojure wasn't tied to the jvm, do you think it would be as popular?
11:23bawrIt's hardly "tied" to the JVM as it is.
11:23hyPiRionyedi: Depends.
11:23hyPiRionMost likely not due to lack of libraries.
11:25hyPiRiongfredericks: Hmm, you can cast generics if you don't define them before given.
11:25hyPiRionhttps://www.refheap.com/paste/8896
11:28TimMchyPiRion: Whee, covariant types...
11:30TimMchyPiRion: What is this syntax? {{add(1); add(-2); add(3);}}
11:30TimMcSome sort of initializer?
11:30AnderkentTimMc: static initializer
11:30TimMcHow long has that been there? :-/
11:30Anderkentit's basically a hack
11:31TimMcAnonymous class?
11:31Anderkentyou're creating an anonymous inner class
11:31Anderkentyep
11:31TimMcnasty
11:33Anderkentanyone knows how to check if an element has children in clj-webdriver? no? thought so :(
11:35MorgawrI've got a fairly basic clojure question... let's say I have a vec made like [1 2 3 4 5 6 7] and I want to "update" one of its element based on the position (update = return a new vector that looks like that just with an element changed), how do I do that?
11:35MorgawrI mean, I want a new vector with the nth element changed into something else
11:36MorgawrI know how to use map/reduce/whatever but I have no idea how to specify an index to change
11:36Anderkent,(assoc [1 2 3 4 5 6] 0 0)
11:36clojurebot[0 2 3 4 5 ...]
11:36Anderkentuh, bad values chosen..
11:36Anderkent,(assoc [1 2 3 4 5 6] 0 123)
11:36clojurebot[123 2 3 4 5 ...]
11:36Anderkentthere :P
11:36Morgawroh that's great
11:36Morgawrthanks
11:36Morgawr:)
11:37TimMcAnderkent: I wasn't aware you could do a non-static initializer. o_o
11:40TimMcMorgawr: You can also append an element that way, since vecs will accept an index one beyond the end when assoc'ing.
11:41AnderkentTimMc: I shouldnt have said static. It's not a static initializer, it's an instance initializer. static {} run on class init, not instance init
11:41Morgawrneat, good to know
11:41TimMcIt can be a little confusing to the reader, though.
11:41TimMcAnderkent: So do those run before the constructor chain?
11:42Anderkentyes, they run when the class is being loaded
11:42Anderkent'those' -> static initializers
11:42Anderkentnot double brace initializers
11:42TimMcNo, the instance initializers.
11:42Anderkentoh. Instance initializers run before the actual constructor
11:43TimMcAnd before the super constructor?
11:43Anderkentyeah
11:43TimMcFreaky.
11:43Anderkentthey run in literal order together with other static initializations
11:43TimMcNo wonder I've never seen them used.
11:43Anderkenti.e. you have class { my_field = 1; { my_field += 1 }; constructor() }
11:43Anderkentin weird pseudocode
11:44Anderkentthen the myfield will be set to one first, then the initialization block will run
11:44hyPiRionMorgawr: You should also check out ##(update-in [0 1 2 3] [1] + 10) if you're using the previous value
11:44lazybot⇒ [0 11 2 3]
11:44AnderkentI don't like explaining java because writing example code is so much pain :P
11:45hyPiRionI don't really mind Java when it comes to its verbosity, it's more its lack of expressiveness.
11:45MorgawrhyPiRion: nice, thanks
11:45hyPiRionAnd its default mutability.
11:45craigbroi always thought of it as tinker toys
11:45craigbroi felt like I was building stuff from tinker toys
11:45craigbromutability doesn't bother me
12:01brainproxyanybody here using the jnbridge pro product in conjunction with their clojure apps?
12:01brainproxyexperiences? good, bad?
12:13tomoj&(into {} [(list (clojure.lang.MapEntry. 1 2) (clojure.lang.MapEntry. 3 4))])
12:13lazybot⇒ {1 2, 3 4}
12:13tomoj(into {} [[1 2] [3 4]])
12:14tomojoh right
12:14tomoj&(conj {} (seq {1 2 3 4}))
12:14lazybot⇒ {3 4, 1 2}
12:16tomoj&(apply conj {} (seq {1 2 3 4}))
12:16lazybot⇒ {3 4, 1 2}
12:45muhooi could swear there was a let-fn in clojure somewhere, but i can't find it. or was i imagining it?
12:45eggheadmuhoo: letfns
12:45muhoothanks
12:45eggheadoops
12:45egghead-s
12:45muhooyep, no dash
12:55ohpauleezDoes anyone know of an example illustrating loop unrolling via Clojure macros?
12:58gfredericksohpauleez: what's a loop? something like dotimes?
12:58ohpauleezyeah, essentially a doseq that I want to force to unroll
12:58gfredericksor I guess you include not a full unroll (which requires iteration count to be known at compile-time) but also unrolling every 2 or 3?
12:58hyPiRionohpauleez: That requires knowledge of the seq at compile-time
12:59ohpauleezhyPiRion: totally, I have that
12:59gfredericksohpauleez: so it's (doseq [x <some vector literal>] ...)?
13:00ohpauleezyeah, (doseq [x <A seq of objects created at compile time>] )
13:00hyPiRionWell, then it's rather straightforward I believe. Just do a `(do ~@(map clojure.walk/some-fn-replacing-stuff the-seq))
13:01hyPiRionIt won't give you any speed improvement though.
13:01hyPiRionOr barely any.
13:01ohpauleezhyPiRion: definitely, I already wrote basically that, but I wanted to make sure I wasn't duplicating something tucked away in core
13:01ohpauleezoh, not for speed
13:01ohpauleeznative library needs things done upfront
13:02hyPiRionoh, okay
13:02gfredericks(defmacro unrolled-doseq [[name elems] & body] (let [names (repeatedly (count elems) gensym)] (list* 'let [(vec names) elems] (for [name' names] (list* 'let [name name'] body)))))
13:02hyPiRionohpauleez: I can see at least immediate bugs with it though
13:02hyPiRiontwo immediate*
13:03hyPiRionerroneous return value and improper handling of multiple body elements
13:03hyPiRionSo just be aware of that.
13:06Frozenlockohpauleez: Ping. What's the status with shoreleave?
13:07ohpauleezFrozenlock: As in, what's left?
13:07warzi see that maven stores downloaded repos into ~/.m2. i have a maven repo that's not available on the sites that leiningen checks though. whats the best way to get this repo into that m2 directory that lein checks?
13:08warzcopy and paste it in there? or is there a way to tell lein to check other online repos
13:08technomancywarz: just add it to :repositories in project.clj; see `lein help sample`
13:08FrozenlockAs in: last time IIRC you were almost ready to release a major updrage
13:08Frozenlockupgrade even.
13:08warzok ill check that out
13:09ohpauleezFrozenlock: Just smoothing stuff out, building up the example. Swamped at day job recently, so it's been a little slow going
13:11warztechnomancy, oh i see. awesome! thanks.
13:15ibdknoxohpauleez: what's the day job for you at this point? :)
13:15ohpauleezibdknox: I'm not sure I can say in #clojure haha
13:19hyPiRionohpauleez: Oh, I didn't knew you were programming stateful programs with locks, mutexes and hairballs.
13:19hyPiRion/s/knew/know/
13:20ohpauleezhyPiRion: It's all in really bad, STL C++
13:20ohpauleez:)
13:20ibdknoxwhich has been macro'd so far that you can't even tell it's C++
13:21ohpauleezibdknox: Turn off the VNC viewer - stop looking at my code
13:21ohpauleezhaha
13:21ohpauleezIf I every publicly interview Rich, I want to know the worse abuse of C++ he ever wrote
13:21ohpauleezbut I want it documented for everyone else
13:23technomancyif you asked me that I'd only answer on condition of anonymity
13:23ohpauleezhaha
13:23ibdknoxtechnomancy: you do much C++ work in the past?
13:23technomancyibdknox: about a year's worth at university
13:24technomancymercifully all but forgotten
13:24hyPiRionohpauleez: Have you seen the Java he's written?
13:25ohpauleezAll the more reason to want to see the C++ - he bends Java SO far, it's incredible
13:25hyPiRionhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L802
13:25ohpauleezI imagine Guy Steele and James Gosling look at Clojure's Java code and nod in approval
13:25hyPiRionFor some strange reason I always laugh when I see it.
13:26ohpauleezand then Steele says something about phantom types
13:27`fogus"Callbacks in C++ using template functors" a paper by Rich Hickey (1994) http://www.tutok.sk/fastgl/callback.html
13:27S11001001hyPiRion: set tab-width 4
13:27clojurebothyPiRion: Probably because it is using the IRC protocol directly -- the equivalent of you putting /say in front of your messages.
13:27ohpauleez `fogus: I've read it. It's gruesome
13:27ohpauleez(in a good way)
13:27ohpauleezfor a long time, Hickey Callbacks were the "it" thing i C++
13:27ohpauleezin*
13:28`fogusI remember the technique from back in the day. :-O
13:28hyPiRionS11001001: Ahh, that explains everything. I've never bothered to check the tabs etc.
13:29technomancyhttp://www.emacswiki.org/emacs/TabsSpacesBoth
13:29ChongLihaha
13:30hyPiRion`C-x h M-x untabify`
13:30ChongLiyou could do the same thing with the "K&R style vs one true brace style" debate
13:31technomancyChongLi: so glad we don't have those discussions in clojure
13:31ChongLiyeah haha
13:31technomancyif anyone puts parens on their own line, everyone just tells them they're wrong and gets on with it
13:39ChongLiI'd like to see Crockford style context coloring
13:39ChongLiseems like it'd work pretty well in a lisp
13:40ChongLiit makes it easy to follow the scope of free variables in a deeply nested function
13:41ChongLiwhat I don't get is why Crockford hates on S-expressions
13:42ChongLihe actually likes writing crap like this: (function (a, b) {return a + b;}());
13:43technomancyheh; statements
13:43ChongLithat's actually a "function expression"
13:43technomancyI mean explicit returns
13:43ChongLiit becomes a statement if the f in the reserved word function is in the first column
13:43ChongLioh, yeah
13:45ChongLiI like his story about how somebody told him jslint should warn about switch cases falling through due to missing breaks
13:45ChongLihe told the person "sometimes you actually want them to fall through"
13:46ChongLithe next day that person sent him a bug report; the bug was caused by a case falling through
13:46ChongLiin jslint!
13:46cbp`I got this email: Dear LispWorks user,
13:46cbp`
13:46cbp`LispWorks 6.1.1 Personal Edition is now available, free of charge
13:46Bronsalol
13:46cbp`:D
13:46iwilligChongLi: yeah that was a good story
13:49ChongLiit really seems to fly in the face of his argument that "syntax is good"
13:49ChongLisyntax is bad if it leads to silent errors
13:52Ember-even though Javascript *does* have it's good points (or parts) I'd like to see even one person who thinks that the *syntax* of javascript is good and relevant to the actual language beneath
13:52ChongLididn't brandon eich want to write a scheme interpreter originally?
13:52akhudekSwitch cases falling through has been used forever in other languages to support grouped cases.
13:53Ember-ChongLi: yes and he did I think
13:53ChongLioh it's brendan
13:53Ember-then management wanted to make it more "java like" since java was new and cool and hip
13:53Ember-and Eich got like 3 weeks to turn the scheme-like language to java-like
13:53Ember-and we got what we got
13:53Ember-thank you management
13:54ChongLiand he decided to add some crazy prototype inheritance based on an obscure language called self
13:54Ember-well, that isn't actually crazy
13:54Ember-prototypical inheritance is quite a good concept
13:54technomancyChongLi: hadn't heard that story before; that's great
13:54Ember-but the syntax in javascript does not support that pardigm
13:54Ember-paradigm
13:54ChongLiwell, it was crazy considering his bosses wanted him to make it javalike
13:55Ember-the whole birth story of Javascript is kinda sad
13:55Ember-especially since we still have to live with it
13:55muhoo"Doing the right thing was not possible at Netscape. That's why there's not a Netscape anymore" -- Douglas Crockford
13:55technomancynearly rivaled in craziness by the birth story of Java/Oak though
13:55ChongLiI'd like to know whose idea it was to have so many contradictions in the equality operator
13:55Ember-but then again, if I'd have modules in javascript I could live with most of the stuff in it
13:55technomancythe whole "we have to find someone who would actually want this OO technology for set-top boxes, fast!"
13:56Ember-technomancy: hehe, yeah
13:56ChongLimodules are coming in ES7, no?
13:56muhoohow would i go about type-hinting a reduce?
13:56Ember-ChongLi: ES6 I think actually
13:56Ember-or was it 7, don't remember
13:56Ember-but come on, when can we actually *use* those?
13:57muhoo,(reduce #(+ %2 (* 58 %1)) [0 9 15 21 33 0 4 32 23 30 9 32 27 39 14 41 48 17 1 41 6 32 1 12 22 27 1 17 5 40 29 5 1 41])
13:57clojurebot#<ArithmeticException java.lang.ArithmeticException: integer overflow>
13:57ChongLithey seem to abandon even-numbered releases
13:57ChongLiwe'll be good to go once IE9 is obsolete
13:57Ember-it's like 5-6 years at minimum before you can use those
13:57tomoj&(update-in {} [:foo] identity)
13:57lazybot⇒ {:foo nil}
13:57Ember-5-6 years is a bit too much for my taste
13:58Ember-I'm looking at dart, it's looking better and better each day
13:58ChongLiclojurescript targets es3 right?
13:58Ember-yeah
13:58Ember-Ithink
13:58ChongLiwhy not target the intersection between es3 and es5/strict?
13:58Ember-(chatting via ssh screen in a moving train, might be missing a character or two)
13:58technomancyreally bizarre story worth a read if you have some time: http://www.blinkenlights.com/classiccmp/javaorigin.html
13:59ChongLiseems like that'd get a bit more performance on strict compliant browsers
13:59ChongLiwhile gracefully falling back to es3 on non-compliants
13:59Ember-ChongLi: I'm hoping we'll see a clojurescript compiler for dart vm
13:59Ember-and that dart vm get's implemented into other browsers than chrome too
13:59ChongLiis mozilla gonna ship dart in firefox?
13:59Ember-dunno
14:00ChongLiI doubt microsoft will even touch it
14:00ChongLimicrosoft still wants to stand in the way of the web
14:00hyPiRionChongLi: They may make their own proprietary version.
14:00hyPiRionWith special semantics
14:00Ember-dart vm is completely open source and google is pushing it for the other browsers too
14:00Ember-I wouldn't be too sure about it
14:00Ember-Microsoft wouldn't lose anyting with dart really
14:00ChongLiwhy else would they vote to ratify es5/strict and then not implement it in IE?
14:01ChongLimicrosoft loses whenever the open web grows
14:01Ember-but let's see what happens
14:01Ember-too early to tell if dart lives or dies
14:01ChongLiis dart a better candidate host for cljs?
14:01Ember-but in any case, it's already many multiples better than javascript in all possible aspects
14:01Ember-ChongLi: dart vm is already faster than v8
14:02Ember-and has support for lot's of stuff
14:02ChongLiI see that it has classes
14:02Ember-it's a full blown vm, not a script interpreter
14:02Ember-WAY closer to JVM
14:03ChongLi"So, I've thought for a long time ... if I could take a clean sheet of paper and write [a new language] that retains all the goodness of [Javascript] ... I would not have come up with anything like Dart."
14:03technomancyhow is V8 not a VM?
14:03ChongLi-- Douglas Crockford
14:03Ember-technomancy: in a way it is, it's a JIT compiler and VM
14:03Ember-with a bunch of pretty crazy optimization magic
14:04Ember-but dart vm runs bytecode
14:05Ember-many good things about that, if anyone is interested then there's a ton of information in the g+ dart feed
14:07ChongLiEmber-: so the browser downloads bytecode archives from the server?
14:08Ember-ChongLi: that's the main way to run dart, not the only one though
14:08Ember-there's dart2js compiler and stuff like that
14:08Ember-but yeah, with dart vm you run compiled bytecode
14:09Ember-allows a LOT faster startup times, smaller files, better optimization, real remote debugging and so on
14:09ChongLiso we could target that with clojurescript (or something similar)
14:09technomancymight be interesting to finally have a bytecode-based VM where the authors actually care about startup time
14:09Ember-current dart ide allows debugging running code directly from the browser
14:09ChongLiI'd like to know what douglas crockford really thinks about it
14:10ChongLithat quote is a frustrating non-answer
14:10Ember-or run the code without the browser, it's a separate VM afterall
14:10ChongLidart has bigints
14:10ChongLinice
14:10Ember-technomancy: dart developers are reporting over 10 times faster startup times even in early versions of dart vm compared to similar javascript
14:11Ember-I think it's in RC2 currently
14:11Ember-so closing on 1.0 final
14:12ChongLieverybody from the other browsers is angry about dart
14:12dnolen_Ember-: I don't see Dart going anywhere beyond Chrome.
14:12dnolen_ChongLi: angry? they don't care
14:12Ember-dnolen_: I know, it's a risk
14:12Ember-but then again, you always have dart2js then
14:13ChongLiI'm not really interested in dart2js
14:13Ember-then it's in a similar position as clojure script with the exception that you can run native dart if dart vm is available
14:13ChongLiI'm more interested in a better host and browser API for cljs
14:13Ember-but I'm more excited about dart vm than about the dart language
14:14dnolen_Ember-: I don't know why you would wan to use the dart vm outside of the browser - in Clojure's case you have the JVM.
14:14Ember-I *really* want an efficient bytecode Vm into browsers to host several different languages
14:14ChongLijvm is too slow to start up
14:14dnolen_ChongLi: for server applications who cares
14:14dnolen_for scripts you can target JS
14:14ChongLiwe're talking about in the browser
14:14Ember-js script startuptime is slow
14:15Ember-it really is
14:15dnolen_ChongLi: I understand - I was simply saying that Dart VM outside of Chrome is uninteresting
14:15ChongLispecifically: making the browser a faster and better host for cljs
14:15Ember-or any other language for that matter
14:15Ember-the more the merrier
14:15ChongLiyeah
14:15dnolen_and so Dart VM's chance for success is quite small
14:15ChongLiprobably zero
14:15Ember-let's wait and see
14:16dnolen_and don't forget it's not like JS engines are continuing to push ahead performance wise
14:16Ember-I'm not keeping my hopes too high, but one can hope, right?
14:16dnolen_are not continuing
14:16dnolen_Dart ... massive meh
14:16Ember-well actually, google engineers (and others too) have said that the current js interpreters are closing the limit what can be done with javascript
14:16Ember-that's the reason dart vm is almost twice as fast as v8 already
14:17dnolen_Ember-: I guess that's why JSC 64bit is surpassing V8 on it's it's benchmark suite?
14:17dnolen_cause there's no more progress to be made ...
14:17Ember-well, it's about what kind of language javascript is
14:18Ember-if you've ever studied what for example v8 does to achieve it's performance it's what one could call a one huge hack :)
14:18dnolen_Ember-: otherwise known as engineering?
14:19Ember-propably the best performance boost v8 does is to make it possible to turn object property references into constant time operations
14:19hyPiRionSame reasoning can be applied on Intel's processors
14:19hyPiRionOr any CPU for that matter.
14:19ChongLioh god
14:19ChongLiintel's in particular
14:19ChongLifrankenCPUs
14:19Ember-hehe
14:19ChongLiand it's what is killing them in mobile
14:20hyPiRionI'm happy ARM is around and kicking.
14:20technomancyit's not really interesting whether JS engines can make JS in general fast; the interesting question is how fast they can make that subset of JS which the closure compiler emits.
14:20ChongLitechnomancy: it comes down to the assumptions they're allowed to make
14:21technomancycourse if I spent any amount of time in that runtime I'd probably be cheering for it to be replaced by something that did arity checks by default and actually had integers, but whatever
14:21technomancynie moj cyrk, nie moje malpy.
14:21Ember-yeah, the fact that javascript has only floats is... mindboggling
14:22dnolen_Ember-: the list of thing that are mind boggling about JS is not short
14:22Ember-indeed
14:22Ember-but that is among the top of my list
14:22hyPiRionWell, javascript has booleans
14:23hyPiRionSo you know... In theory
14:23Ember-hyPiRion: lol, you don't mean what I'm thinking? :D
14:23hyPiRionI'm just saying you can represent integers as boolean arrays, nothing more.
14:23Ember-custom made binary calculus based integers? :)
14:23Ember-yeah, that
14:23Ember-I wonder how fast that would be
14:24Ember-not fast
14:24ChongLiprofoundly slow
14:24ChongLiyou might as well use strings
14:24Ember-ChongLi: most likely would be faster
14:24aaelonyI'm writing a usage function for a clojure command line app where I'd like to say, Usage: $0 <arg1> <arg2> and have $0 resolve to the name of the executable. I found this http://stackoverflow.com/questions/41894/0-program-name-in-java-discover-main-class, but it's not great. Is there anything more clojure-like for $0 that I can use?
14:25Ember-hyPiRion: but I do like that idea even if it is perverse
14:25Ember-might actually implement that for fun :)
14:25technomancyaaelony: pretending to be unix-like is not one of the JVM's strong suits unfortunately
14:26Ember-I've already implemented a purely functional immutable list for javascript :P
14:26JasonSmith1Each bit would be represented in memory as a 32 bit integer.
14:26aaelonytechnomancy: that's what I thought. I don't want to be too clever and call the system to tell me $0 but i might...
14:26Ember-that would be a good thing to do next for my "cool but totally useless pieces of code" -series
14:26ChongLiI seem to recall some guy wrote a DSL for those usage messages
14:27technomancyaaelony: depending on how you're distributing it you might find https://github.com/dekellum/hashdot useful
14:27aaelonyChongLi: sounds promising links pls ;)
14:27hyPiRionChongLi: clojure.tools.cli?
14:27aaelonycool, all good ideas :)
14:27ChongLiI'm trying to find it again
14:30aaelonytechnomancy: it will be pretty much linux or mac os bsd for dekellum looks interesting
14:30aaelonys/for/so/
14:31ChongLigah
14:31ChongLiit's so hard to find because the word "usage" is totally generic
14:31aaelonyhaha, no worries
14:32ChongLiI think there's actually an ISO standard for those usage messages
14:32ChongLiif I could figure out what that is
14:32ChongLiI'd have better luck finding it
14:32aaelonySiri doesn't know? lol
14:35ChongLihere it is!
14:35aaelony:)
14:36ChongLihttp://docopt.org/
14:36ChongLiit's not a clojure thing, I hope I wasn't getting your hopes up
14:36aaelonythat's okay, will read what its about. thanks :)
14:36ChongLino reason it couldn't be implemented in clojure however
14:37ChongLiat the bottom they list a bunch of different implementations
14:38aaelonyhyPiRion: thanks for the link to clojure.tools.cli
14:47aaelonytechnomancy: would it be a nice idea to be able to specify the name of a CLI executable in the project.clj for leiningen to faciliate? I'm thinking that maybe a config file of sorts could be read by the clojure program to tell it what the name is… or something...
14:48technomancyaaelony: I don't think that's a good fit for project.clj
14:49aaelonyyeah, probably not a great idea
14:52gfredericksso protocol extensions can't be retracted in the same manner as remove-method, right?
14:52gfredericks(or overridden)
14:53amalloygfredericks: welllllll, you could probably hack it
14:53amalloydefinitely not recommended
14:53gfredericksI've been pondering https://github.com/fredericksgary/java.jdbc/commit/c5ea0ac2b8a0fedc383b985c90c3f69956b1f287
14:53gfredericksand the fact that I had to put in the Object and nil extensions to get it to work
14:54gfredericksit's hard to imagine a user wanting to define those to do something else, but seems kind of icky that I had to rule it out
14:54gfredericksI imagine the only alternative is to remove the extension but wrap the call in an (if (satisfies? ...) ...)
14:54amalloyi think so, yes
14:55gfredericksshould I expect worse performance for that?
14:55gfredericksthe not-calling case would be the common one
14:55amalloyobviously it won't perform exactly as well
14:55gfredericksso is it faster to do a protocol dispatch that doesn't do anything, or check satisfies?
14:56gfredericksnot too hard to do a hasty benchmark I guess
14:56amalloylooks to me like they're basically the same
14:57gfredericksbased on? your knowledge of impl?
14:57amalloya quick scan of the impl
14:58gfredericksman I don't even know what file in the source to look in for that
14:58amalloycore_deftype
14:58ChongLijeez the applause is loud in that video
15:04dnolen_gfredericks: satisfies? is crazy slow in the failing case
15:05dnolen_gfredericks: in core.logic I've removed it, I just check for the interface behind the protocol, which may or may not work for you.
15:05amalloydnolen_: really? is it slower than just calling the protocol method?
15:05dnolen_amalloy: yes, it traverses the inheritance hierarchy and doesn't cache
15:05hiredman^-
15:08ohpauleeztechnomancy: Is there any specific doc I should look at for packaging native deps with my project?
15:08gfredericksyeah haphazard tests at the repl suggests satisfies is a lot slower
15:09ohpauleezI'm not pulling them, I'm providing/packaging them with my jar
15:09technomancyohpauleez: we were just lamenting the lack of such documentation in #leiningen
15:09ohpauleezI'll pop on over :)
15:09technomancytl;dr: there is nothing
15:09ohpauleezok
15:13dnolengfredericks: satisfies? performance in CLJS is much nicer (about the same as instance?) since we just ride on JS prototypes
15:13gfredericksdnolen: nice
15:17dnolengfredericks: oops, actually that's not true anymore. satisfies? is fast *because* we don't really handle the prototypal inheritance case. Should probably be fixed, but no ones complained much about it yet.
15:18gfrederickswouldn't matter unless you're using JS inheritance for some odd reason?
15:18gfrederickse.g., I might extend a protocol to Backbone.Model and expect my models to satisfy but they won't? or they'll work but satisfies? will return false anyways?
15:18ibdknoxwould matter for extending protocols to JS objects
15:19dnolengfredericks: yes, which I think is why people haven't complained. Michal Marcyk proposed a solution at one point - prototype bit masks which would allow us to handle it.
15:19dnolenibdknox: yep
15:20dnolenit's actually an relative ly easy fix for someone curious about how protocols are implemented in CLJS
15:20ibdknoxI haven't run into that *yet*, but I'm pretty sure I will at some point in the not too distant future. So that may end up being me
15:21tomojso we're going to make satisfies? slow?
15:21dnolentomoj: no
15:21ibdknoxbitmasks are pretty darn fast
15:21ibdknoxlol
15:21dnolenprototype bitmasks would allows them to be fast
15:21tomojoh, I see
15:21dnolener allow them to be fast
15:21dnolenwhile handling inheritance
15:21amalloyoh, i thought you guys had already done the bitmask thing
15:22dnolenamalloy: at the instance level, probably better to just move it to the prototype level - should have thought that when I did it but
15:22dnolenoh well
15:23ibdknoxha
15:23ibdknoxthat is the source of the weirdness I was seeing. I don't know why I didn't think about that
15:24dnolenibdknox: heh, I think in benchmarks, putting it on the instance had the perf edge. Going up the prototype chain had a measurable perf hit. So we should probably just do both.
15:24dnoleninstance fields if we can statically determine all protocols
15:25dnolenand prototype bitmask for dynamic case
15:25ibdknoxyeah
15:33tomojI just patched my clojure-mode to do always-2-spaces indentation
15:34tomojit seems to work well when the first argument is distinguished
15:34tomojlike map/reduce
15:35tomojnot so good for namespaces or function calls where the arguments are similar (like, say, +), unless you put zero args in the first line
15:35tomojwhich looks weird but may be the best option..
15:37tomojI wish I could have this https://www.refheap.com/paste/9d76bcb0c36d084fe61b28130 but that's special casing :(
15:43Raynestomoj: Get off my planet.
15:44FrozenlockHmm.. is there a command to clear the inferior-lisp buffer?
15:44tomojwhat I settle for now is extra linebreaks between each cond/expr pair
15:44tomojor, when you're lucky, just one line per pair
15:46tomojI just undid the patch
15:47ibdknoxI thought people lined up condition and return in conds?
15:47tomojthe prospect of committing code written in that style scares me
15:47tomoj'lined up' as in all the conditions and all the returns start in the same column?
15:48ibdknoxno: https://www.refheap.com/paste/8902
15:49tomojyeah, when you're lucky, one line per pair
15:49tomojwhat if the condition and/or return are bigger?
15:50ibdknoxI still do it that way
15:50ibdknoxlet me find one
15:50tomojeven when it's the condition that's big? huh
15:50tomojnever thought of that option
15:50ibdknoxit's definitely uglier in the condition case
15:50ibdknoxbut I don't usually have multi-line conditions
15:50tomojyeah
15:52tomojhttps://www.refheap.com/paste/fef7e4256e143b00b156b3208 guess I should factor things out and just make the cond simpler
15:54ibdknoxI'm not sure why, but that style is very hard for me to read
15:54ibdknoxlol
15:55ibdknoxthe cond isn't idented correctly, but here's one: https://www.refheap.com/paste/8904
15:55amalloyaw tomoj, that double assoc-in should really be an update-in with two assocs
15:56amalloyibdknox: really? neither of those ands should exist at all; doesn't cljs have multi-arity = and >=?
15:56bbloomamalloy: it can be a single assoc with additional args
15:56amalloybbloom: yes, better
15:56bbloomamalloy: sometimes an and is a little clearer than using less-than to mean strictly-ascending
15:57ibdknoxI acutally always forget about being able to do that
15:57bbloomin this case, i'd say that's true of the first and
15:57amalloybbloom: that may be the case on occasion, but the first and was terrible for me to read
15:57ibdknoxyeah, the second one should go away
15:57amalloyis line supposed to be in between the two properties of this thing, or not in between them? if it's just a single <=, it's easy
15:57bbloomthe second one should definitely be 3-arity =
15:58bbloomamalloy: sorry, i misread that first and, you're right, apparently my missreading it is proof that it would be better the other way haha
15:58ibdknoxinbetween or equal to
15:58amalloyright, i figured it out
15:59bbloomas for how cond gets formatted, i prefer to line up a table when it's pretty small/clear & fits horizontally... but past that, i do something that i think others shun: i indent the consequences 2 spaces
15:59amalloycond is just one of those things that no two people treat the same. we need style wars to cull the herd
15:59ibdknoxlol
15:59bbloomit violates the unspoken rule of indentation only ever happening inside a braces nesting, but i really find it so much easier to read
15:59tomojamalloy: https://www.refheap.com/paste/c37abca4581b75e87e1764294 ?
16:00amalloytomoj: sure, although since req is such a small thing i probably wouldn't even bother with the ->
16:00bbloomtomoj: or you can keep the -> and move the app into it
16:00amalloybarf
16:00tomojheh
16:01tomojI did that earlier for (-> req (update-in ...) app (update-in ...))
16:01tomoj..which seems cumbersomely common
16:01amalloyi think i must be the only one on the planet who would write that as (app); i never let un-parenthesized stuff into my ->s
16:02ibdknoxI do that too
16:02bbloomamalloy: reduction of parens is one of the best features of ->
16:02bbloom:-)
16:02tomojI could go for that
16:02bbloomor at least touching parens
16:02ibdknoxmakes it more obvious that it's a function call
16:02amalloybbloom: meh
16:03tomojwait, except -> doesn't call app with zero args there
16:03tomojdown with ->
16:03amalloythe best feature of -> IMO is that it lets me order my code however i want. i like to "emphasize" parts of a call by putting them on the left, and de-emphasize the boring parts by putting them on the right
16:04yogthosI find -> is nice because it flattens the tree out and it makes it really easy to reorder stuff and move it around
16:05bbloomi use the shit out of -> down in my (comment ... ) tests at the bottom for testing multi step processes. i generally put a bunch of intermediate debugging printing steps in there
16:05yogthosand it orders logic left to right
16:05bbloomit lets me centrally locate my tracing code
16:05tomojit orders operations left to right
16:06yogthostomoj: right, so if you're doing a series of transformations it reads more naturally I find
16:06bbloomtomoj: a very lovely property
16:06tomojif you're working with operations
16:06bbloomit's particularly nice if you're threading some state through functions with side effects: side effect order matches the reading order
16:07tomojbut what's nice when you're working with pure functions and values?
16:07tomojwell, -> is still pretty nice
16:10tomojbut it's interesting that get-in and friends go 'right to left'
16:10S11001001tomoj: ->> with sequence ops
16:10gfredericksright to left?
16:10tomojhmm, wait, they match, huh
16:11tomojjust comp that's 'backwards'
16:12gfredericksdoes clojure.test guarantee tests in a ns run in the order they're declared?
16:12hiredmangfredericks: no
16:13gfrederickstesting protocols is messy
16:21Frozenlock&(partition-by odd? [1 1 1 2 2 3 3])
16:21lazybot⇒ ((1 1 1) (2 2) (3 3))
16:21FrozenlockWhat if I want to partition into only 2 seperate groups?
16:22amalloy~separate
16:22clojurebotseparate is in clojure.contrib.seq-utils, but just use (juxt filter remove) instead
16:22FrozenlockThanks!
16:22apwalk&(split-with odd? [1 1 1 2 2 3 3])
16:22lazybot⇒ [(1 1 1) (2 2 3 3)]
16:28hugodbbloom: I am wanting to do some transformation of clojure forms - looks like I could use the transduce functions in fipp to do this :)
16:29bbloomhugod: you need a stateful transformation?
16:29hugodyep
16:30bbloomhugod: do you need reducers or are lazy sequences sufficient?
16:30bbloomi needed reducers in order to have strict handling of side effects (namely: printing)
16:31hugodbbloom: not sure - lazy sequences may suffice
16:31bbloomit's pretty easy to implement a lazy map-state or mapcat-state
16:31hugodI'm not sure I even need it to be lazy
16:31bbloomdo you have any side effects? if so, you want the strict evaluation of reducers
16:32bbloomdo you want your transformation to be foldable? if so, you'd need reducers, but then the state doesn't make much sense, since it's a linear state updated over the seq
16:32bbloomif you don't have side effects and want a state transducer, i suggest just porting my map-state and mapcat-state back to simple lazy-seq recursive functions
16:33hugodum, the state I need is probably scoped to forms, rather than linear
16:34bbloomas in you have a recursive transformation and you're accumulating state in each node?
16:35hugodyes, and the transformation depends on the accumulated state
16:35bbloomhmmmm
16:35bbloomare you familiar with generators and "yield" ?
16:35hugodI was just about to read the paper
16:36bbloomhave you ever used python? or c# ?
16:36hugodoh, yes
16:36bbloomso generators & yield are just like in those
16:36bbloomin haskell land, they implement them using a monad that threads the yield state through all the operations
16:36bbloomgenerators and yield are the strict (as opposed to lazy) equivilant of lazy-seqs
16:37hugodok, thanks - I think you've helped clarify what I need
16:37bbloomif you need to pass data "up" the tree when doing your transformation, you're in a pretty tricky spot
16:38bbloomyou could use a zipper to let functions go up, edit, and then come back down, then resume traversing
16:38hugodI may need to pass state up
16:38bbloomcan you do it in several passes? ie walk the tree once, collect some data, then walk it again using that state?
16:38bbloomthat's much simpler
16:39bbloomyou don't need to pass state up in that case, you just preserve it for the next pass
16:39hugodpossibly - I could annotate forms with metadata
16:39bbloomhugod: probably best if you work with an AST like the one produced by clojurescript's analyzer or ambrose's Analyze
16:40bbloomthen you can just assoc in a ::key
16:40bbloomhugod: also worth studying: http://en.wikipedia.org/wiki/Attribute_grammar
16:40hugodyeah - that was my original though
16:40hugodthought
16:40hugodI was looking for a clojure AST when I remembered fipp
16:41bbloomheh, i guess fipp's pretty print documents are *like* an AST for the outputted pretty printing
16:42hugodI'ld forgotten Ambrose' Analyze
16:43hugodbbloom: thanks again :)
16:44bbloomhugod: no problem. what are you making?
16:45hyPiRionBest check ever: Ran 1 tests containing 100008 assertions.
16:46hugodbbloom: I want clojure semantics for an embedded dsl, and can't achieve it any other way
16:46bawrhyPiRion: the hell. why would anyone do that.
16:46bbloomhugod: what's the dsl?
16:47hugodbbloom: pallet
16:48bbloomhugod: i really got to go study that at some point, but i'm terrified of pretty much all configuration management systems... i generally manage my servers with makefiles and that scaled pretty cleanly to 15+ servers, which is the most ive had to administer myself before :-P
16:48hugodpallet has targets with code attached to them, just like makefiles ;)
16:48technomancypallet's feature list reads like a point-for-point "things that are wrong with chef" document
16:49technomancyvery different approach, which I'm glad of =)
16:49hyPiRionbawr: It's just to check if my prime generator works as intended. Them nasty bugs pop up when trying to implement fast and concurrent data structures
16:50TimMcclasspath wat r u doing, stahp
16:50bbloomtechnomancy: that's good to hear
16:50hugodbbloom, technomancy: the problem is that plan-fn's generate a data structure which is executed in a separate phase, which affects how you have to write code. Too much cognitive overload still.
16:51bbloomhugod: i'm also exploring the world of declaration/plan/act cycles
16:51technomancyhugod: I didn't realize it at first, but now I see parallels to converge and eval-in-project
16:51bbloomhugod: but in the GUI context... so there is declare/plan/act/react/re-re-react :-)
16:52hugodbbloom: interesting - we generate an action plan, that is transformed and then executed. much like a compiler in some ways
16:52hugodtechnomancy: now that you mention it, yes
16:52bbloomhugod: that's precisely what i'm doing with the dom: i generate a script to permute the browser state
16:53TimMcpermute? :-)
16:53warzis :filespecs only for additional clj files? im trying to include a yml file at the root of a jar, but specifying it with :filespecs causes a null pointer exception
16:53bbloomi like the word permute as opposed to the word "update"
16:53bbloomupdate implies a place, it implies mutation
16:53bbloompermute implies just a little reordering of things :-)
16:53technomancywarz: it should work for any file, but the docs are not very good
16:54TimMcDoesn't permute mean shuffle?
16:54technomancywarz: what are you trying?
16:54bbloombut i guess i am "update"-ing the dom
16:54hyPiRionTimMc: I thought that as well
16:54TimMcI like the idea of a DOM lib that only allows you to move things, not add/delete/modify.
16:54bbloom"A way, esp. one of several possible variations, in which a set or number of things can be ordered or arranged."
16:54bbloomarrangement, shuffle, reorder, vary, etc
16:54warztechnomancy, i just have :filespecs [{:type :path :path "plugin.yml"}]
16:55TimMcbbloom: Oh, that is in fact what you're doing? Carry on then.
16:55bbloomTimMc: surely you need to add and remove things lol
16:55warzif the file name doesn't exist, no exception is thrown and nothings included, but if the file name exists, it throws the exception.
16:55warzso i can at least assume it's seeing the file there.
16:55brehautI'd like an honest DOM library; every operation just throws (Exception. "This is going to end in tears; give up now")
16:56TimMcfunction doStuff() { throw new Boolean(false); }
16:56hugodbbloom: pallet's actions have return values representing values or results from operations on a remote node, and I want to be able to use clojure conditionals on these, even though their values aren't available until during the execution phase
16:56amalloyyou could call it DOMinatrix: bringing you the pain you're begging for
16:56bbloomamalloy: which pain is that?
16:57TimMcThe paradoxical boolean is just there to twist the knife.
16:57technomancywarz: works here on lein 2.0.0
16:57bbloom(there are just so many of them when the dom is involved)
16:57technomancywarz: can you put the stack trace on refheap or gist?
16:57bbloomhugod: are
16:57bbloomhit return too soon
16:58bbloomhugod: i'll assume you know what you're doing, but i worry that if you need anything more sophisticated than a result transformation function, you'd be better off with semantics that differ from a normal cond block
16:59hugodbbloom: we have pallet specific forms, but knowing when to use them is proving to require too much cognitive load
17:02hugodat the moment it's an exercise to see how it works out
17:07warztechnomancy, ya ok. sorry i was heating up a hotdog. haha.
17:08warztechnomancy, im new to this so im probably doing something wrong. here is the stack trace: https://gist.github.com/4614501
17:08warzi assumed it was looking for clojure code, because i saw the function EnumerateSeq and invoke and stuff
17:09sshackDid cemerick ever release any bays' network code after his talk on the subject?
17:09brehautsshack: no; he discovered serious flaws
17:09sshackoh?
17:09brehautsshack: i know nothing about bayes so im not qualified to comment on the flaws. i jsut know that there were there
17:10amalloya pretty basic misunderstanding of the maths involved, from what i understand
17:10sshackUnderstood.
17:10amalloyhe talks about it in one of his podcasts
17:10sshackahh. Yeah, it is very tricky.
17:10amalloythe mostly lazy episode with chouser, if you're interested in finding it
17:11technomancywarz: hm; might be a windows-specific bug
17:11technomancywarz: maybe open a github issue for it
17:13sshackamalloy: I will have a look.
17:15sshackamalloy: episode 6 sound right to you?
17:15lpetitHi, what is the current state of marginalia ? Of literate programming in Clojure ?
17:15amalloy*shrug*
17:16brehautlpetit: i think zkim has pretty much taken over maintainance? its slowed down considerably i believe
17:16lpetitI have a source code I'de like to share with others (essentially clojure newbies) so that they can learn by reading, so I want to decompose it intentionally in small pieces, explaining things as I go.
17:17tomojbbloom: can't the state make sense with a fold if there's an identity state and a combine operation?
17:17lpetitbrehaut: because it's stable, or because of lack of interest from most?
17:17brehautlpetit: a bit of both i think
17:17tomojhmm, I'm just thinking of the reduction state, I guess I still don't understand mapcat-state etc
17:18bbloomtomoj: for there to be a combine operation, you need composable state, which is tricky
17:18lpetitWhat would you suggest? Marginalia, some other lib I don't know about, or setting up a blog ?
17:18brehautlpetit: well, its not exactly literate programming like you might expect with knuth's web or literate haskell
17:18bbloomtomoj: lots of folks studying that stuff, things like http://www.eecs.berkeley.edu/Pubs/TechRpts/2009/EECS-2009-173.html
17:18tomojI didn't think the 'state' in map-state was about side effects
17:19technomancylpetit: if you're just going to write it once and not re-publish the HTML for new versions I'd recommend a blog
17:19bbloomwell in my case the printing is in fact linear
17:19bbloomtomoj: the state isn't about side effects, the use of reducers was about side effects
17:19brehautlpetit: you've seen http://fogus.github.com/marginalia/ i assume?
17:19tomojyeah
17:19brehauttechnomancy, lpetit: i second that.
17:19lpetittechnomancy: yeah, I may well rewrite it more than once before it has stabilized, and the blog post may well come after the fact :-)
17:20lpetitbrehaut: yeah, saw the web page
17:20technomancyI use marginalia for publishing API reference for leiningen-core and it's fine, but I'm not an advanced user
17:20brehautlpetit: thats pretty much the norm for marg projects
17:20lpetittechnomancy: ok, so it's still in use :-)
17:20technomancytypically when reading code I prefer to do it in the editor, ironically because it's better at hyperlinking
17:20technomancyTBH I'm not sure if anyone actually uses the API reference I generate
17:21lpetittechnomancy: I can't expect people to install an editor, I want to catch their attention with just a browser :-)
17:21technomancylpetit: yeah, it completely depends on the audience
17:21lpetittechnomancy: Where is it located ? (Ok, I leave the room :-) )
17:21technomancyhttp://leiningen.org/reference.html
17:22brehautlpetit: incidentally, the syntax highlighter that marg uses is a seperate JS project so its easy to stick into your HTML
17:22brehautlpetit: although the default colourscheme is angry fruit salad
17:23lpetitbrehaut, technomancy : do you think marginalia could get help from IDE support, e.g. auto-regeneration, etc. ?
17:24brehautlpetit: i'm the wrong person to ask, but i do forget to run marg for my own projects so maybe?
17:24technomancylpetit: seems unlikely to me but I'm not a heavy user
17:25lpetityeah, I knew that. I did great postponing this idea, then :)
17:27brehautlpetit: one thing about marg im not sure about is the way comments and docstrings are merged in the 'textual' pane
17:28lpetitbrehaut: will check this "live". But I've got to go now, thanks for the feedback
17:41sshackAhh, found the note from cemerick https://github.com/cemerick/raposo
18:01clojure-newbhey guys, I've got a PersistentVector : [({:si ["14"]} {:si ["15"]}) ({:si ["16"]})] which I would like to turn into another PersistentVector : [(["14"] ["15"]) (["16"])], so just grabbing the :si key, any ideas ?
18:02Bronsa, (mapv #(map :si %) ' [({:si ["14"]} {:si ["15"]}) ({:si ["16"]})])
18:02clojurebot[(["14"] ["15"]) (["16"])]
18:03AimHereIf the hash-keys vary, you might replace :si with 'vals'
18:04clojure-newbBronsa: mapv, hmmm did not know about that one
18:04Bronsait was added in clojure-1.4 afaik
18:04AimHereIt was introduced in 1.4, just to clean up the (vec (map ... )) idiom
18:04clojure-newbcool, thx guys, I'll give it a go
18:14aaelonyhas anyone thought about Pentaho (http://community.pentaho.com/projects/bi_platform/) as a potential target for a Clojure DSL ?
18:21muhoowha are you-all using for java profiling in clojure? visualvm? jprofiler?
18:28sirvalianceAny tips for copying a dir and its files specifically for running tests?
18:29scottjmuhoo: yourkit
18:40muhoothanks
18:41sirvalianceAre there any clojure libs that nicely wrap the java io functions?
18:42dnolensirvaliance: clojure.java.io does the basic
18:43dnolens
18:43sirvaliancednolen: Yeah, I just didn't know if anyone made a wrapper lib to simplify larger operations
19:06muhoois there some way to get lein check to stop trying to run main?
19:07amalloymuhoo: bet you a dollar it's not running main
19:08amalloyit's just compiling your namespace, which has side-effecty stuff at the top level (as opposed to in main where it belongs)
19:17muhoothere's sideeffecty stuff in (-main) for sure, but not floating about loose in the ns, at all
19:17muhooin fact, the side-effecty stuff that is running is most definitely inside (-main)
19:17muhooi can tell from the log
19:18muhoobut this is so loaded with java interop stuff, it could be that too
19:19muhoohttps://www.refheap.com/paste/8911 .. start-everything is what is running at lein check time
19:21amalloywell, the code for lein check is very simple, and you can easily tell all it does is require your namespace
19:21amalloytry requiring it yourself in a repl and see if start-everything is called there as well
19:23muhooaha, i see
19:23muhooi've got an injetions
19:23muhoothe injection runs the main, which i want it to do when i start the repl. but i do NOT want it to do when i run lein check. hmm.
19:23muhoo:injections [(do (require 'spazcoin.server) (spazcoin.server/-main))] <-- there
19:38muhoook, i'm lost now. i moved the injection to a profile, and naively tried "lein pdo cljsbuild auto, with-profile autorun repl :headless" with no success
19:50augustlwhy is the ring-anti-forgery middleware only blocking POSTs? Why not PUT etc?
19:53djwonkwhat are some recommended ways to autorun clojure tests?
19:54technomancydjwonk: most people use something like clojure-test-mode; for some reason no one has extracted a generalized run-on-file-change higher-order Leiningen task
20:00djwonktechnomancy: thanks
20:01technomancynp
20:09augustlweavejester: ping https://github.com/weavejester/ring-anti-forgery/pull/11 :)
20:11weavejesteraugustl: Why is CSRF-protection needed for XHR?
20:12weavejesterSurely the same-origin policy does the job of the anti-forgery token?
20:12augustlweavejester: it seems fishy/unsafe to try to detect whether an incoming request is an XHR
20:13augustlit's better to block any POST, xhr or not
20:13augustl..for all I know
20:14tomojdid you figure out why not PUT?
20:14augustltomoj: no, but I think it's because HTML forms can only POST
20:14tomojah
20:14augustleven chrome doesn't allow method="put" in the HTML iirc
20:15technomancywow, is that still a thing?
20:15technomancyamazing
20:16augustlxsrf, http methods, or something else? :)
20:16technomancyI mean method="PUT" not working
20:16technomancyand by amazing I mean sad
20:16warzdoes that work on any browser?
20:16brehautturns out the future is still the future :(
20:16warzi didnt think it did
20:16weavejestertechnomancy: Forms have no same-origin policy, which might be why people aren't in a rush to support PUTs etc.
20:17weavejesteraugustl: I'm still not seeing what advantage using a token for XHR gives you
20:17augustlweavejester: the problem is on the server-side. I want to block any incoming request that doesn't contain the token.
20:17augustlit's not a client side issue, and the XHR block is only on the client side
20:18augustls/XHR block/XHR same origin policy/
20:18technomancyweavejester: huh; hadn't considered that
20:18augustlweavejester: so, for some (most?) XHR requests, a header is more convenient, so my request body can be all JSON
20:19augustlinstead of __anti-forgery-token=123abc&myjson=... and then use form params to parse the JSON, and not set content-type JSON on the request, and ...
20:19weavejesterHm… So the scenario is: what happens if a form from a remote page is used to send a POST to an XHR route?
20:19augustlthere's no such thing as an XHR route, so it will be blocked since the forgery token isn't there
20:20augustlthe route just blocks the POST if the correct token isn't in the form body or in the header
20:20warztechnomancy, dang i must be doing something wrong. i just tried that :filespecs thing that i mentioned a few hours ago, on my linux machine at home. same error.
20:21augustlweavejester: also, I think it is possible for forms to POST raw json to a different origin
20:21augustlso simply checking for JSON in the body isn't enough
20:21augustl<input name="json here" type="hidden" /> will do that iirc
20:21weavejesteraugustl: You wouldn't necessarily need a random token though… any header being set would do it.
20:22weavejesteraugustl: And the content-type would obviously stop it, too.
20:22augustlgood point :)
20:22technomancywarz: if you can narrow it down to a simple case that works with a fresh `lein new` project please open a github issue
20:22weavejesterLet me sleep on it… and read up on best practise :)
20:22augustlRails requires the actual token so I didn't think about it (since I just stole this from Rails)
20:23weavejestergoodnight
20:23augustlweavejester: great! I'll just disable forgery protection for now, won't be in production for a couple of weeks at least ;)
20:23augustlnn
20:25auggieroseso, is leiningen a contextual or a composable tool?
20:25augustlregarding the method="xxx" on forms, I think pretty much every routing framework out there checks the method and the form param _method, which seems to be the convention for specifying the _actual_ method from a form
20:30djanatyntomoj: happy birthday!
20:31tomojwho told? google?
20:32tomojijeki'edo
20:33warztechnomancy, ok i opened one. we'll see if anybody else can reproduce or if im just doing it wrong. :)
20:34technomancywarz: cool; I'll take a look tomorrow
20:34technomancy:filespecs does kinda suck as it is
20:35warzi have to take your word for it. clojure as it is still looks alien to me, but im trying to get into it.
20:36technomancyit's just one of those places where I'm unhappy with the current implementation in Leiningen
20:36djanatyntomoj: yep :)
20:46gdev anyone experiment with game programming in clojure?
20:49Schaeferhey folks... i've got two lists of maps. eg [{:name joe :age 10} {:name bob :age 12}] and [{:name joe: age 10} {:name bob :age 13}]. i want to find the records with names that match but ages don't. in this example, i'd find {:name bob}. i'm pretty new to clojure but this feels vaguely like a zipper problem. is there some canonical solution for this problem?
20:51RaynesMatch what?
20:51RaynesOh, I think I see.
20:51RaynesYou want to find the records that have the same name but different ages?
20:51RaynesStuff like that
20:51Schaefermaybe not zipper. i was thinking
20:51Schaeferzipmap
20:51brehaut,(for [a [{:name joe :age 10} {:name bob :age 12}] b [{:name joe: age 10} {:name bob :age 13}] :when (and (= (:name a) (:name b)) (not= (:age a) (:age b))] [a b])
20:51clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Invalid token: joe:>
20:51SchaeferRaynes: yes
20:51RaynesYeah, I don't think zipper if what you're after here.
20:52brehaut,(for [a '[{:name joe :age 10} {:name bob :age 12}] b '[{:name joe: age 10} {:name bob :age 13}] :when (and (= (:name a) (:name b)) (not= (:age a) (:age b))] [a b])
20:52clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Invalid token: joe:>
20:52brehautwell crap
20:52brehautsomething like that
20:52Schaeferlet me try with quoting
20:52RaynesYou probably want group-by.
20:52Schaefer,(for [a '[{:name :joe :age 10} {:name :bob :age 12}] b '[{:name :joe: age 10} {:name :bob :age 13}] :when (and (= (:name a) (:name b)) (not= (:age a) (:age b))] [a b])
20:52clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Invalid token: :joe:>
20:52brehautSchaefer: you probably dont want to use symbols for non code data
20:52Schaeferdouble crap
20:53RaynesYou probably don't want group-by, actually.
20:53Schaeferbrehaut: yep. that makes sense
20:53brehautSchaefer: thats what keywords are for
20:53Schaeferi figure i could write the algo out longhand but i was hoping for some one-liner. seems like a pretty common problem
20:54brehautkeywords are basically symbols that refer to themselves, symbols are symbols that refer to something else
20:54Schaeferbrehaut: thanks. i was just trying to do something quickly. i probably should have used 'joe and 'bob.
20:54brehaut,(for [a [{:name :joe :age 10} {:name :bob :age 12}] b [{:name :joe :age 10} {:name :bob :age 13}] :when (and (= (:name a) (:name b)) (not= (:age a) (:age b)))] [a b])
20:54clojurebot([{:age 12, :name :bob} {:age 13, :name :bob}])
20:55brehautSchaefer: that for does the cross product of both lists though so it blows out pretty fast
20:56brehautSchaefer: its like SELECT * FROM a OUTER JOIN a WHERE a.name = b.name AND a.age != b.age
20:57Schaeferbrehaut: thanks! that really helps me understand the algorithm
20:57Schaeferi find i have trouble understanding how laziness will affect the computation space
20:58brehautSchaefer: its not laziness in this case, but the cross product
20:58brehautSchaefer: it has to compare every pair
20:58Schaeferbrehaut: i understand the number of operations. would it be constant memory though?
20:59brehautif you reformulated the problem so that you had {:joe 10, :bob 12} and {:joe 10 :bob13} for instance, you could take advantage of indexed lookup
20:59brehautSchaefer: yes it would
21:00brehautin any case for is a fantastic tool though
21:00ibdknoxare you trying to find all of the ages of people with the same name?
21:00Schaeferbrehaut: thanks for pointers! i'll have to think if i can restructure my data. seems plausible
21:01rationalrevoltHi room, can someone help me understand why lein repl gives me cdoc on the user namespace, but using nrepl-jack-in in emacs does not? Is nrepl-jack-in and lein repl totally separate implementations of nrepl protocol? I was thinking nrepl-jack-in uses lein repl underneath... but i'm not understanding
21:01brehautthe repl implicitly uses clojure.repl, jack-in does not
21:02brehautyou can use the emacs to access stuff instead
21:03Schaeferibdknox: actually, i'm playing with datomic. i'm protoyping a reactive query system. right now, the queries are stored in datomic along with their results. i have a list of queries whose results *could* be changed by the most recent transaction. i want to determine the queries whose values actually changed so i can write the results back into the db
21:03ibdknoxsounds like you should be using sets
21:03rationalrevoltdo you mean the lein repl does an implicit require of clojure.repl before giving me the prompt?
21:04brehautyes
21:04ibdknoxSchaefer: if you do a set difference between before and after you'd get what you want, wouldn't you? :)
21:04Schaefera set of maps? well, duh. of course that would work. <slap forehead>
21:04Schaefermake that two sets of maps....
21:05rationalrevoltbrehaut: what would I do if i wanted jack-in to do that as well? do i have to change nrepl.el in order to do that?
21:05Schaeferibdknox: thanks!
21:05ibdknoxSchaefer: np :)
21:05brehautrationalrevolt: you'd be better served by learning the emacs mode ;) otherwise i dont know
21:06rationalrevoltbrehaut: sorry, din't get you - learning the emacs mode?
21:07tomojit seems rather odd to store query results in datomic
21:08brehautrationalrevolt: all the features of the repl namespaces are available in emacs as emacs commands
21:08brehautrationalrevolt: mostly with chord keys
21:10rationalrevoltbrehaut: you mean like C-c-k to load the current buffer into the repl?
21:10brehautetc
21:13brehautrationalrevolt: https://github.com/kingtim/nrepl.el#keys
21:13brehautrationalrevolt: C-c C-d and C-c C-j for clojure docs and javadocs respectively
21:14brehautrationalrevolt: it works in your source and the repl
21:21ttimvisherwhat's the state of swank/nrepl support for clojurescript?
21:25rationalrevoltbrehaut: but i guess if i wanted nrepl-jack-in to auto 'use' clojure.repl when it gives me the prompt, instead of me having to load a buffer containing the (use 'clojure.repl) form or having to type it in - i would have to either make myself some key combination that will execute that form into the repl or some such?
21:26Schaefertomoj: just saw your comment. yes, it's a little odd and i may not keep this design. the current approach is convenient because of dependencies. suppose one query depends on the results of another. my algorithm for computing the new results is pretty simple: take the current transaction, find all affected queries, compute their results. for the queries whose values have changed, write...
21:26Schaefer...them back to the database. repeat the algorithm until the transaction queue is empty
21:26brehautrationalrevolt: im not sure i understand the point of using nrepl from clojure if you are just going to use it like the command line repl
21:28rationalrevoltbrehaut: hmm, i frequently use cdoc and i was looking for some way to automatically have it available when nrepl-jack-in gives me the prompt.. I do use the mode commands (such as C-c-k etc), so i do want to use emacs + nrepl-jack-in.. I'm quite new to clojure/emacs, so i might be coming across confusing
21:29brehautwait, cdoc? what is that?
21:29rationalrevoltbrehaut: clojuredoc, the command that fetches examples from clojuredocs.org
21:30rationalrevoltjust like source or doc, but pulls examples of using command
21:30rationalrevoltlike i can say (cdoc list) and it will give me examples on how to use list
21:30brehautah. thats part of reply not clojure.repl
21:31brehautclojuredocs.org is getting pretty out of date too; the last version it claims ot support is 1.3.0
21:32rationalrevoltbrehaut: oh, ur right - i though it was part of clojure.repl - what did you say it was part of? reply?
21:33brehautrepl-y the new reply by tprtcolin; its the 'lein repl" nrepl client
21:33brehauthttps://github.com/trptcolin/reply
21:34brehautlooks like its using https://github.com/dakrone/clojuredocs-client
21:35rayluwoah, nice
21:35rationalrevoltahh - so, i can accomplish what i wanted by just includng clojuredocs-client as a dependancy in my project.clj, is that right?
21:35brehauti hope you mean as a dev dependancy ;)
21:36rationalrevoltyup
21:37rationalrevoltbrehaut: thank you :)
21:54tomojSchaefer: I see. curious, how do you store the queries themselves?
21:54tomojserialized as bytes?
21:54tomojor like reified with e.g. an entity per where clause, or what?
21:55Schaefertomoj: right now, queries are datomic entities with three fields: a matching entity query, a value function and the current value
21:56Schaeferthe matchin entity query and value function are both strings. i use read-string when i read them out of datomic
21:56tomojah, cool
21:57Schaeferobviously not very efficient at the moment but i figure i can cache them since i don't expect the queries to change very often
22:04ttimvisherWhat am I doing wrong here? https://github.com/timvisher/clojurescript-up-and-running/tree/master/keybord-events
22:04ttimvisherI'm `:require`ing `goog.events`, which is the provide that KeyHandler should be under according to http://closure-library.googlecode.com/svn/docs/class_goog_events_KeyHandler.html
22:05ttimvisherbut I'm getting `undefined is not a function` when trying to use it from the browser
22:05ttimvisherI also see it nowhere in the generated source
22:05ttimvisherbut I didn't think I needed to do anything special to get any of the closure libraries to be available to me to require
22:07ttimvisherchanging my require to a namespace that doesn't exist also triggers an error so `goog.events` is definitely being found.
22:17ttimvisheri can construct a keyhandler now but it requires me to require `goog.events.KeyHandler`
22:17ttimvisherwhat does the `:as` do in that case?
22:19TimMcIt gives you a short alias.
22:19FrozenlockI'm not sure aliases work when dealing with goog libraries.
22:20FrozenlockI always had to require it and still refer to it by its full (or almost full) name.
22:20ttimvisherTimMc: that's what i thought, but it `key-handler.` errored out
22:20bbloomFrozenlock: they generally do/should. i had an issue with some stuff in third_party like the dom query stuff, but if it's not working, it's definitely a bug
22:20TimMcOh, CLJS? No idea on the differences from CLJ there.
22:20ttimvisher(- it)
22:20bbloomplease report such issues
22:21Frozenlockbbloom: Oh great, perhaps it's been fixed then... it was many months ago
22:21ttimvisherbbloom: issues where `:as` doesn't produce a working alias?
22:22bbloomttimvisher: none that i know of, the issue i had had to do with classpaths & loading files that weren't in in src/third_party instead of src/goog
22:22Frozenlockttimvisher: if you are playing with key handler, you might want to look at https://github.com/Frozenlock/zyzanie
22:22FrozenlockNot the prettiest, but it works.
22:23ttimvisherFrozenlock: fun! :)
22:23ttimvisherthis is my first foray into clojurescript so I'm more just playing around
22:23Frozenlockttimvisher: huge fan of your emacs vim-golf btw :)
22:23ttimvisherwill definitely look into that
22:23ttimvisherthanks!
22:23ttimvisheri wish i still had time to do them
22:23ttimvisherthere are downsides to working at a start up, i suppose ;)
22:27ttimvisherThis is what I ended up with. Seems like `:as` has no real effect for `goog` libraries. I get `goog.events` for free because `KeyHandler` requires it for itself. https://github.com/timvisher/clojurescript-up-and-running/blob/master/keybord-events/src/keybord_events/core.cljs
22:28Frozenlockttimvisher: That was my experience as well; never been able to alias a goog library.
22:29FrozenlockAlso, you might want to look at domina https://github.com/levand/domina or enfocus https://github.com/ckirkendall/enfocus to deal easily with events.
22:31tomojI've aliased goog.string as gstring
22:31tomojclojure.string in cljs does the same
22:32tomojprobably issues referring to types using the alias
22:32tomojclojure.string also does [goog.string.StringBuffer :as gstringbuf]
22:33j0niis there an obvious choice for standard crypto operations in clojure - stuff like sha digests and the like?
22:34j0nia cursory inspection shows nothing in core or listed in contrib on clojure.org
22:34Frozenlock[goog.fx.DragDrop :as dd] ---> (dd. some-element) ----> #<TypeError: undefined is not a function> :(
22:35tomojwell you can at least (:import goog.fx.DragDrop) I believe
22:35FrozenlockPerhaps... but I think `require' already does it, even if the alias doesn't work.
22:35tomojit lets you do (DragDrop. some-element) ?
22:36tomojthat seems like a bug
22:36FrozenlockNo, it let's me (goog.fx.DragDrop. some-element)
22:37FrozenlockOnce I've tried to alias it in a require.
22:37tomojright, that's because it's required. if you import you'll be able to (DragDrop. some-element)
22:37FrozenlockOh God no... not another ns tweek to learn... :(
22:37tomojI wouldn't expect (dd. some-element) to work
22:38tomoj:require :as is for namespaces
22:39tomoj:import is for importing classes so they can be referred to without the package
22:40tomojI wonder if (:require [goog.fx :as fx]) (fx/DragDrop. some-element) works
22:40tomojpresumably not?
22:40FrozenlockI'll try.
22:41FrozenlockOh that works!
22:41FrozenlockInteresting
22:41tomojbut I wonder if it doesn't really require DragDrop
22:42ttimvishertomoj: good tip!
22:42ttimvisheri'm still thinking of anything that is `provide`d as a namespace
22:42ttimvisherbut it can totally be a class as well.
22:43Frozenlocktomoj: you mean it might have worked because I have already required DragDrop?
22:43tomojthat's my worry
22:44tomojor that it'll suddenly break in advanced comp or something
22:44FrozenlockWell it works in another namespace. should I reset the repl?
22:44tomojbut I dunno
22:44tomojdon't really understand goog.provide/require or how cljs deals with it
22:44tomojs/really/at all/
22:44FrozenlockNeither do I :P
22:44bbloomtomoj: did you read the docs on the gclosure site?
22:48skelternetanyone used your own reader literals to get something useful done?
22:50tomojbbloom: nope
22:50bbloomtomoj: that's why you don't understand it :-)
22:52tomojyeah
22:54ttimvisherbbloom: have a link to these docs?
22:59ttimvisherFrozenlock: just pushed up some changes that i think follow a better approach. Not sure what the difference between import and require is in those cases but that certainly makes the calling code cleaner.
23:02FrozenlockIndeed. I'll do the same in my own code now that I'm aware of that :)
23:03tomojs3-wagon-private's output makes me appreciate how good we had it when it was just maven uncontrollably spitting out garbage
23:05yedi#clojure is so awesome
23:05Raynesyedi: I know I am
23:15akhudekj0ni: I would suggest using a java library: built in pbkdf2, jbcrypt, or jasypt
23:16tomojif all you want is a sha digest, I don't think you need a library
23:17tomojexample (and a library, though I won't claim it's an obvious choice): https://github.com/tebeka/clj-digest/blob/master/src/digest.clj
23:18j0niwell for now i just used java.security.* directly
23:18j0nii'll take a look at clj-digest though
23:19j0nithanks
23:20aduclojure is so awsome
23:24Rich_MorinI' trying our the Community editions of IntelliJ - are there any plugins other then Leiningen and La Clojure that I should grab?
23:24akhudektomoj: does clj-digest iterate the sha? If so, then it should be fine.
23:25akhudeknon-iterated sha digest is apparently too weak though
23:28Rich_MorinI'm signed into http://dev.clojure.org/display/doc/Getting+Started+with+La+Clojure+and+IntelliJ+IDEA and see a typo, but no way to edit the page.
23:39amalloysometimes i think that's the desired experience for *.clojure.org: a community-maintained site the community isn't allowed to maintain
23:44Rich_MorinIntelliJ wants me to specify an SDK. Do I need one for Clojure?
23:47akhudekRich_Morin: if you've install la clojure, then the way I always get started is to create a new project with "lein new" from the command line
23:47akhudekissue "lein pom"
23:47akhudekthen import the project as a maven project in IntelliJ
23:48akhudekyou'll need to do lein pom every time you change project.clj though
23:48akhudekor rather, change the dependencies in it
23:48akhudekyou shouldn't have to worry about the SDK business (though don't quote me on it)
23:53Rich_MorinI tried "Start Clojure Console" and got "Error: No jdk for module 'ii_1'"
23:57akhudekRich_Morin: hmm. I've never encountered that. One thing I forgot, right click on the project itself in the project pane (default on the left) and select "add framework support"
23:57akhudeknot sure if it will solve that message though
23:58Rich_MorinI tried right-clicking on the project.clj file - is that what you mean?
23:59Rich_Morinnm