#clojure logs

2015-05-14

00:25teajoeIs there any way to check that a function read via edn is the one you are looking for? (= (first (edn-form)) map) where edn-form equals (map) evaluates to false
00:27hiredmanedn is a data interchange format
00:27hiredmanif you mean clojure.core/map, that is a function object
00:28hiredmanwhich don't exist in the edn format
00:28hiredmanlikely you are looking at a list
00:28hiredman(fn [x] x) is a list
00:28hiredmanwhen evaled it is a function object
00:29hiredmanmap is a symbol, unless evaled at which point it is looked up in the environment and ultimately a function object
00:31teajoeok, is there any way to get a function object from an edn symbol? ty
00:31teajoejust eval it in the current context i guess
00:32teajoeyay I took a step, thanks for explaining that
02:48kral'morning
04:05dm3have a question: say you create a new project with `lein new require-do-block`, then `lein repl` and type `require-do-block.core/foo` - obviously this fails with `CompilerException java.lang.ClassNotFoundException: require-do-block.core` as the ns isn't loaded
04:05dm3now you can do `(do (require 'require-do-block.core) require-do-block.core/foo)` which succeeds
04:06dm3but if you restart the repl (or otherwise unload the ns) and put the above in any other form, e.g. `(println (do (require 'require-do-block.core) require-do-block.core/foo)))` - it fails with the same CompilerException
04:06dm3why is that?
04:20amalloy(require x/y) is a totally unsupported syntax. i don't know what you think it's supposed to do, but it doesn't do that
04:21amalloyoh, i see. you're doing it inside the do, but outside the require
04:22amalloydm3: basically top-level do-forms are treated as if they were separate top-level expressions; no other forms (eg println) are given this special treatment
04:23dm3amalloy: thanks, that helps
04:47dm3kind of the same issue: http://technomancy.us/143
07:13kitallisis there a canonical way to handle api versioning with compojure?
07:29crocketHow do I upgrade nrepl for lein and cider?
07:31i-bliscrocket: you can add a tools.nrepl dependency to your profiles.clj
07:31crockethttps://github.com/clojure-emacs/cider/issues/961
07:31crocketi-blis, I executed 'lein repl' and cider outside any clojure project.
07:32i-bliscrocket: add [org.clojure/tools.nrepl "0.2.10"] to :dependencies
07:33crocketi-blis, What only works inside leiningen projects.
07:33crockethmm...
07:33crocketprofiles.clj?
07:33crocketWhere is profiles.clj?
07:34i-bliscrocket: either in profiles.clj or in your project.clj (but then for each prject you cider-jack-in)
07:34i-bliscrocket: ~/.lein/profiles.clj
07:34crocketi-blis, I started clojure yesterday, so I am confused.
07:35i-bliscrocket: cider might be difficult to configure from time to time, but all in all it is a pleasure to use
07:37i-bliscrocket: in profiles.clj, add the vector to {:user {:dependencies […]}}
07:38crocketi-blis, Like {:user {:dependencies [[[org.clojure/tools.nrepl "0.2.10"]]]}} ?
07:38i-bliscrocket: btw, I recommend you try with stable (0.8.2, I think) first (there you need no hack)
07:39i-bliscrocket: {:user {:dependencies [[org.clojure/tools.nrepl "0.2.10"]]}}
07:39crocketi-blis, stable?
07:40i-bliscrocket: I see you use 0.9-snapshot ; this is what I use at the moment, by I regularly had problems with snapshots in the past and had to go back to stable
07:41crocketi-blis, Do you mean the stable version of cider?
07:42i-bliscrocket: oh, are you sure you installed cider-nrepl plugin?
07:42crocketi-blis, There is no cider-nrepl plugin.
07:42i-bliscrocket: so, this is the issue
07:43i-bliscrocket: add [cider/cider-nrepl "0.9.0-SNAPSHOT"] to {:user {:plugins […]}}
07:43crocketi-blis, I can't find cider-nrepl in emacs package list.
07:44crocketIs cider-nrepl an emacs package?
07:45i-bliscrocket: cider-nrepl is a clojure jar dependency, needed by cider
07:45crocketok
07:45i-bliscrocket: lein will pull it from clojars as soon as you lein deps or launch cider
07:45crocketEven with [org.clojure/tools.nrepl "0.2.10"], nRepl is still 0.2.6
07:46crocketREPL-y 0.3.5, nREPL 0.2.6
07:46i-bliscrocket: you can forget what I said with tools.nrepl
07:46crocketi-blis, What am I going to do?
07:46i-bliscrocket: add [cider/cider-nrepl "0.9.0-SNAPSHOT"] to {:user {:plugins […]}}
07:47crocketnrepl is still 0.2.6
07:48i-bliscrocket: and launch cider (preferably go to a clj file with a project.clj)
07:48i-bliscrocket: and cider complains ?
07:49crocketyes
07:49crocketWARNING: CIDER requires nREPL 0.2.7 (or newer) to work properly
07:51i-bliscrocket: can you post your profiles.clj (refheap, gist)
07:51crocketi-blis, I just needed {:user {:plugins [[cider/cider-nrepl "0.8.2"]]}} in profiles.clj
07:51crocketoops
07:51crocketIt is still reported to be 0.2.6
07:51crocketok
07:51crocketI'm delusional right now.
07:51crocketLet me take a rest.
07:52i-bliscrocket: yes, but stable doesn't neeed > 0.2.7
07:52i-bliscrocket: snapshot does and lein still bundles an old tools.nrepl
07:53crocketI have {:user {:dependencies [[org.clojure/tools.nrepl "0.2.10"]] :plugins [[cider/cider-nrepl "0.8.2"]]}}
07:53crocketnrepl 0.2.10 is not recognized.
07:54i-bliscrocket: with 0.8.2 you can live without
07:56i-bliscrocket: if you update to 0.9.0-snapshot, one thing you can do is delete your old versions of tools.nrepl in your local maven repository (I remember it helped me once)
07:56crocketIt seems lein and cider don't automatically load nrepl>=0.2.7
07:58crocketThey are hardwired to nrepl 0.2.6
07:59i-bliscrocket: well 0.9.0-snapshot does load 0.2.10 for sure
08:00crocketi-blis, Somehow, lein and cider are stubbornly stuck with nrepl 0.2.6
08:04i-bliscrocket: as I said, 0.2.10 loads fine with 0.9.0-snapshot
08:06i-bliscrocket: stick to stable, I switched to snapshot once again recently because I needed some facilities provided for boot and cljs
08:13davsHi! I'd like to 'append' a number to the last element of a list: '(+ 1) => '(+ 12). T'm trying (list (butlast mylist) (+ 2 (* 10 (last mylist))), but instead of '(+ 12) I get '('(+) 12), so the first elem gets wrapped up inside a list itself. How could I fix it?
08:13davsI'm constructing a list datastructure, which I'll evaluate later (it will be nested)
08:15crocketi-blis, Why do you think cider load nrepl 0.2.6 on my machine?
08:15i-bliscrocket: with 0.9.0?
08:17crocketi-blis, yes.
08:17crocket'lein repl' also loads nrepl 0.2.7 despite profiles.clj
08:18i-bliscrocket: don't know. as I said, wipping old nprel.tools from my local maven helped once I think, not sure
08:18crocketi-blis, I destroyed ~/.m2, but the problem still persists.
08:19i-bliscrocket: wow, the whole .m2
08:19i-bliscrocket: why do you want to go away from stable to snapshot?
08:21crocketi-blis, I figured it out.
08:21crocketi-blis, http://stackoverflow.com/a/30139330/2104107 was the solution
08:21crocketI just had to execute cider or lein repl inside a leiningen project.
08:23i-bliscrocket: oh, yes (I think I mentioned it quickly: preferably from a dir with a project-clj)
08:23i-bliscrocket: cool
08:24crocketWhat the hell
08:46i-blisdavs: you may want to use concat here
08:48crocketMi amas clojure.
08:50kaiyinwhat is the clojure equivalent of haskell Maybe or Either types?
08:51kaiyinI know clojure is not statically typed, but is there a something similar to cope with possible null input to / output from a function?
08:55justin_smithkaiyin: you can chain with some-> or some->> to ensure no more work is done after something returns nil
08:55justin_smith,(some-> 1 inc (+ 3))
08:55clojurebot5
08:56justin_smith,(some-> nil inc (+ 3))
08:56clojurebotnil
08:56davsi-blis: thanks, concat did the trick
09:06crocket(sum 1)
09:52fourqHow does .. differ from -> in this case `(.. e -target -value)` vs. `(-> e -target -value)` ?
09:53fourqor is it that same with a different approach to accessing the members?
09:53ToxicFrog,(macroexpand-1 '(.. e -target -value))
09:53clojurebot(.. (. e -target) -value)
09:53ToxicFrog,(macroexpand '(.. e -target -value))
09:53clojurebot(. (. e -target) -value)
09:53ToxicFrog,(macroexpand '(-> e -target -value))
09:53clojurebot(-value (-target e))
09:54ToxicFrog.. turns into a bunch of member accesses using .; -> turns into a bunch of function calls.
09:54ToxicFrogjavawise, it's value(target(e)) vs. e.target().value()
09:54fourqso performance wise (obv not for this tiny task) .. is recommended?
09:54fourqyeah
09:54ToxicFrogI'm not sure that's a meaningful question, they're totally different things
09:55scottjthe latter should have been (-> e .-target .-value) no?
09:55fourqyes, you're right
09:55ToxicFrogscottj: oh, if that was the intent it makes a lot more sense
09:56fourqthanks all
09:57fourqIt seems like this is the right chan to ask these questions since #clojure-beginners isn't as active?
09:58TimMcfourq: Huh, I'm not used to seeing that field syntax in Clojure.
09:59TimMcAre you cross-compiling to CLJS?
09:59fourqTimMc http://clojuredocs.org/clojure.core/_..
09:59ToxicFrogfourq: performance-wise I have no idea what the implications are, I can generally get away with not caring about performance in the stuff I work on~
09:59ToxicFrogfourq: I think TimMc means the - prefix, not the ..
09:59dnolenTimMc: the field syntax was added to Clojure and ClojureScript at the same time
10:00ToxicFrogAt least, that's the bit that stands out as weird to me
10:00TimMcdnolen: Yeah, and then I promptly forgot about it because no one uses it in CLJ. (Right?)
10:00TimMcAlso, I love the 404 page: http://clojuredocs.org/404
10:00ToxicFrogTimMc: I've seen it in the wild in a few places, typically in places where clj is calling into java.
10:01dnolenTimMc: "no uses one it" is always a dangerous thought if the features exists at all in my experience :)
10:01dnolener "no one uses it" :P
10:01TimMc*no one within my horizon :-P
10:02TimMcHave you seen it in the wild?
10:02fourqand TimMc yes, I'm compiling with clojurescript
10:03fourqI've been trying to make sure that my clojure questions are indeed clojure and not clojurescript specific for the chan
10:04TimMcAh, that explains it.
10:04TimMcToxicFrog: To distinguish from nullary methods of the same name, or what?
10:05dnolenfourq: it's fine to ask such questions here, but note there is an active #clojurescript channel
10:06puredangerTimMc: yes, .- is *only* field access in Clojure
10:06fourqyeah I know, I didn't even think about the cljs specific syntax in that form since it didn't matter the type of function being called. I was just trying to unsderstand .. vs -> atm
10:06puredangerwhereas . can do both and will prefer methods if both exist
10:06TimMcSure, I just don't see the point in Clojure-only code.
10:07TimMcI guess it would make the code more portable in the future.
10:07puredangerthe only time you *need* it in Clojure is if you have both a field and a 0-arity method of the same name
10:07puredangerin that case you have to use .-
10:07kaiyin(.-x (java.awt.Point. 10 29))
10:07kaiyin(.x (java.awt.Point. 10 29))
10:08kaiyinWhat's the difference between these two?
10:08puredanger(some of this was buggy before Clojure 1.6.0)
10:08puredangerkaiyin: nothing, other than that .x will also look for a java.awt.Point.x() method
10:09puredangerpresuming that doesn't exist, they should result in the same compiled bytecode afaik
10:09kaiyinah, .-x means x is non-static?
10:09TimMcpuredanger: OK, yeah, that's what I had suggested above.
10:09TimMckaiyin: Nothing to do with static.
10:09puredangerwell both of these are instance calls, not static calls
10:09TimMc,Math/-PI
10:09puredanger.x = instance method or field
10:10clojurebot#error {\n :cause "Unable to find static field: -PI in class java.lang.Math"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to find static field: -PI in class java.lang.Math, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to find static...
10:10TimMcJeez, clojurebot, I don't need an essay.
10:11dnolenfourq: to clarify .. and -> are just different convenience macros. and (.. foo -bar -baz) and (-> foo .-bar .-baz) are equivalent
10:11kaiyinok, i see. didn't notice your previous conversation. what a coincidence that I was also reading on this topic, in the Joy of clojure book.
10:11puredangeractually, I guess .- does do static too, forgot that
10:11TimMc,Math.-PI
10:11clojurebot#error {\n :cause "Math.-PI"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassNotFoundException: Math.-PI, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.ClassNotFoundException\n :message "Math.-PI"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :trace\n [[java.net.URLCl...
10:11Bronsadnolen: actually they're not
10:12TimMcerr, my bad
10:12TimMc,(.-PI Math)
10:12Bronsadnolen: (.-foo bar) and (. bar -foo) are not always equivalent on the jvm
10:12clojurebot#error {\n :cause "No matching field found: PI for class java.lang.Class"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching field found: PI for class java.lang.Class"\n :at [clojure.lang.Reflector invokeNoArgInstanceMember "Reflector.java" 308]}]\n :trace\n [[clojure.lang.Reflector invokeNoArgInstanceMember "Reflector.java" 308]\n [sandbox$eval69 invoke "NO_SOURCE_FI...
10:12puredangerdocs here: http://clojure.org/java_interop#dot
10:12TimMcNot seeing it.
10:12Bronsa,(. Math -PI)
10:12clojurebot3.141592653589793
10:12Bronsa,(.-PI Math)
10:12clojurebot#error {\n :cause "No matching field found: PI for class java.lang.Class"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching field found: PI for class java.lang.Class"\n :at [clojure.lang.Reflector invokeNoArgInstanceMember "Reflector.java" 308]}]\n :trace\n [[clojure.lang.Reflector invokeNoArgInstanceMember "Reflector.java" 308]\n [sandbox$eval117 invoke "NO_SOURCE_F...
10:12Bronsa,(.. Math -PI)
10:12clojurebot3.141592653589793
10:12Bronsa,(-> Math .-PI)
10:12clojurebot#error {\n :cause "No matching field found: PI for class java.lang.Class"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching field found: PI for class java.lang.Class"\n :at [clojure.lang.Reflector invokeNoArgInstanceMember "Reflector.java" 308]}]\n :trace\n [[clojure.lang.Reflector invokeNoArgInstanceMember "Reflector.java" 308]\n [sandbox$eval165 invoke "NO_SOURCE_F...
10:13Bronsapuredanger: would you say this is a bug?
10:13dnolenBronsa: huh, did not know that.
10:13puredangernot sure. can't say I've ever done it.
10:13Bronsadnolen: me neither until tools.analyzer exploded because of it one day
10:13TimMc,(.- Math PI)
10:13clojurebot#error {\n :cause "Unable to resolve symbol: PI in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: PI in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: PI in this context"...
10:13TimMcOK, will move this to my own REPL.
10:14Bronsapuredanger: there's written somehere in a design page of confluence that (.-foo bar) and (. bar -foo) are supposed to be identical
10:14Bronsalet's see if i can find it
10:14TimMcLike I said, no one uses this in Clojure. :-P
10:15puredangerwell I use it all the time for instance fields
10:15puredangerjust not for statics
10:15puredangerI would expect (.- Math PI) to work based on the docs (which I wrote :)
10:15hellofun`the .- syntax is very common in clojurescript, however
10:15kralTau > Pi, in every sense. :)
10:17TimMcpuredanger: What does (.instanceMember Classname args*) mean on that page? Isn't Classname really just an instance of Class, and therefore subsumed by the previous line's syntax?
10:17Bronsahttp://dev.clojure.org/display/design/Unified+ClojureScript+and+Clojure+field+access+syntax
10:20Bronsapuredanger: wait are you saying (.- foo bar) should work? I don't think that ever did, just (. foo -bar) and (.-bar foo)
10:21TimMc,(. Math -PI)
10:21clojurebot3.141592653589793
10:21TimMcphew
10:21puredangerBronsa: maybe I'm just confusing myself :)
10:22puredanger,(. Math PI)
10:22clojurebot3.141592653589793
10:23puredangermaybe the .- docs are wrong on that page
10:24Bronsai think so
10:24puredangerI doubt that the most b/c I added it :)
10:24TimMcForms beginning with dot are really confusing. I would expect (. Math (getName)) and (. (identity Math) (getName)) to do the same thing, but the former is a compiler exception.
10:25BronsaTimMc: yeah
10:26TimMcNote to self: Be really careful when writing macros that use this.
10:32jtmarmonwhat's a clean way to indicate that a bunch of functions do the same thing? I'm writing a tool for migrating from mongodb to datomic, and I want the user to pass a list of "transformer" functions which take two args. I think a protocol & record is a bit overkill for this, but I'd like them all to somehow identify as "transformer" type functions
10:33puredangerBronsa: ok, I updated http://clojure.org/java_interop - does that look more accurate?
10:34Bronsapuredanger: yup
10:38kaiyinThe function name "step" could have been omitted, right? https://github.com/clojure/math.combinatorics/blob/602a1128340989ae1829336394ecef65d5cc7662/src/main/clojure/clojure/math/combinatorics.clj#L223
10:39puredangeryes
10:40puredangeranon fn names are useful for describing intent to reader (prob not much benefit here)
10:40puredangerthey also show up in the class name in a stack trace, helpful for debugging
10:41TimMc++ for that
10:43TimMc$fn__3763$fn__3764$fn__3765$fn__3766$fn__3767.invoke is not my favorite thing to see in a stack trace.
10:46shoky"step" is used in the function body, though. line 233. doesn't it need to keep its name for that?
10:47TimMcshoky: Oh! Yeah, good point.
10:47TimMc&(format "lib-%04d" (rand-int 1e4))
10:47lazybot⇒ "lib-5045"
10:47justin_smith(inc shoky)
10:47lazybot⇒ 2
10:55puredangershoky: no, that function is being let bound to a local named step and that's what's being referred to, not the fn name
10:56shokypuredanger: i don't think you can access that let binding inside the function body, though
10:57i-blisshoky: why not?
10:57TimMc,(let [a (fn b [] [a b])] (a))
10:58clojurebot#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" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: a in this context"\n ...
10:58shoky^
10:58i-blis,(let [x 42 f (fn [] x)] (f))
10:58clojurebot42
10:58justin_smith,(let [f (fn [x] (if (> x 10) x (f (* x 3))))] (f 1))
10:58clojurebot#error {\n :cause "Unable to resolve symbol: f in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: f in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: f in this context"\n ...
10:58shokynow i'm confused
10:59justin_smith,(let [f (fn f [x] (if (> x 10) x (f (* x 3))))] (f 1))
10:59clojurebot27
10:59TimMcshoky: You're right, though.
10:59justin_smithshoky: my two examples show you were right, and puredanger was wrong for the first time ever
10:59puredangeryup! I didn't read closely enough
10:59shokyhow does i-blis's example work ?
10:59shokyoh, nevermind
11:00puredangerI'm wrong all the time btw :)
11:00shoky;]
11:00puredanger(inc shoky) ;; !!
11:00lazybot⇒ 3
11:06i-blis(inc shoky) ;; I see now what you meant
11:06lazybot⇒ 4
11:06TimMc,(letfn [(f [x] (if (> x 10) x (f (* x 3))))] (f 1)) ;; :-D
11:06clojurebot27
11:11shoky,(let [f (fn [x] (if (> x 10) x (f (* x 3))))] (f 11))
11:11clojurebot#error {\n :cause "Unable to resolve symbol: f in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: f in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: f in this context"\n ...
11:12fourqDoes the underscore hold a special meaning in this case or is it just another parameter? (defmulti entry-view (fn [person _] (:type person)))
11:13Bronsafourq: just a regular parameter
11:13fourqthanks
11:13Bronsafourq: we typically use `_` for an unused parameter
11:13puredangerleading underscore (or just underscore) is a convention for "unused"
11:13fourqahh gtk!
11:14puredangerso you could also do (defmulti entry-view (fn [person _entry] (:type person))) to transmit info about what the field is but also say you're not using it
11:15fourqnice
11:16fourqleading and tailing _'s are common for this?
11:16fourqoh, i thought you had a tailing
11:16TimMcInterestingly, Java 8's compiler warns that future versions of Java may reject variables named just "_".
11:16fourqnvm
11:16clojurebotIt's greek to me.
11:17fourqTimMcm wonderful... another gtk
11:17TimMcI don't know if that has an effect on Clojure.
11:17TimMc"The use of the variable name _ in any context is discouraged. Future versions of the Java programming language may reserve this name as a keyword and/or give it special semantics."
11:18TimMcSo it might just be a Java thing, or it might be a JVM thing.
11:18ToxicFrogI hope it doesn't affect clojure, I use _ as a throwaway all the time.
11:18fourqinteresting
11:18ToxicFrogA holdover from my Scala days, perhaps.
11:18TimMcI *bet* it's just Java.
11:18fourqI imagine clojjure would mask it
11:19oddcullythat'l show those gettext buggers!
11:19ToxicFrogYeah, clojure already lets you use a whole lot of symbols that aren't valid in java, and the compiler emits java-friendly versions
11:19fourq^
11:19TimMc_ comes through unchanged though, right?
11:20fourqmaybe in the end after it passes through Java
11:20sobeli love that you can name a clojure function 𝄞 if you want to
11:20TimMc,(munge '_a!b?c)
11:20clojurebot_a_BANG_b_QMARK_c
11:20sobelor ♫
11:20TimMcfourq: Clojure code isn't compiled to Java, it goes right to JVM bytecode.
11:21sobel,(munge '♫)
11:21clojurebot
11:21fourqis muI thought it was compiled through java, not to java
11:21fourqs/is muI/I
11:21sobelsome of java's constraints are inherited from the vm
11:22fourqTimMc, again, I think I'm thinking of cljs
11:23fourqI'm only a few days into clojure/script
11:23TimMcClojure goes directly to bytecode, do not pass Java, do not collect 200x the code size.
11:23TimMchttps://github.com/clojure/clojure/blob/clojure-1.6.0/src/jvm/clojure/lang/Compiler.java#L436
11:23fourq=)
11:23ToxicFrogTimMc: I think _ comes through unchanged, but a future version of the clj compiler could change that
11:23fourqthanks
11:24TimMcClojurescript... right to JS, I think. And then through the optimizer.
11:24BronsaToxicFrog: why would it? that would be a major breaking change
11:25ToxicFrogBronsa: the context of the discussion is that future java versions may make _ an invalid name
11:25fourqTimMc didn't realize that. ty
11:25BronsaToxicFrog: java, not the jvm
11:25ToxicFrogIf that happens and is implemented as a JVM change rather than a javac change, clojure would have to make that change.
11:25BronsaToxicFrog: i seriously doubt they're going to introduce such a major breaking change in the jvm
11:40fourqclojure would be a tough mfr if it wasn't for pairedit
11:43fourqanyone have a vim snippets file for clojure that you just can't live without?
11:43fourqfor snipmate
11:49timvisheris it possible set the response body for a 303 in liberator?
11:52oddcullyfourq: right now i basically have just defn because i tend to forget the [] for no params. but if you are looking for inspiration: https://github.com/search?q=clojure+extension%3Asnippets&type=Code
11:53fourqgreat gh search use. ty!
11:53oddcullyfourq: since snipmate is great for languages, that have lots of boilerplate, the need for it in clojure is not that much in my experience
11:54fourqoddcully I was actually just wondering if that was the case.
12:02timvisheris `"null"` a valid json string afaak?
12:02timvisheri'm getting conflicting reports
12:03timvisher,(do (require 'clojure.data.json) (clojure.data.json/read-str "null"))
12:03clojurebot#error {\n :cause "Could not locate clojure/data/json__init.class or clojure/data/json.clj on classpath."\n :via\n [{:type java.io.FileNotFoundException\n :message "Could not locate clojure/data/json__init.class or clojure/data/json.clj on classpath."\n :at [clojure.lang.RT load "RT.java" 449]}]\n :trace\n [[clojure.lang.RT load "RT.java" 449]\n [clojure.lang.RT load "RT.java" 412]\n [clojur...
12:03timvisher:(
12:03timvisheranyway, clojure.data.json/read-str happily turns `"null"` into `nil`. But jsonlint.com claims that valid json has to start with `[` or `{`
12:06hiredmanwell, it is wrong
12:07timvisherhiredman: which 'it'? :)
12:08timvisherhttp://www.json.org/ seems to indicate by my reading that JSON is only valid if it is an object or array
12:08timvisheronly the values are allowed to be null
12:08timvisherbut i may be misreading that
12:09timvisherheh. clojure.data.json also turns `"1"` into `1`...
12:11zerokarmalefttimvisher: I believe that's correct...a strict JSON parser will only validate if the root element is an object or an array
12:15timvisherhmm… not seeing anything in the issue tracker related to this.
12:17timvisherah. and it also write's invalid json.
12:20timvishernoooooooooo! chrome developer tools do the same thing! :(
12:22zerokarmalefttimvisher: aeson, the go-to json parser for haskell, has strict and non-strict encoders/decoders
12:23timvisheri wonder what the browser fragmentation is on this though. i can only imagine in true browser vendor fashion that all of them default to non-strict.
12:23timvisherif they even provide strict.
12:24zerokarmaleftdb vendors may handle them differently as well
12:24zerokarmaleftso it seems at the library level, supporting both use cases is appropriate
12:28timvisherhttp://dev.clojure.org/jira/browse/DJSON-20
12:29timvishernow that i know it's a wider issue this suddenly feels like less of a big deal though...
12:34bobbywilson0Is there any incanter users around? I am trying to do the first example in the readme, and it looks like the proper value is returned from `view` but it doesn't pop open a window with the chart.
13:07TimMctimvisher: It is not clear to me that the JSON spec precludes top-level values that are not object or array.
13:08timvisherTimMc: which part of json.org would indicate that? or is that not the spec?
13:08timvishercertainly implementors have by and large agreed with you, it would seem. :)
13:09TimMctimvisher: http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf
13:10TimMcBut that's basically the same thing.
13:11TimMcAnyway, the term "JSON value" is suggestive; I think in the absence of other directives, it indicates to me that "primitives" can be top level.
13:12TimMcI *do* seem to recall something about requiring object or array at top level, but I don't know where I saw that.
13:13oddcullyTimMc: object at top level is about security
13:14TimMcoddcully: You mean, making it easy to be secure?
13:14oddcullyTimMc: https://www.owasp.org/index.php/OWASP_AJAX_Security_Guidelines (`Always return JSON with an Object on the outside`)
13:14oddcullyTimMc: making it secure at all :)
13:15TimMcHmm, will hvae to look later.
13:16oddcullyTimMc: just some random input, why somebody might to pick one over other. i have not really followed the initial discussion. take with salt (and beer)
13:44moquistI've got an Om front end with a text input field, and I have an :onChange fn that cleans the input and calls om/update! with the result. When the user types garbage characters, the browser updates the text field. After cleaning the garbage out, om/update! ends up making no change to the cursor value, so no re-render is triggered, and the garbage stays there until another valid char is typed and a re-render
13:44moquistis triggered. I feel like I'm surely missing something obvious, and googling and looking at the Om API haven't clued me in, yet.
13:45moquistIs there some way I should be forcing a re-render, or should I just not handle validation this way, or...?
13:45oddcullyjust in case you didn't know: there is also #clojurescript
13:45moquistoddcully: I did not; thanks.
13:55dnolenmoquist: you going to have to review the tutorials it covers controlled inputs, it's a bit more finicky than React because of async rendering but the same result can be achieved
14:25fourqif `text` is a cursor and the second param to om/trasact! is a function that receives the value from the cursor, how is this function setting the value of e? I don't see any argument literals in it. https://gist.github.com/fourq/ff0d7a8f65f5c699d54f
14:30TimMcoddcully: That owasp page doesn't actually explain the threat. I know about JSON hijacking, but it doesn't seem relevant here.
14:33TimMcAh, here we go: http://stackoverflow.com/a/21510402/20772
14:33dnolenfourq: there's really no support for treating JS scalar values as cursors, don't do it
14:34fourqdnolen I'm just going off Om's tutorial.
14:34dnolenfourq: right at some point I will probably remove that, and the tutorial does discourage that pattern. It only shows it for the purposes of demonstration
14:35fourqI see. thanks
14:36dnolenfourq: I would definitely direct Om questions to #clojurescript
14:37fourqdnolen I wasn't sure if it was an om question or not. I thought that I wasn't understanding how the fn was going to receive the text value.
14:37oddcullyTimMc: iirc this revolves around using json in eval etc. as i said, i have not followed the discussion and the "non-object at root level" just tingled my security attic. sorry for the confusion
14:37dnolenfourq: definitely an Om question :)
14:38fourqk, thanks again
14:38TimMcoddcully: Oh, the basic discussion was around whether it was valid for a JSON decoder to accept "1" or "null" as an input instead of an encoded array or object.
14:38fourqdnolen I just now read "Note the following is for demonstration purposes only, it is not recommended in most real applications." =)
14:39oddcullyoh man a 2k upvotes answer on SO... now i have seen it all ;)
14:39TimMcoddcully: The security issue here is a malicious client using a script tag to load a cookie-authorized resource from a victim server. It's implicitly a call to eval, not explicitly.
14:41amalloyoddcully: http://stackoverflow.com/q/1732348/625403 is the most famous SO question/answer i know of
14:41amalloybeats 2k handily
14:42TimMcThe funny thing is that it is wrong.
14:43amalloywell, that sorta depends what you mean by "regular expressions"
14:43TimMcand "can't"
14:43amalloyif you mean formal regular expressions then it is right
14:43TimMcNo, even formal regular expressions.
14:44amalloyuhhhhhh, i don't think that's true. the html spec is context-free but not regular
14:44TimMcHTML *tags* are a regular language.
14:44TimMcHTML *documents* are not.
14:44amalloyTimMc: but you can't find an html tag within an html document
14:44oddcullyamalloy: yeah for hilarity
14:44amalloyi see what you mean, though
14:44TimMcamalloy: You can if you walk through it. And if you add a stack, BAM, you have a parser.
14:44amalloythe question doesn't make clear whether he's somehow magically isolated only tags from the document, and now wants to match them with this regex
14:45TimMc"Regex queries are not equipped to break down HTML into its meaningful parts." is just not true.
14:45amalloyif you add a stack, you don't have a regular expression or a finite automaton
14:48TimMcWhat is it, a PDA?
14:48TimMcI don't remember the categories. Anyway, I wrote this some time ago: http://lab.brainonfire.net/markup-sanitizer/demo.html
14:49amalloyTimMc: yes
14:49TimMcAin't nothing wrong with Public Displays of Affection.
14:50TimMc(Mess up the HTML in that textarea to see the demo in action.)
14:56TimMcThat answer is funny, and I understand why the author wrote it, but it is incorrect and does not answer the question.
14:57moquistdnolen: Ah! I knew I'd seen an example of exactly what I wanted, but couldn't remember where. Sounds like component-local state is the answer I was looking for. Thanks for the polite RTFM; it was exactly what I needed.
14:57oddcullydownvote it! that'll show him!
14:58TimMcNo, I think whoever wrote that deserves to live their retirement from answering HTML/regex questions in peace.
14:59amalloyis it even downvotable anymore? it's historical-locked, which i thought meant you can't really interact with it anymore
15:00oddcullyamalloy: nope
15:00oddcullyas it: no can be downvoted anymore
15:01TimMc"This post has been locked; locked posts can't be voted on"
15:11zhadnCan someone help me understand -> vs. ->> and threading?
15:11zhadnwhy would (->> [5 4 3 2 1] (drop 2) (take 3)) work
15:11zhadnbut not
15:12zhadn(-> [5 4 3 2 1] (drop 2) (take 3))
15:12amalloyzhadn: have you tried macroexpanding the two?
15:12amalloy,(macroexpand '(->> [5 4 3 2 1] (drop 2) (take 3)))
15:12clojurebot(take 3 (drop 2 [5 4 3 2 1]))
15:12amalloy,(macroexpand '(-> [5 4 3 2 1] (drop 2) (take 3)))
15:12clojurebot(take (drop [5 4 3 2 1] 2) 3)
15:13zhadnoh I had no idea macroexpand existed
15:13amalloyit's even simpler if you compare just (-> x (drop 2)) and (->> x (drop 2))
15:14zhadn, (macroexpand (-> x (drop 2))
15:14clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
15:14zhadn, (macroexpand (-> x (drop 2)))
15:14clojurebot#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" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: x in this context"\n ...
15:14amalloyzhadn: you need to quote it
15:15zhadn, (macroexpand '(-> x (drop 2)))
15:15clojurebot(drop x 2)
15:15zhadn, (macroexpand '(->> x (drop 2)))
15:15clojurebot(drop 2 x)
15:15zhadnoh I see
15:16zhadnso -> will put the arg at the beginning, and ->> at the end
15:16amalloyyes
15:16zhadnI was thinking about it the wrong way
15:16zhadnthat the difference was in which direction the forms started executing
15:17zhadnwhere I thought -> would be the first form
15:17zhadnand ->> started from the end
15:17amalloyindeed that is wrong
15:19dnolenmoquist: no problem
15:29zhadnthanks amalloy
15:30oddcully(inc amalloy)
15:30lazybot⇒ 267
15:30zhadnis there a point system?
15:31oddcullysure
15:31TEttinger(inc oddcully)
15:31lazybot⇒ 8
15:31oddcullywill this cascade down the whole chanel?
15:31TEttingeroddcully has 8 points of karma, amalloy has 267.
15:31oddcullynow i going to kill mysself ;P
15:31TEttingerjust demonstrating
15:32TimMc(inc TEttinger)
15:32TEttingerthat won't get you bonus karma
15:32lazybot⇒ 54
15:32TEttingerhaha
15:32TimMcchoo choo, all aboard the karma train
15:32TEttingerwhen did I get past 50???
15:32lazybotTEttinger: Yes, 100% for sure.
15:32oddcullyno pitypoints?! the fsck it!
15:32oddcullys/the/&n/
15:33TimMcoh man I forgot about &
15:35TEttingerwell I'm thinking about making a toy language, obviously clojure is a heavy inspiration. I'd like to compile either to luajit bytecode or lua (luajit dialect only, so I have a good C FFI) source.
15:36TEttingerand I'm wondering about whether it's a good or bad idea to implicitly map fns that take a scalar over each element when passed a collection
15:37TEttingerlike if you called (inc [1 2 3]) that would implicitly be the same as (map inc [1 2 3])
15:37TEttingerdifference here is that map would not change the type of its argument
15:38amalloyto me that sounds, not disastrous, but bad
15:39oddcullywhat will (nth [1 2 3] 1) return with lua then?
15:43TEttingerhm...
15:44TEttingerit might only make sense with certain operations. this is one of those everything is implicitly curried things, so (nth [1 2 3]) would be a fn that takes a scalar. you could do (nth [1 2 3] [0 1 0])
15:45fourqWhat exactly is the syntax `(. object` telling me?
15:45fourqwhere object is any object
15:45fourqit's the (. that I'm wondering about
15:45TEttinger. calls a method on that object
15:45fourq(. object method) ?
15:45TEttinger,(. (new java.util.Random) nextDouble)
15:45clojurebot0.31682342160924615
15:45TimMcor gets a field :-)
15:46TEttingerright, that too
15:46TEttinger(inc TimMc)
15:46lazybot⇒ 98
15:46fourqyeah I get it when it's a prop access, but I dind't know about the method
15:46fourqthank you
15:46TEttinger,(. Math PI)
15:46clojurebot3.141592653589793
15:46fourq\o/
15:46oddcullyTEttinger: i didn't even want to scratch on the implicit map. i meant, what is the base for vector/list access? will 1 return you the first or the second element? (lua uses 1 for the first element)
15:47oddcully(at least iirc... haven't used it for a year or two now)
15:47TEttingerah, I forgot about that. except, luajit can use either 0-indexed or 1-indexed arrays, it just starts with whatever is lower if you supply a 0 element for the array
15:49oddcullyah that's nice. i only used c++ > swig > lua - and the 1-base was always a source of errors for me
15:49TEttingerso I'm thinking I may go with just defaulting to 0-based, it's going to be easier to port non-lua code that way, and I won't be using the 1-based vanilla lua stdlib anyway, I'd be aiming toward a core.clj type deal
15:51TEttingerI mean, the only difference is whether [1 2 3] compiles to {1=1,2=2,3=3} or {0=1,1=2,2=3}
15:54TEttingerthe main thing I'd like to add is type contracts, but unlike typed clojure they'd be accessible and modifiable at runtime. this would use the concept of Domains from Chapel, a lesser-known language designed to replace Fortran for supercomputing stuff by doing similar stuff but actually being nicer to write (supporting FP out of the box, lots of crazy typesystem things)
15:55TEttinger$google github chapel cray
15:55lazybot[chapel-lang/chapel · GitHub] https://github.com/chapel-lang/chapel
16:04fredfeIf I want to get the :session value from a ring request in a "global" sort of way, are there any functions in ring to access the request map at any point? Or do we strictly use middleware only for those things?
16:05arohnerfredfe: not really. You'd have to storm the request in an atom or something
16:06arohner(def last-request nil) (defn my-handler [handler] ... (reset! last-request req) ...
16:06amalloycrikey, arohner! your webservers never have more than one request in flight at a time?
16:07arohneramalloy: I didn't say it was a good idea...
16:07amalloyarohner: well it's a bad implementation of a mediocre idea
16:07amalloyyou can at least use a dynamic var to store it
16:08arohneramalloy: he specifically said global
16:08fredfeok, just using the leiningen template for compojure which uses ring-defaults. Could I work with middleware instead of an atom to get request data and change how the handler behaves?
16:08amalloyarohner: dynamic vars are global
16:08amalloythe request just sounds to me like "how can i get the session of the current request, without having to pass it around to every function manually"
16:08fredfeYes
16:09arohneramalloy: I've never seen var-set var-get used, anywhere, so I wasn't going to use it in an example
16:09amalloyarohner: neither have i. i wouldn't recommend you use those
16:09amalloyyou'd use binding
16:09arohneramalloy: which is thread local
16:09amalloywhich is the point!
16:10amalloyyou are interpreting fredfe's request as asking for something nonsensical and insane, instead of the fairly normal thing fredfe is actually asking for
16:11arohneramalloy: sigh. I think that's condescending and shortsighted. The next words out of my mouth were going to be "but that's probably a bad idea, what are you trying to do"
16:11fredfeMy goodness, but yes, I phrased my question odd perhaps. I want to be able to access the request map at different points without having to pass the request map through a dozen functions every time.
16:12arohnerfredfe: you can use binding, but I'd recommend getting used to passing the request around. It gets less annoying, and leads to simpler code
16:13arohnerfredfe: I always regret using binding later, when I introduce threads
16:13fredfeok
16:14fourqIs this form calling `send` of xhr, or is it feeding xhr the results of clojures' send? https://gist.github.com/33e49ed3a5f5113b0914
16:14arohneralso, if you have "dozens", I'd suspect a layering violation, or an opportunity for refactoring. Passing the session to 2-4 things is probably more reasonable
16:16arohnerfourq: it's calling send on xhr http://clojure.org/Java%20Interop-The%20Dot%20special%20form-(.%20instance-expr%20member-symbol)
16:17fourqarohner I wasn't sure because the params don't match and it's within a form itself. (new here obv)
16:17fourqor rather, within another form
16:17arohnerfourq: np. we were all new at some point
16:17fredfeThanks guys, I'll just keep passing the request map around
16:18arohnerfourq: that usage is fairly rare
16:18arohner(.foo bar) is far more common
16:18fourqI wondered if that was the case
16:18fourqthanks
16:20TEttingerfourq: but it's (.method object), not the same as (. object method)
16:20fourqarohner would you mind helping me understand how that gist is calling xhr.send if the params are not correct (according to the xhr docs? http://google.github.io/closure-library/api/namespace_goog_labs_net_xhr.html
16:20fourqor anyone for that matter
16:20TEttinger,(.nextDouble (new java.util.Random))
16:20clojurebot0.49141840279783167
16:21amalloyTEttinger: (.method object) is shorthand for (. object method)
16:21TEttingeryeah, I just mean the order is different
16:22fourqthanks TEttinger
16:22TEttingerno prob
16:22arohnerfourq: aren't the parameters correct?
16:22fourqwell the first param is a method
16:22fourqin the doc
16:22fourqand the gist has the first param as the url
16:22arohneroh, yeah, that is strange. different versions?
16:22arohnerdo you know that this code is being called and works?
16:22fourqpossibly
16:23fourqI'm running this from the Om tutorial. that was my next step, finishing it to see it run, but I have been trying to understand what I'm doing as I go along
16:24fourqI'm partially ok with the fact that I'm pointing stopping points that are not extremely trivial (and if they are just don't tell me that =))
16:26fourqI think the params might just be switched around, and should have been (meths method) url opposed to url (meths method)
16:38fourq[let xhr (XhrIo.)] is "constructing" an instance correct? (I'm almost done for the day...I'll shut-up soon)
16:42oddcullyfourq: yes (Class.) constructs you a new thing of Class
16:42fourqperfect
16:42oddcully,(String. "asdf")
16:42clojurebot"asdf"
16:42oddcully(inc clojurebot)
16:42lazybot⇒ 50
16:43oddcullyhe's such a helpfull fellow
16:43fourq=)
16:43TEttingeramalloy: I'm thinking about what makes the implicit map behavior bad. I think a central difference between clojure and this hypothetical language is that since it compiles to Lua, as opposed to JVM .class files, a function can be "as optimized as it will be" even if it doesn't always return the same type.
16:43TEttingerthat, combined with the type contracts, means you could have map return a vector when passed a vector, a hashmap when passed a hashmap... and a scalar when passed a scalar
16:45TEttingerthat doesn't allow for fairly common constructs like ##(map #(repeat 3 %) [1 2 3])
16:45lazybot⇒ ((1 1 1) (2 2 2) (3 3 3))
16:46TEttingerhm, maybe it would...
16:48amalloyso, TEttinger, suppose i want to call (f x), and f takes a scalar. if x is a scalar, then of course everything works fine of course. your goal is to "fix" the error of accidentally calling (f [x]) by returning [(f x)]
16:48amalloybut (a) that just hides the issue, if what i actually intended was (f x)
16:49amalloyand (b) it doesn't help if f wants a list and x is a list: (f x) is what i intend, but if i write (f [x]) accidentally, your "fix" doesn't do me any good at all
16:52TEttingerwell as to (b), if f wants a list, it doesn't take a scalar, so the implicit mapping doesn't apply in this case.
16:53amalloyTEttinger: right. my point is your feature is intended to fix accidental uses of (f [x]) instead of (f x), but it doesn't work if f takes lists, even though you can still make the same mistake
16:53TEttingernot accidental
16:54TEttingerI think you misunderstand my intent here
16:55amalloywell, it will have the *effect* of fixing those accidents
16:55TEttingerI think being able to treat rank (dimensionality) as a core concept can be useful
16:56TEttingerand if a rank 0 thing is at its core incompatible with something that takes higher-ranked things, it isn't that useful
16:57TimMcI think I've seen this feature in some other languages but I don't remember which ones.
16:58TEttingerJ uses rank as its term
16:58TEttingerit also implicitly maps
16:58TimMcThat might be the main one.
16:58puredangerR ?
16:58TEttingeralso K
16:58TEttingerprobably R too, it's common in array programming languages
16:58TimMcBut not C? Shame.
16:59puredangerbasically array languages :)
16:59turbofaili think supercollider's sclang does it too?
16:59TimMcHow about matlab?
16:59TEttingeryeah, we're basically listing wikipedia's array language category
16:59TimMcRuby at least fakes it up.
17:00TEttingeranyway, clojure's seq abstraction would be handy as an extension of sorts to array programming.
17:00TimMc(Adding something to every element of an array is easy, but I don't think it's general.)
17:01TEttingercan you give an example, TimMc?
17:09TimMcTEttinger: Nope! Doesn't work the way I remembered. (I don't relaly know Ruby, so there's that.)
17:10TEttingerI think having domains be a core part of the language could be helpful for this. the rank of a rectangular collection (anything that isn't jagged or a mix of datatypes, I guess?) is the number of keys required to access a scalar element when converted to a seq or seq of seqs or seq of seq of seqs... being able to define a hashmap as an associative domain applied to a sequence could be handy
17:11TEttingerand by extension, you could define a vec of maps as a rank 2 domain over a sequence
17:14TEttingera rank 0 domain is a single possible value, so applying that to a sequence would be the same as the map entry corresponding to the first element in the sequence, I suppose
17:21TEttingerhm. so a rank 1 associative domain is effectively the same as an ordered keyset. a rank 2 associative domain is an ordered map of ordered sets.
18:50drojasis there any short way fully qualify everything in a list?
18:53amalloydrojas: is there any short way to fully qualify a single thing?
18:53TimMcdrojas: Can you give me an example of what it means to fully qualify a single thing?
18:53TimMcdammit amalloy
18:54amalloythat's what you get for typing more letters
18:54drojasTimMc: (= 1 1) -> (clojure.core/= 1 1)
18:56TimMcHOw do you know that = -> clojure.core/= ?
18:58TimMcOr let me put it another way -- what's the *long* way of doing it?
18:58drojasbecause it has a binding inside *ns* I guess.. like (resolve x)
18:58amalloythat's why i liked my question better, TimMc
19:00drojasTimMc: (eval (read-string (str "`" '(= 1 1))))
19:01TimMcOh yikes. :-)
19:02drojasI was wondering if there is a better | cleaner | smarter | shorter way
19:02crazydiamondHi. I have an object which is {:projects #<HashSet [[17592186045418 task foo]]>} when I print it, but it turns into {:projects #{[17592186045418 "task foo"]}} when I prn-str it. What can I do to turn 1st form into 2nd?
19:10drojasTimMc: so I want to produce qualified symbols at the first argument of the assertion so I dont have to give the full qualified name of the symbols in the examples at the docstring
19:10drojasTimMc: that way I only need to refer the symbols on the test namespace
19:11jtmarmoni'm working on a tool to orchestrate the migration from mongodb to datomic and i'm looking for a bit of design feedback as i'm new to clojure. the user needs to provide functions that transform mongodb documents into datomic txes. do you guys prefer the top or bottom style, or think there's a different way to implement this design that might be better? https://gist.github.com/jtmarmon/08d66a8a0f95f0510b92
19:12TimMcdrojas: Neat.
19:13TimMcdrojas: I think if I were in your place I'd start with rummaging through the source for syntax-quoting and see if anything jumps out at me.
19:15drojasTimMc: yep, sounds like I'll be reading about the reader and syntax-quoting tonight ;)
19:16amalloythe syntax-quoting reader for symbols doesn't do anything more complicated than resolving to get a namespace, does it?
19:19drojasthe only thing I know about it is that it is a reader macro so it is implemented in Java
19:19drojasbut nothing about how it actually does the job
19:25amalloydrojas: for symbols that aren't gensyms or whatever other special case, it just calls Compiler/resolveSymbol. that method isn't public, so you can't call it yourself, but it boils down to little more than a call to clojure.core/resolve
19:43crazydiamondHi. When I have some x, and I do (eval (read-string (prn-str x)), will it be the same as x, or something would change?
19:44justin_smithcrazydiamond: depends, how stateful is x?
19:45amalloyit would almost never be the same as x
19:45crazydiamondjustin_smith, in short, it cames from datomic
19:45justin_smithoh, eval of read-string would do funky things with lists at least
19:46justin_smithwhy eval?
19:47crazydiamondwell... there may be equivalent which doesn't turn vec to list or what it does
19:47crazydiamondwhat that funky things are
19:47crazydiamondjustin_smith, are you asking about eval, or whole expression?
19:51crazydiamondsorry I was disconnected :P
19:58crazydiamondGuys, where do you think I can read about things that would make me understand difference between x and (eval (read-string (prn-str x))?
19:59amalloycrazydiamond: (def x '(1 2 3))
19:59crazydiamondamalloy, ok...
19:59amalloytry it and se
20:00crazydiamondok
20:00crazydiamondit would call 1
20:00amalloyyes
20:00crazydiamondbut error what I get
20:01crazydiamondand what applying (eval (read-string (prn-str x))) solved
20:01crazydiamondis much more complex
20:01crazydiamondI'm getting data from Datomic
20:02crazydiamondand returning it as a result via Castra ( https://github.com/tailrecursion/castra ) RPC
20:02crazydiamondwhen I return x
20:02crazydiamondI've got an error
20:03crazydiamondand when I return (eval (read-string (prn-str x)) I got what expected
20:04crazydiamondwell "eval" was even redundant
20:04crazydiamondcause things I'm working with evaluate to themselves
20:05crazydiamondwell what's difference between (read-string (prn-str x)) vs. x then?
20:10erikcwDoes anyone know of an existing externs file for the Select2 javascript library? I’m trying to get closure advanced compilation working for my clojurescript project…
20:12jtmarmonif I have a large collection of collections - say 1 million items that look like [[123 [{:a 5}] [3456 [{:b 5}]], what would be the most efficient data structure for looking up :a's and performing some operaiton on that number, returning the entire data set?
20:14lvhjtmarmon: 1 million probably isn't enough to start worrying about that
20:14lvhjtmarmon: plain old vectors and maps will do fine
20:14lvhjtmarmon: you might want to take a look at records I guess
20:15lvh(map #(get-in % [1 0 :a]) that), unless there are multiple places the :a can occur in that inner vec
20:16jtmarmonthanks lvh!
20:17jtmarmoni think my strategy is O(n!) which is wonderful so i'm just gonna run a test to see if that's workable
20:29jtmarmonlvh: I want to update, not retrieve. is there a way to do "update-in" over a collection of data? e.g. (update-in-coll [{:a 5} {:a 2} {:b "hi"}] [:a] inc) gives [{:a 6} {:a 3} {:b "hi"}]
20:31amalloyjtmarmon: does that look suspiciously like ##(doc map) to you?
20:31lazybot⇒ "([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhauste... https://www.refheap.com/101121
20:34jtmarmonamalloy: hah yes sorry for some reason i had the idea that map didn't fit the use case...it's been a long day :P
20:34jtmarmonthanks
20:35tieTYTdoes this have a video my browser is blocking? http://www.infoq.com/presentations/Simple-Made-Easy
20:35tieTYTI can’t figure out how to start it
20:36tieTYTah yeah, it’s blocked
20:36tieTYTnm
20:37drojasamalloy: sorry I was on the supermarket... so syntax quote is just a wrapper for resolve, thanks for clarifying
20:44jtmarmonahh