#clojure log - May 14 2015

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:25 teajoe: Is 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

0:27 hiredman: edn is a data interchange format

0:27 if you mean clojure.core/map, that is a function object

0:28 which don't exist in the edn format

0:28 likely you are looking at a list

0:28 (fn [x] x) is a list

0:28 when evaled it is a function object

0:29 map is a symbol, unless evaled at which point it is looked up in the environment and ultimately a function object

0:31 teajoe: ok, is there any way to get a function object from an edn symbol? ty

0:31 just eval it in the current context i guess

0:32 yay I took a step, thanks for explaining that

2:48 kral: 'morning

4:05 dm3: have 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

4:05 now you can do `(do (require 'require-do-block.core) require-do-block.core/foo)` which succeeds

4:06 but 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

4:06 why is that?

4:20 amalloy: (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

4:21 oh, i see. you're doing it inside the do, but outside the require

4:22 dm3: 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

4:23 dm3: amalloy: thanks, that helps

4:47 kind of the same issue: http://technomancy.us/143

7:13 kitallis: is there a canonical way to handle api versioning with compojure?

7:29 crocket: How do I upgrade nrepl for lein and cider?

7:31 i-blis: crocket: you can add a tools.nrepl dependency to your profiles.clj

7:31 crocket: https://github.com/clojure-emacs/cider/issues/961

7:31 i-blis, I executed 'lein repl' and cider outside any clojure project.

7:32 i-blis: crocket: add [org.clojure/tools.nrepl "0.2.10"] to :dependencies

7:33 crocket: i-blis, What only works inside leiningen projects.

7:33 hmm...

7:33 profiles.clj?

7:33 Where is profiles.clj?

7:34 i-blis: crocket: either in profiles.clj or in your project.clj (but then for each prject you cider-jack-in)

7:34 crocket: ~/.lein/profiles.clj

7:34 crocket: i-blis, I started clojure yesterday, so I am confused.

7:35 i-blis: crocket: cider might be difficult to configure from time to time, but all in all it is a pleasure to use

7:37 crocket: in profiles.clj, add the vector to {:user {:dependencies […]}}

7:38 crocket: i-blis, Like {:user {:dependencies [[[org.clojure/tools.nrepl "0.2.10"]]]}} ?

7:38 i-blis: crocket: btw, I recommend you try with stable (0.8.2, I think) first (there you need no hack)

7:39 crocket: {:user {:dependencies [[org.clojure/tools.nrepl "0.2.10"]]}}

7:39 crocket: i-blis, stable?

7:40 i-blis: crocket: 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

7:41 crocket: i-blis, Do you mean the stable version of cider?

7:42 i-blis: crocket: oh, are you sure you installed cider-nrepl plugin?

7:42 crocket: i-blis, There is no cider-nrepl plugin.

7:42 i-blis: crocket: so, this is the issue

7:43 crocket: add [cider/cider-nrepl "0.9.0-SNAPSHOT"] to {:user {:plugins […]}}

7:43 crocket: i-blis, I can't find cider-nrepl in emacs package list.

7:44 Is cider-nrepl an emacs package?

7:45 i-blis: crocket: cider-nrepl is a clojure jar dependency, needed by cider

7:45 crocket: ok

7:45 i-blis: crocket: lein will pull it from clojars as soon as you lein deps or launch cider

7:45 crocket: Even with [org.clojure/tools.nrepl "0.2.10"], nRepl is still 0.2.6

7:46 REPL-y 0.3.5, nREPL 0.2.6

7:46 i-blis: crocket: you can forget what I said with tools.nrepl

7:46 crocket: i-blis, What am I going to do?

7:46 i-blis: crocket: add [cider/cider-nrepl "0.9.0-SNAPSHOT"] to {:user {:plugins […]}}

7:47 crocket: nrepl is still 0.2.6

7:48 i-blis: crocket: and launch cider (preferably go to a clj file with a project.clj)

7:48 crocket: and cider complains ?

7:49 crocket: yes

7:49 WARNING: CIDER requires nREPL 0.2.7 (or newer) to work properly

7:51 i-blis: crocket: can you post your profiles.clj (refheap, gist)

7:51 crocket: i-blis, I just needed {:user {:plugins [[cider/cider-nrepl "0.8.2"]]}} in profiles.clj

7:51 oops

7:51 It is still reported to be 0.2.6

7:51 ok

7:51 I'm delusional right now.

7:51 Let me take a rest.

7:52 i-blis: crocket: yes, but stable doesn't neeed > 0.2.7

7:52 crocket: snapshot does and lein still bundles an old tools.nrepl

7:53 crocket: I have {:user {:dependencies [[org.clojure/tools.nrepl "0.2.10"]] :plugins [[cider/cider-nrepl "0.8.2"]]}}

7:53 nrepl 0.2.10 is not recognized.

7:54 i-blis: crocket: with 0.8.2 you can live without

7:56 crocket: 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)

7:56 crocket: It seems lein and cider don't automatically load nrepl>=0.2.7

7:58 They are hardwired to nrepl 0.2.6

7:59 i-blis: crocket: well 0.9.0-snapshot does load 0.2.10 for sure

8:00 crocket: i-blis, Somehow, lein and cider are stubbornly stuck with nrepl 0.2.6

8:04 i-blis: crocket: as I said, 0.2.10 loads fine with 0.9.0-snapshot

8:06 crocket: stick to stable, I switched to snapshot once again recently because I needed some facilities provided for boot and cljs

8:13 davs: Hi! 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?

8:13 I'm constructing a list datastructure, which I'll evaluate later (it will be nested)

8:15 crocket: i-blis, Why do you think cider load nrepl 0.2.6 on my machine?

8:15 i-blis: crocket: with 0.9.0?

8:17 crocket: i-blis, yes.

8:17 'lein repl' also loads nrepl 0.2.7 despite profiles.clj

8:18 i-blis: crocket: don't know. as I said, wipping old nprel.tools from my local maven helped once I think, not sure

8:18 crocket: i-blis, I destroyed ~/.m2, but the problem still persists.

8:19 i-blis: crocket: wow, the whole .m2

8:19 crocket: why do you want to go away from stable to snapshot?

8:21 crocket: i-blis, I figured it out.

8:21 i-blis, http://stackoverflow.com/a/30139330/2104107 was the solution

8:21 I just had to execute cider or lein repl inside a leiningen project.

8:23 i-blis: crocket: oh, yes (I think I mentioned it quickly: preferably from a dir with a project-clj)

8:23 crocket: cool

8:24 crocket: What the hell

8:46 i-blis: davs: you may want to use concat here

8:48 crocket: Mi amas clojure.

8:50 kaiyin: what is the clojure equivalent of haskell Maybe or Either types?

8:51 I know clojure is not statically typed, but is there a something similar to cope with possible null input to / output from a function?

8:55 justin_smith: kaiyin: you can chain with some-> or some->> to ensure no more work is done after something returns nil

8:55 ,(some-> 1 inc (+ 3))

8:55 clojurebot: 5

8:56 justin_smith: ,(some-> nil inc (+ 3))

8:56 clojurebot: nil

8:56 davs: i-blis: thanks, concat did the trick

9:06 crocket: (sum 1)

9:52 fourq: How does .. differ from -> in this case `(.. e -target -value)` vs. `(-> e -target -value)` ?

9:53 or is it that same with a different approach to accessing the members?

9:53 ToxicFrog: ,(macroexpand-1 '(.. e -target -value))

9:53 clojurebot: (.. (. e -target) -value)

9:53 ToxicFrog: ,(macroexpand '(.. e -target -value))

9:53 clojurebot: (. (. e -target) -value)

9:53 ToxicFrog: ,(macroexpand '(-> e -target -value))

9:53 clojurebot: (-value (-target e))

9:54 ToxicFrog: .. turns into a bunch of member accesses using .; -> turns into a bunch of function calls.

9:54 javawise, it's value(target(e)) vs. e.target().value()

9:54 fourq: so performance wise (obv not for this tiny task) .. is recommended?

9:54 yeah

9:54 ToxicFrog: I'm not sure that's a meaningful question, they're totally different things

9:55 scottj: the latter should have been (-> e .-target .-value) no?

9:55 fourq: yes, you're right

9:55 ToxicFrog: scottj: oh, if that was the intent it makes a lot more sense

9:56 fourq: thanks all

9:57 It seems like this is the right chan to ask these questions since #clojure-beginners isn't as active?

9:58 TimMc: fourq: Huh, I'm not used to seeing that field syntax in Clojure.

9:59 Are you cross-compiling to CLJS?

9:59 fourq: TimMc http://clojuredocs.org/clojure.core/_..

9:59 ToxicFrog: fourq: 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~

9:59 fourq: I think TimMc means the - prefix, not the ..

9:59 dnolen: TimMc: the field syntax was added to Clojure and ClojureScript at the same time

10:00 ToxicFrog: At least, that's the bit that stands out as weird to me

10:00 TimMc: dnolen: Yeah, and then I promptly forgot about it because no one uses it in CLJ. (Right?)

10:00 Also, I love the 404 page: http://clojuredocs.org/404

10:00 ToxicFrog: TimMc: I've seen it in the wild in a few places, typically in places where clj is calling into java.

10:01 dnolen: TimMc: "no uses one it" is always a dangerous thought if the features exists at all in my experience :)

10:01 er "no one uses it" :P

10:01 TimMc: *no one within my horizon :-P

10:02 Have you seen it in the wild?

10:02 fourq: and TimMc yes, I'm compiling with clojurescript

10:03 I've been trying to make sure that my clojure questions are indeed clojure and not clojurescript specific for the chan

10:04 TimMc: Ah, that explains it.

10:04 ToxicFrog: To distinguish from nullary methods of the same name, or what?

10:05 dnolen: fourq: it's fine to ask such questions here, but note there is an active #clojurescript channel

10:06 puredanger: TimMc: yes, .- is *only* field access in Clojure

10:06 fourq: yeah 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:06 puredanger: whereas . can do both and will prefer methods if both exist

10:06 TimMc: Sure, I just don't see the point in Clojure-only code.

10:07 I guess it would make the code more portable in the future.

10:07 puredanger: the only time you *need* it in Clojure is if you have both a field and a 0-arity method of the same name

10:07 in that case you have to use .-

10:07 kaiyin: (.-x (java.awt.Point. 10 29))

10:07 (.x (java.awt.Point. 10 29))

10:08 What's the difference between these two?

10:08 puredanger: (some of this was buggy before Clojure 1.6.0)

10:08 kaiyin: nothing, other than that .x will also look for a java.awt.Point.x() method

10:09 presuming that doesn't exist, they should result in the same compiled bytecode afaik

10:09 kaiyin: ah, .-x means x is non-static?

10:09 TimMc: puredanger: OK, yeah, that's what I had suggested above.

10:09 kaiyin: Nothing to do with static.

10:09 puredanger: well both of these are instance calls, not static calls

10:09 TimMc: ,Math/-PI

10:09 puredanger: .x = instance method or field

10:10 clojurebot: #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:10 TimMc: Jeez, clojurebot, I don't need an essay.

10:11 dnolen: fourq: to clarify .. and -> are just different convenience macros. and (.. foo -bar -baz) and (-> foo .-bar .-baz) are equivalent

10:11 kaiyin: ok, 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:11 puredanger: actually, I guess .- does do static too, forgot that

10:11 TimMc: ,Math.-PI

10:11 clojurebot: #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:11 Bronsa: dnolen: actually they're not

10:12 TimMc: err, my bad

10:12 ,(.-PI Math)

10:12 Bronsa: dnolen: (.-foo bar) and (. bar -foo) are not always equivalent on the jvm

10:12 clojurebot: #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:12 puredanger: docs here: http://clojure.org/java_interop#dot

10:12 TimMc: Not seeing it.

10:12 Bronsa: ,(. Math -PI)

10:12 clojurebot: 3.141592653589793

10:12 Bronsa: ,(.-PI Math)

10:12 clojurebot: #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:12 Bronsa: ,(.. Math -PI)

10:12 clojurebot: 3.141592653589793

10:12 Bronsa: ,(-> Math .-PI)

10:12 clojurebot: #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:13 Bronsa: puredanger: would you say this is a bug?

10:13 dnolen: Bronsa: huh, did not know that.

10:13 puredanger: not sure. can't say I've ever done it.

10:13 Bronsa: dnolen: me neither until tools.analyzer exploded because of it one day

10:13 TimMc: ,(.- Math PI)

10:13 clojurebot: #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:13 TimMc: OK, will move this to my own REPL.

10:14 Bronsa: puredanger: there's written somehere in a design page of confluence that (.-foo bar) and (. bar -foo) are supposed to be identical

10:14 let's see if i can find it

10:14 TimMc: Like I said, no one uses this in Clojure. :-P

10:15 puredanger: well I use it all the time for instance fields

10:15 just not for statics

10:15 I would expect (.- Math PI) to work based on the docs (which I wrote :)

10:15 hellofun`: the .- syntax is very common in clojurescript, however

10:15 kral: Tau > Pi, in every sense. :)

10:17 TimMc: puredanger: 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:17 Bronsa: http://dev.clojure.org/display/design/Unified+ClojureScript+and+Clojure+field+access+syntax

10:20 puredanger: wait are you saying (.- foo bar) should work? I don't think that ever did, just (. foo -bar) and (.-bar foo)

10:21 TimMc: ,(. Math -PI)

10:21 clojurebot: 3.141592653589793

10:21 TimMc: phew

10:21 puredanger: Bronsa: maybe I'm just confusing myself :)

10:22 ,(. Math PI)

10:22 clojurebot: 3.141592653589793

10:23 puredanger: maybe the .- docs are wrong on that page

10:24 Bronsa: i think so

10:24 puredanger: I doubt that the most b/c I added it :)

10:24 TimMc: Forms 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:25 Bronsa: TimMc: yeah

10:26 TimMc: Note to self: Be really careful when writing macros that use this.

10:32 jtmarmon: what'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:33 puredanger: Bronsa: ok, I updated http://clojure.org/java_interop - does that look more accurate?

10:34 Bronsa: puredanger: yup

10:38 kaiyin: The 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:39 puredanger: yes

10:40 anon fn names are useful for describing intent to reader (prob not much benefit here)

10:40 they also show up in the class name in a stack trace, helpful for debugging

10:41 TimMc: ++ for that

10:43 $fn__3763$fn__3764$fn__3765$fn__3766$fn__3767.invoke is not my favorite thing to see in a stack trace.

10:46 shoky: "step" is used in the function body, though. line 233. doesn't it need to keep its name for that?

10:47 TimMc: shoky: Oh! Yeah, good point.

10:47 &(format "lib-%04d" (rand-int 1e4))

10:47 lazybot: ⇒ "lib-5045"

10:47 justin_smith: (inc shoky)

10:47 lazybot: ⇒ 2

10:55 puredanger: shoky: 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:56 shoky: puredanger: i don't think you can access that let binding inside the function body, though

10:57 i-blis: shoky: why not?

10:57 TimMc: ,(let [a (fn b [] [a b])] (a))

10:58 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" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: a in this context"\n ...

10:58 shoky: ^

10:58 i-blis: ,(let [x 42 f (fn [] x)] (f))

10:58 clojurebot: 42

10:58 justin_smith: ,(let [f (fn [x] (if (> x 10) x (f (* x 3))))] (f 1))

10:58 clojurebot: #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:58 shoky: now i'm confused

10:59 justin_smith: ,(let [f (fn f [x] (if (> x 10) x (f (* x 3))))] (f 1))

10:59 clojurebot: 27

10:59 TimMc: shoky: You're right, though.

10:59 justin_smith: shoky: my two examples show you were right, and puredanger was wrong for the first time ever

10:59 puredanger: yup! I didn't read closely enough

10:59 shoky: how does i-blis's example work ?

10:59 oh, nevermind

11:00 puredanger: I'm wrong all the time btw :)

11:00 shoky: ;]

11:00 puredanger: (inc shoky) ;; !!

11:00 lazybot: ⇒ 3

11:06 i-blis: (inc shoky) ;; I see now what you meant

11:06 lazybot: ⇒ 4

11:06 TimMc: ,(letfn [(f [x] (if (> x 10) x (f (* x 3))))] (f 1)) ;; :-D

11:06 clojurebot: 27

11:11 shoky: ,(let [f (fn [x] (if (> x 10) x (f (* x 3))))] (f 11))

11:11 clojurebot: #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:12 fourq: Does the underscore hold a special meaning in this case or is it just another parameter? (defmulti entry-view (fn [person _] (:type person)))

11:13 Bronsa: fourq: just a regular parameter

11:13 fourq: thanks

11:13 Bronsa: fourq: we typically use `_` for an unused parameter

11:13 puredanger: leading underscore (or just underscore) is a convention for "unused"

11:13 fourq: ahh gtk!

11:14 puredanger: so 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:15 fourq: nice

11:16 leading and tailing _'s are common for this?

11:16 oh, i thought you had a tailing

11:16 TimMc: Interestingly, Java 8's compiler warns that future versions of Java may reject variables named just "_".

11:16 fourq: nvm

11:16 clojurebot: It's greek to me.

11:17 fourq: TimMcm wonderful... another gtk

11:17 TimMc: I don't know if that has an effect on Clojure.

11:17 "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:18 So it might just be a Java thing, or it might be a JVM thing.

11:18 ToxicFrog: I hope it doesn't affect clojure, I use _ as a throwaway all the time.

11:18 fourq: interesting

11:18 ToxicFrog: A holdover from my Scala days, perhaps.

11:18 TimMc: I *bet* it's just Java.

11:18 fourq: I imagine clojjure would mask it

11:19 oddcully: that'l show those gettext buggers!

11:19 ToxicFrog: Yeah, clojure already lets you use a whole lot of symbols that aren't valid in java, and the compiler emits java-friendly versions

11:19 fourq: ^

11:19 TimMc: _ comes through unchanged though, right?

11:20 fourq: maybe in the end after it passes through Java

11:20 sobel: i love that you can name a clojure function 𝄞 if you want to

11:20 TimMc: ,(munge '_a!b?c)

11:20 clojurebot: _a_BANG_b_QMARK_c

11:20 sobel: or ♫

11:20 TimMc: fourq: Clojure code isn't compiled to Java, it goes right to JVM bytecode.

11:21 sobel: ,(munge '♫)

11:21 clojurebot:

11:21 fourq: is muI thought it was compiled through java, not to java

11:21 s/is muI/I

11:21 sobel: some of java's constraints are inherited from the vm

11:22 fourq: TimMc, again, I think I'm thinking of cljs

11:23 I'm only a few days into clojure/script

11:23 TimMc: Clojure goes directly to bytecode, do not pass Java, do not collect 200x the code size.

11:23 https://github.com/clojure/clojure/blob/clojure-1.6.0/src/jvm/clojure/lang/Compiler.java#L436

11:23 fourq: =)

11:23 ToxicFrog: TimMc: I think _ comes through unchanged, but a future version of the clj compiler could change that

11:23 fourq: thanks

11:24 TimMc: Clojurescript... right to JS, I think. And then through the optimizer.

11:24 Bronsa: ToxicFrog: why would it? that would be a major breaking change

11:25 ToxicFrog: Bronsa: the context of the discussion is that future java versions may make _ an invalid name

11:25 fourq: TimMc didn't realize that. ty

11:25 Bronsa: ToxicFrog: java, not the jvm

11:25 ToxicFrog: If that happens and is implemented as a JVM change rather than a javac change, clojure would have to make that change.

11:25 Bronsa: ToxicFrog: i seriously doubt they're going to introduce such a major breaking change in the jvm

11:40 fourq: clojure would be a tough mfr if it wasn't for pairedit

11:43 anyone have a vim snippets file for clojure that you just can't live without?

11:43 for snipmate

11:49 timvisher: is it possible set the response body for a 303 in liberator?

11:52 oddcully: fourq: 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:53 fourq: great gh search use. ty!

11:53 oddcully: fourq: 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:54 fourq: oddcully I was actually just wondering if that was the case.

12:02 timvisher: is `"null"` a valid json string afaak?

12:02 i'm getting conflicting reports

12:03 ,(do (require 'clojure.data.json) (clojure.data.json/read-str "null"))

12:03 clojurebot: #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:03 timvisher: :(

12:03 anyway, clojure.data.json/read-str happily turns `"null"` into `nil`. But jsonlint.com claims that valid json has to start with `[` or `{`

12:06 hiredman: well, it is wrong

12:07 timvisher: hiredman: which 'it'? :)

12:08 http://www.json.org/ seems to indicate by my reading that JSON is only valid if it is an object or array

12:08 only the values are allowed to be null

12:08 but i may be misreading that

12:09 heh. clojure.data.json also turns `"1"` into `1`...

12:11 zerokarmaleft: timvisher: I believe that's correct...a strict JSON parser will only validate if the root element is an object or an array

12:15 timvisher: hmm… not seeing anything in the issue tracker related to this.

12:17 ah. and it also write's invalid json.

12:20 noooooooooo! chrome developer tools do the same thing! :(

12:22 zerokarmaleft: timvisher: aeson, the go-to json parser for haskell, has strict and non-strict encoders/decoders

12:23 timvisher: i 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:23 if they even provide strict.

12:24 zerokarmaleft: db vendors may handle them differently as well

12:24 so it seems at the library level, supporting both use cases is appropriate

12:28 timvisher: http://dev.clojure.org/jira/browse/DJSON-20

12:29 now that i know it's a wider issue this suddenly feels like less of a big deal though...

12:34 bobbywilson0: Is 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:07 TimMc: timvisher: It is not clear to me that the JSON spec precludes top-level values that are not object or array.

13:08 timvisher: TimMc: which part of json.org would indicate that? or is that not the spec?

13:08 certainly implementors have by and large agreed with you, it would seem. :)

13:09 TimMc: timvisher: http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf

13:10 But that's basically the same thing.

13:11 Anyway, 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:12 I *do* seem to recall something about requiring object or array at top level, but I don't know where I saw that.

13:13 oddcully: TimMc: object at top level is about security

13:14 TimMc: oddcully: You mean, making it easy to be secure?

13:14 oddcully: TimMc: https://www.owasp.org/index.php/OWASP_AJAX_Security_Guidelines (`Always return JSON with an Object on the outside`)

13:14 TimMc: making it secure at all :)

13:15 TimMc: Hmm, will hvae to look later.

13:16 oddcully: TimMc: 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:44 moquist: I'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:44 is 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:45 Is there some way I should be forcing a re-render, or should I just not handle validation this way, or...?

13:45 oddcully: just in case you didn't know: there is also #clojurescript

13:45 moquist: oddcully: I did not; thanks.

13:55 dnolen: moquist: 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:25 fourq: if `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:30 TimMc: oddcully: That owasp page doesn't actually explain the threat. I know about JSON hijacking, but it doesn't seem relevant here.

14:33 Ah, here we go: http://stackoverflow.com/a/21510402/20772

14:33 dnolen: fourq: there's really no support for treating JS scalar values as cursors, don't do it

14:34 fourq: dnolen I'm just going off Om's tutorial.

14:34 dnolen: fourq: 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:35 fourq: I see. thanks

14:36 dnolen: fourq: I would definitely direct Om questions to #clojurescript

14:37 fourq: dnolen 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:37 oddcully: TimMc: 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:37 dnolen: fourq: definitely an Om question :)

14:38 fourq: k, thanks again

14:38 TimMc: oddcully: 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:38 fourq: dnolen I just now read "Note the following is for demonstration purposes only, it is not recommended in most real applications." =)

14:39 oddcully: oh man a 2k upvotes answer on SO... now i have seen it all ;)

14:39 TimMc: oddcully: 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:41 amalloy: oddcully: http://stackoverflow.com/q/1732348/625403 is the most famous SO question/answer i know of

14:41 beats 2k handily

14:42 TimMc: The funny thing is that it is wrong.

14:43 amalloy: well, that sorta depends what you mean by "regular expressions"

14:43 TimMc: and "can't"

14:43 amalloy: if you mean formal regular expressions then it is right

14:43 TimMc: No, even formal regular expressions.

14:44 amalloy: uhhhhhh, i don't think that's true. the html spec is context-free but not regular

14:44 TimMc: HTML *tags* are a regular language.

14:44 HTML *documents* are not.

14:44 amalloy: TimMc: but you can't find an html tag within an html document

14:44 oddcully: amalloy: yeah for hilarity

14:44 amalloy: i see what you mean, though

14:44 TimMc: amalloy: You can if you walk through it. And if you add a stack, BAM, you have a parser.

14:44 amalloy: the 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:45 TimMc: "Regex queries are not equipped to break down HTML into its meaningful parts." is just not true.

14:45 amalloy: if you add a stack, you don't have a regular expression or a finite automaton

14:48 TimMc: What is it, a PDA?

14:48 I don't remember the categories. Anyway, I wrote this some time ago: http://lab.brainonfire.net/markup-sanitizer/demo.html

14:49 amalloy: TimMc: yes

14:49 TimMc: Ain't nothing wrong with Public Displays of Affection.

14:50 (Mess up the HTML in that textarea to see the demo in action.)

14:56 That answer is funny, and I understand why the author wrote it, but it is incorrect and does not answer the question.

14:57 moquist: dnolen: 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:57 oddcully: downvote it! that'll show him!

14:58 TimMc: No, I think whoever wrote that deserves to live their retirement from answering HTML/regex questions in peace.

14:59 amalloy: is it even downvotable anymore? it's historical-locked, which i thought meant you can't really interact with it anymore

15:00 oddcully: amalloy: nope

15:00 as it: no can be downvoted anymore

15:01 TimMc: "This post has been locked; locked posts can't be voted on"

15:11 zhadn: Can someone help me understand -> vs. ->> and threading?

15:11 why would (->> [5 4 3 2 1] (drop 2) (take 3)) work

15:11 but not

15:12 (-> [5 4 3 2 1] (drop 2) (take 3))

15:12 amalloy: zhadn: have you tried macroexpanding the two?

15:12 ,(macroexpand '(->> [5 4 3 2 1] (drop 2) (take 3)))

15:12 clojurebot: (take 3 (drop 2 [5 4 3 2 1]))

15:12 amalloy: ,(macroexpand '(-> [5 4 3 2 1] (drop 2) (take 3)))

15:12 clojurebot: (take (drop [5 4 3 2 1] 2) 3)

15:13 zhadn: oh I had no idea macroexpand existed

15:13 amalloy: it's even simpler if you compare just (-> x (drop 2)) and (->> x (drop 2))

15:14 zhadn: , (macroexpand (-> x (drop 2))

15:14 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

15:14 zhadn: , (macroexpand (-> x (drop 2)))

15:14 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" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: x in this context"\n ...

15:14 amalloy: zhadn: you need to quote it

15:15 zhadn: , (macroexpand '(-> x (drop 2)))

15:15 clojurebot: (drop x 2)

15:15 zhadn: , (macroexpand '(->> x (drop 2)))

15:15 clojurebot: (drop 2 x)

15:15 zhadn: oh I see

15:16 so -> will put the arg at the beginning, and ->> at the end

15:16 amalloy: yes

15:16 zhadn: I was thinking about it the wrong way

15:16 that the difference was in which direction the forms started executing

15:17 where I thought -> would be the first form

15:17 and ->> started from the end

15:17 amalloy: indeed that is wrong

15:19 dnolen: moquist: no problem

15:29 zhadn: thanks amalloy

15:30 oddcully: (inc amalloy)

15:30 lazybot: ⇒ 267

15:30 zhadn: is there a point system?

15:31 oddcully: sure

15:31 TEttinger: (inc oddcully)

15:31 lazybot: ⇒ 8

15:31 oddcully: will this cascade down the whole chanel?

15:31 TEttinger: oddcully has 8 points of karma, amalloy has 267.

15:31 oddcully: now i going to kill mysself ;P

15:31 TEttinger: just demonstrating

15:32 TimMc: (inc TEttinger)

15:32 TEttinger: that won't get you bonus karma

15:32 lazybot: ⇒ 54

15:32 TEttinger: haha

15:32 TimMc: choo choo, all aboard the karma train

15:32 TEttinger: when did I get past 50???

15:32 lazybot: TEttinger: Yes, 100% for sure.

15:32 oddcully: no pitypoints?! the fsck it!

15:32 s/the/&n/

15:33 TimMc: oh man I forgot about &

15:35 TEttinger: well 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:36 and 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:37 like if you called (inc [1 2 3]) that would implicitly be the same as (map inc [1 2 3])

15:37 difference here is that map would not change the type of its argument

15:38 amalloy: to me that sounds, not disastrous, but bad

15:39 oddcully: what will (nth [1 2 3] 1) return with lua then?

15:43 TEttinger: hm...

15:44 it 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:45 fourq: What exactly is the syntax `(. object` telling me?

15:45 where object is any object

15:45 it's the (. that I'm wondering about

15:45 TEttinger: . calls a method on that object

15:45 fourq: (. object method) ?

15:45 TEttinger: ,(. (new java.util.Random) nextDouble)

15:45 clojurebot: 0.31682342160924615

15:45 TimMc: or gets a field :-)

15:46 TEttinger: right, that too

15:46 (inc TimMc)

15:46 lazybot: ⇒ 98

15:46 fourq: yeah I get it when it's a prop access, but I dind't know about the method

15:46 thank you

15:46 TEttinger: ,(. Math PI)

15:46 clojurebot: 3.141592653589793

15:46 fourq: \o/

15:46 oddcully: TEttinger: 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:47 (at least iirc... haven't used it for a year or two now)

15:47 TEttinger: ah, 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:49 oddcully: ah that's nice. i only used c++ > swig > lua - and the 1-base was always a source of errors for me

15:49 TEttinger: so 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:51 I 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:54 the 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:55 $google github chapel cray

15:55 lazybot: [chapel-lang/chapel · GitHub] https://github.com/chapel-lang/chapel

16:04 fredfe: If 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:05 arohner: fredfe: not really. You'd have to storm the request in an atom or something

16:06 (def last-request nil) (defn my-handler [handler] ... (reset! last-request req) ...

16:06 amalloy: crikey, arohner! your webservers never have more than one request in flight at a time?

16:07 arohner: amalloy: I didn't say it was a good idea...

16:07 amalloy: arohner: well it's a bad implementation of a mediocre idea

16:07 you can at least use a dynamic var to store it

16:08 arohner: amalloy: he specifically said global

16:08 fredfe: ok, 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:08 amalloy: arohner: dynamic vars are global

16:08 the 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:08 fredfe: Yes

16:09 arohner: amalloy: I've never seen var-set var-get used, anywhere, so I wasn't going to use it in an example

16:09 amalloy: arohner: neither have i. i wouldn't recommend you use those

16:09 you'd use binding

16:09 arohner: amalloy: which is thread local

16:09 amalloy: which is the point!

16:10 you are interpreting fredfe's request as asking for something nonsensical and insane, instead of the fairly normal thing fredfe is actually asking for

16:11 arohner: amalloy: 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:11 fredfe: My 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:12 arohner: fredfe: 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:13 fredfe: I always regret using binding later, when I introduce threads

16:13 fredfe: ok

16:14 fourq: Is this form calling `send` of xhr, or is it feeding xhr the results of clojures' send? https://gist.github.com/33e49ed3a5f5113b0914

16:14 arohner: also, 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:16 fourq: it's calling send on xhr http://clojure.org/Java%20Interop-The%20Dot%20special%20form-(.%20instance-expr%20member-symbol)

16:17 fourq: arohner I wasn't sure because the params don't match and it's within a form itself. (new here obv)

16:17 or rather, within another form

16:17 arohner: fourq: np. we were all new at some point

16:17 fredfe: Thanks guys, I'll just keep passing the request map around

16:18 arohner: fourq: that usage is fairly rare

16:18 (.foo bar) is far more common

16:18 fourq: I wondered if that was the case

16:18 thanks

16:20 TEttinger: fourq: but it's (.method object), not the same as (. object method)

16:20 fourq: arohner 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:20 or anyone for that matter

16:20 TEttinger: ,(.nextDouble (new java.util.Random))

16:20 clojurebot: 0.49141840279783167

16:21 amalloy: TEttinger: (.method object) is shorthand for (. object method)

16:21 TEttinger: yeah, I just mean the order is different

16:22 fourq: thanks TEttinger

16:22 TEttinger: no prob

16:22 arohner: fourq: aren't the parameters correct?

16:22 fourq: well the first param is a method

16:22 in the doc

16:22 and the gist has the first param as the url

16:22 arohner: oh, yeah, that is strange. different versions?

16:22 do you know that this code is being called and works?

16:22 fourq: possibly

16:23 I'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:24 I'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:26 I think the params might just be switched around, and should have been (meths method) url opposed to url (meths method)

16:38 [let xhr (XhrIo.)] is "constructing" an instance correct? (I'm almost done for the day...I'll shut-up soon)

16:42 oddcully: fourq: yes (Class.) constructs you a new thing of Class

16:42 fourq: perfect

16:42 oddcully: ,(String. "asdf")

16:42 clojurebot: "asdf"

16:42 oddcully: (inc clojurebot)

16:42 lazybot: ⇒ 50

16:43 oddcully: he's such a helpfull fellow

16:43 fourq: =)

16:43 TEttinger: amalloy: 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:43 that, 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:45 that doesn't allow for fairly common constructs like ##(map #(repeat 3 %) [1 2 3])

16:45 lazybot: ⇒ ((1 1 1) (2 2 2) (3 3 3))

16:46 TEttinger: hm, maybe it would...

16:48 amalloy: so, 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:48 but (a) that just hides the issue, if what i actually intended was (f x)

16:49 and (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:52 TEttinger: well 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:53 amalloy: TEttinger: 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:53 TEttinger: not accidental

16:54 I think you misunderstand my intent here

16:55 amalloy: well, it will have the *effect* of fixing those accidents

16:55 TEttinger: I think being able to treat rank (dimensionality) as a core concept can be useful

16:56 and if a rank 0 thing is at its core incompatible with something that takes higher-ranked things, it isn't that useful

16:57 TimMc: I think I've seen this feature in some other languages but I don't remember which ones.

16:58 TEttinger: J uses rank as its term

16:58 it also implicitly maps

16:58 TimMc: That might be the main one.

16:58 puredanger: R ?

16:58 TEttinger: also K

16:58 probably R too, it's common in array programming languages

16:58 TimMc: But not C? Shame.

16:59 puredanger: basically array languages :)

16:59 turbofail: i think supercollider's sclang does it too?

16:59 TimMc: How about matlab?

16:59 TEttinger: yeah, we're basically listing wikipedia's array language category

16:59 TimMc: Ruby at least fakes it up.

17:00 TEttinger: anyway, clojure's seq abstraction would be handy as an extension of sorts to array programming.

17:00 TimMc: (Adding something to every element of an array is easy, but I don't think it's general.)

17:01 TEttinger: can you give an example, TimMc?

17:09 TimMc: TEttinger: Nope! Doesn't work the way I remembered. (I don't relaly know Ruby, so there's that.)

17:10 TEttinger: I 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:11 and by extension, you could define a vec of maps as a rank 2 domain over a sequence

17:14 a 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:21 hm. 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:50 drojas: is there any short way fully qualify everything in a list?

18:53 amalloy: drojas: is there any short way to fully qualify a single thing?

18:53 TimMc: drojas: Can you give me an example of what it means to fully qualify a single thing?

18:53 dammit amalloy

18:54 amalloy: that's what you get for typing more letters

18:54 drojas: TimMc: (= 1 1) -> (clojure.core/= 1 1)

18:56 TimMc: HOw do you know that = -> clojure.core/= ?

18:58 Or let me put it another way -- what's the *long* way of doing it?

18:58 drojas: because it has a binding inside *ns* I guess.. like (resolve x)

18:58 amalloy: that's why i liked my question better, TimMc

19:00 drojas: TimMc: (eval (read-string (str "`" '(= 1 1))))

19:01 TimMc: Oh yikes. :-)

19:02 drojas: I was wondering if there is a better | cleaner | smarter | shorter way

19:02 crazydiamond: Hi. 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:10 drojas: TimMc: 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:10 TimMc: that way I only need to refer the symbols on the test namespace

19:11 jtmarmon: i'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:12 TimMc: drojas: Neat.

19:13 drojas: 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:15 drojas: TimMc: yep, sounds like I'll be reading about the reader and syntax-quoting tonight ;)

19:16 amalloy: the syntax-quoting reader for symbols doesn't do anything more complicated than resolving to get a namespace, does it?

19:19 drojas: the only thing I know about it is that it is a reader macro so it is implemented in Java

19:19 but nothing about how it actually does the job

19:25 amalloy: drojas: 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:43 crazydiamond: Hi. 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:44 justin_smith: crazydiamond: depends, how stateful is x?

19:45 amalloy: it would almost never be the same as x

19:45 crazydiamond: justin_smith, in short, it cames from datomic

19:45 justin_smith: oh, eval of read-string would do funky things with lists at least

19:46 why eval?

19:47 crazydiamond: well... there may be equivalent which doesn't turn vec to list or what it does

19:47 what that funky things are

19:47 justin_smith, are you asking about eval, or whole expression?

19:51 sorry I was disconnected :P

19:58 Guys, 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:59 amalloy: crazydiamond: (def x '(1 2 3))

19:59 crazydiamond: amalloy, ok...

19:59 amalloy: try it and se

20:00 crazydiamond: ok

20:00 it would call 1

20:00 amalloy: yes

20:00 crazydiamond: but error what I get

20:01 and what applying (eval (read-string (prn-str x))) solved

20:01 is much more complex

20:01 I'm getting data from Datomic

20:02 and returning it as a result via Castra ( https://github.com/tailrecursion/castra ) RPC

20:02 when I return x

20:02 I've got an error

20:03 and when I return (eval (read-string (prn-str x)) I got what expected

20:04 well "eval" was even redundant

20:04 cause things I'm working with evaluate to themselves

20:05 well what's difference between (read-string (prn-str x)) vs. x then?

20:10 erikcw: Does 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:12 jtmarmon: if 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:14 lvh: jtmarmon: 1 million probably isn't enough to start worrying about that

20:14 jtmarmon: plain old vectors and maps will do fine

20:14 jtmarmon: you might want to take a look at records I guess

20:15 (map #(get-in % [1 0 :a]) that), unless there are multiple places the :a can occur in that inner vec

20:16 jtmarmon: thanks lvh!

20:17 i think my strategy is O(n!) which is wonderful so i'm just gonna run a test to see if that's workable

20:29 lvh: 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:31 amalloy: jtmarmon: does that look suspiciously like ##(doc map) to you?

20:31 lazybot: ⇒ "([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:34 jtmarmon: amalloy: 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:34 thanks

20:35 tieTYT: does this have a video my browser is blocking? http://www.infoq.com/presentations/Simple-Made-Easy

20:35 I can’t figure out how to start it

20:36 ah yeah, it’s blocked

20:36 nm

20:37 drojas: amalloy: sorry I was on the supermarket... so syntax quote is just a wrapper for resolve, thanks for clarifying

20:44 jtmarmon: ahh

Logging service provided by n01se.net