#clojure logs

2013-08-26

00:02SegFaultAXUgh I'm so close on #89. Passing all but 1 test. :(
00:03callenokay, no more owning things.
00:03callenowning things sucks.
00:04TEttingercallen, stealing is bad, mm kay?
00:09callenTEttinger: in the process of moving, I'm reflecting on how much I hate owning stuff.
00:13SegFaultAXI'm all out of brain juice to make this work: https://gist.github.com/SegFaultAX/42ed69e7d8c479a59792
00:13SegFaultAXIt's almost definitely something really obvious.
00:17TEttingerSegFaultAX, graph theory and really obvious are not concepts that I understand being together
00:18ToxicFrogWhat is the best way to call a function by name?
00:18ToxicFrogI have a namespace containing functions to handle various user commands and I'd rather not just have a huge (case)
00:19SegFaultAXActually, the problem is obvious. I mentally ignored undirected edges as the last constraint.
00:19SegFaultAXI just need to figure out how to make my algorithm work with undirected edges instead of directed ones.
00:19TEttingerToxicFrog, like the name as a string?
00:20ToxicFrogTEttinger: yes
00:20TEttingerthis is the time I wish I knew how macros worked
00:21ToxicFrogMacros own but I'm not sure they'd help here, I have the string at runtime from user input.
00:21TEttingeroh. sounds like a reflection thing?
00:22s4muelToxicFrog: multimethods and a dispatch function that takes the user string and runs the right fn
00:22SegFaultAX,((resolve (symbol "+")) 1 1)
00:22clojurebot2
00:22ToxicFrogSegFaultAX: awesome, thank you.
00:23SegFaultAXToxicFrog: Noooo, don't do that.
00:23SegFaultAXSo unsafe.
00:23SegFaultAXYou need to validate input. Create a map of all possible inputs to fns.
00:24SegFaultAX,(({"+" #'clojure.core/+ "-" #'clojure.core/-} "+") 1 1)
00:24clojurebot2
00:24callenToxicFrog: don't do that :|
00:25SegFaultAXcallen: I immediately regretted it.
00:25callenSegFaultAX: as you should.
00:26TEttinger,((resolve (symbol "eval")) "(with-precision 10 (/ 1M 6))")
00:26clojurebot"(with-precision 10 (/ 1M 6))"
00:27SegFaultAXTEttinger: You need to read it as data first.
00:27ToxicFrogcallen, SegFaultAX: anything evil the user can do with this they can do just as easily by, you know, starting the repl.
00:28SegFaultAXToxicFrog: What are you doing?
00:28TEttinger,((resolve (symbol "eval")) (read-string "(with-precision 10 (/ 1M 6))")) ;; ##((resolve (symbol "eval")) (read-string "(with-precision 10 (/ 1M 6))"))
00:28lazybotjava.lang.SecurityException: You tripped the alarm! resolve is bad!
00:28clojurebot0.1666666667M
00:28TEttingerinteresting contrast
00:29ToxicFrogSegFaultAX: program for making batch edits of Backloggery game entries
00:29SegFaultAXToxicFrog: Why do you need to call functions by name like that?
00:30ToxicFrogSegFaultAX: because I'd rather have a namespace containing all of the handlers for user commands and resolve them automatically than manually enumerate them all.
00:30ToxicFrogHmm. I guess I could write a defcommand macro that stuffs them into a map instead, then look them up in the map...
00:30SegFaultAXToxicFrog: Yes, do that.
00:54SegFaultAXGot it.
00:58amalloyjust to emphasize and generalize, ToxicFrog, i'd say that using maps as namespaces is much better than using namespaces as maps, in general
01:00ToxicFrogamalloy: part of this may be that I'
01:00ToxicFrogm used to lua, where maps and namespaces are the same thing.
01:05SegFaultAXToxicFrog: He isn't talking about implementation details.
01:05SegFaultAXToxicFrog: He's talking about the semantics of namespaces vs maps in an application.
01:06SegFaultAXYes you /can/ look something up by name in a namespace, but that isn't the ideal usage (in Clojure or Lua)
01:09callenah, the memories of using getattr and a string in namespaces in Django.
01:10callen#metaprogramming #lel #killmenow
01:10callenToxicFrog: listen to them. Been there, done that, you don't want to shove that shit to runtime.
01:22dissipatenoncom, ping
01:24bjaso if I'm starting up a cljs.repl/repl via some random -main (so I can just "lein run -m browser-repl" for instance) how might I go about getting back the improved repl experience that lein repl provides?
01:25dissipateclojurebot, noncom
01:25clojurebotTitim gan éirí ort.
01:26ddellacostabja: have you seen austin or piggieback? https://github.com/cemerick/austin
02:02muhooiirc, in clojure, namespaces *are* maps. not sure though if i'm misremembering
02:04bbloommuhoo: you're misremembering :-P
02:04bbloommuhoo: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Namespace.java
02:09ambrosebsmuhoo: http://www.infoq.com/presentations/Clojure-Namespaces-Vars-Symbols
02:12ambrosebscallen: thanks for that recommend btw ^
02:19ddellacostawhat is the best way to compare a list and a vector? I can do this: (clojure.set/difference (set ["a" "b" "c"]) '("a" "c" "b")) but is there a smarter way?
02:20dissipateddellacosta, hmm, doesn't a list require something in the 'function' position, while a vector does not?
02:20dissipateseems like apples and oranges to me
02:21SegFaultAXFinally got it.
02:21ddellacostadissipate: I'm just curious about how to compare the values of the two.
02:21SegFaultAXAnd about a million times faster than the naive formulation.
02:21dissipateddellacosta, convert the list into a vector first, that's what i would do
02:21ddellacostaSegFaultAX: 4clojure question?
02:22ddellacostadissipate: how? This: (= ["a" "b" "c"] (vector '("a" "c" "b"))) …for example, doesn't work
02:22callenddellacosta: I'm with dissipate. Don't do the set thing, just make them both vectors.
02:22ddellacostawhoops, apply
02:22sontekAnyone developing webapps in clojure and done benchmarking on basic check for how many requests per second a standard stack could handle?
02:22callenddellacosta: vec.
02:22callenddellacosta: don't use apply, it's slow.
02:22callen,(vec '(1 2 3))
02:22clojurebot[1 2 3]
02:23callenddellacosta: the short words are usually casts. (int, vec, str, etc...)
02:23sontekMy python app handles about 200 requests per second right now and I've had to start adding servers to it, was wondering if a rewrite in clojure would allow me to keep servers down
02:23callenddellacosta: vector exists as a constructor, like for mapping across multiple seqs.
02:23ddellacostacallen, dissipate: okay, but none of this solves my problem, comparing two collections by value
02:23ivansontek: you can try it with pypy first
02:23ddellacosta,(= ["a" "b" "c"] ["a" "c" "b"])
02:23clojurebotfalse
02:23SegFaultAXddellacosta: Yea, 89
02:24callensontek: don't bother with pypy, it doesn't make typical web stuff faster.
02:24dissipateddellacosta, what are you ultimately trying to do?
02:24callenddellacosta: if you want order-agnostic, then you're getting into set territory, but why aren't they both sets to begin with?
02:24sontekivan: callen: thats on pypy
02:25sontekcallen: pypy did improve it by about 30-50 rps
02:25callensontek: something to keep in mind, 200 requests per second is 525948000 requests per month. Do you really need more?
02:25ivanare you actually getting 200 requests/sec? nice problem to have
02:25dissipatecallen, i'm curious. how does clojure check the equality of an ordered set?
02:25sontekcallen: but the warm-up of the JIT is extremely slow, so it takes forever before pypy is helpful
02:25callendissipate: check the source.
02:26ivansontek: it would take 20+ seconds with Clojure
02:26ddellacostacallen: because I am writing a test. What the function returns is a vector, it doesn't need to return a set. I only need to ensure I'm getting back what I expect. I mean, let's be clear, I know how to do this, I just was asking if there was some more clever way to compare two collections by value that I didn't know.
02:26ivansontek: unless you have a really new Intel
02:26dissipatecallen, the source of how ordered sets are represented?
02:26callenddellacosta: do you expect duplicates or care if there are any? if not and order agnosticism is desired, that's a set.
02:26callendissipate: the equality check.
02:26callendissipate: just go read the code.
02:27sontekcallen: I don't need more *all* the time, just at the high load times, and I've been wanting to add some real-time stuff using socket.io, so improving the UI would add more requests for the same user base
02:27dissipatecallen, is that a macro? i haven't looked at the clojure source. i thought clojure was in java.
02:27ddellacostacallen: yeah, what I want to prove is that the difference of two sets is empty, I suppose. In the end, I guess what I really want is some set action here, I'll just do that.
02:27callendissipate: just go read the code.
02:28callenddellacosta: I find it helps sometimes to step away from 'code' and instead think about 'data' and what I do and not care about the data and what it should represent.
02:28callendo and do not*
02:28sontekI'm really just looking for a reason to play with clojure anyways
02:28dissipatecallen, i don't know where that code lives.
02:28callendissipate: you really want to get in the habit of reading code to answer your own questions, it will make you a vastly better programmer.
02:29callendissipate: learning to navigate code you didn't write is part of learning to read code.
02:29ddellacostadissipate: https://github.com/clojure/clojure
02:29dissipatecallen, i'm barely through the first chapter of the Clojure Programming book. i'm not good at reading the code, yet. :P
02:29callendissipate: you won't get good at it without reading code.
02:29TEttingerdissipate: the source is here for ordered sets, yes, java https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentTreeSet.java
02:30callenyou're *going* to encounter things you don't understand, that's part of the point. You create new questions and ten answer them.
02:30sontekMost people using luminus for their web stack in clojure?
02:30callensontek: I don't know about most, but yogthos, myself, and others are happy with it.
02:30callensontek: Luminus itself is a roll-up of best practices for Ring/Clojure based web apps. You can learn from it and then write your own stuff bespoke afterward.
02:31callenor enjoy the labor-saving aspects of using Luminus. up to you.
02:31sontekcallen: Is there any small demo apps you guys have built that I can pull down and tinker with?
02:32dissipateTEttinger, why was it implemented in Java and not clojure itself?
02:32callensontek: github.com/bitemyapp/neubite/
02:32TEttingerdissipate, because it's needed before clojure can evaluate anything
02:33TEttingerall the core types are done in java
02:33callenpretty typical for bootstrapping a Lisp
02:33TEttingerbut only very basic operations on them
02:33TEttingerthe more complex stuff is in clojure's core.clj
02:33TEttingerand by more complex, I mean nicer to use
02:33sontekcallen: thanks
02:33TEttingermore complex to implement
02:34dissipateTEttinger, but i was told that anything that is not a special form is a macro, function or something else written in clojure
02:34callenI still need to see if I can hijack AnnotationWriter.java
02:34TEttingerhttps://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L395
02:34dissipatecallen, i thought it was bootstrapped from the special forms alone
02:35TEttingerdissipate, keep in mind, special forms includes calls to java
02:35callendissipate: there are plenty of ways more efficient for learning why it was implemented the way it was.
02:35callendissipate: some of those ways include reading the code or watching talks hickey has given
02:35TEttingerdissipate, see how that function just calls the PersistentTreeSet I linked earlier?
02:36TEttingerit's still only using a special form
02:36TEttingerjust the java interop one
02:36dissipateTEttinger, yes. but couldn't PersistentTreeSet be implemented in pure clojure?
02:36TEttingerand it needs some thing in hava before, like []
02:36TEttingerfor args I mean, if there was no vectors, you couldn't do defn...
02:36callendissipate: honestly - who cares?
02:37TEttingerdissipate, it was a goal at one point, to help with cljs
02:37callendissipate: the data structures need to be reliably fast because they underly most of clojure.
02:37dissipatecallen, those who are curious?
02:37callenI already presented a good path for satisfying curiosity
02:37TEttingerbut it ended up I think being easier to just implement a little bit in java, then a little bit for js
02:37TEttingeryou saw how the TreeSet was less than 100 lines?
02:37TEttingerthere's other parts that are bigger
02:38dissipateyeah, and it looks awful
02:38TEttingerit's efficient, is why it is the way it is.
02:38callenyou clearly haven't seen enterprise Java code.
02:38TEttingerhaha
02:38TEttingeryeah anything by google
02:38TEttingerguice and all that horror
02:38callendissipate: you're not accustomed to reading code you didn't write, so you're not really seeing it properly.
02:38dissipatecallen, i have explicitly tried to avoid java entirely
02:38callendissipate: what would help with that is learning to read code.
02:39callendissipate: well your prejudice is adorable but probably limiting you.
02:39sontekFound these benchmarks of servers: https://github.com/ptaoussanis/clojure-web-server-benchmarks
02:39callensontek: techempower is better.
02:39TEttingerdissipate, it's surprisingly hard to avoid java, since all the libs are written in java and may or may not have clojure bindings
02:39ddellacostadissipate: if you want to use Clojure, you cannot be afraid of Java
02:39callensontek: benchmark whoring really isn't the way to make decisions like that.
02:39TEttingerbut it really isn't so bad
02:39callenit really isn't.
02:39dissipatecallen, i spend a lot of time reading code. BTW, i'm not saying that code is awful because the author wrote it poorly, i'm saying it's awful from an absolute standpoint. Objects and casts are terrible IMO.
02:39sontekcallen: Its just one of many things i'm evaluting
02:40TEttingerdissipate, woah
02:40callenwrapping java libs in Clojure is nicer than stumbling into somebody's psychotic meta-universe of weirdo libraries in Common Lisp.
02:40Ember-I very rarely see any type casting in good Java code
02:40TEttingerclojure isn't normal java code, keep in mind
02:40Ember-indeed
02:40ddellacostareally don't know what to say about where this conversation is going
02:40TEttingerit is a dynamically typed language, so you could have a ##(sorted-set 1 2 "STRONG")
02:40lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
02:41TEttingererr maybe not
02:41callenddellacosta: ITT: people that have never implemented a language criticizing the first bit of code they see in a language implementation.
02:41callenddellacosta: I say we show them gcc's source and see if they piss blood.
02:41sontekHow is writing interop code between java and clojure? (Speaking of things I'm evaluating)... Java has such a large ecosystem of great libraries, does it take much work to take advantage of that?
02:41dissipatecallen, i'm willing to get dirty with Java if i can reap the rewards of clojure
02:41ddellacostacallen: haha
02:41ddellacostadissipate: Excellent! Problem solved.
02:42TEttingerwell I am just saying, clojure needs objects and casts to be able to be able to represent lisp stuff. you don't need it in "good java" but this isn't for java
02:42dissipatecallen, read what i said above. i'm not criticizing the author. i'm saying Java is bad in general.
02:42callendissipate: so moving on to the part where we all use our time more effectively, I strongly suggest you watch some talks and read some material on the implementation of Clojure and read the code.
02:42TEttingeralso, 4clojure rules
02:42callenTEttinger: yes it does.
02:43ddellacostacallen: g'night!
02:43callenddellacosta: g'night :D
02:43TEttingernight all of you
02:43ddellacostaTEttinger: 'night!
02:44TEttingeri ain't sleepin'!
02:44ddellacostaoh, I ain't either, but I do have to write some code.
02:44dissipateI have watched talks, but i don't see the point of reading code at this point because I don't know the absolute basics of the language. sheesh
02:45shaunxcodeseriously who sleeps?
02:47TEttingerdissipate: definitely going to recommend trying as many 4clojure problems as you can until you hit one you can't solve. then read your book until you find a possible solution
02:47TEttingerit is really empowering to see a big list of "solved" in the site
02:49dissipateTEttinger, thanks, looks like a great way to learn
02:52dissipateTEttinger, have you solved all the problems?
02:53TEttingerhaha no way! only less than... 20 people have?
02:53TEttingererr 21 now
02:53dissipatedamn, guess they get tough!
02:54dissipateseems a lot like Euler Project
02:54TEttingerindeed. the one only 54 people solved is a poker hand thing, which looks all kinds of hard
02:56dissipateTEttinger, ah, i see it.
02:57dissipateTEttinger, i solved the first one! yay
02:58TEttingerheh
02:59TEttingerkeep at it, the seq stuff gets tricky
02:59TEttingerthe early things should be very fast
03:04SegFaultAXFinally top 100 on 4clojure!
03:05dissipateTEttinger, these exercises have lists that have things that don't make sense in the function position, like the literal 1
03:05dissipateTEttinger, if you evaluate these lists, you get an error
03:05TEttingerdissipate: which problem, link?
03:07dissipateTEttinger, http://www.4clojure.com/problem/5
03:07noonianthey are still data structures and you can use them as such
03:07noonianthey are quoted so they will not be evaluated
03:08TEttinger'(1 2 3) is a list
03:08TEttingerthe ' prevents it from trying to call 1
03:08dissipatenoonian, true, but wouldn't a vector be better suited?
03:08TEttingerindeed, but!
03:09TEttingerconj has different behavior (slightly) for vectors
03:09TEttingerthat comes later
03:09TEttingerthere's a reason clojure has both
03:09dissipatenoonian, i don't think i would pass a list around that couldn't be evaluated. a vector would safely evaluate to itself.
03:09nooniandissipate: depends on you need, for recursive functions lists will be just as fast
03:10noonian,(map (fn [k] (+ k 5)) (list 1 2 3 4))
03:10clojurebot(6 7 8 9)
03:10TEttingerand you can use a quoted list much like a vector: ##(map + [1 2 3] '(10 20 30))
03:10lazybot⇒ (11 22 33)
03:10nooniandissipate: usually you don't need to know whether its a list or a vector because all of the core functions will work on both
03:11noonian,(= [1 2 3] '(1 2 3))
03:11clojurebottrue
03:12noonian,(= (type [1 2 3]) (type '(1 2 4)))
03:12clojurebotfalse
03:13TEttingerthat's sometimes called the "seq abstraction" (seq short for sequence), and it's one of the best parts of clojure's design IMO
03:13dissipateTEttinger, so why have vectors at all? one could just use quoted lists everywhere, right?
03:13TEttingerdissipate, performance reasons. lists are slower for random access, vectors are slower for sequential I think
03:14dissipatei see.
03:14TEttingervectors also have different conj ordering, which is a common pitfall but the reason why they act differently
03:15TEttinger,(conj 1 [1 2 3])
03:15clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IPersistentCollection>
03:15TEttinger,(conj [1 2 3] 1)
03:15clojurebot[1 2 3 1]
03:15TEttinger,(conj '(1 2 3) 1)
03:15clojurebot(1 1 2 3)
03:16dissipatea queue vs. a stack?
03:16TEttingervery close
03:16TEttingerthe list is a linked list
03:17TEttingerthe vector is something more complicated, built over arrays I think.
03:17TEttingerbut they are as different as queues and stacks most of the time
03:20noonianimplementing an efficient queue with lists is not as straightforward as it is with vectors
03:21noonianbut a list could be faster for a stack
03:21TEttingerif I am correct about this, conj is very fast for lists, but not as fast for vectors. vectors have array-like (very good) speed for random access, linked lists need to go through each element's links to get to the one they want, which is a little slow unless you're doing recursive stuff, in which case it isn't a problem
03:22TEttingerthere's lots of subtle differences you won't encounter until you hit a bottleneck on performance
03:23zeroem,(apply str 1 2 3 [4 5 6])
03:23clojurebot"123456"
03:27dissipateTEttinger, is clojuredocs.org a good place for clojure documentation?
03:27TEttingeryes
03:28TEttingerit hasn't been updated since 1.3, but the core language hasn't changed
03:31dissipatecool
04:53quanticleAre any of you awake? I'm wondering why I get ArityExceptions when I try to call a multimethod that I've defined.
04:54quanticleOne sec, I'll Gist the code
04:55ucbquanticle: I'm awake (kind of)
04:56quanticlehttps://gist.github.com/quanticle/6339254
04:57quanticleI think I'm getting an ArityException when I try to call the send-command multimethod
04:57ucbyou think? Can you gist/paste the actual stacktrace?
04:57quanticleYeah. It's just one line, so it's not very helpful.
04:57ucbquanticle: btw, you've defn and def-multi send-command
04:58quanticleArityException Wrong number of args (3) passed to: core$eval95$fn clojure.lang.AFn.throwArity (AFn.java:437)
04:58vijaykiranquanticle: why is there a defn and defmulti ?
04:58quanticleOh
04:58ucbnot sure how that's going to play ;)
04:58quanticleIf that's the issue, I'm going to cry.
04:58quanticleYeah, I started writing it as a function, and then decided that a multimethod was more appropriate.
05:01quanticleNo, I deleted the defn, and I'm still getting the same error. Let me update the gist.
05:02ucbquanticle: is this in a running repl? Just wondering about lingering definitions
05:02quanticleucb: I restarted the REPL. I thought that might have been the problem as well, but even after the restart I see the same error.
05:02quanticleUpdated gist: https://gist.github.com/quanticle/6339254
05:04ucbquanticle: are you sure you can define multimethods with different arities? (I've never done it nor seen it done.)
05:05alexyakushevquanticle: dispatch function and methods should have the same arity
05:05alexyakushevquanticle: you need to add command-type to methods' arguments as well
05:08quanticleAhhhh, okay.
05:08quanticleThanks.
05:08vijaykiranquanticle: or - use : http://stackoverflow.com/questions/10313657/is-it-possible-to-overload-clojure-multi-methods-on-arity
05:11quanticleThanks vijaykiran, alexyakushev, ucb.
05:12quanticleI've got past the initial error; the code still doesn't work, but I know where to go from here.
06:38jwr7So I just found out that (merge-with conj {:abc nil} {:abc :cde}) will give a different result than (merge-with conj {} {:abc :cde}). I did not expect this.
06:39ucbthat's reasonable, right?
06:39jwr7But, the way merge-with is written, the merge function will only get called if a key exists in two merged maps.
06:39ucbI mean, {} doesn't have a key :abc
06:39ucbso there's no clash
06:39ucbunless I'm missing something
06:39jwr7ucb: not if my values are sequences and I want to *always* keep them as sequences
06:40ucb,(merge-with conj {} {:abc :def})
06:40clojurebot{:abc :def}
06:40ucb,(merge-with conj {:abc nil} {:abc :def})
06:40clojurebot{:abc (:def)}
06:40ucbthat's the behaviour I would expect
06:43jwr7I guess I expected to be able to also initialize values using the merge function. But perhaps that isn't reasonable...
06:44ucbwell, the merge function gets called only when there's a key clash
06:44ucbotherwise, it's plain merge
06:44ucbit's a conflict resolution scheme really
06:45jwr7so (merge-with conj ...) makes little sense.
06:48ucbwell, it depends on what you're after
06:49jwr7I think I'm after (merge-with concat) :-)
06:52ucbok!
07:16clgvjwr7: that might be dangerous - if you stack too many conacts your stack will blow up
07:16clgvsimilar to (reduce concat ...)
08:31noncomhow do i find the first matching entry in a colelction
08:31noncom?
08:32rkneufeldnoncom: sounds like you're looking for some + an anonymous function
08:33noncomoh, right
08:48dark_elementnoncom what need is 'some'
08:48noncomlooks like it is indeed!
08:48dark_elementoh i didn't read rkneufeld response.
08:49noncomi did not try yet also haha
08:55clgvnoncom: but beware ##(some odd? (range 10))
08:55lazybot⇒ true
08:55noncomheh
08:56clgvnoncom: you'd nee to write it as ##(some #(when (odd? %) %) (range 10))
08:56lazybot⇒ 1
08:56clgvnoncom: first+filter is a solution as well
08:56noncominteresting.. these functional combinations always make so much fun
08:58clgvthey should have implemented "some?" as predicate and a separate thing to find the first matching on a predicate ^^
08:59kohkanei guess some is implemented as a short circuit eval
09:06clgvyeslike "some?" would be as well ;)
09:13kohkaneis there any way to "apply" to a macro
09:13noncom,(doc some?)
09:13clojurebotI don't understand.
09:14noncom,(doc +)
09:14clojurebot"([] [x] [x y] [x y & more]); Returns the sum of nums. (+) returns 0. Does not auto-promote longs, will throw on overflow. See also: +'"
09:14noncomi always though there is some? predicate
09:14noncomas ther eis every? predicate
09:14Ember-,(doc some)
09:14clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
09:14Ember-there is that
09:14Ember-but it isn't a predicate
09:36clgvnoncom: no. that was the point I was making ;)
09:42noncomi try (let [^double d bla-bla-bla]) and i get Can't type hint a local with a primitive initializer
09:42noncomfor what reason?
09:42noncomwhy is clojure's computation capabilities are so crippled for no good reason?
09:43bjanoncom: crippled how?
09:43noncomfirst i find that floats and ints are not frist class citizens , so a while load of java interop or opengl interop (opengl only accepts floats, as the ahrdware does) simply goes away, here take these doubles and casting lags..
09:44noncomnow i can't typehint even doubles for speed...
09:44tim___noncom: example code?
09:44noncomman, i need to compute things.. and do it fast... i'm on a computer...
09:45noncomhttps://www.refheap.com/18029
09:45noncomi get Can't type hint a local with a primitive initializer here
09:46opqdonutnoncom: use d (double ...)
09:46opqdonutinstead of hinting
09:47noncomso casting instead of immediate typization..
09:47noncomoh well..
09:47noncomas much as clojure is fascinating with anything else, so much it is frustrating on computations
09:47bjanoncom: I've always just dipped down to java for that stuff
09:48noncomagreed, i will do that too.
09:48bjabut agreed, that it is a shame that we have to
09:48tbaldridgenoncom: you are talking about using a dynamic language for high performance situations. Clojure is way faster/flexible than any other language I've used for this. Try doing what you're doing in Python for instance.
09:48bjatbaldridge: numba actually makes this pretty reasonable in python
09:49noncomtbaldridge: fully i agree with you, no argument here.. i enjoy clojure very much - full credit, but... i simply see no reason to ignore ints and floats and to disallow local unboxed computations in manner of local mutability like with transients
09:50noncomjvm does it
09:51tbaldridgenoncom: using ints instead of longs is a bit pointless. Memory is cheap, using longs on a 64bit system isn't going to be slower.
09:52noncomtbaldridge: yes, i know, but lots of hardware works with ints and floats, for example, the whole opengl graphics adapters world knows nothing of 64 bit (as of yet).. so.. instead of adding support for them in the core, we simply lose opengl.. fair trade?
09:52tbaldridgenoncom: same for doubles, both get turned into 10-byte reals... http://stackoverflow.com/questions/417568/float-vs-double-performance
09:53noncomit just turns out that any opengl program is ways slower coz no floats here
09:54tbaldridgenoncom: always slower...how? Casting is slowing you down that much?
09:55noncomtbaldridge: sure! casting is very slow! imagine having like thousands of vertices on a dynamic mesh... each vertex is 3 components. So, you cast them all. And if you compute, say, deltas for them, then you have to cast these too. And if you get float values from the opengl driver to include in your coputations, you cast them too.
09:56noncomthousands of thousands of casts
09:56noncomper frame
09:56noncomand you also have many other things to do besides that
09:57tbaldridgeshouldn't all that be done via vertex buffers and vertex shaders anyways?
10:00noncomtbaldridge: buffers are just that - buffers, datastructures. you have buffers of floats or ints. if you deal with coordinates, them are floats. if you deal with indices, them are ints. and you do computations in the program anyway. you can't put all in your shaders. shaders are just VFX.
10:00noncomimagine a buffer of 1000000 floats that you have to cast from doubles each frame..
10:01noncomshaders are too, programmed and communicated from your main program
10:01noncomthey receive floats
10:01noncomthere are no magical double <-> float adapters on a video card...
10:02clgvnoncom: you do not need to type hint or cast values to doubles if the compiler already nows they are. the compiler performs local type inference (in compilation units, e.g. defn) for that
10:03clgvunrelated question: I want to store experiment results in a database. which clojure library should I go for? I'd like to define the entities in a high level way
10:04noncomi use monger + mongodb
10:04noncomsimply you put in and get {}
10:04Ember-doesn't provide any abstractions for defining the entitites, but that's kinda easy with records
10:05noncomi think that in clojure, entities cannot be anything but {} or [].. and them are mapped to mongo 1:2
10:05noncomahaha
10:05noncoms/1:2/1:1
10:05Ember-noncom: well, records are maps but they are also a bit more
10:05clgvmongodb is not sql, right?
10:05Ember-yes
10:06noncomright
10:06tbaldridgeclgv: datomic's Clojure integration is very very tight
10:06noncomyeah, right, datomic should be great too, just never used it before
10:06noncomgonna try some time too
10:08clgvso datomic and mongodb are the main options?
10:09Ember-you can use sql too if you want
10:09Ember-but in my honest opinion sql is pretty crappy abstraction for persisting data structures
10:09clgvI really dont know if I need sql features.
10:09nDuffclgv: There are plenty of alternatives to MongoDB if you want something with a similar model but more of a focus on reliable storage.
10:09Ember-that doesn't mean that sql is bad
10:10noncomclgv: what kind of data you want to store?
10:11clgvnoncom: experiment results, i.e. numbers and solution datastructures
10:11clgvI want to generate additional attributes based on that data
10:11noncomclgv: i think no need for sql then
10:11noncompick a db with a loose schema (no schema :D)
10:11clgvand generate plots from it
10:12tbaldridgeclgv: datomic also stores values/entities as raw data, in an extremely efficient serialization format. This means massive arrays of primitives take up little space.
10:12tbaldridgeclgv: could be better than whatever mongodb uses
10:12noncommongodb uses bson
10:12clgvtbaldridge: ok. how easy is it to set up datomic on a machine?
10:13noncomi am all ears.. wanted to test datomic for a long time too
10:15tbaldridgeclgv: [com.datomic/datomic-free "version"]
10:15tbaldridgeversions are here: http://downloads.datomic.com/free.html
10:15tbaldridgeclojure api http://docs.datomic.com/clojure/
10:16tbaldridgebasic docs: http://docs.datomic.com/
10:19clgvtbaldridge: do I understand correctly that the free version only has in-memory storage?
10:20tbaldridgeclgv: no it also has the free:// storage, which is stored on disk.
10:20clgvtbaldridge: ah ok. :)
10:21tbaldridgetransactor url would look like this datomic:free://localhost:4334/<DB-NAME>
10:21clgvtbaldridge: ok. I'll need to work through a tutorial then ...
10:22tbaldridgeclgv: it can be a bit daunting at first, but after playing around with it a bit I like it more than any other DB I've used from Clojure.
10:30fredyriirc the day-of-datomic repo was nice to play around with from the repl
10:32clgvgood hint
10:32rkneufeldhttp://www.learndatalogtoday.org/ is pretty badass for learning the datalog syntax
10:51jamiiHotspot is so fast it goes back in time - https://gist.github.com/jamii/6341985
10:52wakeuphi
10:52wakeupHow do I get the list of values from a set?
10:52wakeuptried vals without luck
10:53jamiiwakeup: (seq ...)
10:53wakeupcool thank you jamii
11:00Denommushi
11:00Denommusis the Clojure REPL application for Android open source or something?
11:01degcemerick: You around? re the pprng/cljsbuild issue (https://github.com/cemerick/pprng/issues/1 for lurkers)... So, what's best practice until the cljsbuild issue is resolved? Remove the libs line and copy the js file into my project for now?
11:02nDuffDenommus: https://github.com/clojure-android/clojure
11:03DenommusnDuff: no, I was talking about Clojure REPL, an application for android. They have a splash screen, aparently written in Java. But I can't get my own splash screen to work
11:03nDuffDenommus: that repo is created by the one from sattvik, who created the Android application you refer to.
11:03DenommusnDuff: thanks
11:04nifffcan someone help me with reducers/pmap ,i know pmap is for slow functions and similar evaluation time for each member
11:04nifffwhen to use reducers?
11:07noncomnifff: afaik reducers be used when possible... this is a development of the theory where the formulation becomes more abstract and allows for generalizing the concept. that results in writing better implementation for reduce
11:08nifffi am new and confused,sometime when i use reducer its fast others its not,i dont know when to use them
11:14TimMcjamii: That's not good. :-(
11:15TimMcjamii: You should maybe file an issue about that?
11:15jamiiTimMC: Was just making sure its not expected behaviour first :)
11:18coventry`nifff: Use reducers when you have some reason for wanting to do a reduction in a nonstandard way. In a similar fashion, pmap will get you the same result as map, but does the function evaluations in parallel if possible, whereas map does them in series. Same result, different style of calculation. See the "Basics" section of http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html
11:19nDuffnifff: generally, you'll only get parallelization from reducers when operating on data structures that support random access -- so, say, vectors, not seqs.
11:27squidz_at_workI am trying to translate a iterative function to clojurescript(functional) and am stuck. The function takes an array of maps(js objects) and if there isnt an equal number of maps containing certain date values, it creates a default map for the array. Here is the javascript example: http://jsfiddle.net/N4E5c ... only the function and the data are important
11:27seangrov`$seen bodil
11:27lazybotI have never seen bodil.
11:27squidz_at_workI would be very grateful if anybody could give me an idea
11:28hyPiRionseangrov`: her nick is Bodil, lazybot is bad a captializing
11:28hyPiRionat
11:28tbaldridgebad lazybot
11:29seangrov`$seen Bodil
11:29lazybotBodil was last seen joining on clojure 1 week ago.
11:29seangrov`That was awhile ago, just heard on twitter she's not going to JSConfEu, a bit bummed
11:29BodilThat bot is pretty useless. :)
11:29TimMc$seen lazybot
11:29lazybotlazybot was last seen joining on elixir-lang 1 week and 4 days ago.
11:30seangrov`squidz_at_work: Looks like something I'd be happy to help with in a fe whours if you can wait
11:30seangrov`thanks hyPiRion
11:30squidz_at_workseangrov`: Yeah I would be thankful for any help
11:30muhoo$seen a function more prone to abuse
11:30lazybota was last seen joining on clojure 59 weeks and 1 day ago.
11:30squidz_at_workseangrov`: if I can't figure it out by then
11:30seangrov`Bodil: Woops, I guess it is
11:31Bodilseangrov`: Yeah, I basically had to choose between JSConf and Strangeloop. And that's not a choice. :)
11:31TimMcuh-oh, I may have precipitated another seenstorm
11:31hyPiRionmuhoo: it's safe, really. nicks can't start off with a comma
11:31muhoo$seen the light
11:31lazybotI have never seen the.
11:32seangrov`Bodil: Ah, I didn't have that luxury, just barely ended up getting two tickets to JSConf
11:32seangrov`I'll have to be on top of my game next year for Stangeloop
11:32seangrov`Oh well, I'll chat with you about cljs stuff in person another time
11:33BodilEuroClojure? :)
11:33squidz_at_workthe array should have an equal number maps containing the same key. if not -> insert map with default values. [{:key group1 :date 1/1/13 :val 200} {:key group1 :date 1/1/12 :value 400} {:key group2 :date 1/1/12 :val 100}] -> since there are not two group2's insert insert map {:key group2 :date 1/1/13 :val 0}
11:33dnolensquidz_at_work: let me see if I understand
11:33lgs32ai have a very strange problem
11:34dnolensquidz_at_work: each group may not have the same number of entries, so you want to pad them in with a default date value?
11:34seangrov`Bodil: Might be irresponsible for me to spend more than a month in Europe, what with this whole "job" thing :)
11:34seangrov`But I did see it, and if it were one week earlier, I would go
11:34Bodilseangrov`: Ah, well, Clojure/conj? :)
11:35lgs32asince today i cannot import anything from sun.jvmstat.monitor package anymore, on openjdk
11:35lgs32ai even tried it with a different user on my system with a blank leiningen project
11:35lgs32athe package is gone
11:36seangrov`Bodil: Yes, that seems reasonable. I'll add it to my calendar and look at tickets
11:36lgs32ais this related to some leiningen update? can anyone confirm?
11:38anildigitalI am solving this http://www.4clojure.com/problem/99 here is solution of mine .. but why is it not working https://gist.github.com/anildigital/5035a058027e878fe3d6
11:38anildigitallooks correct to me.. but 4clojure is saying
11:38anildigitalYou tripped the alarm! def is bad!
11:39hyPiRionanildigital: you're not allowed to use def.
11:39noncomlgs32a: do you get an error message?
11:39ToxicFroganildigital: don't use def/defn. Like it says, the code needs to fill in the blank - it needs to be something you can splice into the code given.
11:39anildigitalhyPiRion: then?
11:39anildigitalToxicFrog: okay let me try
11:39hyPiRionanildigital: make an expression returning a fn
11:40lgs32anoncom: (import
11:40lgs32a '[sun.jvmstat.monitor MonitoredHost]) ==>
11:40lgs32a ClassNotFoundException sun.jvmstat.monitor.MonitoredHost java.net.URLClassLoader$1.run (URLClassLoader.java:366)
11:40noncomlgs32a: and your IDE is?
11:40lgs32aemacs/nrepl
11:40lgs32ai tried it in a plain lein repl as well
11:41dnolenlgs32a: I doubt it, http://stackoverflow.com/questions/6196984/how-do-i-include-jvmstat
11:41Denommushm, it seems the newer version of lein droid already creates a splash activity for me. Great :D
11:41DenommusI just... don't know where the source code is
11:41lgs32adnolen: thanks
11:41anildigitalhyPiRion, ToxicFrog thanks
11:42noncomjarfinder is cool
11:42lgs32adnolen: i already found this but the strange thing is that until yesterday it worked
11:42hyPiRionlgs32a: did you update the jdk version of yours?
11:43lgs32ano
11:43lgs32ai changed nothing
11:43lgs32amaybe leiningen updated itself or some other library
11:43hyPiRionNo, leiningen doesn't update itself
11:43lgs32ahmmmm
11:43hyPiRionIt pulls snapshots daily though
11:44lgs32ais it possible to add tools.jar globally in profiles.clj?
11:44ToxicFrogThis is probably not the best way to do it: (fn [x y] (->> [x y] (apply *) str vec (map int) (map #(- % (int \0)))))
11:44ToxicFrogWhat's the good way to turn \1 into "1"? (int ...) is a ClassCastException.
11:44hyPiRionToxicFrog: str
11:45ToxicFrogWait, sorry, wrong question
11:45ToxicFrog\1 into 1
11:45ToxicFrog(int ...) returns the character code, (int (str ...)) is a ClassCastException.
11:45solussdhrm.. clojurescript doesn't have 'extends?'. How do you check to see if a record type extends a particular protocol?
11:45hyPiRionToxicFrog: (- (int char) 48)
11:45ToxicFrogWell yes, that's basically what I'm doing there
11:45ToxicFrogIt seems like there should be a better way, though.
11:45hyPiRion(48 is the 0 char)
11:46ToxicFrogThat doesn't e.g. rely on being in a character set where the digits are contiguous and start with 0.
11:46ToxicFrogYes, I know, there's a (map #(- % (int \0))) right there
11:46hyPiRionToxicFrog: well, you could use a map if you wanted to
11:46hyPiRion{\0 0, \1 1, \2 2} etc
11:46`cbpToxicFrog: I've never seen a 'better' way unless its some dumb trick like js's +
11:46ToxicFrogIt seems like there should be a general, character-set-independent function for "turn a char or str into the int it represents"
11:47ToxicFrogA la lua's tonumber(), or C's atol()
11:47hyPiRion(comp read-string str) does the job then
11:47solussdparseInteger?
11:47ToxicFrogsolussd: where is that?
11:47hyPiRionsolussd: no, that's too hard.
11:47hyPiRionToxicFrog: Integer/parseInt
11:48solussdthere we go
11:48ToxicFrogOh, it's in Java.
11:48ToxicFrogThat explains why I couldn't find it.
11:48solussdand in javascript
11:48`cbpToxicFrog: you cant parseInt a char though
11:49ToxicFrog`cbp: you can ->> the-char str parseInt, though
11:49ToxicFrogWhich I find less ugly than subtracting \0 from it
11:49tbaldridgeToxicFrog: ick
11:49solussd(Integer/parseInt (str mychar)) ? :)
11:49jamiiSurprised to find that (instance? Foo x) is significantly faster than (= Foo (class x))
11:49solussdoh, wait, brb
11:49`cbpyou have weird taste imho :-)
11:49ToxicFrogtbaldridge: well, in this case it's part of a longer ->> chain
11:49dnolenjamii: = is equiv, it'll do an identity check but slow for the failed case (bunch of other checks)
11:49ToxicFrogIf it were just that I'd probably (parseInt (str the-char))
11:50dnolenjamii: use identical?
11:50ToxicFrogThat said, I do like the whole -> family for making things more readable.
11:50jamiidnolen: ah, will try that
11:50tbaldridgeToxicFrog: char num to string:
11:50tbaldridge,(- (int \0) 48)
11:50clojurebot0
11:50tbaldridge,(- (int \4) 48)
11:50clojurebot4
11:51ToxicFrogtbaldridge: we just went over this twice
11:51`cbpHe says that's too ugly
11:51solussdToxicFrog: how about this? https://www.refheap.com/18031
11:51tbaldridgeToxicFrog: ah, didn't see the history.
11:51ToxicFrogNot only is it ugly, it relies on the characters being in a character set where digits are contiguous and ascending from 0.
11:51jamiidnolen: I remember testing the same thing last year in core.logic (closed dispatch on type) but I don't remember what won...
11:51ToxicFrogInteger/parseInt is what I was looking for.
11:51TimMc,(Integer/parseInt "८९")
11:51clojurebot89
11:51tbaldridgeStill, a char is a integer, just do simple math, simpler cleaner, etc.
11:52TimMc^ parseInt also does that
11:52ToxicFrogI just couldn't find it because I was looking for a Clojure function rather than a Java one. That's all.
11:52dnolenjamii: probably best to use instance? or something similar if you can
11:52TimMcWhether you see that as a positive or a negative is unclear.
11:52ToxicFrogtbaldridge: simple math that gets you nonsensical results as soon as you're working in something not ASCII-compatible!
11:53tbaldridgeToxicFrog: true, I don't often work with non ASCII numbers, actually I don't do it at all, so I am biased in that respect.
11:53nDuff...anyone have a feel for whether/when rhickey will be merging feature expressions?
11:53tbaldridgeGlad you found a solution
11:53jamiidnolen: it does look like that is the fastest. I guess its pretty heavily optimised in the jvm
11:53tbaldridgenDuff: There was some talk about it a few months ago, then we got a bit tied up with core.async, haven't heard about it since. Also I'm not sure anyone fully likes any of the ideas.
11:54ToxicFrogIn other news: is there a reason that :require/:use aren't overloaded to support Java classloading as well, instead having :import instead?
11:54tbaldridgenDuff: I think everyone involved in that confluence page is hoping a better solution appears, as they all have some rather serious drawbacks
11:55tbaldridgeToxicFrog: don't complect things? :-P
11:55ambrosebsnot *more* features for use :)
11:55nDufftbaldridge: *nod*. Reader macros aren't so great for tools that round-trip code, either, which makes me somewhat unhappy with that proposal too. Unfortunately, _not_ having any solution in place at all is arguably worse than having something with significant flaws.
11:56ToxicFrogambrosebs: it's more that if I :require foo.bar, I would expect that to work whether foo.bar is a clojure or a java package.
11:57ambrosebsclojure and java packages have different syntax, which is probably why they are separated.
11:57tbaldridgeToxicFrog: the mechanics of the two are completely different, I prefer to have more control over what happens, if I don't want the interface a protocol defines, I simply don't import it.
11:59scriptortrying to get a basic understanding of protocol internals
11:59scriptorwhen you call defprotocol, does clojure generate a dispatch function for each protocol function you declare?
12:01tbaldridgescriptor: yes. It also creates a Java interface that types can inherit for super fast dispatch, and the functions also look at an internal hashmap for fallback in cases where you extend-type after the type has been created. There is also magic that makes all this work with excellent performance.
12:02scriptorit's that magic that's intriguing the hell out of me :)
12:03scriptorI figure with the internal hashmap a new entry gets added for each new type, function-implementation pair added via extend-type
12:06degcemerick: ping?
12:07cemerickdeg: maybe-pong
12:07degRe the pprng/cljsbuild issue (https://github.com/cemerick/pprng/issues/1 for lurkers)... So, what's best practice until the cljsbuild issue is resolved? Remove the libs line and copy the js file into my project for now?
12:08cemerickdeg: either that or don't run auto
12:09degYou mentioned that you had removed the lib line altogether from your projects. That would break things even without auto.
12:09rurumateHi, when I do (let [[a b] x] (if (= 1 a) "a is 1" [a b]), will a new vector [a b] get created in the else case, or is the compiler smart enough to reuse the input?
12:10rurumateoops, seems like it needs another bracket
12:12rurumateI mean, this: (let [[a b] [2 2]] (if (= 1 a) "a is 1" [a b]))
12:12cemerickdeg: I meant, from a project that wasn't using pprng or otherwise required :libs at all.
12:12rurumateit will return [2 2], but was a new vector created or was the input reused?
12:12`cbprurumate: (let [[a b :as y] x] ... y)
12:13cemerickI had blindly copied it over from a prior project.clj in that case
12:13rurumate`cbp: ok nice
12:13`cbpoh wait nevermind im wrong
12:14squidz_at_workdnolen: yes they may not have the same number of enttires, and in that case i want to create additional maps for those groups so that each group has the same number
12:15degcemerick: Ah, ok. So for now, I can either copy the lib or deal with slowness and no auto. Both are acceptable for the now. I had just hoped you had some magic bullet. Ah well.
12:15cemerickdeg: nope. I'll see about getting a fix into cljsbuild shortly.
12:16`cbprurumate: well you can use that in your [2 2] example, but if you have x then the y is redundant :-P
12:16dnolenscriptor: there's also call site caching for protocol fns to avoid hash table lookups.
12:16squidz_at_workdnolen: so that for each group there is a map for each date
12:16squidz_at_workand in the cases where a map is created the value be set to 0
12:18squidz_at_workwhich is what that first function does in http://jsfiddle.net/N4E5c/ but i'm not sure how to translate that to clojurescript
12:19squidz_at_workdnolen: sorry here is the correct link http://jsfiddle.net/N4E5c/3/
12:24ucbcallen: ping
12:39anildigitalwhat's wrong with this code https://gist.github.com/anildigital/830d565a5e05c911b972
12:39anildigitalnot compiling as expected
12:40bbloomanildigital: would help if you said what is expected and what you're actually getting
12:42anildigitalClassCastException java.lang.String cannot be cast to clojure.lang.IFn bob/response-for (bob.clj:5)
12:42anildigitalbbloom: ^
12:42bbloomanildigital: that's what i expected :-) but trying to teach a man to fish here
12:42bbloomanildigital: that error is saying that you have a string where the runtime expects an IFn
12:42nDuffanildigital: well, ("foo") is trying to call "foo" as a function.
12:42rasmustoanildigital: it's trying to call "Tom-ay-to, tom-aaaah-to." as a function apparantly
12:42coventryanildigital: What do you want ("Tom-ay-to, tom-aaaah-to.") to do?
12:43bbloomnDuff: shhhh trying to help him help himself :-)
12:44coventryMaybe you want (println "Tom-ay-to, tom-aaaah-to.")?
12:45cmajor7anildigital: ("Tom-ay-to, tom-aaaah-to.") is interpreted as function
12:45cmajor7anildigital: but it is in fact a string
12:45anildigitalbbloom: return as string
12:45coventryIf you want it to return that string, just take it out of the list it's in.
12:45bbloomanildigital: parens, generally, mean to call a function
12:45cmajor7anildigital: (defn response-for [input] (when (= input "Whatever.") "Tom-ay-to, tom-aaaah-to."))
12:45coventryI.e., ("Tom-ay-to, tom-aaaah-to.") => "Tom-ay-to, tom-aaaah-to."
12:46anildigitalcmajor7: thanks
12:47anildigitalbbloom: thanks.. I though something in parens get returned as it is
12:47coventryWhat can I use to get a parse tree of a clojure form prior processing of reader macros like backticks?
12:47coventrys/prior/prior to/
12:47bbloomcoventry: tools.reader, probably
12:49hiredmanbbloom: I doubt it
12:49coventrytools.reader.read is great for mimicking the results of the clojure reader, but I am not sure how to turn off the reader macros. Is there a way to reach into the tools.reader ns and monkeypatch private fns like read-syntax-quote?
12:49bbloomhiredman: i thought Bronsa made the quasi-quote a dynamic function you could configure & just replace w/ identity
12:49bbloomor maybe i imagined that
12:51coventrybbloom: I could certainly do that if I copy-and-pasted the library and monkeypatched it. Is there a less icky way to achieve the same result?
12:51bbloomcoventry: contribute a patch to parameterize it? :-) I think just throwing a ^:dynamic on that function & making it part of the API would pretty much solve the issue
12:52coventryThanks for the suggestion, I'll try that.
12:55coventryActually, I think the structure to make dynamic is probably the dispatch functions `macros` and `dispatch-macros`.
12:56coventry(or something like that.)
12:59dnolensquidz_at_work: so you're actually trying to port this to D3 using CLJS? You will have to do some data conversions.
13:04Bronsabbloom: there never was such a thing in tools.reader, you must have imagined it
13:04bbloomBronsa: you should add that :-)
13:04squidz_at_workdnolen: i'm using the strokes library which takes care of converting for me
13:06Bronsabbloom: it's probably best to make `macros` dynamic then
13:07bbloomBronsa: i'll assume that's a map of reader macros? i haven't studied the source closely
13:07Bronsathat's where the dispatch happens, not a map but a case for performance
13:07coventryIt's a function with a case switch, which I was thinking could easily be made to depend on a configurable map instead. (But maybe that's not the best idea.)
13:09ownatikHow should I store global config that I want accessible across multiple namespaces?
13:09ownatikatom?
13:09nDuffownatik: ...well, it's ideal not to do that. :)
13:10nDuffownatik: a dynamic var probably makes more sense than an atom.
13:10ownatiknDuff: Im actually looking for the ideal way :)
13:10dnolencemerick: are you planning on bumping lein-cljsbuild to the latest release? it seems that lein-cljsbuild actually needs to be kept in sync for browser REPL. Probably best to just remove the dependency as I'd suggested in the past.
13:11ownatikpassing the configuration data from functions to function does not seem very clean in my current application state.
13:12`cbpownatik: I'd say that is cleaner than global state and you can use partial to set some defaults, otherwise a dynamic var or atom are fine if they are supposed to change
13:13ownatikthey are not supposed to change .... I will be storing command line arguments in there.
13:15`cbpownatik: then just use a dynamic var if you feel its too cumbersome to pass values or use partial. Extra argument passing is normal in functional programming though.
13:33seangrov``cbp ownatik: referential transparency and all that
13:37justin_smithis clojure-clr actually usable?
13:39nDuffjustin_smith: it was originally a first-tier implementation, maintained in lockstep with Clojure for the JVM.
13:39justin_smithhow out of step is it?
13:39nDuffHard to say. The language hasn't been moving _that_ quickly, though, so I'd expect it to be thoroughly usable still.
13:40justin_smithI may consider using it for stuff where the spin up time of the jvm is a nogo
13:45justin_smiththe github page does not mention a version, and the references to the jvm in the changelog confuse me (copy paste error?) https://github.com/clojure/clojure-clr/blob/master/changes.md
13:55seangrov`Ok, found a hackish-way to get the constants table output at the right location, more of the cljs test suite passes now
13:57eric_normandclojure error messages!
13:58eric_normanddoesn't even tell me what file it's in
13:59mabeseric_normand: are you printing the full stack trace?
13:59eric_normandyes
14:00eric_normandI believe so
14:00eric_normandit's a compiler error
14:00mabes,(doc pst)
14:00clojurebot"([] [e-or-depth] [e depth]); Prints a stack trace of the exception, to the depth requested. If none supplied, uses the root cause of the most recent repl exception (*e), and a depth of 12."
14:00mabesyeah, compiler errors can be tricky at time but they generally have some hint as to what file caused the problem
14:00eric_normandI'm definitely seeing that one of the imports of a particular file is failing to compile
14:01eric_normandbut not which required file it is
14:01eric_normandmabes: but I found it
14:01eric_normandmabes: I had only edited a few files before compiling
14:01mabeseric_normand: yeah, I am typically compiling as I go so the problem is obvious when I see it
14:02eric_normandmabes: me, too
14:02eric_normandmabes: I usually have nrepl open to compile to
14:02eric_normandmabes: this time, no
14:16swarthy_Any chance that was answered when I disconnected?
14:34justin_s`After finding the latest clojure-clr download (1.4.1) and getting mono up and running; the start time is significantly better but not great, ram usage is quite a bit lower
14:34callenjustin_s`: whyyyy?
14:34callenjustin_s`: java without -server is generally fast enough / good enough for me.
14:34callenin terms of start time, mem usage, etc.
14:34mdrogalistbaldridge: ping
14:34justin_s`mono interop has some interesting possibilities, and even on my beast of a multiprocessor laptop startup isn't transperent enough for, say, implementing command line utilities
14:35justin_smithalso, I have crusty old linux using friends who won't use clojure because of the mem footprint on their outdated computers, so an order of magnitude less memory used helps me spread the good word (if the ecosystem turns out to be usable)
14:36callenjustin_smith: use Drip.
14:36callenclojure llvm is probably the real path forward for command line utilities. technomancy sidesteps the problem with OCaml.
14:36technomancyjustin_smith: mono typically doesn't go over will with the crusty crowd =)
14:36justin_smithtechnomancy: true enough, but until a bare metal or llvm clojure is usable, it is worth looking at maybe
14:37tbaldridgemdrogalis: pong
14:37callenI don't know about that. Vala exists because crusty Linux/Gnome people didn't want to use mono for desktop and command line utilities.
14:37callenVala is a credible language for writing things like that, even if it doesn't suit my fascist FP preferences.
14:38mdrogalistbaldridge: Would you be able to do a small code review (~150 lines) sometime? I want to make sure I'm using core.async sanely. :)
14:38tbaldridgemdrogalis: sure, send it to my irc handle at gmail
14:39mdrogalistbaldridge: Thanks man :)
14:43coventryI'm trying to run a criterium benchmark, and with-progress-reporting is outputting a long string of messages like "classes loaded before 73864 iterations" every second or so, with the number of classes increasing by about 1000 for each message. Is this normal? It's taking forever.
14:43coventry(And this is with quick-bench.)
14:44hiredmancoventry: are you calling eval?
14:44coventryYes.
14:45hiredmaneval generates classes, new classes being loaded can change runtimes (the jit does class hierarchy analysis and new classes loading can cause deoptimizations, etc)
14:45hiredmannot sure if cirterium restarts the benchmarck in that case
14:47ToxicFrogcallen: so I watched the infoQ talk and that actually did help a lot, thanks.
14:47coventryhiredman: Thanks, I test that out.
14:49callenToxicFrog: Good. :)
14:51cemerickis anyone having any luck using Firefox with any browser-REPL impl?
14:51cemerickClearly, I've been using Chrome exclusively for too long. :-/
14:53malyncemerick: Yeah, Firefox is the main browser that I use with the REPL.
14:53cemerickmalyn: OK, thanks. Maybe something is wrong in my env. Which version?
14:54nDuff(noscripts? adblock? ...?)
14:55malyncemerick: Hmm... I just picked up a Firefox upgrade (23) and haven't tried with that one. Definitely worked with the previous one (22, I guess?) though.
14:55cemericknDuff: flashblock is the only intrusive thing I have installed
14:55kmicucemerick: no problems with bREPL in conkeror (xulrunner/gecko) from version 22.0 to 25.0
14:55cemerickkmicu: nice, thanks.
14:56malyncemerick: What problem(s) are you having?
14:59kmicuSome problems with cljs/pedestal rendering code, but not with REPL
14:59cemerickkmicu: seems like simple connection failure. I haven't dug into what's going on with the x-page channel yet.
15:01seangrov`jesus christ, the never-ending chained ternary conditions cljs generates are unpleasant to look at
15:02TimMcI ? don't : know ? what : your ? problem : is ;
15:03seangrov`TimMc: Thinking on it for a minute, I'm not sure it's any worse than endlessly nested if/else's
15:06pandeirocemerick: i have often screwed up the repl URL by forgetting to append '/repl' to the host & port...
15:06cemerickpandeiro: nah, I have that all automated
15:08callenTimMc: wars have been fought over less than that.
15:11dnolenseangrov`: that's artifact of Closure
15:11dnolenseangrov`: it's rare for CLJS to emit those, can only be done in a statement context
15:56kmerzhi
15:56dobry-denhttps://github.com/magomimmo/modern-cljs is amazing
15:58coventryFor the sake of speed, clojure.tools.reader has a case statement switching on characters. It would be ugly to replace that with a HashMap<Character, Object> for the sake of configurability while preserving speed, right? How do you say "new HashMap<Character, Object>();" in clojure, anyway?
15:58stuartsierracoventry: Clojure's `case` is essentially that.
15:59stuartsierrai.e. a hash map.
16:02coventrystuartsierra: Oh, interesting.
16:04amalloycoventry: new HashMap<Character, Object>() => {}
16:05amalloyor (HashMap.) if you're really set on using a mutable map
16:06coventryamalloy: But Clojure's hashes can take arbitrary keys. I thought a HashMap<Character, Object> would have faster lookups.
16:06amalloycoventry: that's nonsense
16:07amalloyHashMap<X,Y>() is just HashMap<Object,Object>() with some casts automatically thrown in by the compiler
16:07stuartsierracoventry, amalloy: It's not necessarily nonsense, just not relevant in the context of the JVM.
16:08stuartsierraJava collections are weakly-typed.
16:09coventryThanks, I went down the wrong path, then. What I meant is something which would take advantage of the fact that all the keys are characters to give fast lookup times. An array 256 elements long would work just as well, I suppose.
16:09amalloycoventry: s/256/65536?
16:09amalloya character is two bytes
16:11coventryI was assuming all of the reader macro characters are ascii.
16:11tbaldridgecoventry: they are, the two byte character thing doesn't matter in this case
16:13tbaldridgecoventry: the java version of the reader uses an array : https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L59
16:13stuartsierraIn theory, you could make some clever hack that takes advantage of the small key space, but it would have to be really clever to beat a hash map.
16:13tbaldridgecoventry: but in some cases, the JVM may actually compile the case statement down to a jump table, so I'm not sure that it matters in the end
16:13clj_newb_2345I recently swithced from Vim to Emacs-Live for clojure development. Despite all the cool config options of Emacs-Live, anyone else find Emacs-live to be really slow / laggy?
16:14technomancyclj_newb_2345: probably auto-complete
16:14technomancybut that's the problem with starter-kit-like stuff, it's very difficult to tell where the problem comes from
16:15coventryThanks for the patient explanations, everyone. I think I've thought of a less ugly way.
16:17ozzloyis there a way to import a maven based project as a lib for use in a leiningen project?
16:18ozzloyi could swear i had seen an example of this before, but now i can't find it. specifically, i have a clojure project and i want to use hapi to generate hl7 messages http://hl7api.sourceforge.net/
16:19llasramozzloy: You just depend on the repository-deployed artifacts
16:20stuartsierraIt looks like `case` will compile into a jump table when possible: https://github.com/clojure/clojure/blob/229bf8fe9a751e4f48bb2b7ea57e27ebc43d26ae/src/jvm/clojure/lang/Compiler.java#L8128
16:20llasramozzloy: Looks to be in maven central. You should just need to add [ca.uhn.hapi/hapi "2.1] to your :dependencies
16:20llasram(or whichever the correct specific artifact is)
16:21ozzloyer... so i would add a line to project.clj like :dependencies [...[ca.uhn.hapi/hapi-base "2.1"]... ?
16:21ozzloy(according to http://hl7api.sourceforge.net/getting_started.html&quot;
16:21llasramYep, exactly
16:21ozzloyllasram, cool, i'll give that a shot
16:24dnolenstuartsierra: looks like only for integers and keyword - which excluded characters.
16:25dnolenBronsa: I wonder if that means it would be faster to use condp + identical?
16:26stuartsierradnolen: Unless you treat characters as integers! https://github.com/clojure/data.json/blob/1b0d829077f607ead37269f78fd6f04a3b2462d7/src/main/clojure/clojure/data/json.clj#L39-L57
16:26dnolenstuartsierra: aha! nice :)
16:28Bronsadnolen: I'll check if case+converting the chars to int speeds up
16:29coventrydnolen: as far as I know, Bronsa is happy with the efficiency of the current case statement. I'm trying to arrange things so that the dispatch on reader-macro characters is configurable by users of the library. It would be natural to make the dispatch functions maps, but Bronsa says he chose functions with case statements because it's faster.
16:29stuartsierraProfile, profile, profile!
16:30coventrySo I was trying to devise a way which would make it configurable and keep the current speed.
16:31Bronsacoventry: I'm happy to take a patch if the performance penalty is not significant
16:33stuartsierraWhy should the reader macro dispatch characters be configurable?
16:33tbaldridgecoventry: why are we trying to make the reader configurable?
16:34stuartsierratbaldridge: Ha!
16:37ozzloyllasram, thanks!
16:37jtoywhat kind of object is 699N ?
16:37ozzloyllasram, that totally worked
16:37coventrystuartsierra, tbaldridge: Because I would like to get the parse tree of clojure forms prior to modifications by reader macros. This is for making something like edebug or tools.trace which can do sensible things with macros without being told how to, by using the location metadata tools.reader's indexing readers put on the symbols it returns. I want the unmodified parse tree so that I can compute the MST of the symbols in the current
16:37coventryform.
16:37ozzloyi should have just tried that
16:38jtoyBigInt
16:38coventry,(class 699N)
16:38clojurebotclojure.lang.BigInt
16:38jtoywhat is N here mean though?
16:39stuartsierracoventry: OK, fair enough. But that probably constitutes a completely new parser.
16:40justin_smith,(class 699L)
16:40clojurebot#<NumberFormatException java.lang.NumberFormatException: Invalid number: 699L>
16:40justin_smithoops
16:40stuartsierracoventry: I believe Christophe Grande has done some work in this area: https://github.com/cgrand/sjacket
16:41coventrystuartsierra: Awesome, thank you.
16:41stuartsierracoventry: You're welcome.
16:50gtrakhas anyone a macro that lets you use 'clojure.test/is' in utility functions but transfers the reporting bits to the calling stack frame? I'm about to write one.
16:51gtrakI keep writing assertions macros that could be functions except for that reporting annoyance.
16:51gleagcoventry: I don't know much about clojure, but in most dialects of Lisp, when reader macros kick in, there's no parse tree yet, and vice versa, when you have a parse tree, all reader macros are already off for the weekend.
16:53coventrygleag: Yes, but a parse tree of the form prior to reader macro modification still might be useful in some circumstances, e.g. for development tools.
16:54gleagcoventry: the point is that reader macros are special in the sense that they don't operate on expression trees but on sequences of input characters.
16:54gleagWhich means that "a parse tree prior to reader macro modification" is something that never happens.
16:56Bronsastuartsierra: dnolen there seems to be no performance enhancement when using codepoint-case instead of case in tools.reader
16:56coventryNo, it never happens in the standard reader, but it's something you could construct independently, at least with the current set of reader macros, I think.
16:56stuartsierraBronsa: Interesting.
16:57gleagcoventry: i don't see how that would be possible. Once a piece of core receives a parse tree to operate on, it's not a reader macro anymore *by definition*.
16:57gleag"piece of code"...
16:58Bronsa(my test was `(dotimes [_ 10] (read-core.clj))`)
16:58stuartsierraBronsa: That's probably not enough for JVM optimizatiton.
16:58Bronsanot the best of benchmarks admittedly
16:58Bronsastuartsierra: do you think criterium will do?
16:58callenBronsa: use criterium.
16:59stuartsierraBronsa: Yes, also be careful to eliminate any startup-time optimization settings added by Leiningen.
16:59Bronsaok, so criterium + bare java -cp
16:59stuartsierraBronsa: That's pretty good, in my experience.
16:59coventrycallen, Bronsa: if you use criterium, you might have trouble using clojure/core. (See earlier IRC discussion with hiredman.)
17:00callencoventry: it's worked for the various template lib benchmarks I've done.
17:00coventrys|using clojure/core|using clojure/core for the test source code|
17:00tbaldridgecoventry: that's only if your lib is doing runtime code generation.
17:05gtrakanyone have any feelings about this clojure.test hack? give you control over file-and-line: https://gist.github.com/gtrak/6346408
17:05coventryI'm still not sure what the problem was, but I was benchmarking with (let [s (slurp "core.clj")] (bench (read-string s))) when I ran into that problem before.
17:07Bronsastuartsierra: no difference even with criterium (53ms vs 52ms)
17:07stuartsierraBronsa: Not terribly surprising.
17:07coventrygleag: Yes, this parse tree is not something I want to execute code from. I want to use it to map the forms in the macro expansion back to a form in the source by the taking the MST of the symbols they contain.
17:07BronsaI'll stick with clojure.core/case then
17:09tbaldridgeBronsa: I've been very happy with the performance of case, core.async abuses it to some extent, and yet I really can't find a faster int->code block dispatch.
17:10coventryBronsa: could you post read-core.clj, and the command you used to run it, please? I think it will be useful for me.
17:11Bronsacoventry: it's a silly script but here http://sprunge.us/WEbT
17:14hiredmanztellman: I would be very surprised if using a protocol like https://github.com/hiredman/tuples/blob/master/src/tuples/core.clj#L24 (and of course implementing it for your tuple type) didn't outperform using nth to access elements
17:15hiredmanztellman: of course you still need to implement nth for destructuring, but the getN functions give you something hotspot can easily optimize that sort of drops down under nth when you need peformance
17:15ztellmanhiredman: agreed, but the idea here was to make something that was a transparent stand-in for the existing sequence types
17:15ztellmanif I care about that, it's maybe easier to just create a deftype and use member accessors
17:16ztellmanwhich will be faster than a defprotocol invocation
17:16hiredmanztellman: but less generic, a protocol can be extend to other types as well, vectors for example
17:17ztellmanhiredman: but then get3 has inconsistent performance
17:17coventryBronsa: thanks. Do you know why that would work, but (bench (read-string s)) would fail because of class loading? Actually if you could show me the criterium harness and your command-line to invoke it, that would be useful, too. Today was the first time I used it. Sounds like it was a mistake to just run it in the repl, for starters.
17:17hiredmanztellman: nth has inconsistent performance
17:18hiredmannth is linear access on seqs
17:18ztellmanhiredman: absolutely, but it doesn't claim anything else
17:18ztellmanthis is "a faster nth, sometimes, maybe"
17:19hiredmanztellman: the use case I see for something like tuples is: oh I want something faster than vectors, ok swap in the tuples, ok I want to go faster still, oh I can switch to the tuple access protocol
17:19hiredman(which of course leaves out the smaller memory foot print for tuples)
17:19ztellmanright, but why extend the access protocol to vectors?
17:20ztellmaninlined interface calls are significantly faster
17:20ztellmanso you're sacrificing performance for the case where you want to switch from tuples back to a slower collection
17:20hugodcoventry: criterium tries to ensure that jit is completed, and checks for classloading as a sign that jit is still in progress - at present it does not support eval, etc
17:21hiredmanztellman: if you extend the protocol to the type inline it is an interface call with the little wrapper and cached callsite
17:21ztellmancached callsite ain't free
17:21hiredmanztellman: sure :)
17:22ztellmanif all the function is doing is returning a value, the difference shows
17:22hiredmanztellman: sure, but odds are if you are chasing speed you are doing more than that in your inner loop
17:23ztellmanhiredman: get0 by definition only returns a value
17:23ztellmanI'n not sure I follow
17:23ztellmanI'm*
17:23hiredmanztellman: yeah, but it is the protocol function, the callsite isn't in get0, it is in the client code that consumes it
17:24ztellmanit's still 1:1 with get0 invocation, right?
17:24ztellmanis there something clever being done that I'm unaware of?
17:25hiredmanztellman: well that depends what you mean by invocation(runtime function calls? function calls in the code), if you put get0 in a loop, you will get one callsite and multiple invocations at runtime
17:25coventryThanks, hugod. I'm trying to understand why Bronsa's (r/read (rt/string-push-back-reader (slurp "core.clj")) true nil true) doesn't trigger that issue, whereas my (r/read-string (slurp "core.clj")) does.
17:28hiredmanztellman: anyway, clj-tuple is a neat little library
17:28ztellmanhiredman: I had assumed the callsite lookup was once per invocation
17:29ztellmanI guess I need to look at that a bit more closely
17:29ztellmanand thanks, I didn't realize you had done something similar
17:29hiredmanmeh, just toying with the idea
17:31hiredmanactually amalloy did a pr switching the backing to an array which changed some performance characteristics
17:32hiredmanbut from the email it sounded like you had already looked at arrays instead of fields
17:34ztellmanhiredman: runtime function calls
17:35ztellmanoh, crap, had scrolled up
17:35ztellmanassumed that was a new message
18:18bjais there a -> variant that accepts a sequence of forms (and manually unrolls them before threading through)?
18:19scriptor,(-> 1 (+ 2) (+ 3))
18:19clojurebot6
18:19scriptor,(apply -> [1 '(+ 2) '(+ 3)])
18:19clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/->, compiling:(NO_SOURCE_PATH:0:0)>
18:19scriptorbleh
18:21`cbp`bja: I don't understand what you're asking, can you provide an example of what you want?
18:21`cbpwhat does unrolling a form mean?
18:21bja(-> 1 [inc inc inc])
18:22bjabasically
18:22bjaI have a sequence of functions that I'd like to thread through
18:22hyPiRionbja: closest is possibly thrush, which is just (defn trush [init & fns] (reduce #(%2 %1) init fns))
18:22hyPiRion$google thrush fogus
18:22lazybot[fogus: Thrush in Clojure – Redux] http://blog.fogus.me/2010/09/28/thrush-in-clojure-redux/
18:23scriptor-> is a macro, so if the sequence is generated at runtime it wouldn't work
18:24justin_smithscriptor: that is why thrush probably does what you want
18:24scriptoryep
18:24justin_smithit just doesn't do the magic argument insertion, which will require some refactoring
18:24`cbpbja: maybe (apply comp (reverse fns)) ?
18:29coventryI think I was getting that criterium failure because I was running it under a lein repl. My script runs fine under Bronsa's framework.
18:41bjahttps://gist.github.com/b018da2c94f5d4b9d9d7
18:41bjathat is essentially what I'm after
18:41bjaperhaps with (list ...) replaced with a literal quoted list or a vector
18:43bbloomi've been reading haskell for years, and yet somehow i find it easier to read an obscure dialect of scheme nobody has ever used than i find it to read haskell
18:44`cbpbja: is there any special reason you need a macro?
18:45bjaI was under the assumption that since -> existed as a macro, that doing nearly the same thing would also be. I don't want a macro. I was just curious if something already existed. The answer appears to be no.
18:47justin_smith(apply comp (reverse fns)) is smaller than many function names in competing languages :)
18:47benkaydoes anyone have tips to share on the topic of rendering clojure well in browsers?
18:48justin_smithyou could look into what 4clojure is using js wise
18:49`cbpor refheap
18:49justin_smithon 4clojure: code: https://www.4clojure.com/script/codebox__v2.0.0-rc1.js usage https://www.4clojure.com/script/foreclojure__v2.0.0-rc1.js
18:50justin_smithoh, nevermind the "code" link, that is wrong
18:51justin_smithhttp://codemirror.net/ it appears this is what they are using (it has a clojure mode) http://codemirror.net/mode/clojure/
18:51brehautcode mirror is pretty amazing
18:52justin_smithyeah, refheap uses codemirror too
18:52justin_smithlooks like that is likely the way to go
18:52patchworkbenkay: I am using SyntaxHighlighter with some success
18:53patchworkThough I also use codemirror in another project
18:53RaynesI don't use codemirror for code highlighting.
18:53patchworkCodemirror is actually an editor though
18:53RaynesI use it for the editor.
18:53RaynesYou *can* use it for highlighting though.
18:53patchworkRaynes: right
18:53RaynesI prefer to just shell out to pygments.
18:53RaynesPygments supports far more languages.
18:53patchworkRaynes: But that has a python dependency : (
18:53`cbp= (
18:53patchworkSyntaxHighlighter is all js
18:53Raynespatchwork: http://www.youtube.com/watch?v=DksSPZTZES0
18:54gtrakcan pygments run in jython? looks like it can: http://pygments.org/docs/java/
18:54patchworkRaynes: Ha! I would rather not run python every time I want to deploy my project
18:54patchworkgtrak: That would solve that
18:54Raynespatchwork: Are your code samples dynamic or static?
18:54RaynesIf they're static then you need to generate HTML with pygments exactly once.
18:55patchworkBut if they are dynamic… you need js
18:55RaynesNo you don't :p
18:55RaynesRefheap uses pygments and you can change pastes/add new ones/etc.
18:55RaynesIt just regenerates when it needs.
18:55patchworkIt is not compiling the html in the background?
18:55patchworkAha yeah
18:56patchworkBut if you don't want to have a python process running in the background on your server, then yeah
18:56patchworkyou need js
18:57benkaywell thanks y'all
18:58seangrov`dnolen: How do you output debug statements when debugging core_test.cljs? I've caused a stack overflow somewhere, but it's nmot easy to see where
18:59seangrov`Specifically for v8
19:02seangrov`I can set the d8 stack_trace_limit to 15000 and it works enough to find the line, but it's not ideal
19:02mikerodis there a good work around to clojure.walk/walk not throwing "UnsupportedOperationException Can't create empty:" when a Symbol referencing an IRecord is found in the nested structure?
19:03mikerodI see this https://github.com/stuartsierra/clojure.walk2 exists, but has not replaced clojure.walk yet.
19:06bbloommikerod: the usage of the extend function in that code makes me happy
19:08mikerodbbloom: are you referring to extend in clojure.walk2? I agree it looks to be a better implementation of clojure.walk.
19:08bbloommikerod: well stuart wrote the first walk too, i believe :-)
19:08mikerodI'd prefer to not have to take on this additional dependency in my current project though.
19:08mikerodI think I remember reading that he wrote the first one.
19:09bbloommikerod: but i was making a more general comment that i like the "extend" function as opposed to macros that expand to extend-type or extend-protocol
19:09Bronsathere's still hope with http://dev.clojure.org/jira/browse/CLJ-1239
19:10seangrov`Hrm, something about Keyword$IEquiv is causing a stack overflow when building BitmapIndexedNode
19:10mikerodI saw these related jiras. I wished they'd be accepted :P
19:10mikerodbbloom: you like the usage of extend over extend-type and extend-protocol?
19:11mikerodI'm used to seeing the macro variants being used
19:11bbloommikerod: extend-type and extend-protocol are syntax, they are macros. they are appropriate for that use. but here, he's using doseq over a vector of types & calling a *function* not a macro
19:12bbloomdnolen: ^^ that's why we need extend in cljs :-)
19:13mikerodbbloom: It looks like a clever approach to not repeating the walkt-transient on all the types that use it in the extend-protocol
19:14bbloommikerod: yup, that's exactly what it's for. but sadly you don't see it much b/c 1) most of clojure's internal abstractions are java interfaces and 2) extend isn't in cljs
19:15mikerodah, I see. sad indeed.
19:23Raynes$login
19:23lazybotYou've been logged in.
19:23Raynes$shell git pull
19:24RaynesHm.
19:24Raynes$shell git pull origin master
19:24lazybotUpdating 1d0a2f5..6c592a3 Fast-forward src/lazybot/plugins/seen.clj | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-)
19:24Raynes$reload
19:24RaynesI suck at configuring things.
19:25`cbpcheshire doesnt support joda.time.DateTime =(
19:26dakrone`cbp: it's easy to add your own encoders
19:26Raynes$reload
19:26lazybotReloaded successfully.
19:26RayneshyPiRion: Your change should be live now.
19:26dakrone`cbp: it doesn't by default because it would require bundling joda with cheshire
19:27hyPiRionRaynes: whoa what man
19:27RaynesNot going to bother converting the old nicks.
19:27hyPiRion$seen hypirion
19:27lazybothypirion was last seen talking on #clojure 44 milliseconds ago.
19:27`cbpdakrone: Oh I'll look up how to do that
19:27hyPiRionYou're damn fast
19:28dakrone`cbp: https://github.com/dakrone/cheshire#custom-encoders
19:28hyPiRion(inc Raynes)
19:28lazybot⇒ 36
19:29`cbpdakrone: thanks
19:34callendakrone: also I liked your alter-var-root for removing encoder protocol implementations :)
19:37dakronecallen: hah, thanks
19:42ddellacostaRaynes: <java idiot> upgrading from fs 1.2.x to most recent, I see temp-file args no longer contain directory. Can I set this, or is it best practice to assume java.io.tmpdir is where temp files should be going?</java idiot>
19:43Rayneswat
19:43Raynestemp-file shouldn't have changed since it was added.
19:43ddellacostareally? huh, wait a sec then, chances are I'm being stupid...
19:43Raynesddellacosta: I don't think it ever had a directory argument.
19:44Raynesddellacosta: However, it gets java.io.tmpdir every time so you can change that if necessary.
19:44ddellacostaRaynes: okay, thanks for the sanity check. Not sure what is up with this old crusty code I'm fixing up, but I didn't write it originally so don't know what the deal is.
19:45ddellacostaone of those, "it was working before" kinda dealies
19:45justin_smithis there a standalone nrepl client
19:46technomancyjustin_smith: working on it
19:46Raynesddellacosta: I'm stupid.
19:46ddellacostaRaynes: ?
19:46Raynesddellacosta: There was an old implementation that took directory.
19:46justin_smithlike say I have a long running process with an nrepl server, and I decide to connect to it to debug - is that only possible from within an editor? is there a standalone program? a way to make one nrepl actually send all commands to the other in a "sub repl"
19:46RaynesI just checked my git history.
19:46justin_smithtechnomancy: cool
19:47technomancyjustin_smith: I have a command that can send a single form
19:47Raynesddellacosta: I changed all of that around because there were race conditions and such.
19:47technomancyit's not so much of a repl as a rep
19:47justin_smithtechnomancy: I would like to see that
19:47ddellacostaRaynes: ah, so I'm not crazy. Well, it's no biggie, I just wanted to make sure I wasn't doing something stupid. Mostly I want to figure out the best thing to do in this particular case, which you answered my question regarding above. But thanks for checking. :-)
19:48technomancyjustin_smith: that said, you can use `lein repl :connect $PORT` and it works a lot better if you don't mind waiting for JVM startup
19:48justin_smithtechnomancy: that actually is acceptable
19:48muhoo`cbp: https://www.refheap.com/18049
19:49callenmuhoo: cool :)
19:49callen`cbp: any news on pomegranate/sync! ?
19:49callendid you look at the Ritz implementation?
19:49technomancyjustin_smith: that's probably for the best; then you don't have to spend half an hour installing ocaml compilers+libs
19:50danielszmulewicztechnomancy: when you type `lein run` just after `lein new app my-project` with no modification, you get the `hello world` string, but when you type `lein uberjar` and then run `java -jar standalone.jar`, you get class not found. Not what I expected. Is this by design?
19:51technomancydanielszmulewicz: hm; no, that's an oversight
19:51hyPiRiondanielszmulewicz: do `lein upgrade` :)
19:51technomancyit's missing both :main and :gen-class, the heck
19:52danielszmulewicztechnomancy: :gen-class is there, :main too
19:52technomancyoh, never mind
19:52`cbpcallen: from what I vaguely recall from 2 weeks ago Ritz only reloads the classpath and doesnt fetch any dependencies, also I don't think just reloading would work but I cant try in a couple hours
19:52technomancyI was invoking the default template
19:53hyPiRionoh, you silly sausage.
19:53danielszmulewiczLeiningen 2.3.1 on Java 1.6.0_51 Java HotSpot(TM) 64-Bit Server VM
19:53`cbpcallen: I'll work on it over the week promise! =P
19:53hyPiRiondanielszmulewicz: just upgrade to 2.3.2
19:53technomancythe app template is missing :aot though, which is silly
19:53`cbpI can try in a couple hours*
19:53danielszmulewicztechnomancy: oh, that's it, right, thanks.
19:55`cbpI need to reread the Ritz code so I can remember. Anyway be back in 1.5 hours
19:55callen`cbp: nuts @ Ritz. I'm grateful for anything you put into it, thank you! :)
19:56`cbpcallen: np
19:56`cbpmuhoo: thanks for the snippet
19:56hyPiRiontechnomancy: the app template has `:profiles {:uberjar {:aot :all}}`, doesn't it?
19:57technomancyhyPiRion: yeah, but it emits a warning because of :main nonetheless
19:58hyPiRionah
19:58technomancyit needs ^:skip-aot
19:58technomancynot :aot
20:00hyPiRionright
20:03danielszmulewiczhyPiRion: can I see somewhere an app template with the correct aot settings. I think it's possible to run into issues when using org.clojure/tools.namespace
20:03hyPiRiondanielszmulewicz: well, 2.3.2's `lein new app foobar` should work, even though there are some warnings during uberjaring
20:04danielszmulewicztechnomancy: aot disabled in dev profile, but enabled in production, is that right?
20:04technomancydanielszmulewicz: that's my recommendation, yeah
20:04technomancydanielszmulewicz: though you don't benefit from it unless you customize :target-path =\
20:05technomancy(see the end of `lein help faq`)
20:05hugod`cbp, callen: what's pomegranate/sync!?
20:05danielszmulewiczhyPiRion: thanks.
20:06danielszmulewicztechnomancy: thanks
20:09seangrov`dnolen: Ok, I have real keywords and the test suite passes on simple mode except for this test in spidermonkey: (assert (not (integer? 1e308)))
20:10danielszmulewiczhugod: have you seen this? https://github.com/cemerick/austin/issues/11
20:10seangrov`Looks like it works with advanced optimizations as well
20:10danielszmulewiczhugod: does it make sense?
20:11ddellacostaRaynes: on another note, fs seems to be barfing on the Java 7 (java.nio.file.Files and the like) import--I see there is a conditional import commit () but it's not released yet.
20:13hugoddanielszmulewicz: I'll try and take a look later
20:13danielszmulewiczhugod: sure.
20:15ddellacostaRaynes: ah, I see there is a 1.4.5 in clojars, never mind.
20:16callenhugod: "sync with project.clj"
20:16callenhugod: it was in my to-do list, but `cbp wanted something to do so I let him pick it off the queue.
20:16callenhugod: automatically downloads deps and syncs classpath with whatever is in project.clj
20:23seangrov`bbloom: Up for a code review for a cljs patch?
20:23bbloomseangrov`: um…. i've got about 15 minutes :-)
20:24seangrov`Heh, I'll commit and push if you wouldn't mind perusing
20:25bbloomsure, i'll do what i can before i gotta run to dinner
20:27seangrov`bbloom: https://github.com/sgrove/clojurescript/compare/real_keywords
20:28bbloomseangrov`: ooo interesting commit message. i'm interested….
20:28seangrov`dnolen asked to make this a configurable thing, which I suppose I really haven't done, on reflection
20:28bbloomwhy configurable? in what way?
20:28seangrov`The compiler/analyzer/closure stuff is configurable, but I've changed core.cljs so that it depends on real keywords
20:29seangrov`So you can keep the old "string as keywords" behavior if you don't want to switch over initially
20:29bbloomhmm… i'm not sure why we'd ever want to have both co-exist in the code base.. but ok… let me just check this out a bit
20:30seangrov`Example constants_table.js output - it's output after cljs.core, before any user code https://gist.github.com/sgrove/d139e439394689febbcd
20:30bbloomdoes core use those values?
20:30seangrov`All the tests pass and String.prototype no longer has .call or .apply
20:31seangrov`Yeah
20:31seangrov`But it's all late-binding, so it works ouyt
20:31bbloomok… good thing we made it so that core executes no code during bootstrap :-)
20:31bbloomthat was a tricky first step!
20:31seangrov`Exactly, was quite worried about that
20:31bbloomyeah, i think david & i got the last of that out of there a few months ago
20:32seangrov`Well, thank you, I had a difficult enough time as it was :)
20:32seangrov`Though this is definitely getting a lot easier
20:32bbloomdo you have a unit test for comparing & doing map look up with dynamic keywords?
20:32bbloomI dont see "(keyword " in this diff :-)
20:33seangrov`Hrm..
20:33bbloomalso, is the plan to support other types of constants too?
20:33seangrov`bbloom: I was supposed to support other constants, but I'm unclear on what they would be
20:33bbloomlike we wanted to get constant data structures too, which i think we annotated as :constant? or something like that
20:33seangrov`But they would fit in here pretty easily
20:33bbloommaybe you should break this patch up as follows:
20:34bbloomstep 1) constant table
20:34bbloomstep 2) reified keywords
20:34bbloom[1 2 3] should be a constant
20:34bbloominstead of inline construction of PersistentVector.fromArray[....
20:34bbloomwould be a HUGE perf win
20:34seangrov`Ah, interesting
20:34seangrov`Would be willing to tackle that later
20:34bbloomwould also be a much smaller patch
20:35bbloomso yeah, that's my feedback: 1) test the interaction between dynamic & static keywords. i suspect you have some major bugs there, just from my cursory glance at this
20:35seangrov`bbloom: So 1.) constants table would just be in the analyzer
20:36bbloom2) don't bother with #1 or reified keywords until after you do constant tables for already reified types (like symbols & collection types)
20:36seangrov`bbloom: You mean (= (keyword "a") :a)?
20:36bbloomseangrov`: yeah
20:36seangrov`Seems to work
20:36seangrov`It's in the test suite
20:36seangrov`The specific change being here https://github.com/sgrove/clojurescript/compare/real_keywords#L3R2049
20:36bbloomwhat about identical?
20:36bbloomright now, keywords are considered identical to each other
20:37bbloomb/c they use js string compare
20:37bbloomoooh you know what, you're also really lucky that we fixed PersistentArrayMap
20:37bbloomb/c ObjMap required keywords to be identical? for perf
20:37bbloomso it might not be an issue any more
20:38bbloombut yeah, start w/ the constant table w/o reifying keywords
20:38bbloomthat a bigger perf win than reified keywords are a usability win :-)
20:39bbloom& the patch should be a bit easier to review like that. it should be pretty easy for you to split out the keyword parts
20:39gfredericksTimMc: a generalization to what?
20:39lazybotjava.lang.RuntimeException: Unable to resolve symbol: the in this context
20:39bbloomanyway, i gotta run.
20:39bbloomseangrov`: cool stuff! thanks :-)
20:39seangrov`Thanks bbloom!
20:41seangrov`Ok, now I see the need for keyword-identical?
20:45gvickersHey guys, so I have a ref with a bunch of namespace names as symbols in it, each of them has function foo, is there any way to call foo on each of the namespaces?
20:46gfredericksyes.
20:46gfredericks(doseq [ns @my-ns's] ((resolve (symbol (name ns) "foo"))))
20:54hugodcallen: fwiw, alembic already has lein running in a classloader via classlojure - it should be straightforward to add it there
20:55rasmustogfredericks: that's cool. Is it common to have many namespaces that all have the same function like that?
20:57gfredericksrasmusto: I don't think so
20:57gvickersI have n number of plugins that will all have the same functions that can be called on them.
20:58gfredericksthere's usually a better data-oriented way to do abstraction like that than using namespaces for it
21:03rasmustogfredericks: I guess I have a weird case where I have a very similar function that needs to be called in my 'core' namespace, so now I have a list of each of them
21:10justin_smithwe had something similar with a web framework - the lib needs to know which initializations need to be applied to its data, so giving it a bunch of namespaces, from which it would call "init" in each one, seemed to make sense
21:14seangrov`,(let [m {"name" "test"}] ("name" m))
21:15clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
21:15seangrov`So, that may be a migration for people when moving to keywords
21:19gfredericksoh geez that works in clojurescript?
21:19seangrov`WOOOO
21:19seangrov`Rapportive + Zenbox work together now
21:20seangrov`ClojureScript is a much better citizen of the world now without the String.prototype modifications
21:20seangrov`gfredericks: Yeah
21:20gfredericksseangrov`: I think I patched underscore.js to be compatible with the String.prototype mugglings
21:20seangrov`But as a kind of accidental side-effect of Strings and keywords being conflated
21:21seangrov`gfredericks: Yeah, we don't have access to Rapportive's code, can't patch it at runtime, serving our own modified version would be a violation of ToS, and they won't change it for us
21:21seangrov`So only option is to get ClojureScript to behave properly
21:21gfrederickshttps://github.com/jashkenas/underscore/commit/2206092e25f66f3a0dbb05c24509a7831b1863fe
21:23seangrov`ah, from just method.call -> _.isFunction(method) ?
21:23gfrederickssomething like that, yeah
21:23gfredericksthey seemed to like the idea for unrelated reasons
21:23seangrov`Wouldn't that still cause "test" to be recognized as a fn though?
21:23gfredericksthe string "test"?
21:24gfredericksI think isFunction checks that the .prototype == Function
21:24seangrov`I see, ok
21:25seangrov`Phew, very happy that this change fixed the cause of the bug, would have been debilitating had it not
21:25seangrov`Should also fix cljs + dojo stuff, though I don't use any of those
21:32dissipatewhat's the best javascript framework to use with cljs?
21:33gfredericksto do what?
21:35dissipategfredericks, build a single page app
21:35devnweirdest application ive ever used: Argeïphontes Lyre
21:36devnwrong channel, sorry
21:38pandeirodissipate: i was reading something recently about using angular
21:40dissipatepandeiro, angularjs with cljs??
21:40lazybotdissipate: Uh, no. Why would you even ask?
21:40pandeirohttp://keminglabs.com/blog/
21:44pandeiroanyone gotten around to trying the new lighttable?
21:44dissipatepandeiro, that's nice, what about ext js?
21:45pandeirodissipate: not familiar but i think people have used it
21:45oakmacI have a question about recursion: http://pastebin.com/jeC1qAiK
21:45oakmacseems I can't call "new-position-id" at the end there
21:48dissipatepandeiro, not using EMACS? The treachery!
21:51pandeirodissipate: no I do use emacs but I have been interested in lighttable as a more 'web-native' tool
22:17muhoo(inc lazybot)
22:17lazybot⇒ 20
22:17muhoo(inc clojurebot)
22:17lazybot⇒ 31
22:18muhoo(inc inc)
22:18lazybot⇒ 3
22:31dissipate(inc def)
22:31lazybot⇒ 1
22:31dissipate(inc def)
22:31lazybot⇒ 2
22:58TimMcgfredericks: A generalization of "trampolining" with loop/recur and argument sets for the remainder of a computation.
22:59TimMcgfredericks: Probably monads or somesuch. :-P
23:39dnolenseangrov`:
23:39seangrov`Totally
23:40seangrov`Always strive to leave 'em speechless
23:40dnolenseangrov`: glad to hear you fixed that abomination, if you have a link to a squashed diff I can comment on changes, and then you can attach patch to ticket.
23:41seangrov`dnolen: https://github.com/sgrove/clojurescript/compare/real_keywords
23:41seangrov`Started looking into bbloom's suggestions, but it seems like it's a bit bigger than just initially getting keywords
23:42dnolenseangrov`: yes if you can squash that then I can comment on the whole commit.
23:42dnolenseangrov`: we can look into the bigger stuff later
23:42bbloomseangrov`: i was trying to suggest something *smaller* :-)
23:42dnolenseangrov`: keywords are critical.
23:43bbloomcan you produce a constant table of symbol objects? sure, they are far less used than keywords, but it would be a much smaller patch
23:43bbloombut i guess dnolen is the one to review & accept, so it's up to him
23:43seangrov`bbloom: But that doesn't help with the main problem I'm trying to solve
23:43seangrov`Happy to do it bit by bit though
23:44dnolenbbloom: I don't see how it would be smaller?
23:44dnolenseangrov`: glad to see you removed all the gnarly keyword special casing from the string related code.
23:45bbloomdnolen: he's detecting & emitting a constant table and ALSO reifying keywords at the same time. he could detect & emit constants, THEN reify them in two patches
23:45bbloomi like to have multi-commit patches in steps like that
23:45bbloommakes it easier for me to understand
23:45bbloombut you like squashed patches :-)
23:45dnolenbbloom: yes :)
23:45bbloom*shrug* you've got commit bit, not me
23:46bbloomif i had to review the patch, i'd probably do so by rebasing it in to two parts, lol
23:46bbloomi hate huge patches
23:46dnolenseangrov`: please squash those commits so I can comment on the whole thing.
23:46seangrov`How can I squash these commits so they can be commented on?
23:46seangrov`git merge --squash?
23:46bbloomseangrov`: no, you want rebase
23:46bbloomgit co my-branch
23:47bbloomer checkout
23:47bbloomgit checkout my-branch
23:47bbloomgit rebase --squash `git merge-base my-branch master`
23:48bbloomer nevermind
23:48bbloomi always do interactive
23:48bbloomapparently rebase has no --squash, only --interactive and --autosquash
23:48seangrov`Haha, just tried that, didn't quite work. I've avoided this for a long time
23:48bbloomso use merge, my bad :-P
23:48tbaldridgednolen: just fixed a core.async bug that would cause errors when someone generated tons of inactive handlers (via alts!). I don't think it'll impact performance much, but the commit is here: https://github.com/clojure/core.async/commit/70f45e939c889858b9263e5a1b3c9dfbd311ecf9
23:48bbloomlearning to use rebase, especially interactively, was LIFE CHANGING for me
23:49bbloomnow i use git to edit code almost as much as i use vim ;-)
23:49dnolenseangrov`: I just do it the poor mans way, new branch, rewind, recommit
23:49xeqiI usually use `git rebase -i master` and then mark them to be squashed
23:49bbloomxeqi: that's what i actually do, but -i requires you learn how to use that :-)
23:49bbloomwhich i highly recommend
23:49tbaldridgednolen: we have to run cleanup (we weren't before this patch). So I decided to add a counter and only run cleanup every 64 puts/takes.
23:49bbloomi have an alias for rebase -i w/ merge-base master
23:51dnolentbaldridge: gotcha, did someone run into this in practice?
23:52tbaldridgednolen: no, it was one of those moments when you wake up in the middle of the night and think "well crap, I just introduced that bug...".
23:52dnolentbaldridge: hehe, gotcha
23:55devnRecommended reading on distributed systems? Fault-tolerant systems? Things of that nature?
23:55tbaldridgedevn: anything by Joe Armstrong (if you haven't already)
23:56devntbaldridge: one cannot hear those phrases and think about anything than erlang.
23:56devnanything other than*
23:56hiredmanI suggest the letrec email
23:56devnhiredman: link?
23:57hiredmanhttp://erlang.org/pipermail/erlang-questions/2011-May/058768.html is pretty much my all time favorite email
23:57devnthanks hiredman