2016-01-16
| 00:23 | retrogradeorbit | hey. I need some opinions on style |
| 00:23 | TimMc | You've come to the right place. |
| 00:24 | retrogradeorbit | where is the line between threading macro and just nesting? |
| 00:24 | retrogradeorbit | https://github.com/retrogradeorbit/geoip/commit/3e79e5adb2384121017ab1aee98136d04af64d8c |
| 00:24 | retrogradeorbit | whats better? |
| 00:24 | retrogradeorbit | stylistically... before the commit? or after? |
| 00:26 | justin_smith | retrogradeorbit: why do you use ->> twice on lines 35 and 36 instead of using one ->> starting on line 34? |
| 00:26 | justin_smith | (->> d-map (keys) (filter ...) (reduce ...)) |
| 00:27 | retrogradeorbit | justin_smith: nice. yes! |
| 00:28 | justin_smith | retrogradeorbit: similarly on line 26, instead of ->> inside ->, you could just use ->> |
| 00:28 | retrogradeorbit | of course, cause they're all single arity |
| 00:28 | justin_smith | (->> d-map (keys) (sort) (take-while ...) (last) (d-map)) |
| 00:31 | retrogradeorbit | so when do you thread, and when do you nest? |
| 00:31 | retrogradeorbit | is there some thinking around this? |
| 00:31 | retrogradeorbit | or is it just do what you want? |
| 00:31 | justin_smith | I nest when it's less than four calls deep, usually - more than three and threading is usually clearer. |
| 00:32 | justin_smith | but I think this is a preference thing, some prefer never to use threading |
| 00:32 | justin_smith | sometimes let bindings are simpler than threading also |
| 00:42 | TimMc | retrogradeorbit: Also see as->, which expands the number of situations in which threading can be used. |
| 00:47 | slim_ | list |
| 03:48 | sztamas | hi, is http://dev.clojure.org/jira/secure/Dashboard.jspa the current JIRA page for Clojure? It seems to be unresponsive ATM |
| 03:51 | hiredman | works for me |
| 03:53 | sztamas | yes, loaded for me now as well |
| 03:53 | sztamas | thanks for checking |
| 03:56 | sztamas | very slow though |
| 04:35 | favetelinguis | how can i jump to the source of the error in emacs cider from the error buffer? |
| 05:11 | WickedShell | can you type hint the content of a delay'd var? IE I always know that when I deref it I will be looking at a object Foo, and currently for interopt reasons I have to hint every location where I deref the var |
| 05:47 | amalloy | no. but you can write a function that derefs the var, and hint that function |
| 05:49 | TEttinger | a ha! |
| 05:51 | TEttinger | ,(defn ^_^ ^String [a] @a) |
| 05:51 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Metadata must be Symbol,Keyword,String or Map> |
| 05:51 | TEttinger | aw |
| 05:52 | TEttinger | ,(defn -_- ^String [a] @a) |
| 05:52 | clojurebot | #'sandbox/-_- |
| 05:52 | TEttinger | ,(def at (atom "hey")) |
| 05:52 | clojurebot | #'sandbox/at |
| 05:52 | TEttinger | ,(-_- at) |
| 05:52 | clojurebot | "hey" |
| 05:53 | lokien | TEttinger, whaat are you doing here? |
| 05:58 | TEttinger | testing what amalloy said |
| 05:59 | TEttinger | I wonder when gfredericks will awaken |
| 05:59 | lokien | too bad irc doesn't show history |
| 05:59 | TEttinger | gfredericks did some neat work regarding splittable immutable PRNGs |
| 06:00 | TEttinger | benchmarking over here seems to show that the core of SplittableRandom, which is the SplitMix64 algorithm, is really really good on the JVM |
| 06:02 | lokien | splittable immutable prngs - what does "splittable" mean? |
| 06:03 | lokien | "Splittable |
| 06:03 | lokien | PRNG |
| 06:03 | lokien | s, |
| 06:03 | lokien | in contrast to linear |
| 06:03 | lokien | PRNG |
| 06:03 | lokien | s, allow the creation of two (seemingly) |
| 06:03 | WickedShell | amalloy, valid approach. I really need to learn how to write clojure macro's apparently :/ |
| 06:03 | lokien | independent generators from a given random number generator"? |
| 06:03 | lokien | oh man sorry |
| 06:03 | lokien | I won't ctrl+v into irc ever again |
| 06:05 | TEttinger | 1,269,975,332 nanoseconds to generate 1,000,000,000 numbers |
| 06:05 | TEttinger | that's pretty good |
| 06:06 | jonathanj | if i have a structure like [[1 2] [3] [4 5 6 7] [8]] what's the easiest way to end up with the same result as (+ 1 2 3 4 5 6 7 8)? |
| 06:06 | TEttinger | it's an extremely simple RNG, but yeah that's pretty good |
| 06:06 | TEttinger | I'll benchmark j.u.Random next |
| 06:06 | lokien | flatten and apply +? |
| 06:06 | jonathanj | (reduce + (mapcat identity xs)) is not really very readable |
| 06:07 | jonathanj | lokien: usually mentioning (flatten) gets you lynched |
| 06:07 | lokien | jonathanj: lynched? on #clojure? pff |
| 06:07 | Bronsa | (transduce cat + xs) |
| 06:08 | jonathanj | ,(transduce cat + [[1 2] [3] [4 5 6]]) |
| 06:08 | clojurebot | 21 |
| 06:08 | jonathanj | nice |
| 06:08 | Bronsa | only works on clojure 1.7+ |
| 06:09 | jeaye | Given a 2D array in clojure clr, how can I access/update elements? |
| 06:10 | jeaye | I have a System.Single[,] |
| 06:11 | TEttinger | jeaye: I wondered the same thing, and the uncertainty in the docs made me hesitant |
| 06:12 | jeaye | I'm trying to use Arcadia and Unity is giving me this 2D array. |
| 06:13 | lokien | how'd we do it in normal clojure? |
| 06:13 | TEttinger | lokien: it turns out java.util.Random is insanely slow generating 64-bit longs |
| 06:13 | TEttinger | benchmark still running |
| 06:14 | lokien | TEttinger: these random numbers were 64 bit longs?! |
| 06:14 | TEttinger | 22,837.146,419 ns to generate 1,000,000,000 longs |
| 06:14 | TEttinger | yes |
| 06:14 | TEttinger | so what one finishes in 1.2 seconds, the other takes 22.8 seconds |
| 06:15 | TEttinger | jeez... I thought LCG RNGs were supposed to be the fastest to make up for their shoddy quality |
| 06:15 | lokien | let's write a blogpost about how clojure is faster than java :^) /s |
| 06:16 | TEttinger | oh they're both java |
| 06:16 | TEttinger | but you could in theory rewrite this in clojure |
| 06:16 | jonathanj | jeaye: i think you want aget and aset |
| 06:16 | jonathanj | (at least that's how you'd do it with Java arrays) |
| 06:16 | lokien | TEttinger: ew, I thought it was in clojure already |
| 06:17 | TEttinger | it's easy enough to port |
| 06:17 | lokien | I wonder how much slower it would be |
| 06:19 | jeaye | jonathanj: Nah, it's not that simple. |
| 06:19 | jeaye | jonathanj: aget fails, saying the array isn't one dimensional. |
| 06:19 | Bronsa | in clojure on the jvm aget works for multi dimensional arrays |
| 06:20 | jeaye | As mentioned above, this is clojure clr. |
| 06:20 | jeaye | ,(aget [[0 1] [2 3]] 0) |
| 06:20 | clojurebot | #error {\n :cause "No matching method found: aget"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching method found: aget"\n :at [clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 80]}]\n :trace\n [[clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 80]\n [clojure.lang.Reflector invokeStaticMethod "Reflector.java" 207]\n [sandbox$eval47 invokeStat... |
| 06:20 | Bronsa | ,(aget (into-array [(object-array [1 2 3])]) 0 0) |
| 06:20 | clojurebot | 1 |
| 06:21 | jonathanj | ,(aget (to-array-2d [[1 2] [3 4]]) 0 0) |
| 06:21 | clojurebot | 1 |
| 06:22 | jeaye | Right. |
| 06:22 | jeaye | clojurebot isn't running on clr though. |
| 06:22 | Bronsa | TIL to-array-2d |
| 06:22 | Bronsa | https://github.com/clojure/clojure-clr/blob/master/Clojure/Clojure.Source/clojure/core.clj#L3792 |
| 06:22 | Bronsa | clojure-clr's aget works as the clojure-jvm one |
| 06:23 | jonathanj | jeaye: are you passing two indices to aget? |
| 06:23 | Bronsa | oh, I see that comment https://github.com/clojure/clojure-clr/blob/master/Clojure/Clojure.Source/clojure/core.clj#L3783 |
| 06:23 | jeaye | jonathanj: I've tried with both one and two. |
| 06:25 | lokien | anyone here using boot instead of leiningen? |
| 06:25 | jonathanj | that comment says the author isn't sure how to discern multidim from ragged arrays, but isn't that what Array.Rank does? |
| 06:25 | jonathanj | https://msdn.microsoft.com/en-us/library/system.array.rank(v=vs.110).aspx |
| 06:26 | jonathanj | jeaye: can't you do (.GetValue the-array idx1 idx2)? |
| 06:26 | jeaye | jonathanj: http://dpaste.com/0XCNMZC |
| 06:27 | jeaye | Ah, .GetValue doesn't throw. |
| 06:27 | jonathanj | i don't know why the clojure-clr codes doesn't use the .GetValue(Int[]) form |
| 06:28 | jonathanj | jeaye: when in doubt interop |
| 06:28 | jeaye | Thank you. |
| 06:39 | TEttinger | lokien: I told you it was going to be ugly, right? |
| 06:39 | TEttinger | ,(do (def state (long-array [9000])) (defn splitmix ^long [] (let [z (aset-long ^longs state 0 (unchecked-add (aget ^longs state 0) -7046029254386353132)) z (unchecked-multiply (bit-xor z (unsigned-bit-shift-right z 30)) -4658895280553007687) z (unchecked-multiply (bit-xor z (unsigned-bit-shift-right z 27)) -7723592293110705685)] (bit-xor z (unsigned-bit-shift-right z 31))))) |
| 06:39 | clojurebot | #'sandbox/splitmix |
| 06:39 | TEttinger | ,(splitmix) |
| 06:39 | clojurebot | -304103417993225237 |
| 06:40 | TEttinger | ,(time (dotimes [n 1000] (splitmix))) |
| 06:40 | clojurebot | "Elapsed time: 3.276121 msecs"\n |
| 06:40 | TEttinger | not bad |
| 06:41 | TEttinger | ,(time (dotimes [n 1000000000] (splitmix))) |
| 06:41 | clojurebot | #error {\n :cause "Unable to resolve symbol: splitmix in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: splitmix in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: splitmi... |
| 06:41 | TEttinger | ,(do (def state (long-array [9000])) (defn splitmix ^long [] (let [z (aset-long ^longs state 0 (unchecked-add (aget ^longs state 0) -7046029254386353132)) z (unchecked-multiply (bit-xor z (unsigned-bit-shift-right z 30)) -4658895280553007687) z (unchecked-multiply (bit-xor z (unsigned-bit-shift-right z 27)) -7723592293110705685)] (bit-xor z (unsigned-bit-shift-right z 31))))) |
| 06:41 | clojurebot | #'sandbox/splitmix |
| 06:41 | TEttinger | ,(time (dotimes [n 1000000000] (splitmix))) |
| 06:41 | clojurebot | eval service is offline |
| 06:41 | TEttinger | gah |
| 06:41 | lokien | D: |
| 06:41 | TEttinger | seriously? |
| 06:41 | TEttinger | ,(time (dotimes [n 1000000] (splitmix))) |
| 06:41 | clojurebot | "Elapsed time: 138.176458 msecs"\n |
| 06:42 | TEttinger | ,(/ 1.0 7.0) |
| 06:42 | clojurebot | 0.14285714285714285 |
| 06:42 | TEttinger | still under a seventh of a second for a million |
| 06:42 | lokien | it hangs in my repl |
| 06:42 | TEttinger | is state defined? |
| 06:43 | TEttinger | maybe dotimes doesn't like a certain number |
| 06:43 | lokien | (time (dotimes [n 1000000000] (splitmix))) -> "Elapsed time: 52572.653161 msecs" |
| 06:43 | TEttinger | hm! |
| 06:43 | TEttinger | not as good, wonder why |
| 06:44 | lokien | 1000 000 -> 68.64 msecs |
| 06:45 | TEttinger | I mean, the java code relies on integer overflow all over the place |
| 06:45 | TEttinger | so that's why I needed unchecked variants |
| 06:45 | lokien | umm, how? |
| 06:45 | TEttinger | it's really ugly in clojure |
| 06:45 | lokien | how can you benefit from that? |
| 06:45 | TEttinger | most RNGs do |
| 06:45 | lokien | TIL programming is spooky |
| 06:46 | TEttinger | it assigns massively higher numbers than can fit in 32 or 64 bits, then it wraps around semi-"randomly" (it's 100% predictable but seems random) |
| 06:47 | lokien | so, pretty much useless for any crypto stuff |
| 06:47 | TEttinger | oh yeah this is not a crypto generator |
| 06:47 | TEttinger | in fact |
| 06:47 | lokien | /dev/urandom is good enough for crypto junkies, I heard |
| 06:47 | TEttinger | I have a function that, given a state, will tell you what state you will have after generating n numbers (or go back to previous states) |
| 06:48 | lokien | TEttinger: what for? |
| 06:48 | TEttinger | in java it's: long skip(long advance) |
| 06:48 | TEttinger | { |
| 06:48 | TEttinger | return state += 0x9E3779B97F4A7C15L * advance; |
| 06:48 | TEttinger | } |
| 06:48 | TEttinger | gah |
| 06:48 | TEttinger | that was one line in my IDE! |
| 06:49 | TEttinger | however that constant is too large for a long in clojure, you need |
| 06:49 | TEttinger | ,(unchecked-long 0x9E3779B97F4A7C15) |
| 06:49 | clojurebot | -7046029254386353131 |
| 06:49 | TEttinger | not sure why Java allows unsigned longs |
| 06:50 | TEttinger | and they even compile to signed ones I think |
| 06:50 | lokien | can't you use unchecked math at the beginning, once? |
| 06:50 | TEttinger | you can set it but not in the bot |
| 06:51 | TEttinger | and yes that would help with almost all those long calls |
| 06:51 | TEttinger | unsigned-bit-shift-right is not an unchecked thing, it's the >>> operator in Java |
| 06:51 | Bronsa | java doesn't allow unsigned longs |
| 06:51 | TEttinger | try it Bronsa |
| 06:51 | Bronsa | there's no unsigned type in the jvm |
| 06:51 | TEttinger | 0x9E3779B97F4A7C15L |
| 06:51 | TEttinger | I know |
| 06:52 | TEttinger | but that acts like the sign bit is part of the literal and not as a negative sign |
| 06:52 | lokien | TEttinger: have you seen benchmark game programs in clojure? they're hella ugly |
| 06:52 | TEttinger | in many languages |
| 06:52 | lokien | in every language |
| 06:52 | lokien | it's hand crafting assembly |
| 06:53 | lokien | I wonder how would it look if all languages just used their idiomatic, readable code |
| 07:33 | lokien | hey, how can I treat .boot files as .clj files in vim? it's very frustrating that I don't have any highlighting nor auto indentation in here |
| 07:34 | lokien | I'm using vim-plug if it helps |
| 07:49 | jeaye | lokien: au BufNewFile,BufRead *.boot set filetype=clojure |
| 07:53 | lokien | jeaye: thank you very much |
| 07:53 | jeaye | Sure. |
| 07:54 | lokien | I was desperate enough to mv build.boot build.boot.clj :( |
| 09:10 | TMA | lokien: also adding this line to the bottom/top several lines of the file helps ; vim: set ft=clojure : |
| 09:14 | TMA | lokien: see :help modeline for details |
| 09:21 | gfredericks | lokien: did TEttinger3 point to https://www.youtube.com/watch?v=u0t-6lUvXHo and https://github.com/clojure/test.check/blob/master/src/main/clojure/clojure/test/check/random.clj? |
| 09:24 | lokien | gfredericks: no |
| 09:25 | lokien | TMA: I'll check this out |
| 09:26 | lokien | TMA: will this set every file to be a clojurey one? |
| 09:29 | lokien | gfredericks: nice diagrams. I'll bookmark it and watch it after I'm done with cljs intro |
| 09:45 | lokien | noncom: hello |
| 10:08 | lokien_ | gfredericks: I got lost after like 15 minutes |
| 10:09 | lokien_ | but it's an interesting talk |
| 10:26 | gfredericks | haha |
| 10:26 | gfredericks | my apologies |
| 10:27 | gfredericks | communicating is hard |
| 10:30 | lokien_ | gfredericks: nah, that's my fault |
| 10:31 | lokien_ | I don't get concepts that quickly and I barely know rng stuff |
| 10:43 | TMA | lokien_: the jeaye's method [if put into .vimrc] will make every *.boot file clojurey -- my suggestion will make the file this modeline is in clojurey, but not others |
| 10:44 | TMA | lokien_: the jeaye's method will make all *.boot clojurey just for you, whereas the modeline will make the particular file it clojurey for everyone using vim |
| 10:45 | TMA | lokien_: these are the main tradeoffs |
| 10:45 | lokien_ | TMA: okay, I'll use your solution then |
| 10:45 | TMA | *file it is present in |
| 11:06 | qsys | if I have a collection of items and want to turn this into a list of vectors of every first and third item... what's the best/cleanest way to do that? (item1 item2 item3 item4 item5 item6) shoud be transformed into ([item1 item3] [item4 item6]) |
| 11:07 | justin_smith | ,(map (fn [[a b c]] [a c]) (partition-all 3 (range 1 7))) |
| 11:07 | clojurebot | ([1 3] [4 6]) |
| 11:08 | qsys | lol, easy, thx! |
| 11:10 | qsys | it's always easier than I think... |
| 11:10 | justin_smith | the more you use all the core functions, the easier it is to see how to use and compose them to get your result |
| 11:11 | qsys | it's partition-all I couldn't think of :p |
| 11:22 | justin_smith | in case one forgets it exists, it could be something like -- |
| 11:22 | justin_smith | ,(defn part ([n coll] (part n n coll)) ([n step coll] (when (seq coll) (lazy-seq (cons (take n coll) (part n step (drop step coll))))))) |
| 11:22 | clojurebot | #'sandbox/part |
| 11:22 | justin_smith | ,(part 3 (range 1 7)) |
| 11:22 | clojurebot | ((1 2 3) (4 5 6)) |
| 11:27 | late20 | hey! i have (() ([1 2]) () ([3 4])) and would need to get ([1 2][3 4]), so need to get rid of the inner lists. can't figure out any good way... |
| 11:27 | justin_smith | ,(filter seq ' (() ([1 2]) () ([3 4])) ) |
| 11:27 | clojurebot | (([1 2]) ([3 4])) |
| 11:28 | justin_smith | ahh, wait |
| 11:28 | justin_smith | ,(apply concat ' (() ([1 2]) () ([3 4])) ) |
| 11:28 | clojurebot | ([1 2] [3 4]) |
| 11:28 | justin_smith | late20: if you got that list via "map", you can just replace "map" with "mapcat" btw |
| 11:37 | engblom | I wonder if refs is the tool I need in this case: I a single state I need want to update in a threadsafe way. The state update function takes a few steps and while it is running, I want reading of the state to be blocked. |
| 11:37 | justin_smith | engblom: there is nothing in clojure that blocks reading while an update is in process |
| 11:37 | justin_smith | engblom: with refs, agents, atoms, you just read the old value while it is mid update |
| 11:38 | engblom | justin_smith: Is not dosync doing it? |
| 11:38 | justin_smith | no |
| 11:38 | justin_smith | engblom: dosync makes sure they read the old value, or the final one |
| 11:38 | justin_smith | it doesn't block reading |
| 11:38 | engblom | What if I wrap the places where it is read also with a dosync? |
| 11:39 | late20 | justin_smith: sweet, thanks! |
| 11:39 | justin_smith | engblom: then you'd get retries, and eventually it would return the new value |
| 11:39 | justin_smith | engblom: but it's still not blocking, it's just forcing the code to run again |
| 11:40 | engblom | justin_smith: So the effect is still that I get the new value and not the old if I wrap the @ with dosync? |
| 11:40 | justin_smith | if there's any overlap, yeah |
| 11:40 | engblom | Ok, thanks! That is what I want |
| 11:42 | engblom | My exact case is this: If I have a stepper motor and its 8 phases that I want to store in a ref. I need to both change the ref and the stepper motor together, so if anything would want to read the state of the motor, it would always be right. |
| 11:48 | lokien_ | I'm trying to learn cljs, but I'm spooked by html and css. do we have any wrapper around these? |
| 12:03 | favetelinguis | ,(let [a "3"] (case a (str 3) "ETT")) |
| 12:03 | clojurebot | #error {\n :cause "No matching clause: 3"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching clause: 3"\n :at [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6927]\n [clojure.lang.Compiler eval "Compiler.java" 68... |
| 12:03 | justin_smith | favetelinguis: case only allows literals |
| 12:04 | justin_smith | favetelinguis: that clause matches str or 3, but not "3" |
| 12:04 | justin_smith | ,(case str (str 3) :OK) |
| 12:04 | clojurebot | #error {\n :cause "No matching clause: clojure.core$str@e9ea392"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching clause: clojure.core$str@e9ea392"\n :at [sandbox$eval51 invokeStatic "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval51 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval51 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Compiler.java" 6927]\n ... |
| 12:04 | justin_smith | hmm |
| 12:04 | justin_smith | ,(case :str (:str 3) :OK) |
| 12:04 | clojurebot | :OK |
| 12:06 | favetelinguis | what i want to do is something like this |
| 12:08 | favetelinguis | ,(let [in-msg :key2 m {:a :key1 :b :key2}] (case in-msg (:a m) "A" (:b m) "B")) |
| 12:08 | clojurebot | #error {\n :cause "Duplicate case test constant: m"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: Duplicate case test constant: m, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6875]}\n {:type java.lang.IllegalArgumentException\n :message "Duplicate case test constant: m"\n :at [clojure.co... |
| 12:08 | justin_smith | favetelinguis: right, that is impossible |
| 12:08 | justin_smith | use cond instead |
| 12:08 | favetelinguis | ok thanks will look that up ty |
| 12:08 | justin_smith | case only allows literals |
| 12:13 | bcoburn_ | ,(let [a "3"] (case a "3" "ETT")) |
| 12:13 | clojurebot | "ETT" |
| 12:14 | bcoburn_ | oh I see |
| 12:14 | bcoburn_ | Ignore my sillyness |
| 12:15 | justin_smith | ,(case 'str (str 3) :OK) |
| 12:15 | clojurebot | :OK |
| 13:01 | favetelinguis | are there any restrictions on how to require records? im trying to require a defrecord but getting the error it cant be found... |
| 13:04 | justin_smith | you require namespaces, not records |
| 13:04 | justin_smith | you can import the class, but the class won't exist for importing until the namespace is required |
| 13:07 | favetelinguis | hmm i have a prismatic schema required as s then i have a s/defrecord MyTypeSchema in ns a, then in ns b i want to do (s/validate MyTypeSchema in-value) |
| 13:07 | justin_smith | then you need (:require [a :refer [MyTypeSchema]]) |
| 13:08 | justin_smith | or you can do a normal require, and use a.MyTypeSchema |
| 13:08 | favetelinguis | getting an error when doing that, but then i know it shuld be no problems, must be somthing else then |
| 13:08 | justin_smith | sorry, a/MyTypeSchema |
| 13:09 | justin_smith | favetelinguis: "an error" |
| 13:09 | favetelinguis | No such var... |
| 13:13 | favetelinguis | anyone uses cider in emacs here and knows how to jump to file of error from the error buffer? I found M-g s should do this but it does not work... |
| 13:49 | favetelinguis | justin_smith: no mather what i try im not able to use a record defined in ns a in ns b, im following the recomendations of first require the ns a than explicitly import the record but still the var can not be found, might there be somthing else im missing? |
| 13:58 | favetelinguis | newer mind i was using it wrong with prismatic schema |
| 14:01 | justin_smith | favetelinguis: working demo https://gist.github.com/noisesmith/265d375137b842d055dd |
| 14:01 | justin_smith | but it sounds like you solved it already |
| 14:34 | favetelinguis | justin_smith: the thing is i wanted to record class and not the constructor function |
| 14:35 | favetelinguis | but i got it working when i realised that the imported class is accesed using ClassName. not only ClassName :) |
| 14:37 | favetelinguis | if an exception is thrown in a go block will that be propagated and diplayed or will the go block only siliently die? |
| 14:41 | favetelinguis | (timbre/info "HERE") |
| 14:42 | favetelinguis | This is what i want to do but i want to exeption to be propagated no EX never prints (a/go (Thread/sleep 2000) (println "ONE") (throw (Exception. "EX")) (println "TWO")) |
| 14:43 | justin_smith | favetelinguis: yes, you need a try catch that prints inside the go block if you want it to print |
| 14:44 | justin_smith | favetelinguis: also, updated that example https://gist.github.com/noisesmith/265d375137b842d055dd |
| 14:51 | favetelinguis | thanks, however i never go that workign with the prismatic schema defrecord macro, and use it with validate. |
| 16:15 | lambda-11235 | When is hasheq used for symbols? |
| 16:57 | gfredericks | probably when putting them in a hash map? |
| 16:57 | lokien_ | what does ^ before a value do? it's hard to google |
| 16:57 | gfredericks | ,(hash 'foo) |
| 16:58 | clojurebot | -1385541733 |
| 16:58 | gfredericks | ,(meta ' ^foo bar) |
| 16:58 | clojurebot | {:tag foo} |
| 16:58 | gfredericks | lokien_: ^ is part of metadata syntax |
| 16:58 | gfredericks | it doesn't go before a value by itself |
| 16:58 | gfredericks | ,(meta ' ^a-symbol ^:a-keyword ^{:a :map} the-real-value) |
| 16:58 | clojurebot | {:a :map, :a-keyword true, :tag a-symbol} |
| 16:59 | gfredericks | ↑ three had syntaxes |
| 16:59 | gfredericks | s/had/hat/ |
| 17:00 | gfredericks | ,(set! *print-meta* true) |
| 17:00 | clojurebot | #error {\n :cause "Can't change/establish root binding of: *print-meta* with set"\n :via\n [{:type java.lang.IllegalStateException\n :message "Can't change/establish root binding of: *print-meta* with set"\n :at [clojure.lang.Var set "Var.java" 221]}]\n :trace\n [[clojure.lang.Var set "Var.java" 221]\n [sandbox$eval97 invokeStatic "NO_SOURCE_FILE" -1]\n [sandbox$eval97 invoke "NO_SOURCE_FILE... |
| 17:00 | lokien_ | gfredericks: why would I need that? |
| 17:00 | gfredericks | ,(binding [*print-meta* true] (print-str 'foo)) |
| 17:00 | clojurebot | "foo" |
| 17:00 | gfredericks | ,(binding [*print-meta* true] (print-str '^a-symbol ^:a-keyword ^{:a :map} foo)) |
| 17:00 | clojurebot | "foo" |
| 17:01 | gfredericks | hrmph |
| 17:01 | Mordus | Is it an antipattern to use an input channel and output channel when using something like Chord? The documentation talks about the channels being two way, but I can't wrap my head around how to use the channel in both directions |
| 17:01 | gfredericks | lokien_: it's mostly used for compiler flags & annotations |
| 17:01 | gfredericks | e.g., type-hints |
| 17:02 | lokien_ | ^{:key item} - it's from reagent intro. |
| 17:03 | gfredericks | whenever you see a form like that, it's attaching metadata to the next thing |
| 17:03 | gfredericks | so if we did this: |
| 17:03 | lokien_ | it says something about unique keys to every item |
| 17:03 | gfredericks | ,^{:key item} |
| 17:03 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 17:03 | gfredericks | we'd get a syntax error since there was nothing to add the metadata to |
| 17:03 | lokien_ | so we'd need item declared earlier, right? |
| 17:04 | gfredericks | yeah that too |
| 17:04 | gfredericks | ,^{:key item} [:still-won't-work] |
| 17:04 | clojurebot | #error {\n :cause "Unable to resolve symbol: item in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: item in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: item in this co... |
| 17:04 | lokien_ | (why would it work anyway?) |
| 17:15 | justin_smith | lokien_: reagent uses metadata before items in collections in order to track the "identity" to know how items should move if the list is altered |
| 17:15 | justin_smith | lokien_: since the object identity isn't helpful with clojure, it needs some other marker to know which entry is which in a table or list etc. |
| 17:17 | lokien_ | justin_smith: well, thanks. is there any good tut about reagent besides intro? |
| 17:17 | lokien_ | I hate how clojure tutorials assumed I know java, and now cljs tutorials assume I know js and html |
| 17:18 | ridcully_ | i dont use reagent, but "the others" usually allow the :key just fine with the attributes |
| 17:19 | lokien_ | ridcully_: kay, I'll take this approach |
| 17:19 | ridcully_ | at least give it a try. e.g. [:td {:key ...} "zerg"] |
| 17:20 | Deraen | lokien_: Re-frame has good Reagent tutorials: https://github.com/Day8/re-frame/wiki#reagent-tutorials |
| 17:20 | lokien_ | I don't know with what, I don't understand a word from this weird code :^) |
| 17:21 | lokien_ | Deraen: you saved my life. they're kind of short though |
| 17:22 | Deraen | And yes, Reagent allows key attribute. Metadata is useful when the element is another component, ^{:key 1} [list-item item] |
| 17:34 | austrinus | W abh- |
| 17:40 | princeso | how do we name it when we do this (:key {:key 1}), im calling it like 'left key call' |
| 17:41 | justin_smith | invoking a keyword |
| 17:41 | justin_smith | calling a keyword |
| 17:41 | justin_smith | if it's not on the left, you aren't calling it |
| 17:41 | justin_smith | ,(:ho :ho :ho) |
| 17:41 | clojurebot | :ho |
| 17:42 | lokien_ | and what does @ do, before a value? |
| 17:42 | kwladyka | What is the point of "complement" function? Personally i feel this is a first step to make unnecessary functions in Clojure. |
| 17:42 | justin_smith | ,'@foo |
| 17:42 | clojurebot | (clojure.core/deref foo) |
| 17:42 | justin_smith | lokien_: ^ |
| 17:43 | justin_smith | kwladyka: it's extremely useful |
| 17:43 | justin_smith | ,(def not-zero? (complement zero?)) |
| 17:43 | clojurebot | #'sandbox/not-zero? |
| 17:43 | kwladyka | justin_smith why not "not" instead? :) |
| 17:43 | justin_smith | ,(not-zero? 1) |
| 17:43 | clojurebot | true |
| 17:43 | justin_smith | kwladyka: try doing that with not |
| 17:44 | justin_smith | kwladyka: not is for negating a single result, complement is for creating the opposite predicate |
| 17:44 | justin_smith | these are not the same thing |
| 17:46 | lokien_ | justin_smith: eww, all these complicated words in docs.. why can't I just (println "hello world") till my program builds itself |
| 17:49 | princeso | justin_smith : thx . :D |
| 17:49 | kwladyka | justin_smith ok it makes a few lines less but the true value will be if editors could show parameters from inner function |
| 17:49 | justin_smith | lokien_: in my experience some programming concepts are not useful until you make the terrible mistakes that go with not understanding them yet |
| 17:52 | justin_smith | lokien_: you can consider each big word you don't get an attempted solution for a mistake you haven't made (or maybe made but didn't understood) yet |
| 17:53 | lokien_ | justin_smith: I'll read "clojure for the brave and true" chapter about it, so I won't do this mistake (which I didn't do) again |
| 17:53 | justin_smith | heh |
| 17:54 | Glenjamin | the trick when learning programming (imo), is to realise that mistakes don't really cost anything |
| 17:54 | Glenjamin | you can just try stuff, and if it doesn't work, try something else |
| 17:54 | justin_smith | Glenjamin: depends on what time's worth, yeah |
| 17:54 | Glenjamin | it's not like building a bridge, or a wall |
| 17:55 | lokien_ | anyway, does anyone know where is j-pb? he promised to help me and now he's gone |
| 17:55 | bcoburn_ | I find that I waste less time making mistakes than I do worrying about all the mistakes I might be making |
| 17:55 | kwladyka | lokien_ i really recommend watch clojure inside out if you are learning and want to understand what is and what not is Clojure |
| 17:56 | lokien_ | kwladyka: is it a talk or something? |
| 17:56 | kwladyka | lokien_ video |
| 17:56 | kwladyka | "clojure inside out" - the title |
| 17:56 | lokien_ | kwladyka: another sleepless night, thanks |
| 17:57 | kwladyka | ;) |
| 17:57 | lokien_ | Glenjamin: I don't like any of this cljs stuff, how do I build a website in clojure? :^) |
| 17:59 | kwladyka | lokien_ there you have courses http://www.purelyfunctional.tv , one of them is about ClojureScript and OM |
| 17:59 | kwladyka | and generally they will help you to learn faster |
| 18:00 | lokien_ | kwladyka: are they free? this site is so ugly on mobile |
| 18:00 | lokien_ | welp, they aren't |
| 18:00 | kwladyka | lokien_ no, you have to pay but it is worth that |
| 18:00 | kwladyka | generally things where you have to pay are better... |
| 18:00 | lokien_ | the problem is, I have like four dollars |
| 18:01 | lokien_ | which is kinda good, since I had three last week |
| 18:01 | kernasi | lokien_, that website looks like shit even on a pc with a big screen :) |
| 18:02 | lokien_ | kernasi: why would I pay them then /: |
| 18:02 | lokien_ | I know, I know, maybe courses are okay |
| 18:02 | kernasi | heh |
| 18:02 | kwladyka | 4clojure.com <- this is free place where you can learn a lot |
| 18:03 | kwladyka | just add the best users to fallow they solutions |
| 18:03 | kwladyka | and after do task you can compare your solution with they |
| 18:03 | kwladyka | and learn a lot |
| 18:03 | kernasi | kwladyka, that's useful, thanks |
| 18:04 | lokien_ | kwladyka: I knew that it existed, I just want to learn how to use react :^( |
| 18:04 | kernasi | eww :P |
| 18:05 | kernasi | kwladyka, nice, now I know how I can waste my weekend :) |
| 18:05 | kwladyka | lokien_ just choose Rum, Om or another tool and start doing it :) |
| 18:06 | lokien_ | kernasi: have you seen advent of code? :^) |
| 18:06 | lokien_ | kwladyka: right now I'm trying to get reagent to work, kind of |
| 18:07 | kernasi | lokien_, no, just projecteuler |
| 18:07 | lokien_ | kernasi: check it out |
| 18:10 | Frozenlock | Is there a situation where 'with-test' is acceptable? It seems I always only see separate test namespaces. |
| 18:42 | gfredericks | one question you might find relevant is if `lein test` supports it out of the box |
| 19:25 | lrc | trying to reify a ConvergenceChecker from http://goo.gl/7B5Q4q. Clojure can't find matching method, and none of my attempts to hint the types have worked either. Is the use of <PAIR> complicating things, I wonder... |
| 19:28 | justin_smith | you shouldn't need to hint the method, does your reify provide "this"? because that's manditory and not providing it can make it look like an invalid method |
| 19:29 | justin_smith | (reify ConvergenceChecker (converged [this iteration previous current] ...)) |
| 19:30 | lrc | yup, my code looks just like that. It gets a reflection warning in lein check, though. (Maybe that's not authoritative?) |
| 19:32 | lrc | actually, hold on a moment. The reflection warning is actually further in the method. Maybe I have to hint the call. |
| 19:34 | lrc | that was it. When I got reflection warnings further along, I tried to include the type hint in the parameter list, but then Clojure couldn't match the method for reify. |
| 19:34 | lrc | Adding a type hint at the call site for those last two params has done the trick. Thank you! |
| 19:34 | justin_smith | np, glad you got it sorted out |
| 21:49 | Mordus | I just started an app using chord, and I'm noticing some strange behavior, I can only send 128 messages through my websocket. Anyone experience this? Is there a setting that's not right or something? |
| 21:54 | hiredman | well, there are three places to check, the producing side, the consuming side, and the middle |
| 21:54 | hiredman | the first thing to check is, are their errors in any of those three places |
| 21:55 | hiredman | stacktraces, exceptions, entries in the console log or however you find errors in the browser |
| 21:57 | Mordus | hiredman, I'm an idiot. Thank you. Websockets were timing out |
| 22:00 | hiredman | go forth and debug |
| 22:01 | pilne | gosh darn it, finding a color theme in atom that will hilight & is proving to be quite difficult |
| 23:11 | lambda-11235 | Does comparing symbols have a time complexity of O(1)? |
| 23:14 | justin_smith | lambda-11235: worst case is two uninterned symbols, that are long and differ at the end I think... |
| 23:14 | justin_smith | this might be where hashCode comes in... |
| 23:20 | lambda-11235 | justin_smith: But symbols are interned in clojure, and compared using this fact, right? |
| 23:21 | lambda-11235 | It's hard to tell looking at Symbol.java. |
| 23:25 | justin_smith | lambda-11235: I am not certain they are all interned - if they are the overhead is all aborbed at symbol creation time of course |
| 23:25 | justin_smith | lambda-11235: I'm going to do a microbenchmark.... |
| 23:31 | lambda-11235 | Symbol.intern doesn't appear to actually do anything, what am I missing? |
| 23:32 | justin_smith | lambda-11235: looks like ~O(n) imperically https://gist.github.com/noisesmith/2abff5c61244452835b4 |
| 23:32 | justin_smith | empirically, however we spell that |
| 23:32 | justin_smith | sorry, I mean O(1) |
| 23:34 | justin_smith | lambda-11235: I assume you are looking here? https://gist.github.com/noisesmith/2abff5c61244452835b4 |
| 23:36 | lambda-11235 | justin_smith: At the site you just posted, yeah. |
| 23:36 | justin_smith | oops, I didn't mean to paste my gist twice |
| 23:37 | justin_smith | I meant to link to here https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Symbol.java#L58 |
| 23:38 | lambda-11235 | justin_smith: That, and the method right above it. |