#clojure logs

2015-07-28

00:35lunaticleonewbie question (.getPath (java.nio.file.FileSystems/getDefault) "/tmp" "/foo") get ClassCastException java.lang.String cannot be cast to [Ljava.lang.String; user/eval2979 (NO_SOURCE_FILE:1)
00:36lunaticleooops maybe I should try #clojure-beginners
00:40amalloylunaticleo: have you tried typing some key words from that error message into google? eg, a search for "clojure java getpath string cast" brings the answer as the second result
00:41lunaticleoah. Note to self try easy stuff first
01:00namrahm how to pass a fn name to a macro which will then be evaluated by the macro?
01:00namra,(defn hello [] (println "hello, world"))
01:00clojurebot#'sandbox/hello
01:01namra,(defmacro with-hello [f] `(let [msg# "Macro"] (println msg#) ~f))
01:01clojurebot#'sandbox/with-hello
01:01namra(with-hello hello)
01:01namra,(with-hello hello)
01:01clojurebotMacro\n#object[sandbox$hello 0x678697ba "sandbox$hello@678697ba"]
01:06namra,(defmacro with-hello [f] `(let [msg# "Macro"] (println msg#) (~f))
01:06clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
01:06namra,(defmacro with-hello [f] `(let [msg# "Macro"] (println msg#) (~f)))
01:06clojurebot#'sandbox/with-hello
01:06namra,(with-hello hello)
01:06clojurebotMacro\nhello, world\n
02:28sm0kehow do you simulate something like (deref futur 10000 :timeout) with core async channels?
02:29sm0kesomething like (<!! chan 10000 :timeout) would have been helpful but i am sure its not there
02:38amalloysm0ke: use alts on a timeout channel
02:38sm0keyea but that will return nil
02:39sm0kewhich makes it looks like channel has closed
02:44sm0kethere is a :default in alts! , not sure what it does
02:56SeyleriusWhat's the easiest way to find the greater of two numbers?
02:58sm0ke,(max 1 2)
02:58clojurebot2
02:58sm0ke,(max 1 2 3 4 5 6 100)
02:58clojurebot100
02:59Seyleriussm0ke: That's it. I was feeding it a vector. Simple change to just give it the values directly.
03:10sm0kei made one https://www.refheap.com/107112
03:11sm0kehope its correct
03:32SeyleriusRounding time.
03:32SeyleriusI've got a decimal: how do I reliably round up or down?
03:36dstockton,(Math/round 0.23)
03:36clojurebot0
03:36dstockton,(Math/round 0.5)
03:36clojurebot1
03:36Seylerius,(doc Math/round)
03:36clojurebotPardon?
03:37Seyleriusdstockton: Thanks. Can that control which way I round?
03:37SeyleriusI.E. can I specify to round up in one function, down in the other?
03:38dstocktonno, ties round up, otherwise the closest int
03:39dstockton,(Math/floor 0.5)
03:39clojurebot0.0
03:39dstockton,(Math/ceil 0.5)
03:39clojurebot1.0
03:39SeyleriusThere we go.
03:39SeyleriusThanks.
03:39Seylerius(inc dstockton)
03:39lazybot⇒ 1
03:39dstocktonyw
03:41dstocktonin case you aren't aware, these are all java methods
03:41dstocktonhttp://docs.oracle.com/javase/7/docs/api/java/lang/Math.html
03:42Seyleriusdstockton: I suspected that, but yes.
03:48SeyleriusGrr... I hate when computer algebra solvers produce absurd output.
03:49SeyleriusI am so not in the mood to solve a fscking quadriatic...
05:19kaiyinwhy can't compareTo be resolved here? Number n = new Integer(0); System.out.println((Integer)n.compareTo(new Integer(4)));
05:24Chousukekaiyin: that looks like you're casting the result of the compareTo call.
05:24Chousuketry ((Integer) n).compareTo...
05:29kaiyinChousuke: ah, i see. thanks!
06:21sheldonhin the exercises i'm doing, there's a lot of (f (first a-seq) (g (rest a-seq))). does clojure have a function that applies this pattern?
06:36sheldonhi hand-rolled my own: (defn traverse [f g a-seq] (f (first a-seq) (g (rest a-seq))))
07:41dnolenBronsa: appears you forgot to drop munge from the cljs.tools.reader ns form, fails to compile :)
07:44dnolenBronsa: also ns-resolve and ns-map aren't a thing.
07:45dnolenand they aren't going to be
07:47nogdenIs there anyway to persiatantly rebind a var in the current thread?
07:48nogdeni.e. not have to always use (binding [...] ...)
07:53Bronsadnolen: did you remove support for that at some point? I'm 80% sure I checked and they were implemented
07:57dnolenBronsa: like more than a month ago
07:57dnolenBronsa: the record problem needs to be handled in some yet undetermined way
07:58Bronsadnolen: are you fine with leaving it an unimplemented feature for now?
07:59BronsaI don't feel comfortable reverting to the old impl using js/eval + munge
07:59dnolenBronsa: yeah you shouldn't do that you just need to give up on the feature period
07:59dnolenboth the record ctor thing and resolve-symbol.
08:00dnolenresolve-symbol should be dynamic var that throws
08:00dnolenit has no sensible interpretation without the ClojureScript compiler being bootstrapped
08:01Bronsadnolen: so throw on resolve-symbol? that means that reading backquoted forms will throw
08:07dnolenBronsa:
08:07dnolenI don't see why this is a problem. People can bind it if they think they can make it work.
08:08Bronsadnolen: ok, fine with me. previous impl just expanded ns aliases and left symbols otherwise unexpanded
08:25Bronsadnolen: ok changes committed, reader tests are passing using last cljs
08:32dnolenBronsa: everything works, if you have chance cut a new release I can make ClojureScript depend on it and simplify my current convoluted dev setup :)
08:33Bronsa0.10.0-alpha3 on its way
08:33dnolenBronsa: thanks!
08:48IceD^hey
08:49IceD^using drift (https://github.com/macourtney/drift) and want to redefine this https://github.com/macourtney/drift/blob/master/src/drift/config.clj#L7
08:49IceD^for some legacy/tooling purposes wana keep them in different directory
08:49IceD^what's prefered way to do this?
08:51IceD^it's your typical lein project etc
08:51justin_smithIceD^: you can set dynamic bindings in project.clj
08:52justin_smithIceD^: *global-vars* https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L258
08:53IceD^awesome
08:53IceD^(and that's why I love clojure - in (rare) cases of some issues I can get immidiate answers ;])
09:09IceD^justin_smith: follow up question - this var is in drift.config ns. I'm lazy and/or stupid and can't find way to specify ns
09:27IceD^lein does this: ~@(map (fn [[k v]] `(set! ~k ~v)) (:global-vars project))
09:38IceD^so - simplifying question - how to set! var in different ns
09:50dabdCould someone help me with using negative lookahead with instaparse? I was expecting to be able to parse the following expression with this grammar: https://gist.github.com/dabd/eb5cb233f9214e527870
09:50dabd(foo-parser "bar")
09:51dabdhow can I specify a rule to parse anything that does *not* start with foo?
09:52expez! is not part of the syntax for context-free grammars
09:53expeznevermind, there's a PEG extension too, right?
09:53dabdyes
09:53dabdif i understood correctly you can use the some PEG operators in CFGs
09:53dabduse some*
09:54expezanyway, your use of negative lookahead is wrong, I think
09:54expezall negative lookahead does is look ahead to ensure that the parser is not satisifed by the following characters
09:55dabdany ideas on how I can parse all lines that start with foo and slurp in the the 'other' non-terminal anything that doesn't match?
09:55expezso instead of !foo you should just create a rule which matches whatever, IIRC PEG rules are ordered
09:57dabdhow would you define a rule that matches whatever?
09:57expezfoo / whatever, first tries to match foo and then tries to match whatever
09:57CookedGryphonis there some reason we can't use (into "" (some-transducer-producing-strings) some-coll)?
09:57dabdand how do you define the non-terminal 'whatever'?
09:57CookedGryphonother than it not being defined currently
09:59expezdabd: whatever ::= #"."+ should probably work. You should check out the instaparse README it covers everything in a very clear manner imo
10:01sveriHi, is tower currently the go to tool for internationalization?
10:12John6374 http://www.n-games-dev.net/black-fps/
10:53lellisGood morning, I'm beginning to set up my test environment and was in doubt how best to create the database, it is generally used the same development bank? Created and destroyed in memory? thanks
11:05IceD^lellis: depends
11:09lellisDid u guys always make integration tests or use mock for those?
11:10justin_smithlellis: by preference I separate pure stuff from side effects, put any nontrivial logic in the pure part, and test that
11:15justin_smithlellis: of course that doesn't always work, but it's a nice way to do it when it does
11:21lellisok ty
11:22justin_smithlellis: it depends what I am testing when it comes to integration vs. mock - in my database abstraction lib I use an in-memory h2 instance for most tests
11:23justin_smithlellis: if using the database is just part of the app logic, and is already tested (in the lib that provides the db abstraction I am using), I'll use with-redefs or arrange for the data source to be passed in so that I can stub it out with a lambda
11:49justin_smith,(defn n [i] (->> (all-ns) (mapcat ns-publics) keys (mapcat #(clojure.string/split (name %) #"[*-.!?]")) shuffle (take i) (clojure.string/join \-) symbol))
11:49clojurebot#'sandbox/n
11:49justin_smith,(n 3)
11:49clojurebotmacroexpand-atom-streams
11:49justin_smith,(map n (repeatedly #(rand-int 5)))
11:49clojurebot(ensure-inc-flush get-unquote-unchecked-val method-char-flush-quot set-long shutdown-Throwable ...)
11:51justin_smith,(map n (repeatedly #(rand-int 5)))
11:51clojurebot(partition fn-file-dissoc seq resultset--add-into ...)
11:51oddcullyi like ensure-inc-flush and shutdown-Throwable
11:51justin_smithheh
11:51justin_smithoddcully: set-long seems quite useful
11:52justin_smith(set-long 5 2) ; from now on (== 5 2)
13:53mglvlHi all, anybody can help me with this question: http://stackoverflow.com/questions/31680028/clojure-core-match-error-with-variant ?
13:58dnolenmglvl: not enough context what is Mobile a deftype?
13:59mglvldnolen: a defalias wich is '{:left Branch, :right Branch}
13:59justin_smithdnolen: toward the top it is a t/defailias for '{:left Branch, :right Branch}
13:59justin_smithoh, heh
14:00dnolenmglvl: doesn't tell me anything at all
14:00dnolenmglvl: does defalias make a deftype? a defrecord? a map?
14:01dnolenmglvl: one immediate thought is that you probably don't intend to match the local?
14:02dnolenmglvl: this is a "feature" of core.match borrowed from other pattern matchers that can be counter-intuitive
14:02mglvldnolen: well I'm not sure how core/typed works - what I intended it to be was an alias for a map with a left Branch and a right Branch
14:02dnolenmglvl: that `mobile` is a parameter and you're going to match that
14:02dnolen`mobile` in the pattern does not introduce a new binding
14:02dnoleni.e. not a wildcard
14:03expezdnolen: if I provide a data-reader for #js, can I use the clj reader to read a cljs file?
14:03mglvldnolen: then why does it work in the other case?
14:03dnolenexpez: probably never tried it myself.
14:03dnolenmglvl: because `local` isn't a local parameter
14:04dnolento summarize
14:04dnolen(fn [x y] (match x y)) != (fn [x] (match x y))
14:04expezdnolen: will cljs in cljs eliminate the need for :refer-macros?
14:05dnolenin the former x must equal y
14:05dnolenexpez: ClojureScript has macro system that is fundamentally incompatible with Clojure's.
14:05dnolenso no ... never going to happen.
14:07expezdnolen: is there an equivalent of the classpath in cljs, e.g. if I want to query the runtime for a list of all available deps?
14:08dnolenexpez: internally yes, but there's no good public way to get at that at the moment, ClojureScript can load many kinds of JavaScript files in many kinds of ways.
14:08expezdnolen: so this: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-add-missing-libspec won't be possible for a while yet in cljs?
14:09dnolenexpez: that works for me in Cursive I believe, you just have to sort out the resolution yourself.
14:09expezshit that gif is pointing to the old clunky version :/
14:10mglvldnolen: I'm sorry, I'm not sure I understood you correctly. Is it because I'm using the same name for a variable already defined, right? so its trying to match against that variable's value and not as a wildcard?
14:10dnolenexpez: short story you must consider classpath, :libs & :foreign-libs
14:10dnolenmglvl: yep
14:10mglvldnolen: ok, thanks!
14:24slesterIs there a fancy way of accessing what's in a project.clj file without slurping it in & fishing out what you want? I couldn't find anything so I assume not.
14:24drbobbeatyslester: Nope. That's it. But I've done it - even when it's in an uberjar, and it's very slick.
14:24slesterdrbobbeaty: slurping?
14:25drbobbeatyslester: Yup. You can `slurp` from an uberjar as well.
14:25slesterdrbobbeaty: oh! sorry, misunderstood. good to hear, thanks.
14:27arrdemBronsa: expected stackmap at branch target. howdoi.
14:28amalloyslester: lein puts your project.clj in META-INF/leiningen/[groupid]/[artifactid]/project.clj
14:30amalloyso you can slurp that path and probably find it. or you can just slurp the path "project.clj" and *probably* find it. but this only works when you're looking for the project.clj in charge of the uberjar; dependencies bundled into a jar don't get their project.clj put anywhere in particular as far as i can tell
14:40Bronsaarrdem: got a minimal example?
14:40Bronsais it the one on jira?
14:42arrdemBronsa: no this is another one, I'm working on a patch for TEMJVM-14 and broke something... trying to understand what/how
14:47seangroveWhat's the overhead of using partial or comp on the jvm? It's pretty expensive and should be avoided in a tight loop for cljs
14:51amalloyseangrove: it's one object allocation with one constructor argument per closed-over variable
14:52amalloyoh, and i guess since you're talking about comp and partial the closed-over variables are just the arguments
14:52justin_smithseangrove: #() creates a new class while partial does not iirc
14:52kwladykahow works tail-call optimization? I need go into lazy deep checking tree https://ivoroshilin.files.wordpress.com/2015/02/backtrack.png not wide. Is it possible with loop and recur? I don't think so?
14:53amalloyjustin_smith: i know you know this, but it's good to be clear when answering: it creates a new class once, at compile time, not every time you evaluate it
14:53justin_smithamalloy: right, thanks
14:53justin_smiths/evaluate/use of course because eval again would create a new one :P
14:54justin_smitheval of the form that made it that is
14:54amalloywell, evaluate is different from "call eval on"
14:55justin_smithso you are talking about calling the bound value?
14:55amalloylike (repeatedly 10 #(+ 2 2)) evaluates #(+ 2 2) 10 times but only makes one class
14:55justin_smithright
14:55amalloyi guess it doesn't actually evaluate that 10 times
14:55amalloyi meant more like... (repeatedly 10 (fn [] #(+ 2 2)))
14:56justin_smithright, my mental model was create class when evaluating, but evaluate only once per binding (and re-use the binding)
14:56amalloyper binding?
14:56andyf_kwladyka: Anything that can be implemented using recursion can also be implemented using iteration with no function calls, if you are willing to implement your own stack by hand.
14:56andyf_in any language, not just Clojure
14:58justin_smithamalloy: hmm, maybe that's the wrong term - in (fn [] #(+ 2 2)) the inner lambda is bound (captured is the more idiomatic term here of course) only once, no matter how many times the outer is called
14:58justin_smithor in (let [f #(+ 2 2)] (repeatedly f)) it's bound and evaluated once and reused
14:58amalloyjustin_smith: it's not, though. it's in the body of the function, not closed over and saved. if you call that fn twice you will get out two different (but equivalent) lambdas
14:59andyf_kwladyka: Here is a Stackoverflow Q&A on the topic. I'm sure there are others: http://stackoverflow.com/questions/159590/way-to-go-from-recursion-to-iteration
14:59justin_smithamalloy: oh... OK
14:59amalloy,(let [f (fn f [] #(+ 2 2)), g (f), h (f)] [g h (= g h)])
14:59clojurebot[#object[sandbox$eval25$f__26$fn__27 0x2962230 "sandbox$eval25$f__26$fn__27@2962230"] #object[sandbox$eval25$f__26$fn__27 0x4e9e7ea3 "sandbox$eval25$f__26$fn__27@4e9e7ea3"] false]
14:59justin_smith,(let [f (fn [] #(+ 2 2))] (= (f) (f)))
14:59clojurebotfalse
14:59justin_smithOK
15:00noncomkwladyka: clojure does not provide tail-call optimisation. you have to manually place (recur) in correct tail places
15:00amalloyit would be easier to realize if the example were like (fn f [n] #(+ 2 n)) (f 1) (f 2)
15:00amalloythere it must be two different lambdas, but there's nothing qualitatively different about the two examples, just whether something is closed over
15:00justin_smithright, there is a possible optimization there of course, which for some reason I assumed could happen
15:00noncomkwladyka: you also have to define what you do on each step and how do you advance in the tree
15:01amalloysure, it could be optimized for no-closure lambdas
15:01noncomfrom that you'll get a clearer view of how your tree-work will work
15:03noncomkwladyka: but as a general advise , i usually separate the stepping function from decision-making function... however that is just a preference of taste.. to me it makes things a little cleaner
15:04noncomkwladyka: also, it is desirable to use (recur) in case of too many calls - not to blow up the stack. or sometimes it is possible to use reduce for that..
15:05kwladykaandyf_, even a backtracking algorithm?
15:05kwladykanoncom, i read clojure has some tail-recursion optimisation on stackoverflow somewhere
15:06ed-gHello I'm trying to debug a problem with Friend interactive-form workflow. My form is calling the interactive-form login page, but it isn't accepting any user or password in my testing map. However when I call the bcrypt-credential-fn using the same username and password my form is submitting, it returns a {:role ...} map. Any suggestions for debugging techniques? I'm afraid I may have wrapped the ring handler in the wrong order or something but have no
15:06ed-gidea how to diagnose if that is the case.
15:06andyf_kwladyka: If recursion can do it, it means there is a call stack with return addresses and arguments. This can be simulated with your own code. It isn't necessarily as short or clean as a recursive version would be to read or understand.
15:07noncomkwladyka: even with backtracking - your looping index in case of a cycle may represent, say the depth level, so you can go up a level even if you use a while{} or for{}
15:07noncombut that seems dirty and goto-like
15:08noncomkwladyka: no, it does not have tail call optimisation.. it has some means, like the (recur) statement to make recursion without an actual funcall (without putting one more frame in the stack)
15:08noncomthat's it i think
15:09noncomyou can use (recur) with (loop) or without it
15:11ed-glooks like Friend is calling my password map with an empty username. Anyone seen this before?
15:11kwladykaso are you suggesting use http://clojuredocs.org/clojure.core/iterate or it is the same name by incidence?
15:12kwladykabacktracking with iterate?
15:12gfredericksfun fact: (binding [*out* nil] (/ 42 0) (catch Exception e :caught)) => :caught
15:13noncomkwladyka: no, i do not think this is a good choice... that'll just make the thing much trickier. why don't you just use (recur) ?
15:13noncomed-g: never used that..
15:13kwladykanoncom, i need lazy algorithm and recur make it unlazy
15:13kwladykanoncom, loop with recur
15:14domokatohey guys, is it idiomatic to use delays when you need to perform some side effects in the middle of a large let binding?
15:14gfredericksdomokato: what is the goal?
15:14kwladykanoncom, https://ivoroshilin.files.wordpress.com/2015/02/backtrack.png <- i have to get as deep as possible branch and then next one, and next one, i can't do it in wide way
15:15kwladykafor now i am doing this with (for) but maybe it is better way
15:15noncomkwladyka: yeah, you don't have to.. it all depends on your algorithm..
15:15domokatogfredericks: the goal is to avoid having a large let binding, followed by a couple lines with side effects, followed by another large let binding
15:15domokatogfredericks: instead combining them into one let
15:16noncomkwladyka: i have to go, but maybe these links can help you http://stackoverflow.com/questions/11409140/stumped-with-functional-breadth-first-tree-traversal-in-clojure and http://squirrel.pl/blog/2010/07/26/corecursion-in-clojure/
15:16domokatogfredericks: reducing nesting
15:16noncomgood luck
15:16kwladykanoncom, thx
15:17domokatogfredericks: previously i've used _ bindings, but it looks ugly to me
15:17gfredericksdomokato: like (let [a b, _ (delay c), d e] ...)?
15:19gfredericks(I can't figure out how you can use delays to avoid having the _ binding)
15:19domokatogfredericks: one sec...
15:22domokatogfredericks: previously, i would use (let [a b, _ c, d e] ...) but would it be better to do something like (let [a b, d (delay e)] c @e) ?
15:23domokatoer
15:23domokatogfredericks: (let [a b, d (delay e)] c @d) i mean
15:25domokatogfredericks: the other thing I'm trying to avoid is (let [a b] c (let [d e] ...)) because of too much nesting sometimes
15:26domokatogfredericks: (where c is a function call or something with side effects needed by e)
15:34gfredericksah yes I see how that works
15:36gfredericksdomokato: I would _probably_ think about how to refactor it into separate functions so you don't have this problem
15:36gfredericksbut I've definitely run into it too
15:37gfredericksand sometimes imagine a fancy macro that would let you insert a :do clause
15:37gfredericksbut I don't actually go write it
15:37amalloygfredericks: the macro would be to find all instances of :do and replace them with _ because that already works?
15:37gfredericksit seems like a useful kind of syntactic salt
15:38gfredericksamalloy: I suppose that would be the easiest impl now that you put it that way, yes
15:38gfredericksamalloy: still kind of dirty, since you're poluting the lexical environment with gensyms or something, but whatever it's just imaginary
15:39amalloyright, it's just a silly implementation that points out how silly the potential macro is
15:39domokatowell, :do would be a little more readable than _ but still kinda ugly, imo
15:40gfredericksamalloy: :P
15:41csd_how can i instantiate java generics in clojure?
15:41csd_Vector<int> for example
15:42gfredericksno need to
15:42Empperifirst of all, Vector<int> can't be made, second the generics have type erasure and thus aren't there when using reflection or at runtime
15:42Empperithus no need to
15:43TEttinger,(doto (java.util.HashMap.) (.put "key" 1) )
15:43clojurebot{"key" 1}
15:44csd_,(java.util.Vector.)
15:44clojurebot[]
15:45csd_got it, thanks
15:45TEttingerperiod after a class name, like ClassName, is short for (new ClassName)
15:46TEttingernew as a macro or special form or whatever it is is rarely used in clojure, the appended dot is much more widely used
15:46csd_i'd accidentally imported [java.lang.Vector], figured it was a different problem than it was :-/
15:56domokatoi gotta say, it's pretty readable using the delays
16:05justin_smith,Vector
16:05clojurebot#error {\n :cause "Unable to resolve symbol: Vector in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: Vector in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6611]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: Vector in t...
16:07justin_smith(inc delay)
16:07lazybot⇒ 1
16:08justin_smith,(doto (java.util.Vector.) (.add 42))
16:08clojurebot[42]
16:09arrdemBronsa: the case I'm encountering is on c8db1c8, attempting to emit clojure.core/line-seq something to do with then when-let ifnul not being structured correctly.
16:10arrdemBronsa: sorry ducked out for lunch, will be hanging out here when you get a chance to look.
16:14ed-gOk, turns out the problem is I *did* need to wrap my Ring handlers in a different order. In general how should I determine which order to wrap ring handlers? Do I look at each projects documentation or are there rules of thumb?
16:14justin_smithed-g: most ring handlers apply after the one they wrap
16:15justin_smithed-g: but theoretically each handler could do some work before they one they wrap, and some more after
16:17ed-gjustin_smith, thanks. I suppose I was surprised I should wrap using Friend's authenticate wrapper before Ring's site-defaults. I would have thought that Friend would want things such as GET and POST parameters and anti-forgery.
16:22ed-gYep, in the friend source authenticate* does do some work before calling the next handler down the line. I suppose I should write my own ring middleware then it will all be clear ;-)
16:23justin_smithed-g: yeah, after writing enough middlewares in that style, it starts to make more sense - each wrapper has the power to redirect or mangle input to or output from each thing it wraps...
16:24justin_smithed-g: my mental model of a middleware is like dude jumps into a lion robot then lion robot jumps up and becomes part of voltron etc.
16:30ed-gjustin_smith, lol what I've discovered is its a good idea to have dude wear a GoPro so I can see what is going on.
16:30ed-gto be fair I remember that Rails routing and wrappers were equally confusing but much more of a mess. no offense intended to any Rails developers here.
16:33TimMcjustin_smith: or a middleware could run the handler multiple times and pick the output it likes best...
16:35arrdemyou could also just add a data flow dependency language for automatically composing middlewares...
16:35expezWhere can I find the documentation for the cljs ns form?
16:36ed-gok robo-voltro-tur-ducken analogy is going into the code comment.
16:39justin_smithTimMc: true - or it could filter handlers and not run the ones it doesn't like
16:41TimMcjustin_smith: Swap the request for whatever is currently in some atom and then use that one instead.
16:42TimMclike one of those silly Starbucks pay-for-the-next-person chains
16:54Fareare the arguments received by a *stararg or **kwarg guaranteed to be fresh lists and dicts?
16:54Fareare they frozen? can they be mutated?
16:54Farewhat if the function was itself called with a *stararg or **kwarg — are they copied or shared?
17:00amalloyFare: is this a clojure question in disguise?
17:04oddcullysmells like python?
17:06Fareoops, wrong channel — though I'm implementing that in clojure
17:08slesterIf I want to maintain the state of four players in a game, what should I use? defrecord? (yes, total newbie)
17:11justin_smithslester: start with a hash-map, upgrade to defrecord if you have a compelling reason to
17:12slesterjustin_smith: cool, with update-in?
17:13justin_smithslester: yeah. I would imagine a recursive function that updates game state and the state of each player on each iteration, returning a lazy-seq of played rounds?
17:14slesterjustin_smith: good idea! I am ripping myself off the OOP way of thinking so I'll need a lot of thinking to make that work in my head. thanks.
17:16justin_smithslester: the lazy-seq version is like oop, in that the state is organized into the "objects", except the data is a series of frozen states over time, and every "method" takes the frozen (immutable) state of a game and returns an updated game object (new frozen state)
17:16justin_smithso the objects disappear into their time traces
17:16justin_smithit sounds pretty cosmic when I put it that way, lol
17:16slesterhahah
17:18justin_smiththe objects in the game world can still have black-box logic like in normal oop, but you also have the added flexibility of knowing you don't have to control access, just update
17:41amalloyhuh, just ran across http://stackoverflow.com/q/13616471/625403 - it seems strange to even ask whether clojure needs let or not
17:45justin_smithI think that guy would like scheme, and his favorite implementation would be the one he could write in a weekend
17:46justin_smiththis is just wild speculation
17:54TimMcamalloy: Referring to the use of a lambda instead of a let... "this is a pattern I tend to use a lot & I love it"
17:54amalloyright!?!?
17:54TimMcThat's fascinating, and I don't think I'd want PRs from them. :-/
17:54amalloywho doesn't love to write ((fn [a b c] (+ a b c)) 1 2 3) instead of (let [a 1 b 2 c 3] (+ a b c))
17:56TimMcThis appears to get at their discomfort a bit: http://stackoverflow.com/a/13618303/20772
17:56turbofaillol
17:56arrdemhere lets save a character in a symbol for another class, more jit pressure and two more parens
17:57justin_smithamalloy: ITYM ((fn [a] ((fn [b] ((fn [c] (+ a b c)) 3) 2) 1)
17:57TimMcarrdem: I don't think it's the alphabetic char count that bothers them. :-)
17:58arrdem(inc justin_smith)
17:58lazybot⇒ 281
17:58TimMcfrom my link, it appears to be the "imperative flavor" of some uses of let -- rebinding.
17:58arrdemI mean in fairness when I see that I try to replace imperative uses of let with -> or ->> as appropriate to avoid rebindings...
17:59arrdembut (let [ _ (println ..) .. ] ..) is legit
17:59TimMcI always feel dirty when I do that.
18:00arrdemyeah but assert in your bindings is kinda nice
18:00turbofailthere is no way in which the ((fn [a] ...) b) pattern is superior to that though
18:00amalloyTimMc: this was all a trap to get you to post a SO referral link so i could find out who you are on SO
18:01TimMc?
18:01TimMcIs that a thing SO does?
18:02amalloyTimMc: the Share link creates one that has your userid in it, yeah
18:02TimMcthat's terrible
18:02TimMcSo I'm 20772 then?
18:03amalloyyou can choose to, instead, just ctrl-L ctrl-C to copy the url from the url bar, which is the generic url that would turn up in google results
18:07TimMcI sent them a feedback thingy to say "stahp".
18:21ed-gEvery library author thinks I want to use their macros. I do not want to use their macros, I want to use the functions that their macros use.
18:24justin_smithed-g: they keep trying to make "fetch" happen
18:27amalloysigh, dynamic types pls. i'm trying to fix an issue in code someone else wrote, and i cannot for the life of me figure out if this "field" of a struct-like map is supposed to be a set or a map. it starts out as a set, and then some stuff is conjed onto it, and then later somehow there is a map in the same slot, and then that map is conjed into a set so that you have a set of map entries
18:28justin_smithclassic
18:29justin_smithclearly that field is of type wooly-milkable-egg-laying-pig
18:29amalloyi think it's supposed to be a map, because there is code that does stuff like (let [method ((:methods m) whatever)] ...), but then why did it start out as a set? and if i make it a map from start to finish, it breaks because someone tries to conj a string into it while it's expected to be a set
18:31amalloyto add to the confusion, this is all inside of the fnparse monadic parser, so there is a :methods key in the "state" half of the state monad thingy, and also sometimes a :methods key in the "value" half so maybe they are two distinct unrelated objects
18:38arrdemwhat are you doing in the guts of fnparse...
18:38arrdemisn't instaparse king these days or just old code
18:41{blake}So...I figured something out that's been annoying me for a while, and I'm not sure whether it's just a personal tic, or something I should communicate to others (like, say, Weavejester, since it's lein-ring related).
18:41{blake}I've mentioned it here: Sometimes when running lein-ring, my code fails to reload because it can't find a function.
18:42{blake}Which began, not surprisingly, when I moved that function into a new namespace.
18:43{blake}But I thought I had caught all the references. After all, my code was running. It just wouldn't reload when running lein ring server...but only sometimes.
18:43{blake}And I discovered that I hadn't changed the references in my tests (which, heh, I haven't been running).
18:44{blake}So, that seems to be the issue: Sometimes, but not always, lein code reloading would trigger the tests being pulled in. Or so it now seems, since I've corrected that, the error has not re-occurred.
18:47SeyleriusAnyone know if it's possible to force Gorilla REPL to use a fresher version of nREPL? Cider's throwing a fit about insufficient freshness.
18:49amalloyarrdem: like i said, it is old code
18:49amalloyi think fnparse was old long before this was written, but here i am all the same
18:50arrdemSeylerius: yeah should be possible, I think a note about this was just added to the CIDER README.md
18:50arrdemSeylerius: it's just an override either in your project.clj or profile.clj
18:51SeyleriusGood deal. I'll look that up and tweak it.
18:51Seylerius(inc arrdem)
18:51lazybot⇒ 45
18:51Seylerius(karma systems are fun)
18:59Seyleriusarrdem: Where does the cider readme live?
19:03justin_smithSeylerius: I would expect it to be on the cider github page https://github.com/clojure-emacs/cider
19:04Seyleriusjustin_smith: I thought Gorilla was talking about a cider-specific readme somewhere in the gorilla project.
19:04SeyleriusHuh.
19:04SeyleriusThat makes more sense.
19:04SeyleriusToo much sense.
19:04SeyleriusWho said the Clojure community could be so sensible?
19:05justin_smithSeylerius: did you just call arrdem Gorilla?
19:05SeyleriusNo, the Gorilla page mentions the same thing.
19:05justin_smithoh, OK
19:05SeyleriusSince the whole reason I'm asking about this has to do with the Gorilla REPL project.
19:06SeyleriusOf course, the one other annoyance that I have about Gorilla is that it eats my emacs-style keybindings from conkeror.
19:10eriktjacobsen Is anyone familiar with Beckon / Signal handlers? I am using a function “core.print-health” which seems to work fine for first day or two of the jar running, but after a couple days it starts erroring out with “classdefnot found core.print_health”. I dont know why scope would suddenly change a couple days into running jar.
19:11eriktjacobsenit errors out inside the signal handler as it tries to call the function
19:16justin_smitheriktjacobsen: wouldn't the class include the full package name not just starting with "core" ?
19:17eriktjacobsenapologies, yes: Exception in thread "SIGTRAP handler" java.lang.NoClassDefFoundError: pipeline/core$print_health$fn__326
19:17eriktjacobsenthis is after several days of calling that function without fail
19:17eriktjacobsenkilling / restarting jar fixes it
19:18hiredmaneriktjacobsen: how are you running this thing?
19:18justin_smithoh, so it's an internal class (anonymous function inside the function) that is suddenly missing?
19:18hiredmanI've seen similar things happen serving a war via jetty-runner, and jetty runner unpacks wars in to /tmp and some systems clear out /tmp once a day
19:19eriktjacobsenNo, not anonymous. In the core file there is a defn, and then that is passed to the beckon signal handler via: “(reset! (beckon/signal-atom "TRAP") #{print-health})”
19:19eriktjacobsenI’m running with just java -jar file.jar
19:20justin_smitheriktjacobsen: foo$fn_xyz means an anonymous function inside the function foo
19:21eriktjacobsenThis is inside pipeline.core ns : (defn print-health [] —code—)
19:21justin_smitheriktjacobsen: right, what I am saying is that the thing it can't find is an anonymous function iside print-health, that's what that message means
19:22eriktjacobsenhmm
19:22eriktjacobsenoutside of timbre logging / deref and atom resetting,this is the only function
19:22eriktjacobsen“ (dorun (map (fn [[name agent]]
19:22eriktjacobsen (if (realized? agent)
19:22eriktjacobsen (report "HEALTH" name " is down.")
19:22eriktjacobsen (report "HEALTH" name " is running."))) @agents)))”
19:23justin_smitheriktjacobsen: the first arg to map is an anonymous function
19:23justin_smithoh, that's what you were saying, heh
19:24justin_smithanyway, maybe it's a bad locals clearing? that's weird though
19:25justin_smitheriktjacobsen: it can't hurt to change that to (map (fn health-checker [[name agent]] ...) ...) - then if that is the class not found, the message will indicate it (clojure uses the anon fn pseudonym if provided)
19:25eriktjacobsenyeah I wouldnt think it could lose that inside the map. Agents is also top level in pipeline.core… there are no arguments to print-health or any let statements anywhere so no locals i think
19:25eriktjacobsenThank you justin_smith, will definitely try that
19:25hiredmanwhat does the stacktrace say?
19:26eriktjacobsendarn I actually lost it when I restarted.. im sure will happen again though, just give it a day =\ Actually I have to run now. Will try that just to narrow down whats failing
19:27hiredmanit could easily be logging stuff causing the error, different logging frameworks can end up doing class inspection
19:27eriktjacobsenthe only things I saw was the beckon handler, clojure internals and then print-health was last thing. Didnt see anything logging related in stacktrace
19:27amalloyalso useful to know is whether you are aot-compiling
19:28hiredmannot directly related, but I would consider ditching beckon for directly using the sun.misc signal handling stuff
19:29hiredmanhttps://github.com/hiredman/songs-of-future-past/blob/master/src/com/manigfeald/sofp/signals.clj#L14-L19
19:30hiredman(beckon is slightly larger than five lines)
19:34hiredman(also putting fns in sets or using them as map keys is gross)
19:34hiredman(same with any type with non-value equality)
20:06gfredericksis there any particular reason why = is extensible but </>/<=/>=/min/max/min-key/max-key are not?
20:08hiredman== is not
20:09gfredericksthat's not meant as an explanation, right?
20:09hiredmanit is meant as a rexamination of the premise the question is based on
20:10gfredericksyou're saying == is in the same family because they all work on mixed-exactness numeric types?
20:10hiredmanright, and = is this weird thing that works on everything
20:10hiredmanbasically I suspect it comes down to the fact that Object implements .equals but not .compareTo
20:11hiredmanand various follow on decisions from that echoing down through the ages
20:11gfredericksthere are other functions that do arbitrary comparisons and throw when necessary
20:11gfrederickscompare, sort, sort-by
20:12gfredericksI guess they all take comparators
20:12gfredericksand the other functions are variadic so couldn't
20:13hiredmanit may also just be the seam where the ml standard library meets the jvm and common lisp
20:14gfredericksI don't know nearly enough about ml or CL to interpret that
20:14hiredmanwell rich took stuff from cl and ml when creating clojure's core, and then there is java interop
20:16hiredmanso maybe the semantics of </>/<=/>= etc came from ml, while comparitors and universal equality stuff came the jvm interop (and egal I guess)
20:16hiredmanbasically, you'd have to ask rich, and when was the last time he was irc?
20:18hiredmanit may even be a performance concern
20:19hiredman==,>,<,etc are considered real hot paths to be made fast, while =, because it interops with .equals is open to any stupid thing
20:21xemdetiabool equals() { TwitterRequest.ask("sooo like does "+a.toString()+"="+b.toString()); }
20:23xemdetiathat is an awful joke
20:23arrdemI had a laugh
20:24xemdetiaI just had a flash of some imaginary obfuscated jvm performance bugs contest
21:05gfrederickshiredman: thanks
21:09hiredmanit is interesting to try and come with as possible reasons for something to be the way it is
21:19vasOhhh is a future a way of doing stuff asynchronously in clojure?
21:20vaslike (normal thang) (normal thingy) (future thingy-that-might-take-a-while) (normal thang)
21:20vaslispiphanies
21:22arrdemvas: yep. future is a way to express threaded async. core.async is for "real" single or multiple threaded async/CSP
21:25vashmm I have heard much about this new style of code-fu known as "code.async" ...
21:25vascore.async*
21:25vasCSP = ?
21:26justin_smith$google programming CSP
21:26lazybot[Communicating sequential processes - Wikipedia, the free ...] https://en.wikipedia.org/wiki/Communicating_sequential_processes
22:42namrahm using atoms within macros is kinda annoying
22:43justin_smithnamra: why?
22:44amalloyusing compile-time atoms would be a hassle, i imagine. but emitting code that deals with atoms at runtime should be no problem
22:44justin_smith,'@foo
22:44clojurebot(clojure.core/deref foo)
22:45namrathere's an atom in the same namespace that the macro is and the atoms value initially is nil and will be reset during runtime
22:46justin_smithnamra: so deref it at runtime?
22:46namrajustin_smith: but that means that all other namespaces that use that macro must also know about that atom
22:47namrai'd like to avoid that
22:47justin_smithnamra: if the atom is needed in order for the macro to be correct, then the namespaces using the macro need to access the atom (at least in macroexpanded code) in order for the code to be correct
22:49justin_smithnamra: does the atom update arbitrarily at runtime? is it only set once as some sort of initialization?
22:50namraonly set once at startup
22:51justin_smithnamra: consider a delay or promise instead of an atom then - they are safer because they only get set once
22:52namrajustin_smith: thanks alot
22:52amalloywhy do the other namespaces need to know about the atom, even if you left it as an atom? your macro will just be emitting code that uses it, but they won't have to know about it
22:53justin_smithamalloy: the macro would break if the var was private, right?
22:53amalloyi mean at the worst case you can emit (swap! #'whatever/atom inc). but it doesn't have to be officially-private in order for other namespaces to not use it
22:54amalloyer, (swap! @#'whatever/atom inc)
23:19vasSo I have a list of keys, I have a fxn that takes 2 keys and returns a number. I want to compare every key against every other key.. doseq seems like the logical choice...
23:20justin_smithvas: (doseq [a keylist b keylistt] (f a b)) >
23:20justin_smithunless you need the results...
23:20justin_smiththen you want for not doseq
23:20vas> means descending?
23:20justin_smithit was a typo for ?
23:21vasOh, cool. yes I want the "results" not just side-effects of running f. but maybe pprint will do for now
23:21justin_smithuse for instead of doseq
23:21justin_smithpretty much the same syntax
23:21vasOkay, groovy.
23:22justin_smithnote this will compare each thing against itself
23:22justin_smithmaybe that's OK
23:24vasYeah that is Ok. it will just gimme a 0.0
23:30vasI would assume comparing them all against themselves should give me n^2 values returned...
23:30amalloyvas: try it and see
23:38vasHmm. How can I go from ("string1" "string2" "stringC") to a vector of strings?
23:39amalloywhy do you need a vector rather than a list?
23:39vasactually I think mapv will do the trick.
23:40vasreason being " java.lang.String cannot be cast to clojure.lang.IFn"
23:41justin_smithvas: wait, were you trying to make a list literal?
23:43vasSo I have a list of tags... ({:tag "heart"} {:tag "cool"} {:tag "whatever}) ... the comparing fxn takes 2 strings, figures out the tag overlap and stuff, needless to elaborate ...it returns a number. but i'm not sure how to format it to play nicely with my comparator ... trying some baby data worked with tags in a vector ["heart" "cool" "whatev"] .. but not in a list
23:47vasOkay I think I figured it out. I was trying to short-cut by doing (for [tag1 (mapv :tag (show-all-tags)) tag2 tag1] ... )
23:47vasbecause tag1 and tag2 are the same, right? but for some reason, that does not work.
23:47vasso it's not like "let" in that sense, it seems.
23:48amalloyvas: tag1 isn't the whole list of tags, it's a particular item in it, remember
23:48vasexplicitly defining tag1 as (mapv :tag (show-all-tags) and tag2 as (mapv :tag (show-all-tags)) Works, however.
23:48vasOh!
23:48amalloyyou can tell, because in the body of your for, you're treating it like an item
23:48vasThank you amalloy
23:48amalloyso you can reuse a definition, but not if you put it inside the for
23:48vasAha. that is good learning right there.
23:49vasno wonder they all came back 0, it was doing identities
23:50vasThanks for the help. =]
23:51vasAnd it returns n^2 items now, yay. =]
23:56vas=) this is fun