#clojure logs

2015-03-22

04:41aneis there a shorter way around this: (map (fn [sym] ((resolve sym) a b)) symbols)
04:42opqdonutwell you can always say (map #((resolve %) a b) symbols)
04:42opqdonutbut that's it I guess
04:47anehm, yes. so there's no handy "anti-quote" macrothing to do what resolve does?
04:50amalloyhow could it be a macro? you're asking it to operate on data the exists at runtime
04:52aneoh, not a macro
04:53opqdonutif you use quote, you'd have to couple it with eval
06:41dysfunwhat's the easiest way to deal with temporary file generation in clojure?
06:42dysfunhrm, me.raynes.fs looks easy enough
08:24spinningarrowThe docstring for empty? says to use seq instead of (not (empty? ...)) but seq doesn't return a boolean. So is that still the right approach when writing a predicate?
08:25Bronsaspinningarrow: clojure generally doesn't care about true/false, truthy/falsy is usually enough
08:25spinningarrowBronsa: so if a function returns truthy/falsy, it is still considered a predicate, I suppose?
08:26gfredericksyeah people do it all the time
08:26Bronsaspinningarrow: eh, no it's not strictly a predicate but we use it as a predicate all the time
08:27gfrederickshello Bronsa
08:27hyPiRionIt sort-of depends – I tend to be a bit careful about that
08:27hyPiRionget and nth may return nil, for instance
08:27spinningarrowah cool. Sorry if that was a stupid question, but I was doing a clojure course and the midje tests were explicitly checking if the predicate returned `true` or `false`. Was just wondering if that's common :)
08:27Bronsagfredericks: o/
08:27gfredericks\o
08:27hyPiRion(for correct lookups)
08:27hyPiRions/correct/successful/
08:28spinningarrowhyPiRion: yeah, that's a good point too!
08:31sahilexit
08:31spinningarrowso I guess that generally it's fine, but something to be careful about
08:45hyPiRionyeah, it depends on what the function can return
08:45hyPiRionyou might get false negatives
08:47gfredericks(defn does-has? "Returns :nope if m contains k and :yep otherwise." [m k] ...)
08:47gfredericksI think I got that backwards
08:49spinningarrowgfredericks: haha
08:50spinningarrowwell, thank you guys very much for all the clarification! I shall mess around some more in clojure-land gfredericks hyPiRion Bronsa
08:51hyPiRiongfredericks: just do (alter-var-root #'does-has? complement)
08:55gfrederickshyPiRion: no we're pretty much stuck with it; don't want to make breaking changes
08:55bcmspinningarrow: what clojure course is that?
08:55hyPiRiongfredericks: oh okay then
08:56spinningarrowIt's this one - 'Functional programming with Clojure' (http://mooc.fi/courses/2014/clojure/)
08:58bcmClojure is listed as an intermediate language. There isn't that much more to setup is there?
08:59bcmThis course looks pretty cool
08:59bcmreally well done use of bootstrap, too
09:49edeferiahi. question for the group: i would like know the most idiomatic way of doing the following: i have a list of functions (literaly as a list) and would like to use the thread macro on it. how?
09:50justin_smithedeferia: macros work before the compilation stage, they are not a runtime thing
09:51justin_smithif the list is known before runtime, you can make a macro that injects that list into a threading macro
09:51justin_smithotherwise, you can use reduce
09:51justin_smith(to get most of the same functionality, but at runtime)
09:51edeferiaah, got it. understand. so basically unroll the list in a macro that uses ->
09:51justin_smith`(-> ~x ~@fs)
09:52justin_smithinside a macro
09:52justin_smithbut only works if fs are known when compiling
09:52edeferiathey are.
09:52hyPiRionWell, if you have the list at compile time, why not write (-> x f-1 f-2 f-3) ?
09:53gfredericksyeah -> is more for readability; not so useful with macros
09:53hyPiRionOtherwise you can just use (defn thrush [x fs] (reduce #(%2 %1) x fs))
09:53edeferiahyPiRion: because although the list of functions is known, their sequence can change from call to call
09:54justin_smithhyPiRion: yeah, that was the reduce version I was suggesting above
09:54gfrederickscan't use -> then
09:54gfredericksor
09:54gfredericksum
09:54gfredericksdepends on what "call to call" means
09:55edeferiamultiple invocations of the equivalent of (-> init (…)) would have different ordered set of functions in (…)
09:56hyPiRionedeferia: I'd say to go with a function first (thrush), as justin_smith originally suggested.
09:56hyPiRionA macro won't give you any notable benefits here, at least not initially
09:56gfredericksand has drawbacks
09:56gfrederickslike it's tricky to reason about
09:56gfrederickscase in point, I still can't tell even with your last clarification whether this would work
09:57justin_smithright. The macro is helpful for readability, and using it programmatically like that avoids that benefit.
09:57edeferiaagree. thank you all for the assistance. i will try justin_smith’s suggestion. thanks again.
11:06Manaphy91Hi! Is there a way to create a non mutable tree, where nodes have parents and childs, with deftype?
11:07justin_smithManaphy91: doubly linked and immutable doesn't work
11:08justin_smithManaphy91: if you don't need parent links from the children, then yeah, you can do that with deftype
11:08Manaphy91mmmh, I suppose it but I would like to ask it for a confirm... I dont linke to use loking manually but I think it's what I will do...
11:08justin_smithloking?
11:08gfrederickslocking
11:08justin_smithwhy would you need to lock anything?
11:10Manaphy91I would like to use this structure concurrently.... I can use atom for a race safe access...
11:10justin_smithManaphy91: I thought you said it would be immutable
11:11Manaphy91Yes!!
11:11justin_smithOK, atoms don't use locking at all, and they wrap an immutable datatype
11:12Manaphy91Ok, thanks, I will try something!!
11:13hyPiRionManaphy91: bbloom had a talk on immutable graphs in Clojure: https://www.youtube.com/watch?v=YgvJqWiyMRY
11:14Manaphy91hyPiRion: Thanks!!
11:14hyPiRionat 6:10 specifically
12:22justin_smithhyPiRion: that bbloom talk is great, it makes me want to make an adjacency-list based follow up
12:23justin_smith(adjacency lists being a way to get a super general reification of traversal context, even handling cycles and cross references)
12:25hyPiRionyeah, it's good
12:34spradnyeshwhy do i see ***[org.clojure/tools.nrepl "0.2.6" :scope "test" :exclusions [[org.clojure/clojure]]]*** in "lein deps :tree" even though my project.clj explicitly lists ***[org.clojure/tools.nrepl "0.2.8"]*** as a dependency?
12:34justin_smithspradnyesh: put the tools.nrepl dep under :dev
12:35spradnyeshjustin_smith: thanks for the pointer, let me check that
12:35hyPiRionspradnyesh: because bugs
12:38spradnyeshjustin_smith: worked. thanks :)
13:15mmgI’m having some basic macro behavior that I don’t get and I’m trying to understand why. I started with a macro I didn’t expect to work but it’s failing in a way I wouldn’t have guessed:
13:15mmg(defmacro macro-foo
13:15mmg [should-run arg]
13:15mmg (when should-run arg))
13:15mmg=> (macroexpand '(macro-foo bar baz))
13:15mmgbaz
13:16mmgwhy does that just expand to baz when it can’t resolve bar at compile time?
13:16justin_smithbecause to the macro code, bar is a symbol
13:16justin_smithand symbols are truthy
13:16mmgoh....
13:16mmgthank you!
13:16justin_smith,(when 'ok :go)
13:17clojurebot:go
13:17mmgyeah I was thinking (when nil :go) => nil
13:17mmgI see what I did wrong now
13:17mmgthanks a ton
13:17justin_smithremember that a macro should return the form that you want to run
13:17mmgyeah, no I get that this was a dumb macro, I was just expecting failure to look different (shrug)
13:17mmgnow I get why ;)
13:17mmgthanks again
13:18justin_smithnp
13:19justin_smithamalloy: on the subject of bad commit histories, I have discovered that the combination of "git merge --no-commit" followed by cycles of "git add -p" and "git commit -m" is like magic
13:20amalloyhm. what is -m?
13:20amalloysomething merge-related, but...
13:20justin_smithamalloy: oh, sorry, just supplying a message on the command line
13:20amalloyoh haha
13:21amalloyso, i do cycles of add -p, commit -m all the time. how does it interact with merge no-commit?
13:21justin_smithso I run git add -p, and select a "themed" group of changes, then commit them together
13:21justin_smithit's like a retroactive cure for add
13:21justin_smithamalloy: merge --no-commit means you get all the changes from the other branch, but not its history
13:22amalloyah, i see now
13:22justin_smithso it's a way of rewriting the history of a series of messy changes because I have no attention span / focus
13:22justin_smithinto an alternate, coherent history
13:23amalloyi'm still not quite sure how you end up with those changes on an alternate branch that you want to merge
13:24justin_smithamalloy: getting mixed up in the development process, and when it comes time to make a pr I realize the history is a total mess
13:24amalloyjustin_smith: so you create another branch, and merge no-commit your disjointed changes?
13:25justin_smithright
13:25justin_smiththen I turn them into sensible commit history
13:25amalloyi would usually just git reset before-dumb-changes, rather than git checkout -b some-branch before-dumb-changes
13:25justin_smithaha, yeah I think as usual git has multiple paths to glory
13:25amalloyyeah
13:27justin_smithoh, yeah, there was actually a reset step in there anyway (between the merge --no-commit and the add-p)
13:27justin_smithbecause even without the commits, it still stages things, so I need to reset to unstage so I can do selective staging
13:28justin_smithoh wow, there is a "reset -p", combine that with "add -p" and you have a nice little choose your own adventure
13:30amalloyjustin_smith: also checkout -p
13:30justin_smithoh wow, nice
13:33Glenjamini really like "git cola" for that sort of stuff - Qt based gui around staging/unstaging/comitting
13:35oddcullyi use tig fiddling togetter proper commits. but i didn't knew about -p
13:35justin_smithmagit does some of that stuff too, but I end up preferring to just use the terminal
13:35justin_smithyeah, -p is like a repl for building commits
13:36Glenjamini dislike the linear nature of add -p
13:36justin_smithGlenjamin: like the way it gives you things in a predetermined order?
13:36Glenjaminguis are a bit better for random access, and easier to split hunks
13:36Glenjaminyes
13:37kwladykahello, i am learning clojure, can you tell me why in this function http://pastebin.com/zTzhVfUy is "when pred"? What is the prupose of this line?
13:37justin_smithkwladyka: if pred is nil or false, the next line does not run
13:37Glenjaminkwladyka: in that scenario, (when) is equivalent to (if)
13:37justin_smithwhen is like if but only one branch
13:38kwladykajustin_smith yes i understand that but why is that necessary? It is example form book, it is index-of-any
13:38justin_smithkwladyka: if pred was nil or false, the next line would throw an exception
13:38kwladykajustin_smith i uderstand technical aspect "when pred" but i don't undrestand why author wrote this line
13:38justin_smithyou'd have to look at the rest of the code to know why pred would be nil or false
13:39justin_smithI suspect index-filter is being called in a recursive context where pred might be updated on each loop, and might eventually be nil?
13:39justin_smithjust a guess
13:39kwladykahmm so in clojure there is no exception like try{} catch{} or something like that? Should i write in all places code prevent to exception?
13:39justin_smithkwladyka: there is
13:39justin_smithkwladyka: but that author is not using it
13:40kwladykaso it wouldnt be miskate if i dont write (when pred) in function like that? What is best pracice in clojure?
13:40justin_smithin general, exceptions (in any language) should be used for exceptional cases, not for control flow
13:41justin_smithwe also have things like some-> that do chaining that short circuits if you hit nil
13:41Glenjaminkwladyka: many core functions are written to behave without exception when they receive nil
13:41justin_smith(doc some)
13:41clojurebot"([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)"
13:41justin_smith(doc some->)
13:41Glenjamin,(get nil)
13:41clojurebot"([expr & forms]); When expr is not nil, threads it into the first form (via ->), and when that result is not nil, through the next etc"
13:41clojurebot#error{:cause "Wrong number of args (1) passed to: core/get", :via [{:type clojure.lang.ArityException, :message "Wrong number of args (1) passed to: core/get", :at [clojure.lang.AFn throwArity "AFn.java" 429]}], :trace [[clojure.lang.AFn throwArity "AFn.java" 429] [clojure.lang.AFn invoke "AFn.java" 32] [sandbox$eval69 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Compiler eval "Compiler.java" 6784] ...
13:41jdeisenbergIs there a way to specify the version of a template that you want to use in Leiningen?
13:41Glenjaminoh, whoops - bad example
13:42justin_smithjdeisenberg: no, a real peeve of mine actually
13:42justin_smith,(get nil :anything)
13:42clojurebotnil
13:42Glenjaminthat's what i meant :)
13:42Glenjaminclojure mostly gives you back nil instead of throwing null pointer exceptions
13:43jdeisenbergjustin_smith: Thanks. Maybe I should look at Leiningen and see if I can figure out how to add that. In my copious spare time, of course :)
13:43justin_smithhaha, of course
13:44kwladykaok so if i undrestand best practice in clojure is: if function can do what should do return value, in other case return nil?
13:44justin_smiththat's the usual thing, yeah
13:45jjttjjwhat are people's preferred clojure dynamoDB clients these days?
13:46jjttjj I guess I prefer operating on a higher level than having more fine tuned control, if that's a factor
13:46kwladykathx!
14:09geekyvin_Hey Guys, I've created a simple web-app in Clojure and deployed it in a remote server. but the problem is my application doesnt seem to serve resource files such as css/javascripts...etc. I couldnt figure out why.
14:09geekyvin_I tried jetty with nginx and tomcat7 with nginx
14:09geekyvin_this is my project.clj
14:09geekyvin_(defproject test_web_app "0.1.0-SNAPSHOT"
14:09geekyvin_ :description "FIXME: write description"
14:09geekyvin_ :url "http://example.com/FIXME"
14:09geekyvin_ :dependencies [[org.clojure/clojure "1.6.0"]
14:09geekyvin_ [compojure "1.1.6"]
14:09geekyvin_ [hiccup "1.0.5"]
14:09clojurebotIt's greek to me.
14:09geekyvin_ [ring-server "0.3.1"]]
14:09geekyvin_ :plugins [[lein-ring "0.8.12"]]
14:10geekyvin_ :ring {:handler test_web_app.handler/app
14:10justin_smithgeekyvin_: don't do that
14:10geekyvin_ :init test_web_app.handler/init
14:10geekyvin_ :destroy test_web_app.handler/destroy}
14:10justin_smithgeekyvin_: stop
14:10geekyvin_ :profiles
14:10geekyvin_ {:uberjar {:aot :all}
14:10geekyvin_ :production
14:10geekyvin_ {:ring
14:10geekyvin_ {:open-browser? false, :stacktraces? false, :auto-reload? false}}
14:10geekyvin_ :dev
14:10geekyvin_ {:dependencies [[ring-mock "0.1.5"] [ring/ring-devel "1.3.1"]]}})
14:10geekyvin_Opps...sry
14:10geekyvin_Opps...
14:10geekyvin_Oops..
14:10andyfGist or paste please
14:10justin_smithgeekyvin_: how are you accessing the resource files?
14:11geekyvin_its a simple web-app created with the command lein new compojure-app <web-app-name>
14:12justin_smithgeekyvin_: that didn't answer my question
14:12geekyvin_the statics files are called from html
14:12justin_smithwhat specifically is being done to fetch those resources
14:12justin_smithare you using wrap-resource?
14:12justin_smithwrap-file?
14:13geekyvin_right, I found then but couldnt really find how to use them.
14:14geekyvin_shld the :wrap-resource be in project.clj or in my handler?
14:14justin_smithwrap-resource is a function, and it should be in your handler
14:18geekyvin_ok let me try that.
14:18geekyvin_thank Justin.
14:19justin_smithnp
14:20gfredericks"in your handler" in the sense that it's a middleware you should use
14:20justin_smithright, "around" would be the better preposition there
15:39michaelr`anyone here uses bidi?
15:39michaelr`err
15:42michaelr`i have one handler which handles both :post and :delete requests, the url of the first is /something and the second is /something/1. is there any way that I can unmatch for both urls from the same handler?
15:45michaelr`both routes are guarded with request methods, essentially I'd like to parametrize url generation with the request method
15:49arrdemAnyone messed with Racket and care to comment on it?
16:02justin_smitharrdem: very clean, a great language for pedagogy, not a huge library ecosystem (like most schemes)
16:02gfrederickstechnomancy likes it
16:02gfredericksfor...kids
16:03justin_smithalso, the way you can explicitly choose a language dialect in your source code is kind of cool
16:04andyfI find its mob associations make it scary to use. License enforcement by limb mangling?
16:06justin_smithandyf: it follows a proud tradition of "scheme" dialect names. See also gambit, larceny, guile
16:06justin_smithand some of them get a bit more conceptual, like stalin
16:06andyfHoly cow. We may have unearthed a conspiracy here
16:19ben_vulpesi've been away from clojure webapp development for a while (9 mos? feels like eternity...). is chestnut awesome or will it be really painful in novel ways after six months?
16:21_2_MiniHola a todos
17:00tolstoyIs there any way to avoid this thing: 'Reflection warning, clojure/data/priority_map.clj:215:19 - call to method equiv on java.lang.Object can't be resolved (no such method).'
17:00tolstoyNot sure why it's showing up all of a sudden.
17:01tolstoyMaybe some interaction with 'aleph'? Hm.
17:01gfredericksthat's interesting
17:01tolstoyUsing :global-vars {*warn-on-reflection* false} doesn't help.
17:02tolstoyAlso: 'Reflection warning, clojure/core/memoize.clj:72:23 - reference to field cache can't be resolved.'
17:02gfrederickstolstoy: are you using priority-map directly? or is aleph requiring it?
17:03gfredericksit looks like there's a "fix reflection" commit in their history included in the latest release
17:03tolstoyI'm not.
17:03tolstoyIf it's a lib, I don't see it in "lein deps :tree".
17:04gfrederickswhat version of aleph are you using?
17:04tolstoy"0.4.0-beta3"
17:06tolstoyRelated: http://permalink.gmane.org/gmane.comp.java.clojure.aleph/693
17:14tolstoyAh, I see it now. core.async is indeed using priority_map.
17:15tolstoyWhat's puzzling is that the latest release is from Sep 2014.
17:16tolstoyAh. Update to the latest priority map, and that goes away.
17:17tolstoyNo newer core.memoize, so out of luck there.
17:25tolstoyhttp://dev.clojure.org/jira/browse/CMEMOIZE-13
18:17_1_Andrz8766hey
18:21_1_Andrz8766hello?
18:21clojurebotBUENOS DING DONG DIDDLY DIOS, fRaUline _1_Andrz8766
18:21_1_Andrz8766how do you use this thinh
18:24justin_smith_1_Andrz8766: are you new to IRC?
18:26Bronsa(inc clojurebot)
18:26lazybot⇒ 48
19:53gfredericks(inc lojurebot)
19:53lazybot⇒ 1
20:01justin_smithI may have done something silly. I am working on a data structure lib that represents graphs natively as adjacency lists, and I have functions that attempt to turn a graph into a tree or list
20:01justin_smithand the list one is just a lazy list that follows a random outgoing edge at teach step until there are no more outgoing edges left
20:02justin_smithso running it twice will give you two different outputs for any graph that can't be represented as a singly linked list
20:02justin_smithmaybe that's useful?
20:02justin_smithif the graph has no non-cyclic paths, you get an infinite lazy-seq
20:10gfrederickshas anybody made an arithmetic lib for dealing with pretend unsigned bytes/ints/longs?
20:10gfrederickspresumably by using primitives but doing the arithmetic differently
20:10justin_smithgfredericks: that seems like a natural thing, like in some java lib that asists in jni stuff or something
20:11gfredericksI think java 8 might have related things
20:11gfredericksbut that doesn't help for writing fluent clojure
20:12gfredericksI was also thinking that anybody who intentionally uses bigdecimal might find a set of arithmetic functions restricted to bigdecimal useful
20:12gfredericksto ensure they never accidentally degrade to doubles
20:13justin_smithgfredericks: hmm, maybe you could even keep the arithmetic the same (but only do unchecked operations) and just override like >, <, and the print method
20:13justin_smithbecause with twos compliment the rest should just work until you hit over / under flow
20:13gfredericksgotta be careful with shifting too
20:14justin_smithahh, yeah
20:19gfredericksjustin_smith: multiplication wouldn't work right would it?
20:20gfrederickswithout a separate impl I mean
20:28justin_smith"The two's-complement system has the advantage that the fundamental arithmetic operations of addition, subtraction, and multiplication are identical to those for unsigned binary numbers (as long as the inputs are represented in the same number of bits and any overflow beyond those bits is discarded from the result)."
20:28justin_smiththat's why I was thinking it would be elegant
20:28justin_smithbasic ops just stay the same (and thus also remain as efficient)
20:29gfredericksoh wow I didn't know it worked for multiplication as well
20:29gfredericksthe more I think about it the more skeptical I am
20:30gfredericksthinking about the highest bit, and what determines it in an unsigned mult
20:30justin_smithgfredericks: I think overflow would just "accidentally" do the right thing
20:31justin_smithbut that's easy to test with some unchecked math, or even by hand
20:32gfrederickswhere did you get this quote
20:32justin_smithwikipedia
20:32gfredericksyou can't trust that did you know anybody can edit it
20:32justin_smithI've heard
20:32gfredericksit's like a button on there; *you can make it say whatever you want!*
20:33justin_smithgfredericks: but that wasn't my original source, it was just easier to look up :)
20:34gfredericksin multiplication the highest bit in the result is dependent on like every bit of the inputs
20:34gfredericksbut in signed multiplication that bit has to be the correct sign of the result
20:35gfredericksbut if it's also dependent on every bit of the inputs I should be able to twiddle the bits of the inputs (without changing their sign) to manipulate the sign of the outputs
20:35gfrederickss/outputs/output/
20:36justin_smithgfredericks: the two's complement signed multiply and the unsigned multiply, when applied two to numbers with the same bit representation, are guaranteed to result in the same bits in the output
20:36justin_smithit's the same operation on the bit level
20:36gfredericksyou're just stating the position I'm arguing against, right?
20:37justin_smithI'm telling you a fact about how two's complement multiply works
20:37gfredericksyes I believe you that it's true but it's also totally impossible and I'm trying to explain why
20:38justin_smithgfredericks: it's because what is overflow on one side, is a correct multiply on the other
20:38justin_smithit's a lot easier to overflow with signed multiply
20:38gfrederickssure, but I'm focusing on the value of the highest bit
20:38gfredericksafter truncating overflow
20:39gfrederickswhich is a bit that must be determined by virtually every bit of the inputs I think
20:40justin_smithOK - they are identical for non-overflowing operations, and are respectively correct for ops that don't overflow (there are some signed results that are overflows, that are not overflows in the unsigned version)
20:40gfrederickshuh?
20:41justin_smithI'm going to try to work this out in a simplified model, like with a three bit number
20:41justin_smithok, maybe four bit
20:41gfrederickswikipedia says something about having to double the precision beforehand
20:44justin_smithif you want to guarantee you don't overflow, sure - double precision and extend the sign bit
20:47gfredericksso what you said earlier is that multiplication doesn't work if the ops are large enough to overflow, right?
20:47gfrederickswhich means the sentence in the wikipedia intro is misleading?
20:49gfredericksI just did 7+(-3) and got -5
20:49gfrederickser 7*(-3)
20:49gfrederickswhich is the correct sign actually
20:50gfredericksnow that I think about it I don't know what you're supposed to expect semantically from overflow of signed multiplication
20:50gfredericksis it equivalent to multiplication mod something somehow?
20:51gfredericksthis must be my problem I don't actually know what I think it's supposed to do; I just assumed that signs should be well-behaved, but maybe not
20:59justin_smithgfredericks: so I just wrote out all the five bit numbers in standard / 2's complement, and picked a random multiplication to show that once you truncate overflowed bits, the output is the same
20:59justin_smithhttp://i.imgur.com/tZX9uuI.jpg
20:59justin_smithsorry it's a little sloppy - on the left is bits - unsigned / signed
20:59justin_smithon the right is signed on top, then bits, then unsigned
21:00justin_smithwith the two truncated bits bracketed
21:02gfredericksjustin_smith: but what happens when the signed op result is semantically out of range?
21:02gfrederickse.g., -5 * 7
21:03justin_smithone second, scribbling
21:03gfredericksI demand moar photo graphs
21:04gfredericksfaxed to me
21:04justin_smithhaha
21:05john2xthere's no date generator in test.check?
21:06gfredericksnope
21:07gfrederickswhat kind of distribution would you want on that?
21:07john2xjust completely random dates. hmm I guess a constant date would work just as well for my current purposes.
21:07gfredericksis 19487917373191-02-28 a date?
21:08john2xheh yeah.. that could get tricky
21:08gfrederickswe've got a lot of design work to do on good numeric generators
21:08gfrederickswhich would probably help with what you're wanting
21:09gfredericksin the meantime if you think of something obviously generally useful I can probably put it in test.chuck
21:13justin_smithgfredericks: with 27*7, / -5*7 they still match for the last five bits (which is all the matters since I was doing five bit two's complement) and they only diverge where they overflow
21:13justin_smithboth end in 11101
21:14justin_smithif cl-format wasn't a filthy liar when it comes to binary, I could show you that easily
21:14justin_smith*signed binary that is
21:16gfredericks,(mod (* 27 7) 32)
21:17clojurebot29
21:17gfredericks,(mod (* -5 7) 32)
21:17clojurebot29
21:17gfrederickswhich is -3 I think?
21:17justin_smithgfredericks: if you refer back to my jpg, it says yes
21:18gfredericksso I guess the semantics are multiplication mod 2^n and then wrapped around to negative as appropriate
21:19gfredericksand therefore the sign is chaotic
21:19gfrederickswhich is what I was intuiting before, but assumed that meant it wasn't working right
21:19justin_smithyeah, that sounds about right, and it is intuitive because multiplication is repeated addition
21:19justin_smithit's just that there are so many overflowing results you get overflowed overflow etc. :)
21:20gfredericksright, a chaotic sign
21:20justin_smithgfredericks: are you coming to clojure/west?
21:20gfredericksyep
21:21gfredericksbooked my flights yesterday
21:21justin_smithcool
21:21gfredericksI've always lived closer to the east coast but I've attended clojure/west a lot more reliably
21:25gfredericksnow I'm curious how you detect multiplication overflow
21:25justin_smiththis will be my first clojure conference, and it will be crazy seeing all these people I know online in person
21:25gfredericksto the Numbers.javamobile!
21:25justin_smithgfredericks: you put the result in a double-sized result, then you check for any set bits
21:25justin_smith(in the extra sized side, of course)
21:26justin_smithgfredericks: but this is why I was saying before that it would be easy if you do unchecked ops :)
21:26justin_smithheh
21:26justin_smithbecause the unchecked results will match (while likely being useless to the application code)
21:26gfredericksyou're just describing how to do it on a chip, no?
21:26justin_smithnot *just*
21:27justin_smithyou can do the same thing in an algorithm
21:27gfredericksNumbers.java is doing something clever
21:27justin_smiththough I guess you would use a bigint instead of like a 128 bit int
21:27justin_smithinteresting
21:27gfredericksomg there's a whole check for x == Long.MIN_VALUE && y < 0
21:27gfredericksmaybe that's an edge case you can't detect otherwise
21:28gfredericksbut then after multiplying it does a divide to see what happened
21:28gfredericksif (x&y)/y != x then overflow
21:28gfredericksx*y rather
21:28justin_smithfascinating, nobody's using those overflow bits on hardware more's the shame
21:29justin_smiths/bits/flags
21:29justin_smithI wonder if there are like experimental languages that use that feature
21:29justin_smithor if everybody's like "c doesn't support it, so we don't"
21:34rksmWhat's the most idiomatic way to read in a project.clj from a jar? I need the project map normally returned from leiningen.core.project/read.
21:34gfredericksis it normally in the jar at all?
21:35gfredericksyou can probably get it into the jar with some :filespecs thing and then just read it with clojure.java.io/resource
21:36gfredericksmight be a plugin that does this kind of thing already
21:37justin_smithgfredericks: rksm: checking a random jar, yeah I find a project.clj
21:37justin_smithnow how do you get a specific version of a resource that is on the class path multiple times again? I always forget
21:38gfredericksa random jar? is it a lib?
21:38justin_smithyeah
21:39justin_smithgfredericks: yeah, I see them in each clojure lib I check
21:40gfrederickshuh. well what do you know.
21:40gfredericksseems a little bit weird
21:40rksmDealing with the classpath and getting content from a jar I managed to do. However, I want to duplicate none (or at least as little as possible) from leiningen.core.project/read (https://github.com/technomancy/leiningen/blob/master/leiningen-core/src/leiningen/core/project.clj#L950)
21:41rksmAs read only accepts a file (not a jar URI or jar entry reader).
21:41rksmHmm... how can I convert a buffered reader to a pushback reader?
21:41tomjack(java.io.PushbackReader. buffered-reader)
21:42justin_smithrksm: so how do I get a resource from a specific jar?
21:43rksmtomjack: yep, that works, thanks. now I can use read-raw :)
21:43DraggorIs there a tutorial to start with on clojure.test?
21:44justin_smithDraggor: the clojuredocs page for it is decent. It's a small library.
21:44tomjackjustin_smith: (-> (Thread/currentThread) (.getContextClassLoader) (.getResources "foo") (enumeration-seq)) will give you a seq of URLs
21:44rksmjustin_smith: I use jar files + jar entries for it: https://github.com/cloxp/clj-system-files/blob/master/src/main/clojure/rksm/system_files.clj#L100
21:44justin_smithtomjack: oh, nice
21:44tomjackI guess you can figure out which one is from which jar from there
21:44tomjackI stole that from the stuff in core.clj for data_readers.clj
21:45justin_smithtomjack: nice
21:46tomjackthank java that is possible..
21:46Draggorjustin_smith: in particular looking to read about doing setup/teardown and setting a variable for tests
21:46Draggorif I were to not use fixtures I'd just do a let form I suppose
21:47justin_smithDraggor: typically there is very little setup/ teardown - with pure functions you do stubbing instead of mocking
21:47justin_smithand the stubbing can just be data literals and the occasional function literal
21:48Draggorjustin_smith: sure, anywhere I can see an example of that?
21:48justin_smithDraggor: and my preferred approach is to have all my complex logic in pure functions (as much as possible), because stubbing to test all the logic is pretty trivial, then making the side effecting stuff as simple as possible so I can avoid / minimize stubbing
21:48justin_smithDraggor: hmm...
21:49justin_smithit would be good to have a go to example for that approach
21:55rksmDraggor: Take a look at how authentication in leiningen itself is tested. There is a credentials function that returns the content of ~/.lein/credentials.clj.gpg: https://github.com/technomancy/leiningen/blob/master/leiningen-core/src/leiningen/core/user.clj#L122 In order to test that without creating an actual file the var leiningen.core.user/credentials is re-defined at test time: https://github.com/technomancy/leiningen/blo
21:55rksmb/master/leiningen-core/test/leiningen/core/test/user.clj
21:55rksmDraggor: Take a look at how authentication in leiningen itself is tested. There is a credentials function that returns the content of ~/.lein/credentials.clj.gpg: https://github.com/technomancy/leiningen/blob/master/leiningen-core/src/leiningen/core/user.clj#L122 In order to test that without creating an actual file the var leiningen.core.user/credentials is re-defined at test time:
21:55rksmhttps://github.com/technomancy/leiningen/blob/master/leiningen-core/test/leiningen/core/test/user.clj
21:56rksmMost of the time you are best of with directly passing dependencies to your functions, though.
22:00DraggorI still feel like I'm missing something simple. I want a fixture that as setup, calls a pure function that returns an immutable object I'm then going to use in my tests. What does that look like?
22:02justin_smithDraggor: why does the fixture need to do that?
22:03justin_smithfixtures are for things with side effects, they don't pass anything to the tests
22:03justin_smithif it's immutable, can't it be a top level def or a let binding?
22:03DraggorGood point
22:03gfredericks,(def my-test-data 42)
22:03clojurebot#'sandbox/my-test-data
22:04justin_smithone moment, I'll upload what I am working on right now
22:04gfredericksI just made a computer somewhere on the internet keep the number 42 around for a little while just in case
22:07justin_smithhttps://github.com/noisesmith/adj/blob/master/test/org/noisesmith/adj_test.clj
22:07justin_smithI define some data structures, and do various things with them in each test
22:08DraggorAhh, yes, it is that simple, thanks!
22:09justin_smithsadly, nothing in this project does side effects
22:09justin_smiththough I guess I may add a db backed ns for persistent graph stuff eventually...
22:09DraggorWhat I'm doing, the side effect is user input which I can fake out in tests, the functions themselves are pure for doing the real work
22:10justin_smithright, and that's very simple to test
22:11rksmDraggor: And in case your input needs to change you can use dynamic scoping, however, be aware that this creates an indirect dependency between the dynamic state and your tests/code. https://gist.github.com/rksm/4a6c0116b32046290af3
22:12rksmAnd to just have a "template" test the are macro is useful: https://clojure.github.io/clojure/clojure.test-api.html#clojure.test/are
22:30underplankHi all. Im using the fantastic clj-http lib, and I’ve been able to find the {:throw-exception false} parameter for the get function. But im using the request function to do arbitrary requests. Is there a way to pass the :throw-exception keyword in?
22:32underplankhmm thats wierd. it seems that the get is actually using request under the covers.
22:32gfredericksdo (clojure.repl/source clj-http.core/request)
22:32gfredericksyou can see a lot of opts there
22:32gfrederickslast I checked they weren't otherwise documented
22:36underplankthanks i’ll take a look
22:47ben_vulpesman i am baffled. where does react.js come from in the chestnut/cljs templates?
22:49tolstoyben_vulpes: I think it's pulled in as a dependency of [org.omcljs/om "0.8.8"].
22:49tolstoyIt's in a jar file, if that helps.
22:49ben_vulpeshm.
22:50tolstoy[cljsjs/react "0.12.2-5"]
22:51tolstoyLast I remember (it's been a while) there's a deps.cljs in the jar and other such conventions.
22:51ben_vulpesi was using an ancient version of om, apparently.
22:52spinningarrowWhich text editor or IDE do most people use for Clojure? (hope I'm not starting a war - just genuinely curious)
22:53sridEmacs
22:53justin_smithspinningarrow: emacs, though cursive (an intellij idea plugin) likely has the best tooling
22:54sridbut I'm open to learn of better IDEs for Clojure
22:54ben_vulpesi know a guy who uses vim/fireplace
22:55sridCursive will be available as an IntelliJ plugin for use with the Community or Ultimate editions, as well as a standalone Clojure-focused IDE. It will be a commercial product, at a similar price point to PyCharm or RubyMine.
22:55srid- https://cursiveclojure.com
22:55justin_smithsrid: yes, but it is available for free right now
22:55sridso it is not production ready
22:55justin_smithsrid: it's more complete than any of the other options
22:57ben_vulpesis emacs even production ready?
22:58justin_smithben_vulpes: cider sure the hell isn't, it still changes the abi all the time
22:58ben_vulpestolstoy: i should expect to see react.js get compiled onto my clojurescript path, right?
22:58ben_vulpesjust by virtue of using org.omcljs/om "0.8.0"
22:58ben_vulpesor am i missing something here.
22:59tolstoyben_vulpes: I think (depending on cljs compiler configuration), it gets merged into your main.js file.
22:59ben_vulpeshm.
22:59tolstoyben_vulpes: For me, it so often "just works" that I've forgotten about it. ;)
23:00ben_vulpesfwiw, i get out/goog/base.js
23:00ben_vulpes"works on my machine..."
23:01tolstoyBuilding a project to see where it goes.
23:01tolstoyI have a "dev" task which does the source map and optimizations :none thing.
23:02tolstoygoog.addDependency("../react.inc.js", ['cljsjs.react'], []);
23:02tolstoyIt's in my "out" directory.
23:02ben_vulpeswhen you say "dev" task, are you referring to a :dev key in your :builds vector?
23:02ben_vulpeser
23:02tolstoyYes.
23:03ben_vulpesa build in the build vector with a "dev" value for the :id key, more accurately.
23:03Draggorrksm: are looks perfect, thanks
23:03tolstoyYeah: {:builds [{:id "dev" ;; but I get what you mean.
23:03tolstoyI've defined an output dir as resources/public/out and react.js gets put in there.
23:04tolstoyExtracts from the jar, I imagine.
23:06ben_vulpesis it possible that the clojurescript compiler thinks it already copied the react file?
23:06tolstoyWhen I do a "release" build (:optimizations :whitespace), react.js is embedded at close to the top of the resulting "single" main.js file.
23:06tolstoyAre you using 0.8.8?
23:07ben_vulpes[org.omcljs/om "0.8.8"]
23:09tolstoyOh. You're experiencing an issue or something?
23:09ben_vulpesit looks like om etc aren't terribly willing to compile.
23:10tolstoyHere's my extremely minimal build config, if that helps.
23:10ben_vulpesi just blew away my resources/public/out directory by hand, reran lein cljsbuild auto, and it did not drop goog/**
23:10tolstoyhttps://www.refheap.com/98782
23:11ben_vulpeslooks pretty identical to mine.
23:11tolstoyYou have the most recent cljs?
23:11tolstoyYeah, I'm not exploiting a whole lot on CLJS. ;)
23:11ben_vulpesyeah, let me restart my jvm
23:12tolstoyActually, I don't have the most recent stuff (this is an EOL project).
23:13ben_vulpeshrm.
23:14ben_vulpeswell i'm rolling back to 0.8.0 rc1 to see if it'll compile google closures etc
23:14underplankOk, so I have a ring server that is being run. I want to se a break point in a handler and use a debug repl to have a look around and step in and out of functions. What is the best way to do this?
23:15tolstoyDoes "lein deps :tree" reveal anything troubling?
23:16tolstoyLatest lib updates produce some interesting warnings, but it all works with regard to react.js.
23:17ben_vulpeslein figwheel screamed about misconfigured output-dir path, interestingly.
23:18tolstoyAh, figwheel. Maybe comment that out and see?
23:19ben_vulpesnow that i think about it, figwheel was how i compiled assets first.
23:19ben_vulpesbut from inside a repl. i was working to shoehorn figwheel-from-repl into a component
23:20tolstoyThere's been a lot of repl thrash lately. I think bhauman has been keeping up, but I've given up on it for the duration.
23:20ben_vulpes*sigh*
23:20ben_vulpesgood to know, thanks.
23:20tolstoyAccording to dnolen, all the repls work great (from Emacs) using an inferior-lisp mode, but not cider.
23:20ben_vulpes(classic me, though: "this workflow isn't right! as part of spinning this project up i will make it do the RIGHT THING")
23:21ben_vulpesmk, that did it.
23:21ben_vulpes:output-dir "resources/public/js/out/"
23:22tolstoyHeh. For me, it's, "Surely I need to get a handle on line numbers properly formatted and dimmed rather than my actual hobby project I love working on."
23:22ben_vulpesokay, commit.
23:24tolstoyThe QuickStart guide might interest you, if you're into back-to-basics on a path to building up again.
23:29ben_vulpesclojurescript quickstart?
23:38tolstoyYeah.
23:39tolstoyhttps://github.com/clojure/clojurescript/wiki/Quick-Start
23:42ben_vulpesyeah, i'm like 80% competent with all of that
23:42ben_vulpeslol okay i got figwheel running awesome
23:42ben_vulpesnow i'm just going to let go of it not being integrated in my component workflow for now, and see if i can hammer out a few om buttons or something
23:42ben_vulpeswoo
23:42ben_vulpesthanks tolstoy
23:43tolstoyExcellent! Nah, I just mention it because cljs dev has been improving a lot lately, and it's always nice to go back to take stock. (Like re-reading clojure.core API every once in a while.)
23:48ben_vulpesdefinitely good ideas.