#clojure logs

2013-04-12

00:01brehauthttps://github.com/pufuwozu/fantasy-land/
00:14ivantoo much interop will put the object adaptation industry out of business
01:01asumuHi. Quick question. Anyone know why the "thrush" operators are called that? Google didn't help much.
01:03asumuOh, maybe it's a reference to Smullyan's "To Mock a Mockingbird"?
01:04technomancyasumu: that's correct
01:09asumutechnomancy: Thanks, that makes sense, given thrush := lambda a b. b a
01:10technomancyasumu: it's not quite the same since thrush in the book is a function and thrush in clojure is a macro, but that's getting pedantic.
01:11technomancythat said if you want to be pedantic you can read http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/
01:17mullrfogus/bacwn or martintrojer/datalog for in-memory catalog?
01:18mullrs/catalog/datalog/
03:22`arrdemis there a naming convention for lurking tmux/screen connections?
03:41MrHusHi I'm using Cheshire for my json encoding and decoding. No I want to add a custom encoding for a Postgresql array. I have the following code:
03:41MrHus(add-encoder org.postgresql.jdbc4.Jdbc4Array
03:41MrHus (fn [array jsonGenerator]
03:41MrHus (let [sequence (seq (.getArray array))]
03:41MrHus (do
03:41MrHus (println sequence)
03:41MrHus (encode-seq sequence jsonGenerator)))))
03:42MrHushttps://gist.github.com/MrHus/d3c385433943a7d57f6c
03:43MrHusHowever I get the following error: clojure.lang.ArityException: Wrong number of args (4) passed to: generate$generate
03:44MrHusI've used this as a reference: https://github.com/dakrone/cheshire#custom-encoders
03:44MrHusbut don't understand what I'm doing wrong.
03:48jjidowhere is generate$generate defined? How many args does it expect?
03:48MrHushttps://github.com/dakrone/cheshire/blob/master/src/cheshire/generate.clj#L111
03:49MrHusIt expects 4 arguments
03:49MrHushttps://github.com/dakrone/cheshire/blob/master/src/cheshire/generate.clj#L182
03:49MrHusencode-seq expects 2
03:49MrHuswhich calls generate
03:50MrHusbut I don't know where *date-format* comes from
04:28clgvwhat do I do wrong if I have no autocompletion in the buffer with the sourcecode file in emacs? slime is running
04:42rodnaph_has anyone used lein-rpm with success? got any example projects you can link?
04:46iartarisihi! is anyone using clojure-test-mode for emacs? How do I see the whole output of a failed test? (I only see the highlight in my code)
04:53iartarisiah, stupid question, it's in the *nrepl* buffer
04:57thm_proverIs there any java library that will let me produce TeX style graphics?
04:57thm_prover(without calling TeX)
04:57thm_proverI want to create techncal illustrations in Java.
04:59AimHereI dunno what TeX graphics consist of; but batik will turn SVG into graphics
05:25clgvthm_prover: why not shell out to TeX? because of deployment?
05:26thm_proverI want animation
05:26clgvso?
05:27thm_provercalling tex to create 30fps seems rather unreasonable
05:27thm_proverunless you're implying that Tex supports animation itself
05:27thm_proverwhich would e awesome
05:28clgvthm_prover: your setup does not allow a pre-calculation of the animation graphics?
05:28arrdem-lurkinComputer says no, try "!bot help".
05:28arrdem-lurkinComputer says no, try "!bot help".
05:28arrdem-lurkinComputer says no, try "!bot help".
05:28arrdem-lurkinComputer says no, try "!bot help".
05:28arrdem-lurkinComputer says no, try "!bot help".
05:28thm_proverclgv: I want rela time animation.
05:42nonubyin the ns macro :require coupled with :refer is the same as :use with :only right?
05:42arrdem-lurkinComputer says no, try "!bot help".
05:56gkunnoIs there a way to manage project dependencies like: [compojure "1.1.*"] or [compojure ">1.1.0"] so that i would always have the updated version
05:57weavejestergkunno: Not really. There's "[1.1.0,)" which will always get the latest version, but that includes snapshots.
05:57gkunnook
05:57weavejesterThere's been some plans about having two clojar repos; one for snapshots and one for release versions
05:58weavejesterBut that hasn't happened yet to my knowledge
05:58gkunnothat would be cool
05:58weavejesterMaven's version range handling is pretty limited unfortunately, and Leiningen uses that behind the scenes.
05:59gkunnoi been using composer for dependency management and its a really good tool
06:00gkunno(in php :/)
06:00gkunnowell, leiningen seem really good too
06:00gkunnoso much more included
06:02CookedGryphonDoes anybody know of a decent clojure library for easily using the java 7 watcher service?
06:03CookedGryphonI want to check for file updates without polling, I found an awesome gist, but it doesn't seem to be packaged up anywhere
06:03CookedGryphonhttps://gist.github.com/moonranger/4023683
06:18GRHiya. I've recently written a library of data structures that includes a 'vector' implementation similar to Clojure's and I've added a pair of new algorithms. Does that sound interesting to anyone?
06:19GRI'm not entirely sure it will work for other implementations, but it is very likely.
06:32naegdoes (first lazy-seq) consume the whole lazy seq?
06:34nbeloglazovnaeg: no, it consumes first chunk - 32 elements
06:36naegso (first lazy-seq) == (take 1 lazy-seq) ?
06:38nbeloglazovno, (first lazy-seq) returns first element while (take 1 lazy-seq) returns sequence that contains first element. I think they both realize chunk of 32 elements from lazy-seq.
06:40naegwhy is (first (drop-while ...)) much slower than (take 1 (drop-while ...)) then?
06:43nbeloglazovHow do you compare them?
06:43nbeloglazovActually (take ...) also returns lazy seq. So unless you realize it initial collection won't be realized.
06:45naegnbeloglazov: with (time ...). (first ...) takes about 1msec whereas (take 1 ...) takes ~0.4msec
06:47nbeloglazovnaeg: try (time (doall (take 1 ...))) so that sequence returned by take is realized
06:49naegnbeloglazov: then it's the same, but I get the same result back with and without (doall ...)
06:52naegis the time not correctly measured if I just do (time (take 1 lazy-seq))? like only the time to create the lazy seq and it is realized after the measurement and then I get the result?
06:52nbeloglazovYes, exactly
06:52naegI see, thanks
06:58necronianI have a function that uses (eval (symbol database)) to turn a string into my korma database object. It works when I call it from inside the namespace the function is defined in. But not from another namespace.
06:58necronianI don't understand why.
07:05hyPiRion,((-> $ #(* % (({(*) {(+) (*)}} % $) (- % (*))))) 10) ;; new factorial in swearjure
07:05clojurebot3628800
07:05hyPiRionA shorter variant, which is amazing
07:17otfrommorning all
07:17otfromdoes anyone have any suggestions for parsing *very* large json arrays?
07:18otfromcheshire's parse-seq is a bit too greedy and I'm wondering if I'm missing something before I start coding up something myself
07:21CookedGryphonotfrom: depending on the data, quite how large it is and what you want to do with it, have you considered importing it into mongo? That can read json directly, and you could then do advanced queries on the data contained
07:22CookedGryphoni don't know how you'd keep the insertion order trivially though
07:22CookedGryphonbut if you didn't care about the order, you could then pull things out lazily through congomongo
07:22otfromnot too fussed about the insertion order
07:23otfromI'd thought about mongo as a possibility. It feels a bit like just relying on mongoloader or similar to do the lazy parsing of the json array.
07:24CookedGryphonyeah, it depends what you want to do with it really, if you're only going to scan through and read this array once, then mongo would be a bit of a ridiculous way to do it,
07:24CookedGryphonbut if it's a dataset you're going to look at a few times, it might be a more convenient way of storing it
07:26otfromI'm just going to scan it once, but I am going to get a new array each day
07:27CookedGryphonhmm, yeah you don't want to be doing a manual import every day
07:27CookedGryphoni take it there's no way to get a stream instead, parse the data as it comes in?
07:28CookedGryphonand use storm or something to set up a pipeline
07:28robewaldHello, I am trying to use the clojurescript js->clj function on an domina event object and I just get back the js object instead of a map.
07:29CookedGryphonotfrom: anyway, i gtg, good luck
07:29robewaldthe culprit seems to be that line in core/js->clj: (indentical? (type x) js/Object) which is false although I would expect it to be true.
07:30robewaldAny clues?
07:46cmdrdatshey guys, in compojure, I'm trying to see from middleware what route matches.. is that even possible?
07:56Glenjamincmdrdats: i don't think so, unless the app, records that in the response
07:56cmdrdatsok - I'm putting together a workaround, using clout the same way as compojure.. was hoping there would be a more direct way :/
07:57AnderkentHey, how can I avoid a lot of quote-unquote when writing an anaphoric macro? Example: https://www.refheap.com/paste/13552
07:57cmdrdatshating the fact that compojure returns black-box functions instead of data structures from POST / GET and defroutes
07:57Anderkenti.e. I don't like how I have to quote-unquote the argument symbols all the time
07:58Glenjamincmdrdats: why do you need this info in the middleware?
07:58cmdrdatsI need to do authentication based on the matching route
07:58hyPiRion,(let [it 'it] `(+ ~it 4))
07:58clojurebot(clojure.core/+ it 4)
07:58hyPiRionlike that, Anderkent?
07:59Anderkenthm, guess that is better, thanks
07:59weavejestercmdrdats: That's the disadvantage of function composition; it's very black-box. I've been meaning to write another routing library based on a data structure; less flexible, but more transparent
07:59Glenjamincmdrdats: there are some patterns for wrapping up groups of routes behind authentication middleware
07:59weavejestercmdrdats: However, if you need to do authentication on the matching route, why not apply the authentication directly to the route itself?
08:00weavejesterSo some routes have the authentication middleware on them, and other routes don't.
08:00cmdrdatsweavejester: you mean, inside the actual endpoint function? I'm kinda wanting to keep those clean from authentication logic
08:00cmdrdatsso that I can't get it wrong in the future
08:00weavejestercmdrdats: No, I mean, divide up your routes into those that need authentication and those that don't.
08:01Glenjamin(require-auth (defroutes admin ...)) and (defroutes public ...)
08:01weavejesterThe disadvantage of using functions is that they're more opaque, but the advantage is that you can arbitrarily nest middleware.
08:01cmdrdatsweavejester: oh, no - mine requirement is more finegrained- one user can have access to one route, but not another user
08:02cmdrdatsweavejester: wouldn't it be feasible to return data structures from the defroutes, POST, GET, et al macro's
08:02weavejestercmdrdats: Ohh, okay, and there's no way of grouping that? e.g. Friend allows you to label certain routes as needing certain access roles.
08:02weavejestercmdrdats: Well, no, because then you couldn't apply middleware to routes.
08:02cmdrdatsand then just make handler/site build the black-box functions
08:03weavejestercmdrdats: That would mean you could only apply middleware at the top, and you couldn't use higher-level functions to generate routes.
08:03weavejesterThere's a big advantage to using functions
08:03cmdrdatsah, ok
08:03weavejesterBut it trades off against transparency
08:04cmdrdatswhat I've done is write a wrapper macro for my routes now
08:04weavejesterIdeally we need two libraries; one for routing via a data structure, with all the limitations that has, and one for routing via functions.
08:04Glenjamini wonder if you could get somewhere by just using compojure.core/routes
08:04wei_(??? [1 2 3 4 5 6 7] [true false false false true false true]) => [1 5 7]
08:04cmdrdatswhich I can then eval to create the actual compojure routes
08:04Glenjaminwait no, thats reutrns a function, ignore me
08:04snrmwgdoes anyone here know and/or use sqlkorma?
08:04weavejesterBut it kinda seems strange that you're doing authentication directly against the routes
08:05weavejesterAnd not assigning roles to sets of routes.
08:05cmdrdatsweavejester: I'm exposing an API, the API key gets assigned a set of routes
08:06cmdrdatsI can later on put grouping on top of it, but for simplicity, I'd rather leave that seperate
08:06Glenjamincan you just tie the auth to URLs in the middleware layer?
08:06Glenjaminlike with http://yogthos.github.io/lib-noir/noir.util.middleware.html#var-wrap-access-rules
08:07cmdrdatsye, that's what I'm doing
08:07cmdrdatsGlenjamin: but directly with things like "/item/:id"
08:07cmdrdatsthat doesn't match the url "/item/123", unless you run the routing through the same logic as compojure
08:08tomojyou can implement a mind reader with nominal logic https://www.refheap.com/paste/ae34df589f4d62e47d771591e
08:08cmdrdatswhich, incidentally, I've just finished doing :P I just compiled all the routes myself using clout like compojure does
08:09Glenjaminright, i'm with you now - you want to check auth after the route's been composed, but before the function is evaled
08:10snrmwghow can i write a query with sqlkorma where i have different limits dependent on my query parameters? i.e. without any parameter i want max 100 rows, with parameters i want max 20 rows
08:10cmdrdatsGlenjamin: yep
08:16cmdrdatsGlenjamin, weavejester: https://www.refheap.com/paste/13554 - the pieces I needed to get it to work :)
08:17cmdrdatsnot including the actual middleware, but that should be fairly obvious
08:26Glenjaminheh, that's really hard to follow!
08:28cmdrdatsxD - I'm just creating a list of symbols out of my routes, then compiling that with clout into 'compiled', into a route => compiled map
08:28Glenjaminyeah
08:28Glenjaminyou still end up searching the routes twice per request
08:28cmdrdatsye, totally
08:28Glenjaminit might be easier to just add an assert-style form in each route
08:28Glenjaminmaybe hide that behind a macro
08:29cmdrdatsyou mean, route it through an implicit function
08:30Glenjamin(authed-route GET "/blah/:id" [id] body) => (GET "/blah/:id" [id] (check-auth "/blah/:id" [id] body)
08:30cmdrdatsye, that's a good idea
08:31cmdrdatsand not use strict 'middleware' for the auth
08:32Glenjaminespecially if you end up looking up the :id against the DB for the auth
08:32cmdrdatsye - it also addresses mixing auth'd and non-auth'd functions properly
08:32cmdrdatsroutes*
08:34Glenjaminaha, there's a generalised version of this concept in express
08:34Glenjaminhttp://expressjs.com/api.html#app.VERB
08:35Glenjaminhrm, it's actually just ->
08:36cmdrdatshaha
08:37Glenjamin(GET "/blah/:id" req (-> req check-auth normal-handler))
08:37Glenjaminexcept you lose the compojure sugar for route param destructuring
08:38Glenjaminor maybe it's more like http://expressjs.com/api.html#app.param - which compojure doesn't have an equivalent of afaik
08:38Glenjaminanyway, gotta go - good luck!
08:39cmdrdatsthanks :)
08:47AnderkentIdiomatic way to check if a map has given keys and they have truthy values? I came up with (every? true? (juxt :key1 :key2 :key3) map) ...
08:48Anderkent(missed parens around juxt and map there)
08:50arcatanAnderkent: (every? map #{:key1 :key2 :key3})
08:51AimHereNote also that true? doesn't just pick truthy values, it demands actual truth
08:51AimHeretruthiness doesn't cut it for the likes of true?
08:51AimHere,(true? "true)
08:51clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
08:51AimHere,(true? "true")
08:51clojurebotfalse
08:52arcatan,(every? {:a 1, :b nil} #{:a})
08:52clojurebottrue
08:52arcatan,(every? {:a 1, :b nil} #{:a :b})
08:52clojurebotfalse
08:52arcatan,(every? {:a 1, :b nil} #{:a :c})
08:52clojurebotfalse
08:52arcatanyay.
08:52Anderkentoups
08:52Anderkentthank's for that
08:53dpathakjre
08:53Anderkent,(every? identity ((juxt :a :b :c) {:a 1 :b 2 :c 3}))
08:53clojurebottrue
08:53Anderkent... I created a monster
08:53Anderkent,(every? identity ((juxt :a :b :c) {:a 1 :b 2 :c nil}))
08:53clojurebotfalse
09:01auastrohey all
09:02auastroany of the clojars maintainers around, I need to get my account name changed
09:02auastro?
09:04auastroanyone alive down here?
09:13Anderkentauastro: I guess the clojars issue tracker is your best bet (that's what they want for deletion request or group name takeovers), though why not just make a new account and transfer your group names to that account?
09:15auastroAnderkent: thanks, I've emailed the contact email twice now, I'd prefer not to put it on the issue tracker, kind of embarrassing actually, put my password in the username field :/
09:15AnderkentAh :P
09:15auastroAustralian? or just up late?
09:15AnderkentEuropean, ain't late here
09:16Anderkentanyway technomancy or xeqi might be able to help you
09:16auastroI see, we are something like +10 here so it's about lunch time where you are?
09:16auastrowhat tz are they in?
09:16auastroUS probably
09:17AnderkentAfraid so
09:18auastrohmm, well let's hope they respond to my email this time.
09:18auastroI'm not quite sure why they don't just have a way to delete an account, isn't that like a reasonably important feature?
09:19Anderkentnot really, and it could get quite confusing since your published artifacts would not get deleted
09:19borkdudeauastro I tried to change something in clojars once, never got a reply
09:20auastroAnderkent: I don't have any published artefacts
09:20auastroborkdude: :(
09:22llllhow do i apply modifier key on regexp?
09:23auastrollll: sorry don't understand the question
09:23lllleg. i want to use "g" for global
09:25llll(re-find #"rabbit" "follow the white Rabbit")
09:26llllor i for case insensitivity
09:28Anderkentyou can embed flags with (?<flag>) : ,(re-find #"(?i)aabb" "AABB")
09:28Anderkent,(re-find #"(?i)aabb" "AABB")
09:28clojurebot"AABB"
09:28Anderkentbut not sure how to pass them in otherwise
09:29llllAnderkent: thank you
09:43lllli am getting an error using cljs
09:43llllI'm using ((re-find #"(?i)^.*?<body[^>]*>(.*?)<\/body>.*?$" html) 1)
09:44llllParse error. invalid flag after regular expression
09:44llllhere is the compilation of the code: cljs.core.re_find.call(null,/^.*?<body[^>]*>(.*?)<\\/body>.*?$/i,p1__24321_SHARP_)
09:45llllthe error marker is on the first / after null
09:46AnderkentAm I right in thinking that the \\/ makes the regex end prematurely and thus it tries to interpret /body as flags?
09:46Anderkentotherwise, sorry, I know nothing about clojurescript
09:50lllli should just run js in cljs
09:51llllhow do i eval js in cljs?
09:52noidiI know this is a bit unhelpful, but you shouldn't be parsing html using a regular expression in the first place :) http://stackoverflow.com/a/1732454/13340
09:53llllbut then how do jquerymobile do it :/
09:54hyPiRionllll: You should try to parse stuff with instaparse
09:54dsapalallll: he didn't say it couldn't be done
09:54hyPiRionit's going to be vastly more readable, and you get more power
09:55rbxbxllll why don't you just use something like enfocus?
09:57jjl`one presumes they built a real parser
09:57jjl`(which is the correct way to do it)
10:01llllrbxbx: its a jquery replacer?
10:02rbxbxllll no, there is https://github.com/ibdknox/jayq to that effect though.
10:03AimHereYou should parse html by search/replacing angle brackets to round ones, then writing a macro and running 'eval' on it
10:06hyPiRionAimHere: read-string only, not eval
10:06hyPiRionEval is for evaluating data
10:06AimHereFair point
10:07AimHereThough why not just booked the string you're reading with "(eval " and ")", for added awesome
10:07AimHere*bookend
10:08ToBeReplacedwhat do people use for logging inside of threading macros? something better than creating an anonymous function that takes in an arg, does logging based on that arg, and returns the arg?
10:09silasdavisI'm trying to require this: https://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/util/request.clj
10:10silasdaviswith this in my (ns ...) block: [ring.util.request :as req]
10:10silasdavisbut it can't find it
10:10rbxbxToBeReplaced you could use `doto`, I'm not sure if that's conventional though.
10:10silasdavis[ring.util.response :as resp] works fine
10:11silasdavisI've got [ring/ring "1.1.8"] dependency and lein-rint 0.8.2 plugin if that matters
10:12ToBeReplacedrbxbx: that's cute!
10:13weavejestersilasdavis: You're using a Ring 1.2.0 namespace but your ring version is 1.1.8
10:13bhenrysilasdavis: [ring/ring-core "1.1.8"]
10:13rbxbxToBeReplaced remember, one should always write cute & clever code. It's the road to longevity.
10:13bhenryeehh...
10:14ToBeReplacedof course
10:14bhenry1.2.0-beta2
10:15silasdavisweavejester, which part is the ring 1.2.0 bit?
10:16weavejestersilasdavis: The namespace "ring.util.request" was only added in 1.2.0
10:16weavejestersilasdavis: You're using Ring 1.1.8, which doesn't have that namespace
10:17bhenrysilasdavis: https://github.com/ring-clojure/ring/tree/1.1.8/ring-core/src/ring/util here's what you have available.
10:18silasdavisahh, thanks. It seems that friend relies on 1.2 then
10:33otfromin a repeat from earlier: does anyone know a good way to parse huge json arrays? (about 1.5gb)
10:34otfromcheshire.core/parsed-seq seems a bit too eager
10:34dakroneotfrom: how so?
10:35otfrommy json looks like this (ish): [{"foo" : 1}, {"foo" : 2}...]
10:35otfromso calling first on parsed-seq gives me the whole array
10:35xeqiborkdude: what did you need changed in clojars? I might have missed the request
10:36zamaterianotfrom, maybe https://github.com/mmcgrana/clj-json/blob/master/src/clj/clj_json/core.clj#L43 can do the trick ?
10:36dakroneotfrom: so, parsed-seq returns a sequence of objects, in your example you have only a single object
10:37dakronezamaterian: that's the same basic implementation
10:37otfromdakrone: basically, yes
10:38borkdudexeqi https://www.refheap.com/paste/13560
10:38borkdudexeqi november 2011 ;)
10:38dakroneotfrom: so in order to take advantage of laziness, you'll need to separate the one object into separate objects
10:39xeqiborkdude: ah, before my time then :p now I should only feel bad about missing auastro's
10:39otfromdakrone: I'm guessing that is outside of what cheshire does
10:40borkdudexeqi deleted the message again
10:40xeqiborkdude: still want it removed?
10:40borkdudexeqi yes
10:40borkdudexeqi nobody is using it anyway
10:40xeqiborkdude: done
10:40borkdudetnx
10:41otfromzamaterian: thx. I'll look at that too
10:41dakroneotfrom: for example: (first (parsed-seq (StringReader. "{\"foo\":1}\n{\"bar\":2}"))) returns {"foo" 1}
10:42dakroneotfrom: if you want recursive laziness, I don't know of any JSON parser that does that yet
10:42borkdudexeqi I thought it was better to just use org.clojars.borkdude
10:43otfromdakrone: thx. That was what I was finding from reading and testing things and I was wondering if I was missing something.
10:44otfromdakrone: sounds like I need the json equivalent of a SAX parser.
10:46dakroneotfrom: it's a neat idea and would be cool to have a lazy-tree of json parsings
10:46otfromdakrone: perhaps one of those new parser libraries... ;-)
10:47zamaterianotfrom, clj-json uses jackson for parsing. jackson does support stream parsing see : http://wiki.fasterxml.com/JacksonInFiveMinutes#A.22Raw.22_Data_Binding_Example
10:47dakronezamaterian: cheshire uses jackson also, and cheshire's stream parsing is the same implementation
10:47dakronesince it was originally based on clj-json
10:48dakroneotfrom: yea, would have to be an optional thing though, since it would not perform as well (but would be better for memory usage)
10:53otfromdakrone: yep
11:10mklappstuhlA few friends of mine and I would like to crunch some numbers and financial market seems to provide lots of room to get creative... whats the best datasource thats out there for this kind of stuff? I guess parsing CSVs from Yahoo isnt it
11:13nDuffmklappstuhl: Hrm. There's a startup here in Austin that specializes in just that kind of thing (assembling datastores, whether publicly available or otherwise), but their name escapes me at the moment.
11:16gfredericksw00h00, I think my ->/->> patch will get into 1.6
11:17the-kennyhttp://clojure.org/lisps says "In Clojure nil means 'nothing'. It signifies the absence of a value, of any type, and is not specific to lists or sequences.". (get {:a nil} :a 1) returns nil. Shouldn't the not-found value (1) kick in, as 'nothing' can obviously not be found (e.g. ":a doesn't map to anything")
11:17bbloomgfredericks: it sems like Rich is on JIRA duty today :-P
11:20CookedGryphonthe-kenny: yeah, but they *key* exists and can be found, just the thing that's been put in that placeholder is nothing
11:20gfredericksha
11:20the-kennyHm
11:22ppppaulcan someone give me pointers on making pretty walk functions
11:27bbloomibdknox: damn you and your lighttable stealing some of my file associations!
11:28mdeboardppppaul: Walk what? file paths?
11:38TimMcgfredericks: Oh no, we were gonna use that bug for Swearjure! I think.
11:40TimMcgfredericks: I think clojure.template may help with the problem that caused me to want inner-macros.
11:41TimMc(The #=(arity 3) thing.)
11:42borkdude,(= 3 3.0) ;; nice
11:42clojurebotfalse
11:43TimMc,(== 3 3.0)
11:43clojurebottrue
11:44borkdudeah cool
11:45borkdude$findfn 3 3.0 true
11:45lazybot[clojure.core/== clojure.core/not= clojure.core/distinct? clojure.core/>= clojure.core/<=]
11:49clgvhttp://starlogs.net/#clojure/clojure
11:53TimMcI tried using this autodoc thingy, but it doesn't seem to work! I guess I'll have to go back to writing my docstrings by hand.
11:53TimMcFalse advertising, I tell you.
12:03S11001001too bad we can't infer core.typed toplevel term types
12:03S11001001then could generate free theorems from them and call those autodocs
12:07TimMcS11001001: hyPiRion used your -> idea to come up with a factorial fn one-liner that can be passed around. Very cool.
12:08S11001001TimMc: great, one step closer to taking over all clojure dev
12:09TimMcThe trick should work for all simple-recursive fns.
12:10TimMcStill no closures.
12:10ppppaulmdeboard, clojure.walk/prewalk postwalk
12:11ppppaulwondering about idioms for those functions
12:17DerGuteMoritzwhat's a good way to have some dirty unsafe mutable place? currently I'm using an object-array with one slot which works but feels a bit clumsy :-)
12:17ppppaulhuh?
12:17DerGuteMoritzhuh!
12:18ppppaulDerGuteMoritz, you could use an atom
12:18ppppaulsometimes a var is ok
12:18DerGuteMoritzyeah well that's safe and clean :-)
12:18DerGuteMoritzI don't want any synchronization etc.
12:18ppppauldynamic var is dirty
12:18DerGuteMoritzno thread-safety
12:18DerGuteMoritzah, can I set! a dynamic var? I thought I couldn#t
12:19ppppaul(bindings [my-dirty-var new-value] my-fn)
12:19DerGuteMoritzah no I need to mutate it
12:19DerGuteMoritzit's a variable I close over in a proxy
12:20ppppaulyou can do with-redefs
12:20DerGuteMoritzunlike deftype, proxy doesn't provide a way to add attributes
12:20ppppaulmaybe alter-var (though i haven't had success with that)
12:20DerGuteMoritzwith-redefs also only affects the body
12:20DerGuteMoritzyeah, alter-var-root would work
12:20ppppaulyou can do (def thing 1) (def thing 2)
12:21DerGuteMoritzppppaul: it's a local variable I close over, not a global var
12:21ppppauloh
12:21DerGuteMoritzI could perhaps instantiate clojure.lang.Var or something
12:21ppppaullol
12:21DerGuteMoritzbut that doesn't seem much better :-)
12:21ppppaulyou are doing crazy things
12:22DerGuteMoritzyeah, just a little friday afternoon goofing around
12:22ppppaulalter-var-root ftw
12:23DerGuteMoritzwell, alter-var-root involves a function call!
12:23DerGuteMoritzI mean one more than my current aset approach
12:25DerGuteMoritz,(let [x (clojure.lang.Var/create 1)] @x)
12:25clojurebot1
12:25DerGuteMoritzthat even works heeh
12:25ppppaul,(let [x (clojure.lang.Var/create 1)] x)
12:25clojurebot#<Var: --unnamed-->
12:26DerGuteMoritzyep! :-)
12:26ppppaulwoah
12:26ppppaulthis is new to me
12:27ppppaultime to make a blog and show people how to program in clojure just like they do in their language of choice
12:27DerGuteMoritztoo bad it just was april first
12:28ppppaulgoing to have to wait a year
12:28ppppaulso, you should start writing and not release anything until next april first
12:29ppppaulthey you can have lots of interesting topics, like clojure for c++ users, without any of the benefits of using clojure at all. hack in some text macros too
12:29ppppaulclojure preprocessor is best preprocessor
12:31S11001001ppppaul: When you bind a value, you have to supply an expression that "destroys" it for when it goes out of scope.
12:31TimMc,(let [b (clojure.lang.Box. 5)] (set! (.val b) 42) (.val b))
12:31clojurebot42
12:32ppppaulwoah
12:32ppppaulthis code is making my eyes hurt
12:35TimMcI'm having trouble writing a templating macro: https://gist.github.com/timmc/5373281
12:36TimMcI want to write a deftype that has nearly the same body for each of its methods, but the bodies vary in what methods and arg names they use in interop calls.
12:36TimMcI've taken a stab at writing what I think I want my source code to eventually look like, but even that isn't quite right.
12:37TimMcA big part of the problem is that I want to splice-inject forms, not just inject them.
12:38technomancyTimMc: whoa, what?
12:38technomancyBox, huh
12:39ppppaul,(clojure.lang.Box. 5)
12:39clojurebot#<Box clojure.lang.Box@1501d0c>
12:39ppppauli could use a Box
12:40ppppaul,(seq (clojure.lang.Box. 5))
12:40clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Box>
12:40technomancybeen around since 2006
12:41DerGuteMoritzTimMc: thanks a lot, Box clearly is the cleanest way to implement this dirty bit :-)
12:42TimMcIt at least telegraphs your intention.
12:42DerGuteMoritzyep
12:43TimMctechnomancy: I think every Java library of sufficient size has a Box class.
12:43DerGuteMoritzthat is, my intention to cause trouble!
12:44technomancyTimMc: I think knowing you need a Box class requires a certain level of sophistication
12:45TimMcActually, I do see one-element arrays used a lot in Java libs. It's a more opaque idiom.
12:46TimMcThe use-case is almost always for allowing a "closure" to send back some data.
12:46ppppaul...
12:46ppppaulwoah
12:46TimMc(because Java inline classes can only refer to final references)
12:47technomancythat's how Mirah implements closures IIRC
12:52DerGuteMoritzexcellent, I now have a criminally offensive function to turn a (potentially lazy) seq of strings into an InputStream!
12:53DerGuteMoritzmaybe I could have implemented it easier with gen-class rather than proxy though
12:54winkyogthos: did you do any performancetests with luminus or got any resources where to start looking?
12:54winkyogthos: I'm basically a noob with JVM stuff in production, but it all felt really slow (just an enhanced guestbook app)
12:58nDuffwink: In terms of the JVM in general -- it's designed to maximize throughput after a long, slow spinup time, so the details of how benchmarking is done matter.
13:00winknDuff: siege -c 10 -r 100 as a rough basic test
13:00squidzwhat would be the best way to write this in clojurescript with domina? https://www.refheap.com/paste/13569
13:01nDuffwink: *nod*; second instance of that run against a server should be fair. I'd throw away the first one.
13:01winknDuff: yup. I'm playing aroudn witrh concurrency levels, but that one above only did 15 req/s on my c2d notebook
13:01nDuffwink: anyhow -- standard Java-centric tools, ie. YourKit, work well.
13:02winknDuff: ah, thanks, I only know of visualvm
13:02nDuffwink: ...a lot of the time when you see really, really awful performance, it'll be related to garbage collection; tuning memory parameters can help a lot with that if it's not something with a clear code fix.
13:07squidzits jquery, but i dont know any jquery, so how could I do this with domina?
13:41yogthoswink: hey so for performance testing there's a few options
13:41yogthoswink: siege is definitely a good one, but if you want to see what's happening in the code that makes it run slow you can use a profiler
13:42yogthosthe jvm ships with jvisualvm and if you run it and connect to a process you can see where the cycles are going
13:42winkyeah, probably a good idea :)
13:42yogthoswink: I've got a tutorial on that here http://yogthos.net/blog/24-Reflecting+on+performance
13:43winkyogthos: awesome, thanks
13:43winkyogthos: I really like luminus so far, good job :)
13:44yogthossquidz: this should work
13:44yogthos(->
13:44yogthos (by-id "datetimepicker4")
13:44yogthos (.-datetimepicker)
13:44yogthos (.-pickTime false))
13:45yogthossquidz: assuming datetimepicker is a property
13:45yogthoswink: glad to hear it :)
14:02DerGuteMoritzthinking about it again ISTR seeing some library that turned seqs into InputStreams ... is anyone aware of something like it?
14:04amalloyseqs of what? you can't just turn an arbitrary seq into an input stream
14:05DerGuteMoritzwell, based on a protocol to turn things into byte seqs
14:08borkdudewhat is the best intro to clojure philosophy talk out there?
14:12stuartsierraborkdude: Maybe "The Value of Values" http://www.infoq.com/presentations/Value-Values
14:12borkdudeor if you will, best Rich Hickey talk to watch for someone new?
14:12borkdudestuartsierra ok cool, thank you. I'm looking for something I can show in class next monday
14:13stuartsierranp
14:16amalloyDerGuteMoritz: it's not what you're asking for, but gloss may be what you want
14:17ppppaulanyone can give me their thoughts on this lib (testing) https://github.com/jaycfields/expectations
14:18DerGuteMoritzamalloy: ah yeah, gloss is cool :-) but no, in my case I am looking for something to turn a seq of strings into an OutputStream; I now have a working proxy based implementation and thinking of maybe packaging it up as a generic library
14:18noidibrudgers, I really like Simple Made Easy http://www.infoq.com/presentations/Simple-Made-Easy
14:19noidioops
14:19noidithat was meant for borkdude :)
14:19amalloyinto an output stream? surely you mean an input stream
14:19borkdudenoidi thanks
14:19DerGuteMoritzamalloy: ah, yes, right
14:20DerGuteMoritzI am now trying a gen-class based implementation, I have a hunch that it might be less hacky
14:20amalloyanyway, that's sorta one unnecessarily monolithic problem: if you break it up into (1) turn a string into an input stream; and (2) turn a seq of input streams into another input stream, then you will find available easy solutions for both things
14:21DerGuteMoritzamalloy: (1) is easy, are you aware of an existing solution for (2)?
14:21amalloyhttps://github.com/flatland/io/blob/develop/src/flatland/io/core.clj#L30-L38
14:22DerGuteMoritzcool!
14:22DerGuteMoritzthat library looks like what I had in mind :-)
14:22DerGuteMoritzthank you!
14:25gfredericksI did not know about SeqEnumeration
14:26amalloygfredericks: i told you about it yesterday, but i think you had already gone
14:26gfredericksI implemented it myself in a thread-dangerous way
14:27amalloywell, enumerations are implicitly not threadsafe anyway, right?
14:27ppppaulanyone using expectations in clojure?
14:29gfredericksamalloy: well you'd hope two threads wouldn't call .nextElement and get the same result?
14:31amalloygfredericks: in java, i wouldn't expect such a hope to be well-founded
14:32amalloyfor example, java.util.ArrayList produces an iterator which doesn't satisfy your hopes
14:33amalloyand, in fact, clojure.lang.SeqEnumeration has exactly the same "problem"
14:33amalloyyou're just not supposed to use iterators or enumerations from multiple threads
14:35DerGuteMoritzamalloy: thanks for pointing me at java.io.SequenceInputStream and clojure.lang.SeqEnumeration, a beautiful solution!
14:48gfredericksamalloy: I mean if I was to go about implementing an Enumeration that might be something to aim for
14:49gfredericksbut perhaps as you say it's not worth the overhead
14:49gfredericksif clients aren't expected to multithread it
14:50gfrederickscurious -- if you're implementing it in clojure and have no need for thread-safety, are atoms still the most straightforward approach?
14:51gfredericksthe only other option I know of is some kind of mutable field on a deftype
14:55amalloygfredericks: you can use an atom and still be thread-safe. i don't understand the question
14:55gfredericksright but if you don't _need_ to be threadsafe and therefore don't _need_ to use an atom
14:56gfredericksmight you do it anyways just because it's so easy?
14:56amalloywell, i'd probably use a ref
14:56gfrederickse.g., the java version of SeqEnumeration does not use an atom
14:56amalloybut yeah
14:56gfredericksbecause from java it would be much more of a hassle
14:57amalloyright
14:57borkdudea var? ;)
14:57borkdude*ducks*
14:58gfredericks(java ISeq v = seq(coll))
15:00lynaghkping: dakrone
15:00dakronelynaghk: pong
15:00DerGuteMoritzgfredericks: haha, I asked exactly the same question a few hours ago
15:00DerGuteMoritzgfredericks: clojure.lang.Box is a good way
15:01DerGuteMoritz,(let [x (clojure.lang.Box. 1)] (.val x))
15:01clojurebot1
15:01DerGuteMoritz,(let [x (clojure.lang.Box. 1)] (set! (.val x) 2) (.val x))
15:01clojurebot2
15:01DerGuteMoritzalternatively, (object-array 1) with aset and aget
15:01technomancylooks like Box is used internally in some implementations of maps
15:01lynaghkdakrone: I think the generators in cheshire 5.1.0 got borked when the key-fn functionality was added
15:02DerGuteMoritztechnomancy: ah, for transients I think
15:02lynaghkdakrone: I'm getting an arity exception when trying to call cheshire.generate/encode-map
15:02gfredericksman I just started using key-fn yesterday
15:02DerGuteMoritzat least in the cljs implementation of PersistentHashMap
15:02gfredericksit's been working fine for me though
15:02dakronelynaghk: hrm, that's no good, can you gist an example?
15:03lynaghkdakrone: yeah, one sec; I'm also happy to submit a pull but wanted to ask you about it first
15:04DerGuteMoritzdoes lein repl :headless :port work for anyone? it doesn't seem to honor the port I'm passing
15:06lynaghkdakrone: https://gist.github.com/lynaghk/5374327
15:07dakronelynaghk: thanks, I'll check it out
15:08lynaghkdakrone: here's the offending line: https://github.com/dakrone/cheshire/blob/master/src/cheshire/generate.clj#L219 I can either add an empty key-fn to the encode-* functions that call generate or add the 4-arity case to the generate fn.
15:11dakronelynaghk: I see the issue, I'll send nil as the key-fn, looks like encode-seq needs to be fixed also
15:12lynaghkdakrone: okay, awesome. thanks dakrone. Do you have a rough ETA on an official release containing those fixes?
15:12dakronelynaghk: less than 30 minutes maybe?
15:12dakrone:)
15:12lynaghkdakrone: Make sure you get a few beers or coffees out of me if we're ever in the same place
15:22ivan&{Float/NaN 3 Float/NaN 4}
15:22lazybotjava.lang.IllegalArgumentException: Duplicate key: Float/NaN
15:22ivan&(assoc {Float/NaN 3} Float/NaN 4)
15:22lazybot⇒ {NaN 4, NaN 3}
15:22Bronsahuh
15:25ivan&(= Float/NaN Float/NaN) ; Bronsa
15:25lazybot⇒ false
15:26Bronsa, (let [x Float/NaN] ({x 1} x))
15:26clojurebotnil
15:26Bronsa&(let [x Float/NaN] ({x 1} x))
15:26lazybot⇒ nil
15:27Bronsa&(let [x {Float/NaN 1}] (map x (keys x)))
15:27lazybot⇒ (1)
15:28ivan&(let [x {Float/NaN 3}] (= x x))
15:28lazybot⇒ true
15:28ivanPython is similarly "broken"
15:28borkdudeis def thread safe?
15:29nDuffborkdude: Setting atoms involves locking.
15:29nDufferr, vars
15:29Bronsa,(let [x {Float/NaN 1}] (map x (keys x)))
15:29clojurebot(nil)
15:29Bronsa&(let [x {Float/NaN 1}] (map x (keys x)))
15:29lazybot⇒ (1)
15:29Bronsawtf.
15:29amalloyivan: it's a brokenness that is required by the IEEE floating-point spec
15:29borkdudeI wonder what things could go wrong with this: http://stackoverflow.com/questions/15979151/can-i-refer-to-a-clojure-hashmap-value-from-another-value-in-the-same-map/15979322
15:29nDuffborkdude: so, you get more concurrency from using atoms
15:29Bronsa&*clojure-version*
15:29lazybot⇒ {:major 1, :minor 4, :incremental 0, :qualifier nil}
15:29Bronsa,*clojure-version*
15:29clojurebot{:major 1, :minor 5, :incremental 0, :qualifier "RC6"}
15:29Bronsauh uh
15:31Bronsaamalloy: I understand why ({Float/NaN 1} Float/NaN) would return false, but it looks to me like (let [x {Float/NaN 1}] (map x (keys x))) should return 1 as it did in 1.40
15:31Bronsa1.4,0*
15:32Bronsaam I right or ..?
15:32Bronsas/false/nil
15:33dakronelynaghk: Cheshire 5.1.1 released, should be good to go. I also added a test using every one of the custom helpers, so hopefully it won't happen it the future
15:33dakronelynaghk: thanks for catching it and letting me know!
15:33gfredericks,(= Float/NaN Float/NaN)
15:33clojurebotfalse
15:35devnGiven: (foo (bar (baz qux))) id like to know how many layers deep it is. for instance (how-deep (foo (bar (baz qux)))) => 3
15:35amalloyBronsa: probably not. getting NaN out of a map is something that should be impossible, since you should never be able to find an object that is equal to the key
15:36Bronsa,(let [x Float/NaN] (= x x))
15:36clojurebotfalse
15:36Bronsaright
15:36Bronsathen it was broken back in 1.4.0
15:37amalloyi expect it changed when rich added EquivPred
15:37Raynesibdknox: I don't like surprises. Tell me what the surprises are.
15:37Bronsayeah
15:37BronsaI wonder if NaN should be allowed at all as a key
15:37amalloyBronsa: NaN isn't the only thing that behaves this way. you can't forbid them all
15:38amalloy(you can advise against them all, of course, but you can't throw an exception)
15:38devnamalloy: in 4clojure where is the code to calculate the golf score?
15:38amalloydevn: it's just (count (remove whitespace? soln))
15:39borkdudeRaynes IE6 support in LightTable?
15:39devnoh, okay.
15:39amalloyyou can just write how-deep yourself; it's not a hard recursive function
15:39Bronsameh. I guess you're right, thanks amalloy
15:39devnamalloy: yeah, you're right
15:39devnthanks
15:40ivanI would guess no one thinks = should deep-descend everything to make (let [x {Float/NaN 3}] (= x x)) false
15:42ivanperhaps collections could taint themselves with a "I cannot possibly be equal to myself" flag
15:48lynaghkdakrone: awesome! thanks again for the quick fix.
15:53TimMc,(let [x {Float/NaN 5}] (= x x))
15:53clojurebottrue
15:54TimMc,(let [x {Float/NaN 5}] (= x (into {} x)))
15:54clojurebotfalse
15:54TimMcAnyway, using numbers as keys is kind of sketchy.
15:54TimMcEspecially floats.
15:56mefesto,(= Float/NaN Float/NaN)
15:56clojurebotfalse
15:56mefestointeresting
15:58Okasumefesto: Nope.
15:59Okasu,(= 1.0 0.99999999999999999)
15:59clojurebottrue
16:00metellus,(- 1.0 0.99999999999999999)
16:00clojurebot0.0
16:00pjstadig,(.equals Float/NaN Float/NaN)
16:00clojurebottrue
16:00asteve,(= 1.0 0.9999
16:00clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
16:00asteve)
16:00asteve,(= 1.0 0.9999)
16:00clojurebotfalse
16:01astevehow many 9's = repeating
16:01asteve?
16:01Okasu,(count "99999999999999999")
16:01clojurebot17
16:01asteve(= 1.0 9999999999999999)
16:01asteve,(= 1.0 9999999999999999)
16:01clojurebotfalse
16:01asteve,(= 1.0 99999999999999999)
16:01clojurebotfalse
16:01astevewhoops
16:02asteve(= 1.0 0.9999999999999999)
16:02asteve,(= 1.0 0.9999999999999999)
16:02clojurebotfalse
16:02astevedamnit
16:02asteve,(= 1.0 0.99999999999999999)
16:02clojurebottrue
16:02mefestoheh
16:02astevethat's what happens when you make a mistake in your irc history; you're bound to repeat it :)
16:03AimHereThose who do not log the past are condemned to repeat it
16:04mishok13are there any test coverage tools that work with Midje?
16:07Okasu,(= 1.0 (reduce + (repeat 10 0.1)))
16:07clojurebotfalse
16:07Okasu,(reduce + (repeat 1000 0.1))
16:07clojurebot99.9999999999986
16:08patchworklovely
16:08alindemanDoes using clojure.xml require something other than just (:require [clojure.xml]) in my ns declaration? Getting a ClassNotFoundException when running `lein jar`
16:09kanwei[org.clojure/data.xml "0.0.7"]
16:09kanweiwhat i use at least :)
16:10MarcoPolo,(= 1.0M (reduce + (repeat 10 0.1M)))
16:10clojurebottrue
16:10alindemankanwei: Is clojure.xml gone in favor of clojure.data.xml?
16:10alindemankanwei: I'm finding it hard to figure out when things came in and out of clojure
16:11alindemanThe docs I have seem to say that clojure.xml is shipped with clojure?
16:11kanweii just did (require 'clojure.xml)
16:12technomancyIIRC clojure.data.xml is better but requires an additional dependency
16:12kanweiboth seem to work here
16:18stuartsierraTo my knowledge, nothing has been *removed* from the Clojure language distribution.
16:27technomancy«As to why xml and zip are in Clojure: because I wrote them, and: zip is non-trivial and without it people would have wondered how to manage these immutable trees, and XML was simply to show, early on, how to "get into Clojure data structures ASAP", an important model for all libraries.» - https://groups.google.com/group/clojure/msg/58ec09f7de93f1d9 (rich)
16:29dakronestuartsierra: seq-contains? was removed
16:29Okasu,((juxt #(reduce + %) #(reduce - %)) [1 2 3])
16:29clojurebot[6 -4]
16:29Okasu,((juxt (partial reduce +) (partial reduce -)) [1 2 3])
16:29clojurebot[6 -4]
16:30dakronestream? was removed
16:31technomancyI thought stream? was only ever on a branch
16:31TimMc,((apply juxt (map (partial partial apply) [+ -])) [1 2 3])
16:31clojurebot[6 -4]
16:31TimMcOkasu: ^
16:32dakronetechnomancy: dunno, just doing a `git log | fgrep remove` and looking at what's been removed from clojure
16:34technomancyI think stuart was implying nothing that made it into a release was then removed
16:39stuartsierrayes
16:40dakroneremoved at all, or removed without feature-parity workaround?
16:41dakronebecause add-watcher and remove-watcher were removed, although they can be implemented in terms of add-watch (but not exactly the same)
16:43dakronestill, stuartsierra's point stands, and it's very difficult to find things that have been removed
16:49kanweii really like that about clojure, coming from a python background where every release was different :)
16:50kanweiwe had to maintain a branch for 2.4, 2.5, 2.6, and 2.7
16:52gfredericksI think rich's plan is to leave deprecated features indefinitely
16:52gfredericksin the same way that j.u.Date is still around
16:53Okasu,((apply juxt (map (partial partial apply) [+ -])) ((reduce (partial partial reduce) (repeat 1 partial)) [1 2 3]))
16:53clojurebot[6 -4]
16:53OkasuTimMc: ^
16:56Okasu,((comp + + + + + + - - - - - - - +) 1 1)
16:56clojurebot-2
16:57Okasu,((comp = + + + + + + - - - - - - - +) 1 1)
16:57clojurebottrue
17:01pl6306How do I use regex in clojure to find a line that starts with "TODAY=" in string?
17:02SegFaultAXpl6306: re-seq probably.
17:03metellusor re-find or re-matches, depending
17:03metellussomething in that family
17:03ToBeReplaced,(re-matches #"TODAY=." "TODAY=FRIDAY")
17:03clojurebotnil
17:03ToBeReplacedoops
17:04ToBeReplaced#"TODAY=.*"
17:04pl6306thanks i got it (defn get-singleline-property "Extracts single line properties from  File." [field sss]  ((split (re-find (re-pattern (str field "=.*")) sss) #"=") 1))
17:04pl6306Thanks
17:05SegFaultAX,(re-seq #"^TODAY=(.*)" sss)
17:05clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: sss in this context, compiling:(NO_SOURCE_PATH:0:0)>
17:06SegFaultAX,(let [sss "TODAY=123\nNOT_TODAY=456\nTODAY=abc"] (doall (re-seq #"^TODAY=(.*)" sss)))
17:06clojurebot(["TODAY=123" "123"])
17:06pl6306How do something like skip lines (a seq) until I hit say "BEGIN" and stop after "END"?
17:07ToBeReplaceddrop-while take-while
17:07pl6306Cool
17:07pl6306thanks
17:08winkbreaking news: as soon as you don't benchmark shitty hardware, the results aren't disapppointing anymore
17:15SegFaultAXClojure's regex flags are weird.
17:18SegFaultAXpl6306: You can add a (?m) to the start of that regex snippet I gave you to enable multiline mode.
17:22squidzwhat needs to be done to make the compiled clojurescript smaller?
17:23TimMcSegFaultAX: s/Clojure/Java/
17:24dnolensquidz: I don't see much room for improvement unless you're talking about more trivial programs. We could probably do smarter things here and there.
17:24SegFaultAXTimMc: Are the inline flags available in plain old Java re?
17:25squidzdnolen: because I think I heard somewhere that clojure in clojure would reduce the size. Am I mistaken
17:25SegFaultAXdnolen: Does clojurescript compress well? Does closure do anything to help?
17:26pl6306How I split a string by say "\r\n" or "\n"?
17:26dnolensquidz: huh, not sure how C-in-C will help with that, it's still work that needs to be done.
17:26dnolenSegFaultAX: it does compress well, we produce the kind of code that Closure was desgned to optimize.
17:27squidzdnolen: okay so the size probably isnt going to improve much?
17:27dnolensquidz: for trivial programs yes, for non-trivial programs we're already doing very well.
17:28gunspl6306: clojure.string/split-lines
17:28squidzby compressing are yall talking about using google closures optimization?
17:28dnolenhttp://blog.sethladd.com/2013/03/i-shrunk-my-dart-to-js-code-by-11x-and.html
17:29dnolenwe're doing about as well as Dart compression-wise, and Dart has way more engineers on it.
17:29MarcoPoloWhat's left to use sourcemaps with clojurescript, and how can I help?
17:29dnolenwe get a lot for free from Closure
17:30kanweidnolen: off top of your head, any idea what a "smallish" cljs gzipped total would be?
17:30dnolenMarcoPolo: read the code, we need to swap in tools.reader and fix emission
17:30kanweii'm an angularjs developer and it's 80k gzipped
17:31dnolenkanwei: the smallest I've see is ~19k, I think 80k gzipped is about right for small applications.
17:31kanweithat's really good
17:31squidzawesome, i didnt know it was that good
17:32kanweinow if someone would port angularjs to cljs :)
17:32dnolenkanwei: hehe, people seem to be happy using angularjs from cljs
17:32dnolenkanwei: angular supports advanced compilation no?
17:32squidzI havent had any luck turning closures optimizations on yet. What can be done to help make clojurescript code take advantage of closures optimizations?
17:33dnolensquidz: closure optimizations are all about code size, we do our own optimizations for perf (which kicks in if you used the advanced setting).
17:33kanweidnolen: never tried advanced, i need jquery and some other stuff for my current project
17:33dnolenkanwei: gotcha
17:34kanweidnolen: do futures work in cljs?
17:35dnolenkanwei: they do not
17:35kanweidnolen: i've seen your talk on Oz, having read the book myself, i'm a big fan of dataflow vars
17:36kanweii think futures can "kind of" replace dataflow vars
17:38scottjdnolen: doesn't look like angular js works with advanced mode https://github.com/angular/angular.js/pull/1951
17:39dnolenkanwei: yes dataflow vars are cool. futures could probably be made to work w/ some compiler hacking - but I haven't looked at it much and people seem to be coming up w/ other solutions that work well enough.
17:39TimMcSegFaultAX: Yeah, Clojure regexes are just Java regexes, straight-up.
17:40TimMcThe Clojure reader provides some syntax that allows for fewer backslashes, that's all.
17:40SegFaultAXTimMc: TIL. I've never used the (?mix) style switches in Java. I just use the appropriate constants.
17:41kanweisorry my internet died
17:41kanweidnolen: any thoughts on dataflow concurrency in cljs?
17:42dnolenkanwei: not really, beyond I think it would be cool, but I haven't looked into much myself.
17:46TimMcalexbaranosky: clj-schema's reporting for :or predicates can be really misleading. Are there plans to change this?
17:55SegFaultAXEheh http://starlogs.net/#clojure/clojure
17:58winkSegFaultAX: htpt://starlogs.net/#s-t-a-r-w-a-r-s/episode-iv beats all
18:38n_bAnyone have experience using Scala within a clojure project?
18:40technomancyn_b: there's a lein-scalac plugin, but it's kind of a proof-of-concept more than anything else
18:41callenThe next time I try to share some professional experience with somebody and the say, <nasal voice>"well that's anecdote"</nasal voice> I am going to go volcanic.
18:41callentechnomancy: sometimes I think Scala is design-by-checklist.
18:41callenwhich is regrettable, because I find about 1/3 of the checklist intriguing.
18:41technomancycallen: that's how I imagine D
18:42technomancypokemon-oriented programming. gotta catch all the paradigms.
18:42callentechnomancy: yep. Although I think half of that was Alexandrescu laughing in his evil lair exclaiming, "MORE POWER!"
18:42n_bcallen: You'll just have to reply Comic Book Guy style; "Worst. Rebuttal. Ever."
18:43n_btechnomancy: Thanks - I'll take a look at that.
18:44callenn_b: it's just annoying because it's that thing not-smart-enough-by-half people do to sound educated where they try to port the jargon and technique from scientific disciplines into something totally irrelevant like workplace interactions and meetings.
18:44callen"This isn't a double-blind study, shuddup"
18:45muhoois there a way to golf this up? (f1 x (f2 x))
18:45callenmuhoo: comp?
18:45callenmuhoo: thrush?
18:45amalloymake it shorter than that? no
18:45amalloybut you could avoid repetition if you want
18:46muhoowow. if amalloy says there's no way to to it, then there's no way to do it. thanks.
18:46n_b(-> x f2 f1)
18:46amalloyif you don't mind making it three times longer :P
18:46muhooamalloy: i'm curious
18:46callenn_b wrote what I had in mind.
18:46muhooprobably won't use it
18:46amalloycallen: because neither of you read the original request :P
18:46callenamalloy: I'm a write-only IRC daemon.
18:46n_bIt's same # of chars, just moving them around a bit :p
18:47muhoocallen: n_b: nope, look, it's got x as the first arg to f1, and the resulst of f2 as the second arg to f1
18:47amalloyhis code is (->> x f2 (f1 x)) or something
18:47amalloyn_b: it also does something totally different
18:47callenmuhoo: write APL if you want that much concision.
18:47n_bohh. yes.
18:47amalloy(apply f1 ((juxt identity f2) x)), lol
18:48muhoohahah
18:48amalloyanyway, as i said it's much longer but has no repetition
18:48muhoowell... i could write a function to do that
18:48muhootakes a vector of f's, and applies it in that pattern. but again, i'm rearranging deck chairs here
18:49muhoothe yak looks back worried. "i'm chilly, i don't *need* a shave!"
18:50callenmuhoo: next step is skinning the yak.
18:55muhoodon't worry, i'm putting that on my to-do-when-bored list
18:56muhooit smells like reduce could be used, maybe. later.
19:04maquinahi guys, i had a question, i have created a function in clojure with defn, and in the function body I instantiate a java object, however the object is instantiated even if the function is not called
19:04maquinado you know why this happens?
19:06maquinaactually, even if i do :import type-name, the type -init method is called
19:12technomancymaquina: yes, that gets called when the class is loaded
19:12technomancythat's what -init is for
19:29maquinatechnomancy: thanks! is there anyway to prevent this? when i call the same clojure code from java, the -init method is not called until i call new, and i would like to replicate this behaviour
19:31noonianHi, I just started messing around with dynamic vars and the binding form. If I want to bind (with binding) a var called foo for code I call from another namespace, do I have to declare (def ^dynamic foo) in each namespace? also if that is the case but there is a more idiomatic way to do something like that I would like to know.
19:38technomancymaquina: you can defer class loading to runtime with reflection
19:41maquinatechnomancy: mm.. ok, so this is just clojure behaviour? i am just surprised because in java if i import the class generated by clojure the method in -init is not called until i call new
19:44nDuffmaquina: it's just like static initialization sections in Java.
19:44nDuffmaquina: those are invoked well before you call new.
19:44nDuffmaquina: ...so, a defn itself won't do that.
19:45nDuffmaquina: perhaps something in your namespace actually calls the function.
19:46maquinanDuff: its just that I am porting some legacy code from java, the java code was calling a clojure generated class, the code inside -init in the clojure class, was only called when i called new in java. however now that i ported to clojure, the code in -init gets called as soon as i do import
19:47nDuffmaquina: Show me the code.
19:59maquinanDuff: its this class: https://github.com/nathanmarz/storm/blob/0.8.2/src/clj/backtype/storm/LocalCluster.clj
19:59maquinanDuff: LocalCluster, in clojure -init is called as soon as i import LocalCluster, in java it is called when i call new LocalCluster
20:04nDuffThat's... surprising. Can you provide the code you use to reproduce or demonstrate that behavior?
20:05nDuff(or, if not the exact code, a minimal reproducer which does so)?
20:20jjttjjf
20:49RaynesDoes the Clojurscript book even mention compiling for node?
20:49RaynesOr working with cljs on node?
20:51chessguyhidy-ho neighbors
21:05rbxbxRaynes breifly, yes.
21:05rbxbxbriefly, also.
21:05RaynesSo it doesn't actually discuss using it?
21:06rbxbxNo, it just mentions that you're able to set it as a compilation target.
21:06rbxbx"Compiling ClojureScript for Node.js is still an experimental feature and not widely used, so we do not cover it in this book."
21:09RaynesHeh
21:09RaynesI wish people cared more. At least we have ohpauleez and friends.
21:12ttimvisheris there any way to tell pr-str to strip out unreadable forms?
21:12ttimvisheri.e. when there's a java object in there?
21:14ttimvisheralso, i'm probably misunderstanding something fundamental here but i thought i could reference a symbol from the surrounding expansion context in a macro. i.e. a let with a particular symbol and then a macro expanded in the let. doesn't seem to be working though. is that a thing?
21:15callenRaynes: cljs and caring don't mix.
21:15RaynesBurn.
22:23romanandreghey, would it be possible at all have something like robert.hooke in clojurescript?
22:28romanandregping
22:28VFeIt may not be practical or performant, but I'm trying to think of reasons that wouldn't be possible, but can't think of any.
22:29jack_rabbitI'm having a problem with aleph whenever I try 'lein run.' The code works fine in the repl, so I'm wondering what I'm doing wrong: http://pastebin.com/L7sEE7qq is the error, and https://github.com/Jack-Rabbit/clojirc/blob/master/src/clojirc/core.clj is the code.
22:54jack_rabbitsorry, I ducked out.
22:57jack_rabbitHuh. It seems that the line "(alter-var-root #'*read-eval* (constantly false))" is causing my problems. Any ideas?
23:01amalloyjack_rabbit: nothing obvious springs to mind; it looks like something in clojirc is trying to compile stuff at runtime
23:01jack_rabbit:/ shouldn't be. Could it be a macro expansion?
23:02amalloynah
23:03jack_rabbitDo I need to compile it specially in order to run it? If I call start-freenode once it seems to "initialize" whatever it is that needs to be compiled.
23:04jack_rabbitAfter calling it, I can run -main fine.
23:06amalloyno. although i'd suggest getting rid of all the AOT in your app; it leads to exciting problems for no reason
23:06jack_rabbitAOT?
23:06clojurebotAOT genclass is http://paste.lisp.org/display/70665 and http://clojure-log.n01se.net/date/2008-11-18.html#14:19
23:06amalloy:gen-class
23:06jack_rabbitWhat exactly is that? leiningen put it there, so I just followed suit.
23:07amalloywell, in order to define a named -main entry point, you need to generate a named class, with gen-class
23:07amalloybut clojure transitively compiles every namespace that your class depends on
23:07jack_rabbitSo I'll need it in my core.clj file?
23:08amalloymy advice, if you don't need any other features of AOT, is to define a "dummy" main namespace that doesn't depend on anything, but requires the real main at runtime and delegates to it
23:09jack_rabbitHuh. It seems to run okay without :gen-class in my core file anyway.
23:10amalloyyeah. you only need to gen-class if you want to create runnable jar files, i think
23:11amalloyand if you do need that, i recommend the technique i just outlined, like https://gist.github.com/amalloy/5376731
23:11jack_rabbitCool. I'll probably do that, then.
23:12jack_rabbitMy core.clj will have gen-class, and 'require' a separate namespace with my real "main"
23:12jack_rabbithmm. It seems to be a problem with lamina.
23:14amalloydoubtful. lamina is pretty solid
23:14amalloybut feel free to ask ztellman, if you find a minimal repro case
23:14jack_rabbitIs it really dangerous to allow code to compile at runtime? That always seemed like a cool feature of lisps to me. It also seems fairly difficult to get a
23:15jack_rabbit"read" prompt with which to compile arbitrary forms.
23:15jack_rabbitUnless that feature is directly built in.
23:18jack_rabbitI guess it's just odd that I don't see any of my functions on the callstack in these errors. I don't have a lot of experience debugging in the JVM. Do you have any suggestions?
23:21amalloyjack_rabbit: of course some of your functions are in the callback
23:22jack_rabbitwhat do you mean?
23:22amalloybut line 47 of your paste indicates that it's happening while compiling some clojure functions, rahter than running them, and i can't really see any reason why they aren't already compiled
23:22amalloysearch for clojirc in that paste, it comes up lots of times
23:23amalloywell, okay, three times
23:23jack_rabbitoh, yeah. I see.
23:31jack_rabbitThe only thing that could really cause compiling should be reading some form from a file or input or somesuch, right?
23:32ttimvisheris it possible to reference a symbol from the surrounding context from a macro?
23:32ttimvisheri.e. i know symbol `r` will exist everywhere the macro is expanded
23:32jack_rabbitIt's possible, but not good practice.
23:33jack_rabbitIt makes your macro non-hygenic.
23:33ttimvisherjack_rabbit: i can definitely see why. i'm trying to write a very simple logging decorator to all my compojure routes
23:33jack_rabbit*hygienic
23:33ttimvisherand i have :as r at the end of each destructuring and i'm trying to simply omit that from the arguing
23:33ttimvisherargument*
23:33ttimvisheri can't seem to make it work though.
23:34ttimvishersyntax quote leaves me with a fully-qualified symbol
23:34ttimvisherand ~ and ~@ require that the symbol be passed as an argument as far as i can tell
23:42amalloyttimvisher: why is this a macro at all? just make it a middleware like anything else
23:43amalloy(defn wrap-logging [handler] (fn [req] (log req) (doto (handler req) log)))
23:44ttimvisheramalloy: lol. good point.
23:45ttimvisheri'm always looking for an excuse to write a macro and then someone comes along and pushes me down. ^_^