#clojure logs

2014-09-02

02:40xy86is anyone using friend with luminus?
02:55mi6x3mclojure how do I get the namespace qualifier in e.g. foo/bar ?
02:58mi6x3m,(namespace 'foo/bar)
02:58clojurebot"foo"
02:58mi6x3m,(namespace 'bar)
02:58clojurebotnil
02:59celwellDoes anyone know what's wrong with my regex? I trying to grab every group of text between "Registration" words in a document. (re-seq #"Registration([.\s]*)Registration" text)
03:00TEttingerwell \s won't work inside a character group, celwell
03:01TEttinger,(re-seq #"Registration(.*)Registration" "Registration TEttinger celwell Registration")
03:01clojurebot(["Registration TEttinger celwell Registration" " TEttinger celwell "])
03:01TEttingerdid you want to guarantee a space being at the end?
03:02celwellno
03:02celwelldoes your regex cover whitespace in the midst of each group?
03:02celwellhmm... i'm getting nil
03:02TEttingerdo you want to grab those as separate things?
03:03celwellno, just the groups (the content between each pair of Registration strings)
03:03TEttinger,(re-seq #"Registration(\s+\w+\b)+Registration" "Registration TEttinger celwell Registration")
03:03clojurebotnil
03:03TEttinger,(re-seq #"Registration(\s+\w+\b\s*)+Registration" "Registration TEttinger celwell Registration")
03:03clojurebot(["Registration TEttinger celwell Registration" " celwell "])
03:03TEttingeroh, so you do just want the first one
03:04TEttingeror possibly re-find
03:04TEttinger,(re-find #"Registration(.*)Registration" "Registration TEttinger celwell Registration")
03:04clojurebot["Registration TEttinger celwell Registration" " TEttinger celwell "]
03:05celwellI have a long document of a bunch of registration info and each one starts with "Registration". I just trying to chunk it by registration and then I'll do further parsing.
03:05celwellthe "Registration" words are on newlines (there are other whitespace characters in the midst of each chunk as well)
03:06TEttingerand you want to keep the whitespace right?
03:06celwellyeah
03:06TEttinger,(re-find #"Registration(.*)Registration" "Registration TEttinger celwell\nRegistration")
03:06clojurebotnil
03:06TEttingerah ha
03:06TEttinger,(re-find #"Registration(.|\n*)Registration" "Registration TEttinger celwell\nRegistration")
03:06clojurebotnil
03:06TEttinger,(re-find #"Registration((:?.|\n)*)Registration" "Registration TEttinger celwell\nRegistration")
03:06clojurebot["Registration TEttinger celwell\nRegistration" " TEttinger celwell\n" "\n"]
03:07celwellah...
03:07TEttingerdammit that's supposed to ignore the find....
03:16celwellTEttinger: hmmm... that stack overflows pretty soon on my machine. Maybe I can't use regexes to tokenize my data here...
03:19celwellTEttinger: Thanks for the help anyways.
03:20celwellTEttinger: Yeah, if you take the "Registration TEttinger celwell\r\nRegistration" string and copy/paste that about fifty times, it'll overflow
03:21celwellI guess that capturing group is recursive and piling up
03:21TEttingerhm, maybe... there could be a better way
03:27TEttingergot it, celwell: ##(re-seq #"Registration([^\000]*?)Registration" (apply str (repeat 100 "Registration TEttinger celwell\nRegistration")))
03:27lazybot⇒ (["Registration TEttinger celwell\nRegistration" " TEttinger celwell\n"] ["Registration TEttinger celwell\nRegistration" " TEttinger celwell\n"] ["Registration TEttinger celwell\nRegistration" " TEttinger celwell\n"] ["Registration TEttinger celwell\nRegistration" " ... https://www.refheap.com/89683
03:28TEttingerthat uses a negated character class and the (can't remember what it's called, opposite of greedy) star
03:29TEttingerminimal, that's what "*?" is
03:29celwellwow, thanks, works well.
03:30TEttingerno prob, I used http://www.regular-expressions.info/charclass.html#negated for all this
03:30TEttingerthat site is pretty great
03:31celwellkind of weird how something this common (i think) requires a negated character class (but I guess there are other ways too)
03:38TEttingercelwell, there's an interesting thing on there about "Dot"
03:38TEttingerhttp://www.regular-expressions.info/dot.html "the most commonly mis-used character"
03:40celwellah, of course it always comes down to this: "This exception exists mostly because of historic reasons"
04:19borkdudesorry if I could have found this in the paredit cheatsheet, but how do I swap/toggle two sexprs? like option-t in normal lines
04:19borkdudein emacs
04:27maxthoursieborkdude: C-M-t
04:29borkdudean, transpose-sexp, thanks
04:29borkdudesexps even
05:09amalloyTEttinger: pretty sure the better solution to celwell's regex problem was to turn on the "dot matches newline" flag, not a weird capturing group
05:10TEttingeramalloy, I didn't know about that flag
05:11TEttingeris it an optional arg in re-seq?
05:12TEttingerthe weird capturing group will have the same behavior though, since \000 (NUL) isn't allowed in strings anyway
05:12TEttingeror it might be in java?
05:12amalloyyou can pass any regex flag to Pattern/compile, or include it inline in the regex with the flag-activating syntax. eg, (?s) activates the S flag, which is dotall
05:13amalloyer, ?s is single-line. dotall is in there somewhere
05:16amalloy,(re-seq #"(?m)Registration (.*)" "Registration TEttinger celwell\nRegistration foo")
05:16clojurebot(["Registration TEttinger celwell" "TEttinger celwell"] ["Registration foo" "foo"])
05:17TEttinger?m eh? that's new
05:17TEttingerwell to me
05:18TEttinger$mail celwell amalloy's better solution uses a regex flag that allows newlines as part of . matches. (re-seq #"(?m)Registration (.*)" "Registration TEttinger celwell\nRegistration foo")
05:18lazybotMessage saved.
05:19TEttingeralthough he specified that the Registration might not be followed by a space
05:19TEttinger(might be tab or newline)
05:19amalloyTEttinger: (?m) is a specific case of the general turn-on-a-flag syntax, which works for all regex flags (eg, (?i) for ignore-case)
05:20amalloy(?M) turns a flag back off
05:20TEttingercool, I saw it but didn't recognize its use on that regular expressions site
05:20TEttingerwhat time zone are you in, amalloy?
05:21amalloyheh, my client refused your ctcp?
05:21amalloypacific
05:22TEttingersame here
05:23SagiCZ1hi, could u just hint me a little bit how to do this?
05:23SagiCZ1[:a :b :c :d] -----> [[:a :b] [:b :c] [:c :d]]
05:23TEttinger,(vector (reductions vector [:a :b :c :d]))
05:23clojurebot[(:a [:a :b] [[:a :b] :c] [[[:a :b] :c] :d])]
05:24TEttingeruh that's not right :P
05:24jkj (partition-all 2 1 [:a :b :c :d]) ?
05:24SagiCZ1,(partition-all 2 1 [:a :b :c :d])
05:24clojurebot((:a :b) (:b :c) (:c :d) (:d))
05:24TEttinger,(partition 2 1 [:a :b :c :d])
05:24clojurebot((:a :b) (:b :c) (:c :d))
05:24SagiCZ1not bad
05:24amalloypartition, not partition-all
05:25jkj(mapv vec (partition 2 1 [:a :b :c :d]))
05:25TEttingerthat too if they should be vectors
05:25amalloyor ##(let [xs '[a b c d]] (map list xs (rest xs))), just for fun
05:25lazybot⇒ ((a b) (b c) (c d))
05:25jkjand this for vectors
05:25SagiCZ1but guys!
05:25jkjdamn.. i have bound , to / in irssi
05:25SagiCZ1i wanted "a little hint" !
05:25TEttingerheheh
05:25TEttingerit's a little task
05:25SagiCZ1heh
05:26TEttingerthe regexes were a legitimate hard problem because they involve leaving clojure land!
05:29amalloynote, by the way, that javascript doesn't support inline flags, so (?s) or whatever won't work in cljs
05:30amalloythough i think if you put them at the very front of the regex, the cljs compiler magically moves them to the global flags section, turning #"(?s)foo" into /foo/s
05:41SagiCZ1do we have square root in clojure?
05:41SagiCZ1how can i static import it from Math? so i can use (sqrt 3) instaed of (Math/sqrt 3) ?
05:45notofiSagiCZ1: (def qrt [n] (Math/sqrt n))
05:47hyPiRionSagiCZ1: https://github.com/baznex/imports
05:49wjlroeHere's a bizare implementation of fizzbuzz https://gist.github.com/wjlroe/90b00fda936fd510ddd6 that I based on one my friend wrote in Go https://gist.github.com/jcinnamond/34177e064e861704ac81 It uses types rather than control structures, if anyone is interested
05:53hyPiRionpeculiar
05:58mpenet"no control structures" but very "goto"'ish
05:59wjlroeyeah, it's just a bit of fun
06:00hyPiRionOhhh
06:00hyPiRionno control structures
06:00wjlroeAlso, I tried doing the same thing in Rust, which was pretty tricky https://gist.github.com/wjlroe/dec2b2d198161b8454d0
06:01hyPiRionwjlroe: have you been working with Rust much?
06:02wjlroehyPiRion, that gist is the sum total of my time with Rust. It really made my head hurt and I kept wishing it was Haskell
06:02mpenetI dabbled a bit with rust as well
06:03wjlroeI would like to do more Rust but I don't have a suitable project for it at the moment.
06:03mpenetwell, it's very different from haskell for sure. all the ownership/lifetime stuff for instance
06:04wjlroeI don't know about that, but it seems to want to be a faster more low level language
06:04mpenetyes
06:05mpenetC with cool compile time stuff to prevent common mistakes, more or less
06:05mpenetnice language imho
06:05wjlroeLike Go but with a better type system
06:06mpenetand no GC :}
06:06hyPiRionyeah, it feels like a sane C++ with guard rails for bad memory management
06:06wjlroeyeah that too
06:09clgva statemachine for fizzbuzz? :P
06:09wjlroeyup. I hope that in the future I can come up with even more outlanding ways to do fizzbuzz
06:10wjlroes/outlanding/outlandish/
06:10clgvwjlroe: how about a concise clojure version with "cond->" ? ;)
06:10wjlroeToo sensible
06:11wjlroeFizzbuzz isn't business logic, it's a way to express your creative side
06:11clgvok then try a version with dependency injection based on spring ;)
06:11wjlroeThat's more like it
06:11clgv"enterprise fizzbuzz" ;)
06:20mavbozoi'm trying to solve this problem http://www.4clojure.com/problem/95
06:21mavbozoabout recognizing binary tree
06:21mavbozoso far, I only found the solution with using ordinary recursion
06:21mavbozobut it might blow up the call stack if the tree is too big
06:21mavbozois there any solution using recur?
06:22wjlroemavbozo, if you can use recursion then you should be able to use loop+recur
06:25mavbozowjlroe: i try to solve using loop recur, but i'm having trouble on putting the recur in tail position
06:26wjlroemavbozo, oh. so your recursive solution didn't tail recur? Ok.
06:28mavbozowjlroe: yes, i did not use recur at all in my first solution
06:29clgvmavbozo: well it cant blow the stack on the examples there - except you are running it on some kind of microcontroller ;)
06:33mavbozoclgv: yeah, but i can't help think about it. As I recall from my courses years ago--when using common lisp or scheme/racket, using recursion is a straight forward solution and I don't have to think about blowing up the stack because the compiler do some tail-recur optimization. But, now in clojure I have to think hard about it.
06:34clgvmavbozo: no you only have to think about it, when you have large data that causes large stack consumption. otherwise you couldnt use recursion in java at all ;)
06:47clgvmavbozo: btw it's not true that you dont have to think hard - in both cases the hard part is to come up with a tail recursion
06:48clgvthe difference in clojure is that you explicitely declare it as tail recursion by using `recur`
06:53hhenkelHi all, I got currently a hard time to change some code I wrote 2 months ago and I haven't touched clojure since then. Can someone please give me a hint how to change this code: https://www.refheap.com/89693 that it is not returning a vector but a hash-map with "unique" id?
06:54mavbozoclgv: i see what you mean. i find it hard to find the tail-recursion's solution.
06:54hhenkelI'm aware that I need to change the (vec), but I'm currently not getting how to have something like a counter added to the (hash-map) as a key.
06:56clgvmavbozo: for problems that are not inherently tail-recursive the general solution is to build the "stack" on the heap
06:58mavbozoclgv: so this binary-tree recognition is not naturally tail-recursive?
06:59clgvmavbozo: yeah, it is not. since you usually need to perform a recursive call for each branch of a node
07:00clgvmavbozo: but you can maintain a list of branches to investigate and thus make it tail-recursive
07:05mavbozoclgv: thank you for your explanation and suggestion
07:14Duke-hhenkel: this might work https://www.refheap.com/89697
07:15clgvDuke-: hhenkel: zipmap
07:15clgv(zipmap (range) (for ...))
07:16Duke-oh yeah
07:41hhenkelclgv: Thanks.
07:41hhenkelDuke-: ^^
08:11Kneivawjlroe: http://thedailywtf.com/Articles/The-Fizz-Buzz-from-Outer-Space.aspx
08:14bounbha
08:14wjlroeKneiva, I haven't read dailywtf for years since it's a bit too close to reality for comfort
08:15Kneivajust thought it funny that you were talking about fizz buzz today and that just published
08:17wjlroeTotally, and that is the best logarithm I've ever seen
08:17Kneiva=)
08:18wjlroeI mean we laugh now, but in several hundred years these scraps of notepaper will be like Fermat's last theorem
08:18mavbozoi thought that fizbuzz solution without control structure is outer-space enough,then comes a solution only using arithmetic operators
08:20clgvI heard a salesguy advertise his project when he started talking of the clever "alogarithms" involved - a verbal typing error ;)
08:20clgv*product
09:30lvhHm. I wrote a functio nwith a default argument (w/ destructuring), but it doesn't appear to compile, and I can't figure out why.
09:30lvhhttps://gist.github.com/lvh/4fb459d55f2e541765e3#file-fn-clj-L13
09:30lvhthe arg line is [components & {:keys [dev-mode] :or {dev-mode false}}]
09:30justin_smithlvh: you provided the wrong number of arguments
09:31lvhjustin_smith: this is one of those cases where you wonder about it for 15 minutes
09:31lvhthen you ask, and suddenly realize, OH right duh.
09:31justin_smithso you figured it out? - that function as defined will always need an odd argument count
09:32lvhjustin_smith: Yeah. I was passing dev-mode positionally, and expecting it to work anyway.
09:32lvh(Python leftover I guess)
09:32justin_smithpositional: [components & [dev-mode]]
09:32justin_smiththat will default to nil
09:32justin_smithwhich is as good as false, usually
09:39lvhhm. are let blocks supposed to work inside compojure routes?
09:39lvh(It seems they don't: only the last block works)
09:39lvherr, route
09:40clgvlvh: where do you put the let-block?
09:40lvhclgv: inside a context
09:41clgvlvh: well I guess the simple rules is, they are supposed to work everywhere where abody expr processing the request is expected
09:43lvhhttps://gist.github.com/lvh/dc967bc751edc30f429a
09:43lvhI hope that clarifies intent :)
09:43lvhI do think I understand why it doesn't work, yes
09:44lvh(not really side-effectful: just a macro that sees what children it has)
09:45visofhi
09:46bounbhi visof
09:47clgvlvh: remember that `let` does only return the result of the last form!
09:48clgvlvh: hence your GET is lost
09:49clgvlvh: you could have a look at how `context? works and build a different version that does not expect multiple routes but a list of routs
09:49clgv`context` ^^
09:54doctormNew to clojure, can someone tell me if this function is idiomatic or if it’s still has imperative feel - https://www.refheap.com/89701
09:54mi6x3mdoctorm: welcome, sec
09:56mi6x3mdoctorm: it can go a lot shorter :)
09:56mi6x3mi mean, it's idiomatic but nobody will write it that way
09:56doctormmi6x3m: Thanks, would you mind telling me how?
09:56mi6x3myes
09:56doctormThat’s what I was worried about
09:56mi6x3m2 good ways
09:57mi6x3m(<= low (count (str v)) high)
09:57samfloresI think even in a non-functional using a if-else to return a boolean value is not idiomatic
09:57wjlroedoctorm, one point - (if condition true false) is the same as just condition
09:57samfloresjust return the value of the condition
09:57doctormWell, there is a nil check there too
09:57TimMcmi6x3m: Are you saying to drop the ability to use nil bounds?
09:57mi6x3mok, my bad :)
09:58mi6x3mskipped the nil bounds visually
09:59doctormsamflores: Right, the if could definitely be gotten rid of entirely
09:59mi6x3mdoctorm: well except for the if, seems ok
09:59mi6x3mpretty ok
10:00samfloresi'd put the string as the first parameter too, but it's just matter of taste :D
10:00clgvhuh metrics-clojure has `start`/`stop` for timers in its docs but they do not seem to exist
10:01maxthoursiedoctorm: the docstring goes before the args
10:01doctormOk, thanks for the spot check everyone. samflores: I don’t put the string as the first parameter because I need to use it with partial
10:01doctormmaxthoursie: Missed that, thank you
10:01karlsdoctorm, mi6x3m, could you do something like (<= (or low 0) cnt (or high Integer/MAX_VALUE)) ?
10:01samfloresit makes sense
10:02TimMcclgv: There are a few places the docs don't match.
10:02TimMcThe params for meter and defmeter are wrong as well.
10:02clgvTimMc: do you know if I can achieve that intended use case somehow else?
10:02lvhclgv: will do :) my first guess involved apply
10:03lvhclgv: doesn't work so well with macros unfortunately
10:03clgvlvh: ;)
10:03maxthoursiedoctorm: and for future if statements, put the else on a new row
10:04doctormmaxthoursie: Will do, thanks
10:04maxthoursiedoctorm: what seems to be ideomatic is to either put all arguments on one line, or to put all of them on new lines
10:04clgvTimMc: ah might be a versioning problem. latest master has thos functions
10:06maxthoursiekarls: I think that's worse, you're introducing a unneccesary limit
10:08TimMcclgv: I suspect you can just call .start and .stop directly. :-)
10:10karlsmaxthoursie: true. depending on the context i would think it's ok.
10:11clgvTimMc: almost. it's `.time` and `.stop`
10:12maxthoursiekarls: definitely could be, but wrapped up in a function like this, I would argue it's incidental complexity
10:13lvhWhen I use http-kit's server, it's awfully quiet. What's the easiest thing I can do to get some logging on stdout/err?
10:14karlsmaxthoursie: agreed. saving a few lines and introducing that limit is probably not worth it.
10:21justin_smithlvh: you could make a middleware that logs details about the request
10:58lvhtbaldridge: hi! just subscrubed to your pivotshare videos. Cool stuff :)
10:58lvhtbaldridge: I know you're probably swamped with requests, but have you done anything on core.async http *servers*?
10:59lvhthe obvious thing is http-kit, but http-kit's server interface (being borrowed from ring) is either a) synchronously return a response (map) or b) use this channel abstraction that isn't core.async channels and ignores middleware
10:59tbaldridgelvh, I haven't yet, but I'll put it on the list
10:59lvhtbaldridge: Awesome, thanks :)
10:59tbaldridgelvh: right, while Pedestal supports full async from top to bottom. It'd be nice to compare/contrast the two
10:59lvhI may end up just trying to write a bunch of (thread ...) blocks in there
11:00mpenetshameless plug: https://github.com/mpenet/jet
11:00mpenetit's jetty9 + core.async in short, has both client/servers
11:00tbaldridgempenet: bookmarked, thanks!
11:00mpenetyw
11:06lvhmpenet: Thanks, that looks awesome!
11:07rweirmpenet, is jetty9 itself async, or is it getting wrapped in threads?
11:07mpenetit has an async api and it should be quite good at it
11:07lvhmpenet: I take it that means all my ring middleware Just Works(TM)?
11:08mpenetyes, the jetty-adapter is vanilla clojure adapter, the async part is done via the option map
11:08rweirah nice
11:08mpenetso just change imports and your code works, then you can work on the ws part
11:10lvhmpenet: this is pretty cool; the thing I'm writing can essentially be described as "when a request comes in, do a ton of coordination based on ~20 other requests that you only find out at runtime"
11:10mpenetlvh: the tests for instance are basically a copy paste work from the jetty adapter that comes with ring + ws/clients tests
11:10lvh(i.e. I really really want core.async)
11:11rweirlvh, how're you liking c.a vs twisted?
11:12lvhrweir: it's like reinventing everything all over again ;)
11:12lvhsorry, not reinventing; discovering is the word I'm looking for
11:12lvhas in, I am trying to find out how to spell gatherResults
11:13lvhrweir: I think Clojure is a significantly better programming language than Python. Obviously Twisted has had some headway in terms of maturity.
11:13lvhrweir: Unfortunately my major gripe is the same: the default is blocking :(
11:15pydave6367lvh: How did you find the transition? Did you find any particularly good resources for someone coming from a Python background?
11:15lvhmpenet: So, I'm trying to figure out if this does what I think; does this mean that the ring handler can just return a channel that fires with a response map, instead of synchronously-a-response-map?
11:15lvhpydave6367: well, I used to be a schemer, so maybe it wasn't so hard for me :)
11:16pydave6367Sounds a better way to do it!
11:17mpenetlvh: yes kinda, if you look at the examples here https://github.com/mpenet/jet#websocket , the async handlers basically receive a map of 3 channels, one for input data, one for output (response) and a control channel (errors, deconnections)
11:18mpenetlvh: so you have control at the rate of input from the clients via the :in channel, you can respond by putting stuff into :out and handle the rest via :ctrl. This plays nicely with core.async/alts!
11:18lvhmpenet: Gotcha. I am not trying to use websockets though; I just want to do regular HTTP requests with high concurrency and while the requests can potentially take a long time :)
11:19mpenetlvh: ah no, this is websocket only
11:20lvhmpenet: ah, alas :(
11:20rweirpydave6367, I've found 'joy of clojure' pretty good for me, coming from python - the biggest problems are that I can never remember how to destructure, and end up contorting my code to make the right thing end up as the final expression, until I remember I should just make more functions
11:22rweirlvh, have you used any mainstream-ish languages that make asynchronicity the default?
11:22bounbpydave6367: i'm loving clojurebook.com. just forget about python and dive in
11:23lvhrweir: Erlang doesn't count I guess?
11:23mpenetjs either
11:23pydave6367rweir: Yeah I've been burned by destructiring a few times too. I've been reading the oreilly book but I'll order a copy of Joy of CLojure based on your recommendation. Thank you!
11:24rweirlvh, mpenet ah, both good points
11:39reiddrapergfredericks amalloy: new test.check fun, a 'shuffle' generator: https://github.com/clojure/test.check/commit/43377ed0954e0066a4bbfb1345cf28af9d28312a
11:41gfredericksreiddraper: hey hey nice nice
11:41reiddrapershrinks toward making fewer and fewer swaps, so [0 1 2 3 4] when shuffled, might shrink to [1 0 2 3 4]
11:42gfredericksrighto
11:42gfredericksI have a subset generator in test.chuck
11:42gfredericks...not sure why I felt that necessary to mention
11:43reiddraperoh neat. would love a pull request.. uh, i mean. jira ticket, for that :D
11:43gfrederickssubsequence might be more accurate
11:43gfredericksi.e. it doesn't really use sets
11:43gfredericksI used it just yesterday to generate divisors based on prime factorization
11:45clgvreiddraper: :D
11:57noncomwhen installing prelude on emacs, what is more common - to let it settle fully in .emacs.d, when init.el is the prelude init.el, or do i better keep it in a subdir of .emacs.d and simply refer it from my own main init.el ?
11:58ToBeReplacednoncom: the former
11:58technomancynoncom: I would really recommend building out your own init.el and stealing things from other sources as you find them. it's a lot less disorienting and more debuggable when things go wrong.
11:58technomancywe get a lot of people in #emacs who are confused about basic behaviour because they installed a starter kit like the prelude and don't actually understand why it's working the way it does.
11:59noncomi see.. :)
12:01ToBeReplacedvalid point from technomancy -- as the counterpoint, i was someone who "drank from the firehose", and now i do direct updates from prelude with no modifications... maybe depends on your learning style?
12:01rweirwhoever wrote the emacs-starter-kit eventually just changed it to be a set of uh better defaults, also ;-p
12:02technomancyrweir: yeah that was me
12:03rweiryeah, I know :)
12:05noncomToBeReplaced: yeah, i guess it really depends on the usage pattern
12:05rweirfwiw I would highly recommend writing your own init.el too
12:05noncombut good to know that people have opinions regarding these points
12:06noncomrweir: i have a long way to go until i really imagine what my init.el should be... for now i guess i am just collecting all kinds of i-might-need-this things..
12:06noncomin the init.el
12:07TimMcLatest thing I am happy with: ace-jump-mode
12:07TimMcIt's a little hard to explain.
12:07ToBeReplacedha, yeah... i'm in the "all of these other people really care about their environment... i'll just do what they do"... and, prelude in particular has been really responsive about issues/prs so gradually i haven't needed anything in my own personal.el
12:08ToBeReplacedmy only unhappiness with it is how wide it makes the attack vector for reading my home directory
12:09noncomthe ace-jump-mode i am reading is a nice nav aid
12:09mi6x3mnth doesn't work on sets wtf?
12:09noncommi6x3m: sets are unordered?
12:09mi6x3mnoncom: first and rest work.....
12:10noncomhaha
12:10tbaldridgemi6x3m: what is nth on a unordered thing?
12:10mi6x3mtbaldridge: what is first on an unordered thing?
12:10tbaldridgemi6x3m: that's because first and rest convert their inputs into a ordered thing
12:10mi6x3mtbaldridge: oh?
12:10justin_smithlvh: I don't think it is that the channel returned by ring ignores the middleware, rather the middleware is not written to wrap channels. But you could write your own middleware that does. Or am I missing something?
12:10tbaldridgefirst and rest are seq functions used for walking through a collection. Nth is a indexed operation.
12:11noncomToBeRaplaced: i guess i'll have to experiment with init el, yeah, since th etopic is soo vast
12:11noncom*ToBeReplaced: sorry for mistyping the nic..
12:11mi6x3mtbaldridge: what is then the impact of making a set a sequence?
12:11mi6x3mso it can be destructured
12:11mi6x3mnegligable I would guess?
12:11lvhjustin_smith: That was about http-kit, not ring
12:11mi6x3msince the order is pretty random
12:12lvhjustin_smith: the docs for that don't seem to suggest that middleware can be rewritten to do better
12:12tbaldridgemi6x3m: yeah, most things in clojure can become seqs, it's basically an immutable iterator
12:12mi6x3mye though so
12:12lvhhttp://http-kit.org/server.html#channel
12:12justin_smithlvh: I fail to see how you couldn't write a function that takes a channel and returns a wrapped / modified channel. And if you can write that function, you can put it in a middleware.
12:15justin_smithlvh: oh, now I see in those docs that ring middleware is not applied to the channel. But you could put your own middleware in the on-receive / on-close blocks
12:16lvhjustin_smith: Yes, but: 1) I'm not actually sure that you can write it as middleware, but whatever, I can wrap it 2) the channel isn't actually the abstraction I want (it wants to do a bunch of back-and-forth req/rep pairs, which makes a lot of sense if you're doing websockets or long-olling RPC, but I'm not doing that) 3) that would mean doing a bunch of work when there's clearly already an abstraction that does *almost* exactly what I wnat
12:18lvhjustin_smith: the http-kit thing is a red herring because it's about long-held connections with a lot of chatter back and forth, like long-polling, http streaming, websockets, whatever
12:18lvhI don't actually want that
12:18justin_smithregarding 1), a middleware is just a function that returns another function - you can put a middleware stack inside that block - regarding the rest, you know more about this api than I do, and I frankly expected something better from http-kit than what I see so far
12:20lvhI think the long-polling example *kind-of* does what I want
12:20tbaldridgelvh: just going to throw out there that this is what Pedestal was designed for, not so much for WS, but middleware can be paused/resumed via core.async, as well as the response body itself.
12:20tbaldridgeserver sent events are supported though
12:20lvhtbaldridge: I'm actually in the super simple case of "I want all of the middleware all of the time"
12:21lvhreally the only difference between what I want and what ring's API gives me is that ring wants me to say "here you go have a response map"
12:21lvhI wnat to say "here's a channel, I promise I'll throw a response map on there and then close it"
12:22lvhthe long-polling example is nearly there, modulo the somewhat displeasing parts (1. ignoring middleware, 2. doing the rendez-vous between channels and open HTTP requests with shared mutable state)
12:23lvhbut, in the same spirit as what justin_smith said, I don't want to accept that the answer is that terrible ;-)
12:23lvhmaybe I should just give up and use pedestal :)
12:23tbaldridgelvh: that's a problem with the way ring is designed, it ties the call stack to the request/response logic. You can't suspend ring handlers and "run them later" because they already exist on the call stack.
12:24lvhtbaldridge: I am chuffed to see that rack/wsgi brain damage has made clojure worse, too ;-)
12:25tbaldridgelvh: yeah, I mean it's kindof sad. Jetty supports async, it's just ring doesn't.
12:26tbaldridgeThere's a reason Pedestal was created, and you've now found that reason.... :-)
12:28lvhtbaldridge: It's unfortunate because I was getting to like wrap-reload & prone.middleware.wrap-exceptions
12:29SagiCZ1whats the best way to do simple if (..) else if (..) else if(..) else (..) in clojure?
12:29SagiCZ1cond has no default action
12:29tbaldridgelvh: yeah, Pedestal has a bit of a learning curve, but after you learn it there's some real "oh...wow... I can do that?" moments.
12:29mi6x3mSagiCZ1: cond has a default action
12:29SagiCZ1:else?
12:29mi6x3mSagiCZ1: yes
12:29SagiCZ1,(boolean :any-keyword)
12:30clojurebottrue
12:30SagiCZ1thats just a trick
12:30mi6x3mSagiCZ1: well, it wil be evaluated last...
12:30mi6x3mso it's half of a trick
12:30justin_smithby using a test that is always true, you create a default branch
12:31SagiCZ1if it works.. ok
12:31justin_smith,(cond false 0 nil 1 :default 2)
12:31clojurebot2
12:31clgv,(macroexpand-1 '(cond (zero? n) :1 :else :2))
12:31clojurebot(if (zero? n) :1 (clojure.core/cond :else :2))
12:32clgv,(macroexpand-1 '(cond :else :2))
12:32clojurebot(if :else :2 (clojure.core/cond))
12:32clgvah cond could get rid of the last `if` but it does not seem to do that
12:32justin_smith,(macroexpand-1 '(clojure.core/cond))
12:32clojurebotnil
12:33justin_smiththe last part is not an if
12:33clgvjustin_smith: I didnt say so. I referred to the last `if`
12:34justin_smithoh, since it knows at compile time the arg is always truthy
12:34clgvdoes the clojure compiler eliminate `if` for always `true` or always `false`?
12:35technomancyclgv: no, but hotspot might
12:36clgvtechnomancy: right
12:36clgvtechnomancy: always forgetting that awesome beast ;)
12:50SagiCZ1i have kind of off-topic question.. do you have any idea how can i find out the shortest distance from polygon to a point? i have already worked out the shortest distance from a line segment to a point.. but dont know how to put it together
12:51mi6x3mSagiCZ1: 3d polygon?
12:53SagiCZ12d
12:54justin_smithtreat the closest edge of the polygon as a line segment?
12:54SagiCZ1but how to determine "closest" edge
12:54mi6x3mSagiCZ1: is it convext?
12:54mi6x3m-t
12:54SagiCZ1mi6x3m: not necesarrily
12:54mi6x3mSagiCZ1: well then find the distance to all edges and get the min
12:55SagiCZ1define "distance"
12:55SagiCZ1it cant be the perpendicular distance
12:55justin_smithif it was convex you could walk it until a side is closer than both neighbors, but with the ability to have a concave shape, you could have a local minima that is not the true minima
12:55SagiCZ1because then if the point is on the same line as the linesegment.. the distance is zero now matter how far it actually is from the polygon
12:55mi6x3mSagiCZ1: distance is usually the perpendicular distance
12:56SagiCZ1then the "closest" edge doesnt have to be close at all
12:56SagiCZ1the point could be infinitely far away.. just on the same line as the edge
12:56mi6x3mwell then, try to find the nearest intersection point
12:57mi6x3mby checking the distance to each vertex
12:57SagiCZ1interesection point of what?
12:58mi6x3mSagiCZ1: of a vector through your point with the polygon
12:58SagiCZ1vector through my point in question and where is the other point, center of polygon??
12:58lazybotSagiCZ1: What are you, crazy? Of course not!
13:00mi6x3mSagiCZ1: the other point is some point on the polygon
13:00mi6x3mthough the shortest distance will always be perpendicular to an edg
13:02TimMcmi6x3m: Not true.
13:02SagiCZ1i think i have an idea
13:02SagiCZ1maybe its what u meant
13:03mi6x3mTimMc: oh?
13:03SagiCZ1i will connect all polygon vertices with my point in question.. determine all intersections of those connections with polygon segments, and then find closest intersection to my point
13:04TimMcYeah, think of a triangle. Think of infinitely long rectangles sitting on each of the edges.
13:04TimMcEverywhere those rectangles do not cover, the shortest line to the polygon goes to a vertex, and is not perpendicular to an edge.
13:05TimMce.g. a point that the triangle is "pointing at"
13:06TimMcSagiCZ1: mi6x3m was right earlier, though -- just iterate through the edges and find the one that has the shortest distance to the point. You can add in optimizations later.
13:06SagiCZ1TimMc: that wont work
13:07TimMcProvide a counterexample.
13:07SagiCZ1distance point - segment is the same as distance point-line .. therefore the point can be anywhere on the line which the segment lies on, to have a distance of zero
13:08TimMcThen you've defined distance-to-segment incorrectly.
13:09SagiCZ1define it differently then
13:09nopromptbbloom, dnolen_: for cljs macros that use macroexpand-1 should i be using the analyzers macroexpand-1 instead of clojure's?
13:10TimMcSagiCZ1: Perpendicular distance to the segment's line *if* the perpendicular crosses the segment, else distance to the nearest endpoint.
13:10aperiodi1couldn't you just find the two closest points and then check the segment in between those to see if that gets any closer than the closest point?
13:10aperiodi1nope
13:10aperiodi1nevermind
13:11SagiCZ1TimMc: sounds reasonable..
13:11SagiCZ1TimMc: i will try to implement that
13:12TimMcSagiCZ1: Are you sure you want to reimplement collision-detection or whatever it is you're doing, or would you rather use a library?
13:14mpinghi
13:14SagiCZ1TimMc: yes im doing a simple collision detection.. it is an exercise and i will always have only 2 objects colliding, ball-ground.. i understand that there are libraries that handle this well and are better optimized then what i will end up doing... but since i use one of them (JBullet) regularly i would like to try how it works inside :)
13:17mpinghi guys can you give me some pointers?
13:17mpingI want to calculate the intersection and difference of two lists of maps based on a given key
13:18TimMcmping: That could mean many things, can you give an example or a more specific problem statement?
13:18mpingsure, in javascript:
13:19mpingsuppose I have
13:19mping v1 = [{name "a" val 1}, {name "b" val 2}]
13:19mpingv2 = [{name "a" val 3}]
13:20mpingI want to calculate the intersection based on the 'name' key
13:20mpingso (intersect v1 v2) would be {name "a" intersection [{name "a" val 1 } {name "a" val 3}]}
13:21justin_smithmping: group-by
13:21mpingand (difference v1 v2) would be [{name "b" val 2}]
13:22mpingjustin_smith: I have to group-by and process the aggregation by hand?
13:22justin_smithhmm - maybe not
13:23justin_smithmping: if I were doing this, I would take each collection, and run group-by based on the "name" key
13:23justin_smiththen use select-keys / dissoc to construct the union and difference
13:23mpinghmm didn't remember select-keys
13:25mpingmaybe I can do two for's, so I know what's missing in where
13:26doctormWhen you have a function that’s uses a map to declare symbols, like (defn foo [& {:keys [bar]}]), what is that called so I can read the docs on it?
13:27noprompti just got totally bit by this https://gist.github.com/noprompt/acf7327ba3b874d25e59
13:27justin_smithmping: to get the union, take the union of the keys of each grouped-map from the vectors, and then merge the selected keys
13:27nopromptwhy does the clojurescript analyzer expand it differently
13:27justin_smithdoctorm: destructuring
13:27doctormjustin_smith: thanks
13:29TimMcnoprompt: Looks like it didn't get expanded at all.
13:29nopromptright?
13:35SagiCZ1,(min (range 5))
13:35clojurebot(0 1 2 3 4)
13:35SagiCZ1why "min" hates lazy-seqs?
13:35SagiCZ1,(min [0 1 2 3 4])
13:35clojurebot[0 1 2 3 4]
13:35SagiCZ1,(apply min (range 5))
13:35clojurebot0
13:35SagiCZ1ooooooh.. got it
13:36justin_smithif you provided a second arg after the sequence, min would have given you an error
13:36SagiCZ1,(min [0 1 2] [3 4 5])
13:36clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number>
13:36justin_smithbut it has a shortcut to return the arg, if it only has one arg
13:37SagiCZ1justin_smith: what is that useful for?
13:37justin_smithit allows a concise implementation
13:37justin_smith$source min
13:37lazybotmin is http://is.gd/uqY0Pg
13:40technomancyworks for clojure too: http://thisotplife.tumblr.com/post/96352585529/using-erlang-for-a-one-off-script
13:40justin_smithhah
13:40SagiCZ1so how would a simple lighter look?
13:42SagiCZ1python?
13:42clojurebotyes let's have another dict subclass
13:42SagiCZ1hahahaha that bot cracks me up
13:43TimMctechnomancy: I think OSHA would have something to say about that. Possibly "HRRRK!"
13:43justin_smiththose machines are nothing to fuck around with - worked with a dude, someone tried to lift him out of a collapsed trench with the bucket, cut him in half
13:44technomancyTimMc: OSHA?
13:44justin_smithoccupational safety and health administration
13:45technomancyhehe
13:46justin_smithas in "get down off the fork of that lift, or osha's going to hand me another $20,000 fine"
13:49TimMcThey set regulations to keep employers from endangering their employees (or enouraging the employees to endanger themselves.)
13:50TimMcSome of the regulations get a little silly, but on the whole they do good work.
14:02stompyjhow do I start a repl on an interface other then 127.0.0.1
14:02stompyjexample, I want to connect to a repl running on an ec2 instance
14:03stompyjbut, lein repl only seems to be able to connect to ec2’s local network interface, which is an internal network
14:03justin_smithstompyj: use an ssh tunnel
14:03justin_smithunless you just want to share the ec2 instance with the entire world
14:03TimMcOr port-forwarding in the policies, which you really don't want in this case.
14:04stompyjI’d prefer to just open that single port, to the specific IP of this office
14:04TimMc(what justin_smith said)
14:04stompyjbut yeah, I guess I’ll ssh in this case
14:04stompyja bit messy
14:04stompyjbut will work
14:04amalloyso much less messy than allowing arbitrary code execution on a public port, though
14:05stompyj50/50 :D
14:06justin_smithstompyj: with port forwarding, you just run ssh in a terminal somewhere, and as long as that remains running, you can connect to the repl port as if it were local
14:06stompyjso, the answer is there is no way via command-line to tell lein repl to listen on an alternative interface?
14:06justin_smithstompyj: oh, you can make it listen to the whole world, it's just a terrible idea (nrepl that is - dunno if lein exposes the options)
14:07technomancyyou can do it, you just shouldn't
14:07TimMcWhat would that look like?
14:07technomancylein repl :headless :host 0.0.0.0
14:07stompyjyeah, that doesn’t work
14:07stompyjthats what I was asking about
14:07technomancyor maybe LEIN_REPL_HOST=0.0.0.0 lein repl :headless
14:07stompyjit just defaults to 127.0.0.1
14:07stompyjI’ll try LEIN_REPL_HOST
14:07stompyjthanks
14:08technomancywait did I say that out loud
14:08TimMcYou were tricked!
14:08TimMcstompyj: I hope you don't care about that box.
14:09stompyjlol thanks :)
14:11justin_smithI hope you expect everyone that accesses that box to get rooted
14:11noprompti sincerely hate clojure's error messages.
14:12nopromptCaused by: clojure.lang.ExceptionInfo: nth not supported on this type: Symbol at line 24 src/xyz/core.cljs
14:12cbpthat looks like clojurescript man
14:12nopromptit is.
14:12noprompti want to help improve these kinds of messages.
14:12justin_smithalso, "nth not supported on this type: Symbol" may be awkwardly worded, but the error is clear
14:13noprompt9 times out of 10 whenever there's an error to be thrown there's enough context to be prescriptive about it.
14:13cbpI think you can just use the browser debugger there if you have source maps on
14:13nopromptjustin_smith: i've been at this for two and a half years, i'm sorry that message is never clear.
14:13noprompti know what it means but it doesn't give me any hope of figuring out *why* that happened.
14:13nopromptthere's zero context.
14:14amalloynoprompt: really, a stack trace, error message, and exact line number is zero context?
14:14nopromptamalloy: i can't *see* the environment.
14:14technomancythe line number might even be correct.
14:14lvhhm, when I watched the video for prone this morning, there was an emacs plugin that auto-sorted the requires/imports in ns
14:15lvhany idea what that thing's called?
14:15nopromptamalloy: the line numbers help to a degree but there's a point when that's not helpful any longer.
14:15technomancylvh: sounds like slamhound
14:15amalloynoprompt: if you pasted the stacktrace and the source file, i bet it would take only a minute or two for someone unfamiliar with your codebase to figure it out
14:15lvhtechnomancy: sounds dangerous; I don't want to be assassinated
14:16nopromptimho programmers don't know how to create constructive error messages. error messages are a form of communication and most programmers simply fail to communicate the nature of problems when they occur through error messages.
14:16technomancyamalloy: "only a minute or two" sounds like abysmally low standards
14:16amalloytechnomancy: i gave myself some wiggle room
14:16nopromptthis is because, again imho, programmers do no understand that an error message is a form of communication with the consumer of a library.
14:16amalloyi really expect it to take a lot less than that
14:17stompyjactually, it’s not really lein repl’s fault, ifconfig and netstat return crazytown data on ec2 boxes now that I’m looking at tit
14:17stompyjit*
14:17nopromptoften there is enough contextual information to *help* the programmer solve the bug but it's often elided because they don't realize they can actually help the programmer they're trying to communicate with because they've lived in a world where only shitty error messages are ever printed to the screen.
14:18technomancynoprompt: you could try to improve it with nrepl middleware
14:18lvhhuh, slamhound is a dep not a plugin
14:18technomancyfixing the root of the problem seems really unlikely, but you could route around the brain damage
14:19stompyjnoprompt: You’re probably right, but that’s a very large problem to solve
14:19noprompttechnomancy: that was actually the direction i was going next, but i had to rant first. :)
14:19cbpin cljs at least you get a pretty decent debugger for free
14:19dbaschto be fair, "nth not supported on this type: Symbol" could come from deep inside some library
14:19lvhtechnomancy: thanks!
14:19stompyjI don’t actually find clojure stacktraces to be as bad as people say
14:19nopromptstompyj: it's not just with clojure though, it's with almost every programming language, operating system, or application i've ever used.
14:19amalloydbasch: but in practice it usually doesn't. almost always, it's because you forgot some square brackets somewhere in let or defn
14:20stompyjnoprompt: yeah, I agree, I just mean, thats a HUGE problem to solve
14:20stompyjonce you dig into it
14:20nopromptmy sister asked me the other day what "Error: 404 not found" meant. turns out she's not an http expert.
14:20dbaschamalloy: first google result: https://github.com/LightTable/LightTable/issues/51
14:20cbpparse errors are pretty brutal though
14:20amalloyoh, in ns. that's right
14:20cbpUNABLE TO FIND CLOSING TAG {
14:20nopromptstompyj: like i said though, often there is enough information available to provide i really decent error message that's helpful. this is especially the case in clojure with ex-info, &env, etc.
14:21noprompt"really decent". wow. extreme decency.
14:21dbaschnoprompt: but 404 is almost pop culture at this point
14:22nopromptdbasch: that's assumptive.
14:22mdrogalisnoprompt: dbasch just dissed your sister. Oooo.
14:22amalloynoprompt: it seems totally absurd to say "error messages are really easy to get right, and yet weirdly all software in the world gets it super-wrong"
14:22dbaschnoprompt: type 404 into google, or error 404
14:22dbaschif pasting an error verbatim into google gives you what you want, then it’s decent enough imho
14:22nopromptdbasch: not to mention, from a UX perspective where you're trying to communicate with the user through a dialog it's especially poor form.
14:23dbaschnoprompt: just playing devil’s advocate
14:23nopromptamalloy: i never said they were. i said they could be better. notably, i was suggesting they could be prescriptive more often than not.
14:24nopromptfor example "You gave me the wrong kind of input" could be stated as "You gave me this kind of input but I expect this kind of input."
14:24amalloyi don't think users would appreciate that. prescriptive error messages sound too much like sass. "mircosoft.com not found. Try browsing to a website that exists."
14:24nopromptand occasionally you get lucky and you get that from someone who gives a shit.
14:25nopromptamalloy: i simply do not agree.
14:25technomancyracket does a great job with this
14:25noprompti'm sorry debugging an error message has only gotten more annoying the longer i do this.
14:25technomancythe beginner languages suggest "maybe add more parens?" and the regular ones assume you know what you're doing.
14:26dbaschtechnomancy: make sure your cable is plugged in
14:26noprompthow long have people been writing software? is it so rediculous to expect better error message out of all the technical advances we've made in the last 20 years?
14:27tbaldridgenoprompt: sadly every error message that contains "better" logic often also contains unknown assumptions.
14:27dbaschnoprompt: to me an error message is not as important as the debuggability of the cause
14:27nopromptseriously. if as much effort was put into making debugging software as making writing concurrent software easier debugging would be a snap.
14:27technomancynoprompt: massive indifference is the easiest explanation
14:28noprompttechnomancy: fair enough.
14:28noprompttl;dr how can i improve these messages?
14:28tbaldridgeI'd also argue that hard-to-understand errors can be the side-effect of badly designed code.
14:29tbaldridgeis the message cryptic, or is my program so complex I can't understand where the message is from?
14:29noprompttbaldridge: and i'd argue you always need context to make that call.
14:29TimMctbaldridge: Such as Clojure's compiler making it difficult to distinguish compiler bugs from syntax errors?
14:29TimMcOh, you mean the code-base being developed.
14:30nopromptthe problem i'm having is from a macro which, in one project compiles fine and in another explodes with an "nth on Symbol" error.
14:30justin_smithtbaldridge: part of this scenario in clojure has to do with our tendency to not validate our input, and just pass it to another layer of abstraction, until finally something in clojure.core or some java interop does the actual work
14:30BronsaTimMc: how many actual compiler bugs have you encoutnered to make that claim?
14:30noprompti've checked macroexpand from the repl in both projects and the generated code is *exactly* the same.
14:30technomancyGIGO is a pretty deeply-baked-in assumption in Clojure
14:30tbaldridgejustin_smith: agreed, sadly doing anything more complex would hurt performance
14:30nopromptbut something else must be happening in one project and not in the other and i can't *see* it.
14:30technomancywitness contains? being problematic for N years
14:30xeqiI've hit errors where the compiler provided no info on what was missing. I think ns A depends on ns B depends on ns C and C couldn't be found was one of them
14:30justin_smithtbaldridge: so the error report is only going to be about the implementation details of the code we call at the top level (or the implementation details of the thing it calls, etc.)
14:31justin_smithtbaldridge: well, we do have these assertions that can be turned off in production after all...
14:31ToBeReplacedisn't there a project from GSoC that set out to improve error messages?
14:31noprompttbaldridge: this is not that complex https://github.com/spellhouse/clairvoyant/blob/master/src/clairvoyant/core.clj#L115-L124
14:32dbaschI remember wishing I had a camera to take a picture of Windows’ BSOD back in the 90s. That was as cryptic as it comes.
14:33noprompttbaldridge: and like i said it compiles and runs fine in one project but not in another with *identical* code. same clojurescript version etc.
14:34TimMcBronsa: I'd call it a fine line between GIGO and failture to check assumptions.
14:34nopromptjustin_smith: +100 to what you just said.
14:34nopromptabout not validating input.
14:35justin_smithespecially given that we have assertions we can turn off
14:35TimMcdbasch: Hah, yeah, remember not everybody having cameras 24/7?
14:36noprompttbaldridge: the question i have to ask is, is clojure core satisfied with the state of error messages in the language?
14:36dbaschTimMc: no camera and no way to save the pertinent data other than painstakingly writing down hex strings
14:37stompyjnoprompt: I don’t think any language is happy with the state of their error messages, but I think all the reasons people are giving you is why nothing has happened
14:38tbaldridgenoprompt: I'm not a person who makes such decisions so I can't answer that question, sorry
14:38noprompttbaldridge: personally, are you happy with them?
14:38dbaschstompyj: java is pretty decent in that sense compared to most other languages
14:39TimMcJava has great error messages, yeah.
14:39tbaldridgenoprompt: as long as I get an error, yes. The worst errors are those that cause silent problems.
14:39nopromptiirc error messages were noted as a key pain point for many in the clojure community.
14:39noprompttbaldridge: maybe you just have thicker skin. :)
14:39tbaldridgenoprompt: I'd prefer "expected symbol, got vector" over "we just compiled code that will hack the FBI, oh is that not what you meant?"
14:40nopromptlol
14:40TimMcwhat
14:40technomancyM-x eyeroll
14:40csd_If I call `re-matcher` in clojure, how can I pass the matcher to Java's Matcher.start method?
14:40tbaldridgenoprompt: my personal opinion is this, Clojure is a lisp, and lisps are extremely powerful languages, things like macros allow you to add logic to the compiler. That stuff is never going to be easy.
14:41technomancytbaldridge: and yet somehow racket manages it with an even more sophisticated macro system
14:41tbaldridgeI'd rather have transducers, core.async, macros, etc, instead of better error messages.
14:41noprompttbaldridge: so what would you're approach be to "it compiles fine in project a but not project b"?
14:41noprompttbaldridge: you're only making my point.
14:42dbaschcsd_: (.start (re-matcher …))
14:42tbaldridgenoprompt: find the differences...you most likely have one you haven't found yet. Either a clojure version, cljs version, library, plugin, lein, jvm, something is different. Even left over aot class files or stale .class files.
14:42tbaldridgeI've seen all of those cause problems like that.
14:42noprompttechnically, i love those things just as much as anyone else here and no one would pick better errors over those things. otoh that's still not admitting that the error messages are still a problem to be solve and, furthermore, is worth solving.
14:43csd_dbasch: so then why does this return an error? (.start (re-matcher #".*\[.*" "t[est"))
14:43stompyjnoprompt: I’ll have to check out java errors again, i haven’t used it seriously since the late 90s
14:43mdrogalisnoprompt: I dont think anyone disagrees that better errors would be nicer. But you're seeing reality play out in front of you. We value X, so we chase X, and we have limited time to do other things.
14:43mdrogalisYou dont have to take a poll, you know? People are going to work on what they want.
14:44stompyjbut the error messages were not good back then, better then clojure, but I couldn’t call them good
14:44technomancymdrogalis: are you using "We" to mean the core team?
14:44mdrogalistechnomancy: Nah, I just mean everyone in general.
14:44stompyjI think he means programmers in general
14:44technomancymdrogalis: that implies we have a say in what happens
14:44nopromptmdrogalis: i would love to help work on improving the error messages situation but it's not something i can do in silence because a) i don't know java well and b) guidance would be helpful.
14:44stompyj#shotsfired
14:44tbaldridgenoprompt: classic example, someone recently submitted a patch that improved an error message. Awesome! Except there was one problem, it blew the JVM inline budget and caused existing code to become slower. That one single line of code took a ton of work/testing to get right.
14:45tbaldridgeI'm still not sure if it was worth it.
14:45mdrogalistechnomancy: Ha! I was trying to keep it from getting dark. :)
14:45mdrogalisnoprompt: Understandable.
14:45TimMccsd_: The fact that it returns an error doesn't have anything to do with how you're calling it.
14:46dbaschcsd_: because you didn’t call find first
14:46noprompti just don't understand the attitude. the mentality is bizarre.
14:46csd_dbasch: find returns a string though
14:46nopromptwhere's the humanity?
14:46technomancynoprompt: usability is simply not a priority; seems pretty straightforward.
14:47dbasch&(def a (re-matcher #".*\[.*" "t[est"))
14:47lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
14:47csd_TimMc: I'm trying to emulate what's suggested in http://stackoverflow.com/questions/4194310/can-string-indexof-handle-a-regular-expression-as-a-parameter. Seems like what I'm doing should work
14:47noprompttbaldridge: so does improving error messages, generally come at the expense of something else?
14:47noprompttechnomancy: weird.
14:47tbaldridgenoprompt: there are always tradeoffs in software
14:47dbasch&(let [a (re-matcher #".*\[.*" "t[est")] (.find a) (.start a))
14:47lazybot⇒ 0
14:47dbasch^ csd_
14:48csd_dbasch: when you do that does the interop mutate a?
14:48dbaschcsd_: yes, Matcher has state
14:48stompyjnoprompt: lol @ where’s the humanity. You should try by writing proposed “better” error messages for errors you see
14:48stompyjand poll people, and see if they think they’re better
14:48noprompttbaldridge: maybe i'm being naive but it seems odd error messages could be so hard to get right in the context of the other technical achievements made by clojure
14:49mdrogalistbaldridge: You're a champ for always jumping in on this argument. :P
14:49stompyjthere’s probably a “lean startup” way to understand this problem may be more difficult then it seems on the surface
14:49technomancyactually cataloging the biggest WTFs would be a good project
14:49csd_I see. I was under the impression that re-matcher would return a Matcher object so that you could directly apply .start to it
14:49dbaschcsd_: “start: Returns the start index of the previous match.”
14:49zerokarmalefttechnomancy: something like java/scala puzzlers, I'd dig it
14:49technomancyzerokarmaleft: actually I was thinking more of a "hall of shame"
14:50technomancyhey, it worked for getting Maven Central over to SSL
14:50csd_dbasch: thanks
14:50gfrederickstechnomancy: there'd be an interesting taxonomy for them
14:50nopromptstompyj: probably what i'm going to do is start cataloging these things with a description of what it generally means.
14:50justin_smithtechnomancy: we could call it ~@wat#
14:50gfrederickse.g., some things are confusing to n00bs but intentional and not too bothersome to experienced folkles
14:50stompyjnoprompt: yeah, I think that sounds like a great first step
14:50csd_dbasch: do you know if a better way to get the index of where a RE match occurs using pure clojure?
14:50gfrederickssuch as clojure.core/contains?
14:51stompyjthe art of error messaging feels like the art of describing by a chord by it’s notes
14:51technomancygfredericks: http://blogs.msdn.com/blogfiles/cdndevs/WindowsLiveWriter/JohnUdellsinTorontoNextWeek_CC69/what_we_need_more_of_is_science_3.jpg
14:51stompyjseems liek if you ask x people, you’ll get x answers
14:51stompyj:)
14:52tbaldridgenoprompt: yeah, that's a good place to start, take your pet error, figure out what the cause is, figure out how to improve it, then hand it off to someone to critique.
14:52tbaldridgeYou'll probably fine it either a) discards some data that could be useful to someone or b) has some other performance tradeoff
14:52tbaldridgeat least that's been my experience, YMMV.
14:52gfredericksprobably half of the error messages if you try to fix them you will 3 months later start screaming about rewriting the compiler
14:53noprompttbaldridge: fair enough. i mean the whole reason i started hacking on this clojurescript tracing project is because it's damn near impossible sometime to understand why things are breaking because of horrible error messages both from clojurescrip and from javascript.
14:53nopromptyou end up littering the planet with println.
14:53noprompttbaldridge: guess i'll start with this one.
14:55tbaldridgenoprompt: I will say that macro input validation is pretty ripe for optimization, no runtime cost, no JIT costs (that anyone cares about). That'd probably be a easy place to start
14:55gfredericksdidn't chouser or someone have a sophisticated project to tackle that?
14:55technomancygfredericks: yeah, that looked really promising
14:55noprompttbaldridge: i know you are a busy guy but would you have any time during the week to help get me started, guide me?
14:56technomancygfredericks: nice to see someone putting some deep thought into the problem
14:56noprompttbaldridge: not to put you on the spot. :P
14:56tbaldridgenoprompt: no, I never help people, now get off my lawn. :-P
14:56noprompt;_;
14:56arohnerhas anyone ever seen weirdness from emacs/nrepl where emacs locks up while typing? I type C-f or C-a, and emacs is just out to lunch until I C-g
14:56gfrederickstbaldridge helped me once he's a damn liar
14:57tbaldridgenoprompt: sure, you can email me or ping me here.
14:57justin_smithsomeone should make a schema/input validator to run as a language middleware, and call it a nanny-state-machine
14:57tbaldridgenoprompt: email may be easier due to my work schedule.
14:57justin_smitharohner: I have seen things like that with autocomplete of various types turned on
14:58arohnerjustin_smith: weird part is, it didn't do this yesterday in a different project, and I don't remember changing anything recently
14:58justin_smitharohner: is it a projectless repl?
14:58arohnerno
14:58arohnercider-connect repl
14:58arohnerinto a 'normal' project
14:59justin_smitharohner: you could try turning off completion and see if the behavior improves - could be something about one of your namespaces or deps triggers a bug
15:00technomancyarohner: using autocomplete.el?
15:00arohnertechnomancy: I don't think so
15:00arohnerand it appears restarting emacs has fixed the problem
15:01technomancygotcha. it seems to be pretty buggy, and a large percentage of cider/nrepl problems can often be solved by just getting rid of it.
15:01arohneraha. C-f is fine, as long as nrepl isn't eval'ing long running code
15:01llasramAh
15:01arohnerbut large numbers of text input stuff hangs during a long C-c C-k
15:01arohnereven Tab
15:02noprompttbaldridge: thanks. email you @ cognitect?
15:02nopromptscratch that i'll simply message you
15:02tbaldridgenoprompt: sure
15:03Bronsatbaldridge: did you see http://dev.clojure.org/jira/browse/ASYNC-86 ?
15:07SagiCZ1can i supply (min) with my own comparator? or better yet how do i implement min to compare only certain keys of elements? using reduce?
15:08llasramSagiCZ1: It only works on numbers, but various utility libraries have Comparator-based versions
15:08SagiCZ1llasram: ok rather than using library, i would like to implement it myself
15:09SagiCZ1but idk how
15:09llasramSagiCZ1: Well, look at `min-key` and `compare`, and mix :-)
15:10SagiCZ1ty
15:10doctormAnyone using vim-fireplace able to get stack traces? I’ve tried :lopen after a failed evaluation, but it gives me “No location list”
15:12SagiCZ1llasram: min-key is enough for me since the key i want to compare is number already
15:12SagiCZ1(inc llasram)
15:12lazybot⇒ 37
15:13mpingwhy can't I map over a lazy seq? I must be doing something wrong
15:13justin_smithmping: you can, you just have to access the result, or else the mapping never happens
15:13justin_smiththat's what laziness means
15:14mpingis there a way to force it?
15:14mpingeven this does not work: (map #(println ">>>" %) all-paths)
15:14justin_smithyes - do you need all the results, or do you just need the action in the map to occur for side effects?
15:14mpingwell, can you tell me both ways? so I can learn?
15:14mpingthis is in the context of a test
15:15justin_smithto get all the results, wrap it in doall or use mapv, to just force the action wrap it in dorun or just use doseq
15:16mpingit works, tks
15:17mpingI expected the test to "unwrap" the lazy seq
15:20SagiCZ1i've watched a video about quick-test last night.. i dont understand how can i let the test know which results are correct and which are not.. since it throws 100 000 random tests.. ?
15:20AeroNotixSagiCZ1: you're thinking of it wrong
15:20AeroNotixyou describe the properties of what your function takes
15:20AeroNotixand then it generates values which satisfy that property
15:20AeroNotixso if your function takes even values betwen 0 and eleventy million, you describe that property and then it passes them to your function
15:21stompyjSagiCZ1: if you’re familiar with mathematical equations
15:21SagiCZ1AeroNotix: lets say my function takes a definiton of a 2 squares and returns boolean iff they intersect.. what properties would i define for my test then?
15:21stompyjwhere f(x) can take any “real number” as input and can output only “negative real numbers”
15:22SagiCZ1stompyj: oh math.. thats where the "forall" notation came from
15:22stompyjthen you’d specify that your input are real numbers, and your output should be negative real numbers
15:22meliponehello! Any idea how I can capture a url that has a semi-colon in a line that is delimited by semi-colons itself? Here's an example: http://buddhayana.ru/2AB@5G8-A-@&gt;A25B;5=85&lt;-8AB&gt;@88-87-687=8-1C44K.html&quot;;1;&quot;db_unfetched&quot;;Tue Sep 02 14:46:47 EDT 2014;Wed Dec 31 19:00:00 EST 1969;0;2592000.0;30.0;0.01;"null"
15:22stompyjand quick-test makes sure those properties are satisfied
15:22stompyjif I understand it correctly
15:22SagiCZ1stompyj: that does not sound very useful in my case
15:23SagiCZ1ok.. so i define ranges for which it should return some defined ouput..
15:23stompyjSagiCZ1: I’m sure there’s people here who understand it much better then myself who could help you, but that’s how I understood it when I checked it out
15:24mahmoudmheisen91then you’d specify that your input are real numbers, and your output should be negative real numbers
15:25mahmoudmheisen91quit
15:25SagiCZ1what just hapenned? did he rage quit?
15:26stompyjLOL
15:26stompyjI’m dying to see what a test suite using quick-check + simulation testing would look like
15:27SagiCZ1i cant imagine how could it test more corner cases than traditional unit testing
15:28stompyjSagiCZ1: I think unit testing is great for when you know what you want to test
15:28stompyjbut often times the errors happen on cases that you’re not thinking about
15:28SagiCZ1if you dont know what to test, you can hardly define properties for whole ranges of input..
15:28stompyjor composition of events that you didn’t expect
15:28SagiCZ1event composition sounds useful..
15:30stompyjI dont’ prefer TDD, but I do appreciate tests, esp. when refactoring
15:30SagiCZ1who doesnt..
15:30SagiCZ1im workin
15:30SagiCZ1on large scale Java EE app at work
15:31SagiCZ1we just started writing test.. 2 months into development
15:31SagiCZ1very painful
15:32stompyjooff
15:32stompyjbrutal
15:32stompyjis that stuff mostly EJB’s still?
15:32stompyjor something different?
15:32SagiCZ1no beans.. no spring.. its vaadin and our own data model
15:42mpingSagiCZ1: ouch
15:54mi6x3many way to get the require mappings of a NS?
15:54justin_smithmi6x3m: ns-imports or ns-aliases
15:55mi6x3mjustin_smith: aliases only returns what you have really aliased
15:56justin_smithso if you require without an :as it doesn't show up>
15:56mi6x3myes
15:57bbloommi6x3m: require is a side effect that just loads the namespace, alias (the :as keyword) is a side effect that modifies the current ns aliases table
15:57mi6x3mbbloom: so it's not kept in the books once the ns is constructed?
15:59justin_smithI guess that's another reason to always use :as
16:03mi6x3mjustin_smith: you are actually right
16:03mi6x3measier to always use :as, especially in my case
16:03mi6x3m(building source code for code demos)
16:12TimMcmi6x3m: There's also no guarantee that a :require form will be present when another namespace is used.
16:13mi6x3mTimMc: I am aware, this is just an internal contract so the demo framework works ok :)
16:13TimMcA great example is clojure.string. A bunch of namespaces use it, so occaasionally someone will write clojure.string/join and forget to :require it -- but it still works, because it has been loaded transitively. :-)
16:16justin_smithTimMc: or clojure.pprint - you don't need to require it in the repl, because the repl loads it at some point, but it can break in your deployed code
16:16justin_smith(if you forget to require it)
16:21atyzI'm trying to use an input stream twice, and I have found several ways to copy it to a bytearrayoutputstream using some java interop but is tehre a "clojure" way to do it?
16:39amalloyhugod: every time i run a benchmark with criterium, i see "WARNING: Final GC required 2.824425435800379 % of runtime" (obviously the percentages differ). am i doing something unusual that this warning comes up every time? or if it's not unusual, why is there a warning at all?
16:52dbaschamalloy: he shows a warning when the final gc takes more than 1% of the total running time, which is pretty much always for any meaningful benchmark I run
16:53amalloyright. so if it's totally normal, it shouldn't be a warning
16:53dbaschI agree, it should be more of an INFO
16:54amalloy"INFO: everything normal" is silly too. it should be quiet unless it's an unusual amount of time
17:03martinklepschdo transducers also take from channels or is that required to be done elsewhere?
17:04hiredmana transducer is a transformation of a reducing fuction there is nothing about channels in them
17:05hiredman(so no)
17:08martinklepschhiredman: are you aware of any more writeups combining core.async & transducers?
17:08hiredmanmartinklepsch: no
17:09stompyjmartinklepsch: there are about 4-5 of them now
17:10hiredmanI suspect the tricky areas of combining transducers and core.async are the same as the tricky areas of core.async, namely not blocking in a go block, closing channels when done, and reporting errors
17:11hiredmanI think core.async is light on documentation on how it applys transducer transforms to things passing through a channel, which can make it difficult to figure out if some operation will end up getting run in a go block or not, which is what you need to know in order to avoid blocking ops in a go block
17:12hiredmanbut pulling up the code should answer those lingering questions pretty quick
17:13martinklepschI had some rough idea about using transducers for something where map< seemed appropriate: https://gist.github.com/mklappstuhl/d6d776317171e01f1178 — maybe someone sees an obvious flaw?
17:17hiredmanit is hard to know where to start
17:17hiredmanio is generally a blocking operation so it shouldn't be done in a go block, you should use thread or future or have your own threadpool blocking ops run on
17:17hiredmanupload-files pretty obsiouly does io
17:17hiredmanobviously
17:17martinklepschhiredman: it's cljs
17:18martinklepschsorry for the wrongly named gist,
17:19hiredmanyou are also using upload-files before it is defed
17:21mi6x3many way to use pprint to produce a string?
17:21mi6x3m(sane way that is)
17:21justin_smith(with-out-str (pprint ...))
17:21dagda1Is there a way to tell if a var is a list, I don't mean vec?, list? or seq? but just a generic away that would be true for [1 2 3] '(1 2 3) etc
17:22amalloysequential?
17:22justin_smithdagda1: coll?
17:22martinklepschhiredman: upload-files returns immediately and takes callback — that's where I planned to put the result in result-chan
17:22dagda1justin_smith: nice one
17:22martinklepschhiredman: that's what I've seen in some cljs ajax core.async examples
17:23amalloycoll? is unlikely to be what you want, because it returns true for maps
17:23amalloy(which is why i said sequential?)
17:27hiredmanmartinklepsch: sure, but you are still using it before it is defined, which is not valid and I am surprised nothing is throwing an error about it
17:29hiredmanmartinklepsch: the xform function you pass to (chan ...) when creating a channel is a transformation of values flowing through the channel, the transform won't happen unless values are flowing through
17:29hiredmanthey won't flow through unless soming is produce values for the channel and something is consuming those values
17:29hugodamalloy: the question is how to define unusual
17:30hiredmansomething
17:30amalloymartinklepsch: what is the deal with these definitions like (def foo (comp f)). that is just (def foo f)
17:31martinklepschamalloy: I wrote them earlier when they did multiple things
17:31mdeboardthat bitrot tho
17:31hiredmanmartinklepsch: you are not consuming values from some channels
17:31tadni_https://www.kickstarter.com/projects/1751759988/sicp-distilled?ref=discovery
17:32martinklepschhiredman: right
17:32amalloyhugod: sure. it seems to me that the bar for "unusual" is currently too low, because that warning is present in every criterium run i've ever seen
17:32tadni_So this says it's going to rewrite the examples of SICP in Clj, I wonder if that means they will distribute a virtual book.
17:32hiredmanmartinklepsch: so nothing happens
17:34mi6x3mis clojure automatically importing all of java.lang
17:34tadni_http://sicpinclojure.com/ Sadly has had very little progress.
17:34mi6x3mwell, most of it anyhow
17:35amalloymi6x3m: yes, just like java does
17:36mi6x3mamalloy: thank you
17:47martinklepschhiredman: thanks a lot. I wasn't really aware things had to enter & leave the channel before the transducer is applied. I think I'm a lot closer to what I wanted to do now than before :)
17:49amalloydakrone: it looks to me like cheshire uses jackson's lexer, but does its own parsing. is that accurate?
17:50ztellmanamalloy: that's correct
17:55sdegutisWhat might cause a Clojure-Ring/Jetty website to just stop responding entirely and need to be kill9'd?
18:04justin_smithsdegutis: next time use jstack, that will tell you what all the threads are doing / where they are stopped
18:04sdegutisThanks.
18:06justin_smithI don't know how much good we can do inventing scenarious that may bring a jetty server to a standstill. deadlock somewhere? trying to use some resource that was erroneously deleted or went inconsistent?
18:07xeqifork bomb, cosmic rays
18:07sdegutisI have the simplest web app, a very simple shopping cart. The most complex part of it is that it sometimes talks to Datomic over TCP on another server.
18:07danielcomptonsdegutis: could be hax0rs
18:08sdegutisI can't imagine this being caused by anything other than trying to communicate with the Datomic server and hanging.
18:08sdegutisThe entire process becomes unresponsive and is spending 99% of the CPU.
18:08justin_smithyeah, then your best bet is to use jstack (or a full on profiler), and finding out what is looping so crazy
18:10amalloysdegutis: whenever my web servers crawl into a hole, it turns out to be because it's stuck in a gc loop because i had a memory leak somewhere
18:10sdegutisAhh, that could very likely be it!
18:11sdegutisamalloy: Does that go on for hours and hours?
18:11amalloyyeah. i don't totally understand why
18:11sdegutisamalloy: Thanks a ton :)
18:11justin_smithfinalizers that use too much memory?
18:11sdegutisjustin_smith: Thanks for the suggestion.
18:11justin_smithnp
18:11sdegutisMy site is written in Clojure, fwiw. But it is using a very old version of Datomic Free.
18:11sdegutisSo there may have been bugs in it that have since been fixed.
18:12sdegutisI will take all this into consideration. Thank you.
18:12hyPiRionamalloy: is that a similar reason to why lazybot eats a CPU when it disconnects from an IRC server?
18:12amalloyjustin_smith: my vague understanding is that it's more like "(1) needed to allocate 20 bytes, but the 10GB heap is full; (2) long GC, freeing up 5kb. (3) GOTO 1"
18:13justin_smithahh
18:13justin_smithso not enough usage to crash the whole thing, but enough to make gc consume hella cpu
18:13amalloyhyPiRion: i dunno. i haven't put much effort into that one. i'd guess there's just something dumb in lazybot's irc retry code
18:13hyPiRionamalloy: yeah, that sounds like something completely different when you put it that way
18:14ticking_Hey it seems that record fields can be accessed through (:field self) (.field self) and field. Any thoughts on what's most idiomatic?
18:14Bronsafield
18:16sdegutisamalloy: LOL that's a funny loop :)
18:16ticking_Bronsa: thanks :)
18:17danielcomptonBronsa: is that only from within the record? Or is it also a function on a record?
18:18Bronsadanielcompton: only methods/protocol-functions defined inside the deftype/defrecord have access to those locals
18:18Bronsaif that's what you're asking
18:18BronsaI didn't fully understand the question
18:18danielcomptonBronsa: so outside of the record you would use .field or :field?
18:18Bronsayeah definitely
18:20BronsaI mean, I don't understand how you'd expect a regular fn to figure out if a local should be a field access on some instance otherwise
18:20danielcomptonBronsa: neither
18:21justin_smithtechnomancy: regarding the conversation earlier, it's OSHA's job to make sure nobody's boss lets them do this on the work site: http://i.imgur.com/sQnrHFc.jpg
18:21technomancyheh, wow
18:21amalloyBronsa: reminds me of http://stackoverflow.com/questions/9345056/in-clojure-how-to-destructure-all-the-keys-of-a-map
18:22danielcomptonIs he also over powerlines?
18:23justin_smithdanielcompton: hard to tell from the perspective, but looks like it
18:23justin_smithif you follow the fence, and see the pole's position relative to that.. yeah I think so
18:27TimMcjustin_smith: Grabbed from https://pay.reddit.com/r/MenonUnstableLadders/ ?
18:27justin_smithno, but I like that this exists
18:28TimMcI like how it is specifically men.
18:28technomancyjustin_smith: hey, if they can have one just for bezels...
18:28TimMcand of course https://pay.reddit.com/r/OSHA
18:29justin_smithTimMc: if you found a woman on an unstable ladder, I think you would need to start a new subreddit just for that
18:29Bronsaamalloy: ew the last answer
18:29TimMcGood luck, they're much less likely to get testosterone poisoning. :-P
18:29amalloyTimMc: are you linking to pay.reddit.com as a side effect of usine https everywhere, or what?
18:29TimMcamalloy: Yeah.
18:29technomancyjustin_smith: http://www.penny-arcade.com/comic/2014/06/27/herstory
18:29technomancyand http://www.reddit.com/r/bezels
18:29TimMcIt's not, like... a subliminal message or anything.
18:30Bronsaeval is the worst function ever to make part of a core library
18:31justin_smithtechnomancy: well, 45° cuts on edges are really important after all
19:04gfrederickstake et al return a "stateful transducer" on one arg
19:06gfredericksat least one function returns a stateful transducer but neglects to say so in the docstring
19:15bounb,((fn [x] (if (= x 1) 1) (if (= x 2) 2)) 1)
19:15clojurebotnil
19:15bounb,((fn [x] (if (= x 1) 1) (if (= x 2) 2)) 2)
19:15clojurebot2
19:15bounbcan someone explain these results please
19:17amalloythere's no such thing as early return in clojure
19:19bounbis the order of the evaluation of the ifs defined?
19:19technomancybounb: what exactly did you expect?
19:19bounbi expected the first one to return 1 and the second 2
19:20bounbi can understand the result if the second if form is evaluated first (+ no early return)
19:20bounbi guess that's it isn't it
19:20hiredmanwhy do you need both?
19:20hiredman(second evaluated first and no early return)
19:20technomancybounb: expressions in the non-tail position are discarded
19:21bounbhiredman: uh yes
19:21bounbi agree
19:21bounbalright nothing to see here folks. cheers
19:22technomancyyeah, the only reason fn takes multiple body args is for side-effects
19:22justin_smithbounb: it might help to know that fn has an implicit do block - each form in the body is evaluated, in order, and there is nothing like a "return statement" available for fn
19:22bounbgood point. thx
19:23justin_smith,((fn [] 1 2 3 4 5))
19:23clojurebot5
19:23technomancy((eval (apply #'fn (concat nil nil [] 1 2 3 4 5))))
19:23technomancyoops
20:25sdfgsdfWhat editor do you people use for clojure?
20:26jtackettlight table
20:26danielcomptonsdfgsdf: emacs
20:26danielcomptonalthough Cursive is on my list
20:26sdfgsdfnever heard of cursive, will check it out
20:26xeqiemacs, but I've dabbled with cursive and its pretty good
20:27amalloysdfgsdf: cursive is the intellij plugin or something
20:28technomancythe proprietary one
20:28splunkanyone know a good synonym for "get" for use in my own protocol?
20:28amalloycall it ----get-protocol---internal-for-real
20:28danielcomptontechnomancy: aka the maintained one
20:29splunkamalloy: ship itttt!!!
20:29xeqiacquire, obtain, grab
20:30sdfgsdfWhat is your protocol and what does get mean in it?
20:30splunkit's like s3
20:30splunk(defrecord S3Storage [cred] StorageProtocol (get [this k] ...))
20:31splunkbut you can't use get with a defrecord because defrecords are already associative, i.e. normal clojure.core/get
20:31splunkIt means to like, lookup / download, more than lock or reserve
20:32justin_smithcopy? download?
20:32ephemeronWhy not a traditional "fetch"?
20:32amalloysplunk: so make it a deftype instead of a defrecord? i can't imagine it's important to be able to treat it like a map, with only the one key
20:32splunkamalloy: I'm trying to copy the stuart sierra component workflow, which appears to advocate `assoc`ing stuff into a defrecord?
20:32Jaood"here-boy-catch"
20:32splunkephemeron: that's a great candidate thanks
20:33sdfgsdf"acquire-the-thing-that-you-want-to-have"
20:33joobushas anyone here worked through clojure-koans?
20:33technomancydo you really need protocols for a function that's guaranteed to be I/O bound?
20:33sdfgsdfjoobus I am in the process of doing that now
20:33splunktechnomancy: just trying to make an abstraction over "get a thing out of storage"
20:33joobuswhat lesson are you on?
20:33sdfgsdfjust finished 14
20:34joobusi'm on 13, and the answers aren't obvious to me. do you have any recommendations for reading/researching recursion?
20:34splunktechnomancy: guess that could be done without protocols / records, though again with the `component` workflow it seems like a decent fit
20:36sdfgsdfWell it was already kind of intuitive to me, probably from earlier non-clojure lisp stuff.
20:36sdfgsdfCan you be more specific about what part of it you are having trouble with?
20:36Jaoodjohn2x: the little schemer
20:36Jaooderr joobus ^^
20:36technomancysplunk: I guess if you have component then you work around all the crazy reloading issues around records, but do you know for sure all the consumers of your lib will have it too?
20:37technomancysplunk: also: introducing semantically-useless arguments to your arglists simply for dispatch purposes is super annoying.
20:38splunktechnomancy: haha, isn't that a critique of protocols in general?
20:38technomancysplunk: yes
20:38sdfgsdfjoobus, are you having trouble with the first question or do your problems start later on?
20:39technomancysplunk: they're super useful for implementing clojure-in-clojure, which is the reason they were added to the language. in application-level code: not so much.
20:39joobussdfgsdf: first, this is my first lisp. i peeked at the answer for the first one, and after seeing it, it made sense, but that's not how i want to solve the rest.
20:39splunktechnomancy: as far as I can tell, the primary alternative to `(fetch my-s3-record my-key)` is `(my-s3-fetching-closure my-key)`, which I've totally done before, but got the impressions readers don't like it
20:40amalloysplunk: technomancy's fortune cookies all contain critiques of protocols in general
20:40xeqitechnomancy: I've been playing with them as reified namespaces, do you have a different alternative for that?
20:40technomancyxeqi: actual reified namespaces? those would be great =D
20:40splunkamalloy: lolz
20:40joobusfor the blanks at the top, there are maybe 3 underscores. i'm not sure how long the functions should be, or if they are elegantly simple.
20:40xeqitechnomancy: dreamz
20:41xeqithough I'd imagine that would have a similar argument for dispatch
20:41joobusi guess i just need to spend more time on them
20:41sdfgsdfDo you understand how loop and recur work, joobus?
20:41joobusno, not yet. i guess that's the place to start.
20:42sdfgsdfYes
20:47sdfgsdfHere are some examples of loop and recur:
20:47sdfgsdfhttp://clojuredocs.org/clojure_core/clojure.core/recur
20:47sdfgsdfyou still here joobus?
20:48joobusyes
20:48joobuslooking through loop and recur docs right now
20:49sdfgsdfIt's something I find that's easier to understand through examples than through an explanation of what it does
20:50sdfgsdfBut in case the latter would help anyhow, it rebinds the variables in the loop to the values you give it in the recur
20:51sdfgsdfBasically you use recur wherever you would otherwise have a function call itself if you're doing the thing without loop and recur
20:52sdfgsdfWith loop and recur it's evaluated differently so you don't get a stack overflow but it's pretty similar to how recursive functions work
20:53joobusso if i have 2 loop bindings, then if the recur has 2 arguments in the list, it will rebind the loop bindings in the order they were declared?
20:53gfredericksjust like a function call
20:53sdfgsdfyes
20:55splunkamalloy: I take it you disagree re: protocols, e.g. I see a few of them in `useful`?
20:56amalloyi don't think they're toxic waste like technomancy does. it's easy to overuse them
20:57joobusi was curious about the answer to the first func in 13, is-even?... is that the quickest way to determine even and odd, or is this just an example? is decrementing from 1000 and alternating true/false the "clojure" way?
20:57splunkwith the takeaway being "do dispatch using a different mechanism" (like multimethods) or "do less fancy dispatch"?
20:57amalloyof the three protocols in useful, i regard only one (Adjoin) as a reasonable idea
20:57sdfgsdfNotice that in the clojure koans you have the factorial function called with large arguments. This demonstrates the utility of loop and recur; if you did it without loop and recur you would get a stack overflow from all the nested functions.
20:58sdfgsdfThe is-even function is a pretty contrived example
20:58joobusok
20:59gfredericks,(source even?)
20:59clojurebotSource not found\n
21:00amalloy~def even?
21:01bbloomclojurebot: even? |is| do you even even?
21:01clojurebotCool story bro.
21:01gfredericks,(defn steven? [x] (contains? #{"steven" :steven 'steven} x))
21:01clojurebot#'sandbox/steven?
21:01gfredericksbbloom: I'm not sure those question marks are workable
21:02gfredericks,(steven? "steven")
21:02clojurebottrue
21:02bbloom~even
21:02clojurebotHuh?
21:02bbloomclojurebot: even |is| do you even even?
21:02clojurebotI don't understand.
21:02bbloom*shrug* gfredericks oh well
21:03amalloybbloom: clojurebot is allergic to question marks in factoids
21:03bbloomamalloy: does he break out in hives?
21:03gfredericksclojure hives
21:03amalloywhat would live in a clojure hive? a swarm of )}] all buzzing around?
21:04amalloythey look like they could fly for sure
21:04gfrederickscontest: a readable string that looks like an insect
21:04gfredericksor at least like it can fly
21:06gfredericksno trivial use of line comments
21:06gfredericksor string literals
21:10joobusi've seen the variable acc used a few places. is this short for accumulator?
21:10gfredericksyeah
21:10joobusk
21:10amalloyi use it for accidents
21:11gfredericksaccursed
21:11amalloysometimes i see someone reducing and they claim it's accumulating data but i swear it looks like it's just accreting
21:11gfredericksaccouterments
21:11gfredericksaccordion
21:11joobusaccelerando?
21:12amalloygfredericks: accouterments is a misspelling that made me laugh
21:12gfredericksit's in my words file
21:12gfrederickswait
21:12amalloydid you put it there some time ago as a self-prank?
21:12gfredericksyou're referring to re <=> er?
21:13amalloyyes
21:13gfredericksgoogle says this is correct but only for plural
21:13gfrederickswiktionary has both with er
21:14gfredericksand another entry for both re
21:14gfredericksI wonder if google is confused.
21:14amalloyhttp://www.merriam-webster.com/dictionary/accoutrement has both RE
21:14amalloyi trust MW over wiktionary or google, when it comes to defining words
21:14gfredericksmy word file has both
21:15gfredericksamalloy: MW lists it as a variant
21:15gfredericksso I assume you owe me $50.
21:15gfrederickswhoops hey wanna bet $50 on this
21:16amalloy"variant" is a euphemism for "hillbilly slang"
21:16gfredericks"hillbilly slang" is a dysphemism for "variant"
21:19TimMcgfredericks: My entry for the contest: ##(read-string "🐝")
21:19lazybot⇒ 🐝
21:21TimMcU+1F41D HONEYBEE
21:23gfredericksokay you've successfully dismantled the contest
21:23TimMcThat means I win!
21:24caternBEEEEEEEEEEEEES
21:28sdegutisgfredericks: it shows up right for me
21:29gfrederickssomewhere in between my emacs->tmux->ssh->gnome-terminal
21:29sdegutisoh
21:29gfredericksthe bee support is lacking
21:29sdegutiswelp.
21:30TimMcIt doesn't show up for me either. :-)
21:31sdegutisShows up for me, using just LimeChat.
21:31xeqigfredericks: I'm gonna blame gnome-terminal as thats what we have in common and it doesn't show up for me
21:31sdegutisOh wait, you mean in CLojure.
21:31sdegutisYeah, it shows up in Terminal.app using `lein repl`.
21:31sdegutisDoesn't work in Hammerterm though.
21:33gfredericksno I mean my irc client
21:33gfredericksxeqi: could it also be the font? I think I have inconsolata
21:34caternsdegutis: is.. this.. a port of st to *OS X*? seriously? gross. suckless would be ashamed
21:34sdegutisThey are.
21:34sdegutisI told them.
21:34xeqigfredericks: maybe, I can't remember if I have inconsolata or terminus
21:34sdegutisOn the other hand, they made my job porting it needlessly hard by sloppily using globals.
21:34blaenkis there an accepted way of detecting whether the app is in dev mode or production, etc?
21:34sdegutisSo we're even.
21:35sdegutishaha https://www.dropbox.com/s/9sc05upwygvdpnx/Screenshot%202014-09-02%2020.34.22.png?dl=0
21:35xeqiapparently inconsolata. so yeah, probably that
21:35sdegutisHammerterm totally fails at Unicode.
21:35sdegutiscatern: Also, X is something to be ashamed of.
21:36sdegutisOkay maybe that's a bit harsh.
21:36blaenkalso anyone know of a good ring logger?
21:37xeqi(fn [f] (fn [req] (log/log (... req)) (let [res (f req)] (log/log (... res)) res))
21:38sdegutisIs log4j the best solution for logging in Clojure?
21:38sdegutisOr maybe Lumberjack?
21:38boyscaredhello. how do i use cider-inspect to actually inspect stuff?
21:38boyscaredcan't find any documentation on the feature
21:39xeqisdegutis: tools.logging?
21:39sdegutisAh.
21:40xeqino idea if thats "best", but probably where I'd start
21:40blaenkall it does is delegate to an actual logging implementation
21:41technomancywait, is this a terminal named after Captain Hammer from Doctor Horrible's Sing-Along Blog?
21:42sdegutisSure why not.
21:42technomancyhttp://img3.wikia.nocookie.net/__cb20080731175820/drhorrible/images/5/50/Captain_Hammer.jpg not a bad mascot, eh?
21:43blaenkthats the guy from firefly too
21:45xeqiI think at this point he's the guy from castle
21:45sdegutisha
21:46sdegutisI have no idea how Habbie came up with the name Hammerterm.
21:46xeqifrom hammerpants ?
21:46sdegutisbut anyway, http://stream1.gifsoup.com/view/980226/hammertime-o.gif
21:47sdegutiscatern: how did you deduce so quickly that it was from st?
21:47gfredericksthere's a link in the repo description
21:49sdegutisOh.
21:49sdegutisBut how did you find the repo?
21:49sdegutisI didn't post one.
21:50xeqi$google sdegutis hammerterm
21:50lazybot[sdegutis/hammerterm · GitHub] https://github.com/sdegutis/hammerterm
21:50sdegutiswow thats fast
21:50sdegutisthey rejected my changes to extract the terminal emulation stuff away from the X stuff
21:50sdegutisoh well
21:50justin_smith,((((((((((((((((((fn f [] f))))))))))))))))))
21:50clojurebot#<sandbox$eval25$f__26 sandbox$eval25$f__26@1fcb359>
21:51technomancyabstraction ain't free
21:51Bronsa,(reify clojure.lang.IDeref (deref [this] this]))
21:51clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>
21:51Bronsa,(reify clojure.lang.IDeref (deref [this] this))
21:51clojurebot#<sandbox$eval73$reify__74@189bd81: #<sandbox$eval73$reify__74@189bd81: #<sandbox$eval73$reify__74@189bd81: #<sandbox$eval73$reify__74@189bd81: #<sandbox$eval73$reify__74@189bd81: #<sandbox$eval73$reify__74@189bd81: #<sandbox$eval73$reify__74@189bd81: #<sandbox$eval73$reify__74@189bd81: #<sandbox$eval73$reify__74@189bd81: #<sandbox$eval73$reify__74@189bd81: #>>>>>>>>>>
21:52justin_smithBronsa: nice
21:53sdegutislook, you...
21:55bounbhaha :)
21:55justin_smithis there a name in the lambda calculus for (fn f [] f) ? (the function of no args that returns itself)
21:56sdegutistechnomancy: So are you in California now. Thanks in advance, ragards?
21:58Bronsajustin_smith: I don't think functions can refer to themselves in lambda calculus
21:58justin_smithOK
21:59technomancysdegutis: I, um, yes?
22:01sdegutisGood I may ship my Atreus to you as a thank-you gift :)
22:01sdegutisI think you'll like it, it's got birch-wood etc.
22:02technomancycool, I'll patch it right up then and you'll be right as rain
22:02sdegutis<3
22:05lavokad__guys, i now have a .clj file in one window, and repl(cider) in the other. When I do C-x C-e, the expression's evaluation result apears above my editing file. How do u make results apear in the repl window?
22:15justin_smithlavokad__: I like to keep a trail of what I evaluate in the repl, and for that to work I switch the repl to the namespace I am working on, and enter code into the repl
22:16justin_smithit is easy to select and copy whole defs at a time
22:16joobusis loop always used to make recursive calls?
22:17justin_smithjoobus: that's what loop is for, yeah, but if you were feeling dumb you could never call recur and use it as if it were let
22:17justin_smithwhich, to reiterate, would work, but would be dumb
22:18joobusok, but one doesn't necessarily need to call 'recur' specifically. one could also call the function containing the loop in the loop?
22:19justin_smithyou don't need loop for that
22:19justin_smithyou can call the function, or even call recur, without a loop
22:19justin_smithloop is for when you want a block that can recur
22:20joobusok, thanks
22:20justin_smith,((fn f [x] (if (> x 100) x (recur (+ x x)))) 10)
22:20clojurebot160
22:20justin_smithexample of recur without loop ^
22:20joobusi'm looking at the recursive-reverse function here: https://github.com/tomshen/clojure-koans/blob/master/src/koans/13_recursion.clj
22:21joobusand here: https://github.com/viebel/clojure-koans/blob/master/src/koans/recursion.clj
22:21justin_smithyes, one is tail recursive, the other is not
22:24amalloyjustin_smith: loop without recur: a poor man's let
22:24amalloycould totally avoid needing let* for bootstrapping!
22:24justin_smithlol
22:24justin_smithyou could totally replace both with fn immediately followed by args :P
22:25sdegutisHello.
22:25sdegutisDoes anyone know what project this is referring to. https://twitter.com/technomancy/status/506146365941219329
22:25sdegutisThanks in advance. Regards.
22:25justin_smithsdegutis: it was atreus, I checked when I first saw it
22:26sdegutisDo you have the link.
22:26justin_smith(when I saw the tweet that is)
22:26justin_smithnope, not handy
22:26sdegutisLooks like https://news.ycombinator.com/item?id=8247803
22:26justin_smithyeah. that looks right
22:27sdegutisReminds me of when my project was on HN for a little bit. After that, I posted a link to the HN thread in my project's FAQ under the question "Where can I find a comprehensive list of alternatives to your app?"
22:28justin_smithnice
22:28sdegutisSame here.
22:28sdegutisBut I guess there's not much else to talk about in HN threads besides alternatives to the topic?
22:29sdegutisbbl adding gui buttons
22:29cataskaHi, what "profiles" means in cljsbuild ?
22:30blaenkthink of it like ruby environment configuration
22:31cataskaI know nothing about ruby
22:32mdeboardme either!
22:32joobusme either!
22:32sdegutisI do.
22:32sdegutisOkay so it goes like this:
22:33sdegutisYou've got an "environment configuration".
22:33sdegutisIt's basically like Leiningen profiles.
22:33sdegutisAnd you can configure your environment.
22:33sdegutisYou can use Gemfiles and Bundler for this.
22:34sdegutisSpecify a "group" of :test or :development in your Gemfile.
22:34sdegutisThat's not how it works in Leiningen though.
22:34sdegutisAnyway, it's handy.
22:37lavokad__why I see 4clojure package in the web http://melpa.milkbox.net/#/ using chrome, but when doing M-x package-install, it is not there..
22:37cataskaHow "profiles" triggerred when type "lein xxx" ?
22:37sdegutisThanks in advance.
22:55danielcomptonlavokad__: is melpa one of the packages in your emacs config?
22:56danielcomptonpackage repositories that is
22:56lavokad__danielcompton: yes, i tried with both stable and the other
22:56lavokad__it is so weird
22:57lavokad__I see bunch of other but not 4clojure
22:58xeqi$google leiningen profiles
22:58lazybot[leiningen/PROFILES.md at master · technomancy/leiningen · GitHub] https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md
22:58xeqi^ cataska
22:59lavokad__i did manually and its ok
23:00lavokad__but why the hell can't do it from package-install...:(
23:02cataskaxeqi: Cool, thank you
23:54Ceterizine>_>