2015-08-09
| 00:01 | rpaulo | grrr, cat again |
| 02:22 | domokato | hm, when i put in a hex value, 0xFFBEBEBE for example (for an argb color), I can't convert it to an int because I get a "value out of range" exception |
| 02:23 | domokato | ,(int 0FFBEBEBE) |
| 02:23 | clojurebot | #<NumberFormatException java.lang.NumberFormatException: Invalid number: 0FFBEBEBE> |
| 02:23 | domokato | er |
| 02:23 | domokato | ,(int 0xFFBEBEBE) |
| 02:23 | clojurebot | #error {\n :cause "Value out of range for int: 4290690750"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Value out of range for int: 4290690750"\n :at [clojure.lang.RT intCast "RT.java" 1198]}]\n :trace\n [[clojure.lang.RT intCast "RT.java" 1198]\n [sandbox$eval47 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval47 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "... |
| 02:24 | hiredman | ,(Integer/toHexString Integer/MAX_VALUE) |
| 02:24 | clojurebot | "7fffffff" |
| 02:25 | hiredman | ,(unchecked-int 0xFFBEBEBE) |
| 02:25 | clojurebot | -4276546 |
| 02:26 | domokato | sweet, thanks! |
| 02:27 | domokato | man, that's not even in the cheatsheet |
| 02:28 | hiredman | if everything was on whatever cheatsheet, the cheatsheet would just be a listing of everying in clojure.core |
| 03:09 | irctc | Hello, quick question : I am trying to import core.async in my REPL : (require '[clojure.core.async] :as async) what's wrong with this ? (runtime exception unable to resolve symbol: async) |
| 03:10 | irctc | this seem to work though at least doesn't throw an error : (require '[clojure.core.async]) |
| 03:11 | irctc | aah nevermind, it's me being stupid : (require '[clojure.core.async :as async]) |
| 04:03 | irctc | Hello, can someone help me debug my protocol ? I can't find the right way to call it https://www.refheap.com/7739d3471f05b3681fde6b0bf |
| 04:04 | justin_smith | irctc: the first argument to every protocol method must be the object implementing the protocol |
| 04:04 | justin_smith | irctc: traditionally we name it "this" |
| 04:05 | justin_smith | irctc: also, the protocol method is a function, it is not an argument to the object implementing the protocol |
| 04:05 | irctc | Do you mean I should do (add-subscriber subscription-store id context) instead ? |
| 04:05 | irctc | hmm thanks just let me 30 secs to process it ^^ |
| 04:05 | justin_smith | irctc: that, and you also need to change the declaration and definition of add-subscriber |
| 04:06 | justin_smith | the declared args must include the this arg |
| 04:06 | irctc | ooh I see |
| 04:07 | irctc | every time, I should have this as first arg ok |
| 04:07 | irctc | and then how will I call it ? like I pasted here ? |
| 04:07 | justin_smith | yes |
| 04:07 | irctc | justin_smith: thanks a lot I'm going to try that now |
| 04:07 | justin_smith | it's OK not to call the arg "this" - eg. if you don't use the arg, it can be called _ |
| 04:09 | irctc | Oh I saw that convention thanks again. I shouldn't need it right ? (the memory store will have a redis store counterpart in case it matters- |
| 04:13 | irctc | justin_smith: Seem to work ! Thanks a ton ! |
| 10:58 | lodin_ | Is it possible to construct a value x such that (let [[& {a :a}] x] ...) makes sense? |
| 11:06 | lodin_ | Or as a test, can (is (nil? (let [[& {a :a}] x] a))) fail? |
| 12:17 | justin_smith | lodin_: what would an ampersand in a let destructure even mean? |
| 12:19 | AimHere | ,(let [[& {a :a}] x] a) |
| 12:19 | clojurebot | #error {\n :cause "Unable to resolve symbol: x in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: x in this context"\n ... |
| 12:19 | AimHere | ,(let [[& {a :a}] 10] a) |
| 12:19 | clojurebot | #error {\n :cause "Don't know how to create ISeq from: java.lang.Long"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: java.lang.Long"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.core$seq__4116 invokeStatic "core.clj" 137]\n [clojure.co... |
| 12:20 | AimHere | ,(let [[& {a :a}] {:foo 10 :bar 20}] a) |
| 12:20 | clojurebot | nil |
| 12:21 | justin_smith | ,(let [[& {a :a}] [:a 0]] a) ; wut |
| 12:21 | clojurebot | 0 |
| 12:21 | justin_smith | it makes me kind of unhappy that that works |
| 12:40 | lodin_ | justin_smith: Hmm, I thought I tried that one. |
| 12:40 | lodin_ | Apparently I didn't. |
| 12:45 | lodin_ | ,(let [{a :a} (seq [:a :A])] a) |
| 12:45 | clojurebot | :A |
| 12:50 | lodin_ | but, |
| 12:50 | lodin_ | ,(let [{a :a} [[:a :A]]] a) |
| 12:50 | clojurebot | nil |
| 12:51 | lodin_ | Presumably because [] is associative, and there's no :a in the vector. |
| 12:51 | justin_smith | ,(let [[{a :a}] [[:a :A]]] a) |
| 12:51 | clojurebot | nil |
| 12:51 | lodin_ | ,(let [[{a :a}] [(seq [:a :A])]] a) |
| 12:51 | clojurebot | :A |
| 13:34 | kwmiebach | Hi. What does the cljr extension stand for? it is mentioned here: http://clojure.org/reader#The Reader--Reader Conditionals |
| 13:37 | hyPiRion | clojure clr probably |
| 13:37 | hyPiRion | http://clojure.org/clojureclr |
| 13:41 | kwmiebach | thank you. and my link above was broken, it should be http://clojure.org/reader#The%20Reader--Reader%20Conditionals |
| 13:49 | kwmiebach | yeah probably :cljr is reserved for the dotnet implementation in reader conditionals |
| 14:02 | gfredericks | are there any strong opinions about indenting styles for top-level reader conditionals? |
| 14:08 | justin_smith | gfredericks: I lament bitter tears over emacs not being able to indent them like hash-maps |
| 14:10 | gfredericks | what is backing the emacs identation stuff currently? |
| 14:22 | justin_smith | gfredericks: the magic happens here https://github.com/clojure-emacs/clojure-mode/blob/master/clojure-mode.el#L638 |
| 14:45 | lentils_ | anyone here experienced with enlive? |
| 14:52 | lodin_ | ,(let [[a :as x b] [1 2]] a) |
| 14:52 | clojurebot | 1 |
| 14:52 | lodin_ | ,(let [[a :as x b] [1 2]] x) |
| 14:52 | clojurebot | [1 2] |
| 14:52 | lodin_ | ,(let [[a :as x b] [1 2]] b) |
| 14:52 | clojurebot | #error {\n :cause "Unable to resolve symbol: b in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: b in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: b in this context"\n ... |
| 14:52 | lodin_ | ^^^ Bug or features? |
| 14:52 | lodin_ | *feature. |
| 14:52 | justin_smith | lodin_: nothing can follow :as |
| 14:53 | lodin_ | justin_smith: Why not? |
| 14:53 | justin_smith | because after ":as x" the destructure ignores all input |
| 14:53 | lodin_ | justin_smith: But why? |
| 14:53 | justin_smith | so anything can follow it I guess, it just won't do anything |
| 14:54 | justin_smith | lodin_: because it was written that way. The destructuring code is weird. |
| 14:54 | gfredericks | lodin_: it's an impl detail, and is confusing, but doesn't prevent anything |
| 14:54 | lodin_ | It's not clear from the docs. But when I read "http://clojure.org/special_forms#Special Forms--Binding Forms (Destructuring)-Vector binding destructuring" I see that you could interpret "Finally, ..." as meaning "in the last position". |
| 14:54 | gfredericks | i.e., (let [[a b :as x] [1 2]] b) is what you really want, right? |
| 14:55 | lodin_ | I actually prefer to put :as first. |
| 14:55 | lodin_ | I always do that with maps. |
| 14:56 | gfredericks | yeah I just mean that it means the same thing |
| 14:58 | lodin_ | gfredericks: Right. |
| 14:58 | lodin_ | Do you think a patch to allow :as anywhere, or at least in the beginning, would be accepted? |
| 15:00 | justin_smith | I doubt it |
| 15:01 | gfredericks | more likely a patch that throws if you put anything after the :as clause |
| 15:01 | justin_smith | yeah |
| 15:01 | gfredericks | which won't give you what you want of course |
| 15:02 | justin_smith | the only reason :as doesn't need to be last in a map is because maps are unordered I guess |
| 15:02 | lodin_ | I don't really understand the rationale for requiring :as to be the last thing. |
| 15:02 | gfredericks | I haven't thought about it till not but |
| 15:03 | gfredericks | you could argue that the normal mode of sequential destructuring where each thing is positional gets interrupted in a confusing way if you allow arbitrary clauses in between |
| 15:04 | justin_smith | destructure is already insane and hairy as code, it would be worse I bet if it had to accept :as anywhere |
| 15:04 | gfredericks | it's visually more confusing because in [a b :as c d e f] |
| 15:04 | gfredericks | c and d are *very* different |
| 15:04 | lodin_ | Yeah. Which is why I also gave the option of "in the beginning". |
| 15:05 | gfredericks | same for [:as c a b d e f] |
| 15:05 | lodin_ | I agree that it would be confusing to have keyword in the middle there, particularly when the subforms are not just symbols. |
| 15:07 | lodin_ | Interesting. I find the leading style to be much clearer, because when you have even just slightly non-trivial destructuring the :as clause gets hidden far to the right. |
| 15:07 | justin_smith | lodin_: I always put :as on its own line |
| 15:08 | lodin_ | like [a {foo :bar {this :that}} :as v]. |
| 15:08 | justin_smith | like that, but with a newline before :as |
| 15:09 | lodin_ | Yeah, I was giving an example of v being pushed to the left. Maybe I'm bad at reading destructurings, but I need to look back left to see what v actually contains. |
| 15:10 | lodin_ | If I get :as v in the beginning, I know that "what I'm reading now is part of v", instead of having to backtrack to update when v started. |
| 15:11 | lodin_ | justin_smith: It makes sense to put :as on it's own line. I should try that. |
| 15:11 | lodin_ | I've tried to not use multiline destructurings, because I find it disrupting when reading the let. But I guess that's something I can get used to. |
| 15:12 | lodin_ | justin_smith: How do you layout the init-expr that follows the binding-form when binding-form is multiline? |
| 15:14 | justin_smith | usually on the same line as the :as clause, depending on how the rest of the let is laid out |
| 15:16 | lodin_ | Ah. Lately, when I have let forms that are too long (usually because it's a vector with long names in it), I have put the init-expr on the next line, but indented. |
| 15:20 | gfredericks | are macros just a lot harder to write in cljs and that's just the end of the matter? |
| 15:20 | gfredericks | (w.r.t. symbol expansion) |
| 15:46 | justin_smith | I've definitely noticed that things that work in clojure macros sometimes don't work in cljs ones |
| 15:47 | gfredericks | I'm starting to think that you just can't use the autoexpansion feature of ` anymore |
| 15:47 | gfredericks | which I'm sure encourages simpler macros |
| 15:48 | justin_smith | gfredericks: time to port hygeinic macros from scheme |
| 15:58 | amalloy | gfredericks: you mean instead of syntax-quote you just get backquote? |
| 16:00 | gfredericks | amalloy: what's backquote? |
| 16:00 | amalloy | like form other lisps |
| 16:00 | amalloy | *from |
| 16:00 | gfredericks | oh I'ven't another lisp |
| 16:01 | amalloy | just like, `(a b c) returns (a b c) instead of (foo/a foo/b foo/c) |
| 16:02 | gfredericks | yeah, you only get the unquoting and the gensym features |
| 16:02 | gfredericks | but what this means in real life is that you still have the symbol expansion feature, it just usually does the wrong thing |
| 16:02 | gfredericks | e.g. `(* 2 3 7) is wrong I assume |
| 16:10 | gfredericks | I think I'm wrong about that, but I have no idea why |
| 16:10 | gfredericks | I.e., I'd assume that expands to ##`(* 2 3 7) |
| 16:10 | lazybot | ⇒ (clojure.core/* 2 3 7) |
| 16:10 | gfredericks | and clojure.core/* doesn't exist in cljs |
| 16:29 | aconz2 | off topic to discuss how to find jobs as a soon-to-be college grad? |
| 16:34 | gfredericks | geography might (or not?) be relevant to that question |
| 16:37 | aconz2 | currently in Maryland, 90% sure I'll be in Tennessee in 6 months, but ideal is remote |
| 17:10 | gfredericks | does anybody understand maven and/or clojure's maven setup well enough to figure out why this commit broke `mvn test`? https://github.com/clojure/test.check/commit/adb0883101e9bb3216539f1f597f6c3075c251f6 |
| 17:14 | gfredericks | I can't tell if it fails while trying to run some kind of cljs thing, or fails because there are now extra files under src/main/clojure/ |
| 17:18 | gfredericks | this must have something to do with the pom.contrib thing |
| 17:20 | hiredman | well, that is a project.clj for lein, likely what is in the maven pom is out of sync with the changes to project.clj |
| 17:20 | gfredericks | hiredman: it's also a file renaming |
| 17:21 | gfredericks | looks like it's the extra cljs files under /src/test/clojure that are doing it |
| 17:22 | gfredericks | I'm guessing this is controlled by the clojure-maven plugin |
| 18:18 | tmtwd | would there be a way to print the value at the key of y in this example? |
| 18:53 | justin_smith | tmtwd: which? |
| 18:54 | tmtwd | http://pastebin.com/Brw6mEZA |
| 18:55 | tmtwd | nvm mind though, I think its impossible/unimportant to do what I wanted to do |
| 18:55 | zardoz2 | if 3.7V means about 50% of the charge is still there (does it?) , can I rely on it always meaning roughly that, regardless of the age of the battery and the number of cycles? |
| 18:55 | zardoz2 | uh wrong channel |
| 19:30 | tmtwd | so, assoc-in is for vectors, and assoc is for hashes? |
| 19:33 | justin_smith | tmtwd: assoc and assoc-in are both for associative collections, associative collections include vectors and hash-maps |
| 19:33 | justin_smith | ,(assoc [] 0 :a) |
| 19:33 | clojurebot | [:a] |
| 19:33 | tmtwd | but they are not interchangeable, i'm trying to see the difference |
| 19:33 | justin_smith | ,(assoc-in [] [0 0 0] :a) |
| 19:33 | clojurebot | [{0 {0 :a}}] |
| 19:34 | justin_smith | tmtwd: assoc-in does a series of nested assoc |
| 19:34 | justin_smith | tmtwd: both default to create a hash-map with nil, but are able to set a numeric index on a vector |
| 19:34 | justin_smith | ,(assoc [] 0 :a) |
| 19:34 | clojurebot | [:a] |
| 19:35 | justin_smith | ,(assoc-in [[[]]] [0 0 0] :a) |
| 19:35 | clojurebot | [[[:a]]] |
| 19:35 | justin_smith | ,(assoc nil :a 0) |
| 19:35 | clojurebot | {:a 0} |
| 19:36 | tmtwd | but, if I have this: (def users [{:name "James" :age 26} {:name "John" :age 43}]), this fails : (assoc users [1 :age] 44) |
| 19:36 | tmtwd | i need to use assoc-in in that case |
| 19:36 | justin_smith | tmtwd: right, that needs to be assoc-in |
| 19:36 | tmtwd | oh I see |
| 19:36 | justin_smith | but that isn't because of vectors versus hash-maps |
| 19:36 | tmtwd | assoc-in is more "recursive" |
| 19:36 | justin_smith | right |
| 19:36 | justin_smith | it digs in |
| 19:36 | tmtwd | or its like a "deep" version of assoc |
| 19:37 | justin_smith | exactly |
| 19:37 | tmtwd | cool thanks |
| 19:37 | justin_smith | tmtwd: this is incredibly valuable when you have nested immutable data structures |
| 19:39 | tmtwd | i see |
| 19:41 | justin_smith | because otherwise you end up writing a lot of boilerplate to get the structures out and put the other stuff in and rebuild it... |
| 20:47 | jefelante | Is it a bad idea to use a transducer to write an EDN file for data that gets put on the channel and put it back as-is? https://gist.github.com/anonymous/623164e2ffbbec86432f |
| 20:51 | justin_smith | jefelante: you could use mult/tap instead |
| 20:51 | jefelante | so tap1 = file writer and tap2 = processor? |
| 20:51 | justin_smith | right |
| 20:52 | justin_smith | also, the fact that you only have one channel means you can't retrieve the data in parallel |
| 20:52 | justin_smith | maybe you actually want that |
| 20:52 | jefelante | i dont really understand |
| 20:53 | justin_smith | jefelante: you have a single data processing pipeline, where every task is independent, and they could otherwise be done in parallel |
| 20:53 | jefelante | oh right |
| 20:53 | justin_smith | so you've artificially slowed down your processing (unless there is a pragmatic reason to only make one request at a time) |
| 20:53 | jefelante | so with mult/tap, I could have the file writer and the processor happening concurrently |
| 20:54 | justin_smith | yes, but with a different design you could be doing all the downloads concurrently |
| 20:54 | justin_smith | whether that's an improvement is another can of worms of course |
| 20:54 | jefelante | right, i see what you mean |
| 20:55 | jefelante | is there another benefit to mult/tap besides just working concurrently? the thing i'm wondering is if maybe its foolish to introduce a transducer that has a side effect |
| 20:55 | justin_smith | jefelante: an idiom I sometimes use is (dotimes [i parallelism] (go ...)) so that the number "parallelism" decides how many parallel data pipelines are created |
| 20:56 | justin_smith | jefelante: transducers and side effects are fine, but with mult/tap the two tasks can go at their own speed |
| 20:56 | justin_smith | which may or may not be a good thing... |
| 20:56 | justin_smith | but usually if one can finish much faster, you'd like it to do so |
| 20:56 | jefelante | ok cool |
| 20:57 | justin_smith | jefelante: also, your task (storing the data on disk as you do the transactions) is something I am doing in my project at the day job right now |
| 20:58 | justin_smith | we are using kafka which stores all messages for a configurable time period on disk |
| 20:58 | justin_smith | and then using transit to encode the body of the messages |
| 20:59 | jefelante | ive read about kafka, but i have this issue where i have trouble understanding something complicated (like kafka) unless i make the mistakes that necessitated building that thing |
| 20:59 | jefelante | first |
| 20:59 | justin_smith | heh, you have a lot of mistakes (or learning one way or another) before you could use kafka, most likely |
| 20:59 | justin_smith | distributed systems are very hard |
| 20:59 | justin_smith | I'm still very bad at them... |
| 21:00 | jefelante | yea, speed isn't an issue for me since i'm rewriting a python script that is plenty fast and runs sequentially, but i'm doing it to try and learn how a larger/async system might work |
| 21:00 | justin_smith | me trying to do hammock driven development on my latest project: http://i.imgur.com/8ryWyNJ.gifv |
| 21:01 | jefelante | it makes one request every ~15 minutes, extracts some information, and occasionally makes additional follow up requests based on that information |
| 21:01 | justin_smith | jefelante: yeah, in that case do the linear version first, and be aware of your options if you want options for speeding it up in the future |
| 21:02 | justin_smith | jefelante: also, though mongo has a bunch of gotchas, it is very easy to use it to store a map of vanilla clojure data as a document for a system like yours |
| 21:02 | justin_smith | with a bit of the fiddly stuff about using files taken care of |
| 21:03 | jefelante | ahh that's an interesting point |
| 21:07 | jefelante | justin_smith: thanks |
| 21:16 | tmtwd | I have an atom http://pastebin.com/HFjCJNZF and I want to assoc such that a new item is appended with a new value |
| 21:16 | tmtwd | whats the best way to achieve this? |
| 21:16 | justin_smith | update-in / conj |
| 21:16 | tmtwd | ah |
| 21:18 | justin_smith | ,(update-in {:items [{:item "program in clojure"}]} [:items] conj {:item "yolo"}) |
| 21:18 | clojurebot | {:items [{:item "program in clojure"} {:item "yolo"}]} |
| 21:18 | justin_smith | or with clojure 1.7, there is also update |
| 21:18 | justin_smith | ,(update {:items [{:item "program in clojure"}]} :items conj {:item "yolo"}) |
| 21:18 | clojurebot | {:items [{:item "program in clojure"} {:item "yolo"}]} |
| 21:19 | tmtwd | cool |
| 21:19 | tmtwd | that worked :) |
| 21:19 | tmtwd | thanks |
| 21:20 | axsk | hey, i need a macro which expands (mymacro a b c) to "a b c" (i need a macro here, as i dont want to eval the symbols, right?) but cant get there since hours. anyone has an idea? |
| 21:21 | namra | ,'(a b c) |
| 21:21 | clojurebot | (a b c) |
| 21:22 | justin_smith | ,(defmacro symstring [& args] (clojure.string/join \space args)) |
| 21:22 | clojurebot | #'sandbox/symstring |
| 21:22 | justin_smith | ,(symstring a b c foo) |
| 21:22 | clojurebot | "a b c foo" |
| 21:23 | justin_smith | axsk: the thing to remember is that the macro gets the literal form as its input, and should return the form that should be evaluated. |
| 21:28 | axsk | wow im surprised by the ease of the answer, (though i still dont understand :>) will come back if i cant work it out, thanks a lot |
| 21:28 | justin_smith | axsk: it's not a hard macro to figure out :) |
| 21:28 | justin_smith | I mean in terms of seeing what it does |
| 21:28 | justin_smith | of course macros are hard, period |
| 21:30 | justin_smith | axsk: the args to the macro are a sequence of symbols (thanks to the & destructuring), and the macro simply puts those symbols into a string |
| 21:30 | justin_smith | ,(symstring (+ 1 1) a b (inc 0)) |
| 21:30 | clojurebot | #error {\n :cause "Unable to resolve symbol: symstring in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: symstring in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: symst... |
| 21:30 | justin_smith | ,(defmacro symstring [& args] (clojure.string/join \space args)) |
| 21:30 | clojurebot | #'sandbox/symstring |
| 21:30 | justin_smith | ,(symstring (+ 1 1) a b (inc 0)) |
| 21:30 | clojurebot | "(+ 1 1) a b (inc 0)" |
| 21:30 | justin_smith | it's literally using the input form |
| 21:32 | axsk | (clojure.string/join \space (a b)) |
| 21:32 | axsk | ,(clojure.string/join \space (a b)) |
| 21:32 | clojurebot | #error {\n :cause "Unable to resolve symbol: a in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: a in this context"\n ... |
| 21:32 | axsk | ,(clojure.string/join \space ('a 'b)) |
| 21:32 | clojurebot | "" |
| 21:32 | justin_smith | axsk: those are function calls |
| 21:32 | axsk | ,(clojure.string/join \space ['a 'b]) |
| 21:32 | clojurebot | "a b" |
| 21:32 | axsk | ah ok |
| 21:32 | justin_smith | there you go |
| 21:32 | justin_smith | ,(clojure.string/join \space '(a b)) |
| 21:32 | clojurebot | "a b" |
| 21:33 | axsk | guess i got it. read so much about syntax quoting and unquoting, that i forgot that args is a seq of SYMBOLS :) |
| 21:33 | justin_smith | axsk: yeah, sometimes you have to think outside the "syntax quote" box. If you are not evaluating any args, you don't need syntax-quote |
| 21:34 | justin_smith | axsk: imho a good macro tutorial would start with list operations, and only introduce ` after the list operations get tedious, so that it's clear that ` is not magic (and why we actually use it) |
| 21:35 | TEttinger | justin_smith: I believe brave clojure is that way |
| 21:35 | gfredericks | my macros talk did that |
| 21:35 | justin_smith | gfredericks: awesome |
| 21:35 | gfredericks | ~` is not magic |
| 21:35 | clojurebot | Ack. Ack. |
| 21:35 | gfredericks | ~` |
| 21:35 | clojurebot | ` is not magic |
| 21:35 | TEttinger | ~~ |
| 21:35 | clojurebot | ~ is how you get factoids from me |
| 21:37 | perif | hi all |
| 21:37 | TEttinger | hey perif |
| 21:39 | justin_smith | TEttinger: today I ended a nethack game that had like 20 hours of total play time - I was in the astral plane, had made it to one altar, and was about to try a second altar |
| 21:40 | justin_smith | TEttinger: neutral monk, first two wishes were the eye of the aethiopica and the orb of fate |
| 21:41 | TEttinger | I am not very good at nethack |
| 21:41 | TEttinger | I would recommend brogue if you aren't totally bound to a true terminal |
| 21:42 | justin_smith | TEttinger: oh, what all that means is I was within 10 minutes of winning the game, after about 20 hours playing, and made a stupid mistake and game over |
| 21:42 | TEttinger | haha |
| 21:42 | TEttinger | well next time |
| 21:42 | justin_smith | by the end, I had 300+ hitpoints plus a magic item that cuts all damage in half |
| 21:42 | justin_smith | so effectively over 600 hp |
| 21:49 | tmtwd | http://pastebin.com/YbhmTiT6 how come the js/alert isn't executed when I call this functions? |
| 21:50 | justin_smith | tmtwd: this doesn't answer your question, but you never need a do inside defn like that |
| 21:50 | tmtwd | hm okay when do I use do then? |
| 21:51 | justin_smith | tmtwd: inside if or for |
| 21:51 | justin_smith | or other contexts that only take one expression |
| 21:51 | tmtwd | or cond? |
| 21:51 | justin_smith | sure, yeah |
| 21:52 | justin_smith | tmtwd: that code is weird because line 3 doesn't do anything at all |
| 21:52 | justin_smith | update creates a new collection, but you don't do anything with it |
| 21:53 | tmtwd | oh |
| 21:53 | justin_smith | so it's as if it wasn't done at all |
| 21:53 | tmtwd | I thought since atoms were mutable we could change them |
| 21:53 | justin_smith | you can, but that's not how |
| 21:54 | tmtwd | would I use assoc-in then? |
| 21:54 | justin_smith | tmtwd: you would use swap |
| 21:54 | tmtwd | oh of course |
| 21:54 | justin_smith | and then you would need to figure out what to do in the swapping function |
| 21:55 | justin_smith | I guess you want to take list-of-items and put it inside a hash-map under the key :items? |
| 21:55 | tmtwd | no I want to take the value of @upcoming-item and append it to @list-of-items (with a key of :item) |
| 21:56 | tmtwd | (def list-of-items (atom {:items [{:item "program in clojure"} {:item "finish web app"} {:item "solve euler problems"}]})) |
| 21:57 | justin_smith | so something like (swap! list-of-items conj {:item @upcoming-item}) |
| 21:57 | justin_smith | nope, not quite |
| 21:57 | justin_smith | (swap! list-of-items update :items conj {:item @upcoming-item}) |
| 21:58 | justin_smith | ,(def list-of-items (atom {:items [{:item "program in clojure"} {:item "finish web app"} {:item "solve euler problems"}]}))) |
| 21:58 | clojurebot | #'sandbox/list-of-items |
| 21:58 | justin_smith | ,(def upcoming-item (atom "yolo")) |
| 21:58 | clojurebot | #'sandbox/upcoming-item |
| 21:58 | justin_smith | ,(swap! list-of-items update :items conj {:item @upcoming-item}) |
| 21:58 | clojurebot | {:items [{:item "program in clojure"} {:item "finish web app"} {:item "solve euler problems"} {:item "yolo"}]} |
| 22:01 | tmtwd | almost works |
| 22:01 | justin_smith | what's missing? |
| 22:03 | tmtwd | i get this instead: (def list-of-items (atom {:items [{:item "program in clojure"} {:item "finish web app"} {:item "solve euler problems"} {:item {:item "yolo"}}]})) |
| 22:03 | tmtwd | an extra :item |
| 22:03 | justin_smith | tmtwd: well chang {:item @upcoming-item} to @upcoming-item |
| 22:04 | justin_smith | I didn't know what was in upcoming-item and I just made a random assumption (that was wrong) |
| 22:05 | tmtwd | oh, ok |
| 22:05 | tmtwd | I'll just get my repl out |
| 22:05 | justin_smith | tmtwd: if you get that result, just change {:item @upcoming-item} in my code to @upcoming-item and it will work |
| 22:06 | justin_smith | but yes, always have a repl open if you are coding clojure |
| 22:06 | tmtwd | justin_smith, yup tried that, the compiler did not like that |
| 22:07 | tmtwd | justin_smith, okay got it :) |
| 22:08 | tmtwd | justin_smith, you were right |
| 22:44 | gfredericks | dnolen: something about the closure-library upgrade in the recent cljs release broke test.check; is there an easy way for me to try out various commits from closure-library? |
| 22:44 | gfredericks | (i.e., to git-bisect the closure-library project by running test.check) |
| 22:45 | dnolen | gfredericks: I can't think of an easy way to do that. |
| 22:45 | dnolen | gfredericks: what is the problem you're seeing? |
| 22:46 | dnolen | the only thing I can think of is something about the PRNG we use |
| 22:47 | gfredericks | dnolen: well this is the new code with the hand-rolled PRNG |
| 22:47 | gfredericks | dnolen: something's undefined at a particular point, which feels like it could be distant from the root cause |
| 22:47 | dnolen | gfredericks: still then would be goog.math.Long thing |
| 22:48 | gfredericks | right; I didn't see any recent changes to goog.math.Long itself; I'll start adding asserts to the code to track down the root cause location |
| 22:49 | dnolen | gfredericks: and you think this is a GCL bug because the error originates from there? |
| 22:49 | gfredericks | dnolen: because explicitly using the older GCL version with new CLJS works fine |
| 22:49 | dnolen | ah interesting |
| 22:52 | dnolen | gfredericks: in ClojureScript repo, in script/closure-library-release there's a script for local Maven install of GCL |
| 22:53 | gfredericks | dnolen: okay cool, I'll use that if it comes to it |
| 22:58 | gfredericks | dnolen: looks like this returns nil https://github.com/clojure/test.check/blob/master/src/main/clojure/clojure/test/check/random/longs.cljs#L56 |
| 22:59 | gfredericks | seems to be an easy workaround if I replace with (long/fromNumber 1) |
| 23:01 | gfredericks | yep everything's passing now |
| 23:07 | gfredericks | I will probably just leave it at that; should I file a ticket? |
| 23:07 | gfredericks | I've never been confident that I was actually doing interop the right way |
| 23:07 | gfredericks | GCL-interop, rather |
| 23:38 | devn | Does anyone here run their production apps with `lein trampoline run`? |
| 23:39 | devn | How are people feeling about AOT these days? I've continued to wonder over the years: to AOT, or not to AOT. |
| 23:39 | devn | (when you have plenty of room for a choice) |