2015-01-13
| 01:06 | koreth_ | Is there no way to get a browser REPL unless you first launch the HTTP server from a (non-browser) REPL and then reload the web page? Seems like the Piggieback code doesn't play nice with the concept of connecting a brand-new REPL to a running browser application (session management depends on a lot of dynamic vars that aren't bound in a fresh REPL session). |
| 01:07 | koreth_ | If there's a ClojureScript equivalent to programmatically starting an nREPL server, I'd love a pointer to it. |
| 04:11 | dysfun | are there any sparse vector implementations for clojure? preferably ones backed by maps? |
| 04:11 | SagiCZ1 | dysfun: maybe check out incanter? |
| 04:12 | dysfun | ugh. server app. i really don't want to embed encanter |
| 04:27 | cfleming | koreth_: Unfortunately all of the existing CLJS REPLs work by making an outbound connection from the browser, since that's pretty much all you can do from JS |
| 04:28 | cfleming | koreth_: There's no way to listen on a port in the browser. Chrome doesn't even let you do it from extensions. |
| 04:29 | cfleming | dysfun: Perhaps mikera's libs have something? vectorz etc. IIRC a sparse matrix fix went in recently, but I don't know if that included sparse vectors. |
| 04:30 | hellofunk | why is it that Cider jack-in sometimes takes me to a user prompt initially, while other times, it takes me directly into the namespace declared at the top of the file on which i called jack-in, having automatically compiled the file upon jack-in? |
| 04:31 | cfleming | dysfun: https://groups.google.com/d/topic/clojure/LLpq4WHx-k8/discussion "It isn't just matrices - you can have sparse vectors, N-dimensional arrays etc." |
| 04:41 | dysfun | wheee! |
| 04:41 | dysfun | thanks |
| 04:42 | sm0ke | ,(not (Boolean. "false")) |
| 04:43 | clojurebot | false |
| 04:43 | sm0ke | http://dev.clojure.org/jira/browse/CLJ-1640 |
| 04:44 | sm0ke | was this reported before? |
| 04:46 | dysfun | that's not a bug |
| 04:46 | dysfun | strings are truthy values |
| 04:46 | sm0ke | ,(class (Boolean "false")) |
| 04:46 | clojurebot | #<CompilerException java.lang.RuntimeException: Expecting var, but Boolean is mapped to class java.lang.Boolean, compiling:(NO_SOURCE_PATH:0:0)> |
| 04:46 | sm0ke | ,(class (Boolean. "false")) |
| 04:46 | clojurebot | java.lang.Boolean |
| 04:46 | scottj | sm0ke: pretty sure it's known and not won't fix. you're supposed to use Boolean/FALSE |
| 04:46 | sm0ke | ,(Boolean. "false") |
| 04:46 | clojurebot | false |
| 04:46 | scottj | s/not// |
| 04:47 | sm0ke | ,(= (Boolean. "false") Boolean/FALSE) |
| 04:47 | clojurebot | true |
| 04:47 | sm0ke | wtf right? |
| 04:47 | dysfun | yeah that is a bit wtf |
| 04:48 | sm0ke | and funny part |
| 04:48 | sm0ke | ,(source if) |
| 04:48 | clojurebot | Source not found\n |
| 04:48 | sm0ke | ,(source not) |
| 04:48 | clojurebot | Source not found\n |
| 04:48 | scottj | sm0ke: " Note that if does not test for arbitrary values of java.lang.Boolean, only the singular value false (Java's Boolean.FALSE), so if you are creating your own boxed Booleans make sure to use Boolean/valueOf and not the Boolean constructors." from http://clojure.org/special_forms |
| 04:49 | sm0ke | aah |
| 04:49 | sm0ke | but i dont get it not's source is (not [x] (if x false true)) |
| 04:50 | sm0ke | ,(if (Boolean. "false") false true) |
| 04:50 | clojurebot | false |
| 04:50 | sm0ke | ,(if (not (Boolean. "false")) false true) |
| 04:50 | clojurebot | true |
| 04:50 | sm0ke | ^^ |
| 04:50 | scottj | read what I quoted and see the page how it's documenting if |
| 04:51 | sm0ke | yea i read that |
| 04:51 | sm0ke | but it always works correctly for `if` and fails for `not` |
| 04:52 | sm0ke | ,(doseq [i (range 1000)] (assert (if (not (Boolean. "false")) false true))) |
| 04:52 | clojurebot | nil |
| 04:53 | sm0ke | ,(doseq [i (range 1000)] (assert (not (Boolean. "false")))) |
| 04:53 | clojurebot | #<AssertionError java.lang.AssertionError: Assert failed: (not (Boolean. "false"))> |
| 04:55 | sm0ke | ugh i did a not in if conition |
| 04:55 | sm0ke | ,(if (Boolean. "false") false true) |
| 04:55 | clojurebot | false |
| 04:55 | sm0ke | makes sense |
| 04:56 | scottj | sm0ke: you understand why (not (Boolean. "false")) is false right? |
| 04:56 | sm0ke | yeah |
| 04:56 | sm0ke | but thats really nasty |
| 04:57 | scottj | ,(doc not) |
| 04:57 | clojurebot | "([x]); Returns true if x is logical false, false otherwise." |
| 04:57 | cfleming | Bronsa: ping |
| 04:58 | sm0ke | scottj: isnt (Boolean. "false") logically false? |
| 04:58 | scottj | no, it's true |
| 04:58 | sm0ke | scottj: i think the doc of the function should mention this |
| 04:58 | sm0ke | ,(Boolean. "false") |
| 04:58 | clojurebot | false |
| 04:59 | luxbock | I'm trying to simulate function argument destructuring |
| 04:59 | luxbock | https://gist.github.com/luxbock/626e8d6192491564c6bf |
| 04:59 | sm0ke | ,(= true (Boolean. "false")) |
| 04:59 | clojurebot | false |
| 04:59 | sm0ke | ,(= false (Boolean. "false")) |
| 04:59 | clojurebot | true |
| 04:59 | CookedGryphon | does anyone know if I can match something like [map* {:foo int}] (vector of maps ending in a map containing :foo int) in miner.herbert? Or does it not work like that? At the moment I'm using a combo of herbert and seqexp |
| 04:59 | luxbock | this works, but I was wondering if anyone can think of a better way to achieve this |
| 04:59 | sm0ke | what are you talking about |
| 05:00 | CmdrDats | ,(not (Boolean/valueOf "false")) |
| 05:00 | clojurebot | true |
| 05:03 | sm0ke | ,(let [a (Boolean. "false")] (when a (print 1)) (when (not a) (print 2))) |
| 05:03 | clojurebot | 1 |
| 05:03 | scottj | sm0ke: "if" only checks for nil or false, and that's the false from Boolean/false or false not (Boolean. "foo"). |
| 05:03 | scottj | sm0ke: and "not" is defined in terms of "if" |
| 05:04 | scottj | sm0ke: that this is confusing I don't know if anyone will argue with you. I'd guess there are good performance reasons for doing it. Just don't use the Boolean constructor. |
| 05:04 | scottj | use Boolean/FALSE or Boolean/valueOf |
| 05:05 | sm0ke | +1 |
| 05:06 | sm0ke | Lets make a point on this |
| 05:06 | sm0ke | and mention it to other java devs too |
| 05:07 | hyPiRion | Let's fork Clojure and make boolean constructors throw an UnsupportedOperationException or something. |
| 05:07 | hyPiRion | (through reflection) |
| 05:07 | foofoobar | Hi. A few question to this clojure irc bot: http://hastebin.com/xizokerura.clj — Line15: Why is doto used here? Is a simple (Thread. #(conn-handler conn)) .start) also possible or is doto the only way to call methods of java classes? |
| 05:08 | sm0ke | hyPiRion: awesome idea bro |
| 05:11 | sm0ke | can be done through proxies |
| 05:12 | sm0ke | http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Proxy.html |
| 05:12 | scottj | foofoobar: your code looks fine. doto may be his preferred method or maybe he used to do more more things with the thread or wanted it as a return value and then changed the code but didn't change the doto |
| 05:12 | sm0ke | it would help catch if some library is using a boolean constructor and kill it before it gets out of hand |
| 05:13 | scottj | foofoobar: oh I didn't read your code. yours should be (.start (Thread. #(...))) no? |
| 05:14 | foofoobar | It works the way it is now. Give me a second, then I try your way. |
| 05:14 | scottj | foofoobar: to have the .start at the end like you have it you would need to use -> |
| 05:14 | scottj | (-> (Thread. #(...)) .start) |
| 05:15 | scottj | foofoobar: (.start ...) is the most common form I believe |
| 05:15 | foofoobar | scottj: Yeah this works, the doto is not needed here. |
| 05:16 | foofoobar | (Thread. #(conn-handler conn)) — the #(..) here is used so it’s a closure, right? So the conn-handler is not executed, instead the Thread does execute this function, correct? |
| 05:17 | scottj | yep |
| 05:17 | sm0ke | https://stackoverflow.com/questions/18676956/boolean-false-in-clojure |
| 05:17 | scottj | foofoobar: are you reading a book or tutorial on clojure? |
| 05:18 | foofoobar | scottj: Yes, I’m reading a guide and testing the things I have read with an irc bot. (I’m trying to understand the irc bot) |
| 05:18 | foofoobar | let .. conn (ref {:in in :out out})] — the ref makes conn atomic so it can be access from different threads, correct? |
| 05:20 | opqdonut | foofoobar: something like that, yes |
| 05:20 | foofoobar | ok. |
| 05:20 | foofoobar | So what happens if the connection drops? |
| 05:20 | opqdonut | to be more precise, the ref is something that can safely be _mutated_ from different threads |
| 05:20 | foofoobar | (Instead of the irc server sending the „closing link“ ? |
| 05:21 | opqdonut | and actually, many refs can be mutated transactionally |
| 05:21 | opqdonut | I have no idea about the concrete code you're looking at |
| 05:21 | clgv | sm0ke: in case no one mentioned it -> "never construct booleans yourself! parse them via valueOf or read-string" |
| 05:22 | opqdonut | foofoobar: but it looks like something like line 20 would just throw an exception |
| 05:23 | sm0ke | clgv: the doc mentioned it |
| 05:23 | opqdonut | foofoobar: or if the conn-handler thread has noticed the exit (see line 28), it will add an ":exit true" to the conn map |
| 05:23 | sm0ke | :D |
| 05:23 | foofoobar | opqdonut: okay. maybe I will test what happens when I disable WLAN while beeing connected |
| 05:23 | foofoobar | opqdonut: Yeah but when the connection drops, it will not notice |
| 05:24 | sm0ke | so in clojure values can be true, false and 'i dont know' ? |
| 05:25 | sm0ke | i am not trying to be pedantic about bools here, but using Boolean constructor can be true/false |
| 05:26 | opqdonut | sm0ke: in clojure a value can be true, false, nil, :borg, {:hello "there"}, (Object.), ... |
| 05:26 | opqdonut | sm0ke: in terms of booleannes though, they can be truthy or falsy |
| 05:26 | opqdonut | sm0ke: where truthy and falsy are defined by what (if val 1 2) returns |
| 05:27 | sm0ke | opqdonut: all those are logically true except nil and false |
| 05:27 | opqdonut | but yeah, java Boolean objects are just horrible |
| 05:27 | sm0ke | opqdonut: but you can say that about a Boolean |
| 05:27 | sm0ke | opqdonut: ok agreed |
| 05:27 | sm0ke | but it effects clojure |
| 05:28 | opqdonut | only if you let it :) |
| 05:28 | sm0ke | to a extend where you cant say values can be truthly or falsely |
| 05:28 | sm0ke | they can be 'god_knowsly' too |
| 05:28 | CmdrDats | smoke: it's a design decision, consciously taken and documented, why belabour the point? |
| 05:29 | clgv | sm0ke: no, the JVM is to blame here |
| 05:29 | sm0ke | guys please i am not blaming clojure here |
| 05:29 | opqdonut | sm0ke: in clojure's eyes, values are either truthy or falsy |
| 05:29 | sm0ke | i agree Boolean with arbit argument constructor is horrible |
| 05:29 | clgv | sm0ke: two static constants for true and false instead of the public constructor would have been a better choice |
| 05:29 | opqdonut | because (if val 1 2) always returns 1 or 2 |
| 05:30 | opqdonut | there is no third alternative |
| 05:30 | sm0ke | clgv: ##(not (Boolean. false)) |
| 05:30 | lazybot | ⇒ false |
| 05:30 | cfleming | Looks like 2 to me |
| 05:30 | sm0ke | cfleming: lol |
| 05:31 | cfleming | There are warnings in at least one of the Clojure books (JoC, I think) about using the Boolean constructor |
| 05:32 | cfleming | Boolean/TRUE |
| 05:32 | cfleming | ,Boolean/TRUE |
| 05:32 | sm0ke | http://grokbase.com/t/gg/clojure/1247108a4b/boolean#20120413qoo2wt5qscaqp5vv6sde4wav6y |
| 05:32 | clojurebot | true |
| 05:32 | sm0ke | ^^ Rich's thought on this |
| 05:32 | cfleming | ,(not Boolean/FALSE) |
| 05:32 | clojurebot | true |
| 05:33 | sm0ke | well at least the doc doesnt say "Note: It is rarely appropriate to use this constructor." anymore |
| 05:33 | sm0ke | :P |
| 05:33 | sm0ke | oh it still does |
| 05:33 | cfleming | I'd say that's an accurate statement |
| 05:33 | sm0ke | well that settles it then |
| 05:36 | sm0ke | but if you see the whole thread it caused a problem due to Boolean constructor being used in a library |
| 05:38 | sm0ke | its just strange, Doesnt clojure's if uses Java's if? |
| 05:41 | opqdonut | let's see |
| 05:44 | sm0ke | also if you could point me to the equality special form code |
| 05:44 | sm0ke | ,(= (Boolean. false) false (Boolean. "false")) |
| 05:44 | clojurebot | true |
| 05:45 | sm0ke | i would like to see why if doesnt borrows some wit from = |
| 05:46 | kyrre | How can I call functions listed in a edn file? |
| 05:46 | sm0ke | oh = is just a function |
| 05:46 | hyPiRion | ,(identical? true (Boolean. true)) |
| 05:46 | clojurebot | false |
| 05:46 | sm0ke | kyrre: edn supports functions? |
| 05:46 | hyPiRion | there's your answer |
| 05:46 | sm0ke | i think it only supports data |
| 05:47 | cfleming | ,(identical? true Boolean/TRUE) |
| 05:47 | clojurebot | true |
| 05:48 | cfleming | sm0ke: Clojure doesn't compile to Java, so you can't really say whether it uses Java's if - it probably compiles to similar bytecode. For truthy/falsy tests it uses RT.booleanCast IIRC |
| 05:49 | opqdonut | https://github.com/clojure/clojure/blob/9f277c80258b3d2951128ce26a07c30ad0b47af0/src/jvm/clojure/lang/Compiler.java#L2688 |
| 05:50 | opqdonut | that shows the compiler generating a comparison to Boolean/FALSE |
| 05:51 | lxsameer | hey guys, what books do you recommend for to learn Clojure ? ( I'm a ruby/python user ) |
| 05:51 | sm0ke | weird |
| 05:51 | cfleming | true and false in Clojure are Boolean/TRUE and Boolean/FALSE, respectively, always |
| 05:52 | sm0ke | ,(= (Boolean. false) false (Boolean. "false") Boolean/FALSE nil) |
| 05:52 | scottj | lxsameer: clojurebook.com is the most frequently recommended. |
| 05:52 | clojurebot | false |
| 05:52 | sm0ke | ,(= (Boolean. false) false (Boolean. "false") Boolean/FALSE) |
| 05:52 | clojurebot | true |
| 05:53 | lxsameer | thanks |
| 05:54 | sm0ke | hyPiRion: thats just comparing refs |
| 05:54 | sm0ke | it will never be equal with a constructor |
| 05:54 | sm0ke | true and Boolean/TRUE are idential because they probably would be interned |
| 05:55 | sm0ke | well at least clojure's = is java's = |
| 05:55 | sm0ke | https://github.com/clojure/clojure/blob/9f277c80258b3d2951128ce26a07c30ad0b47af0/src/jvm/clojure/lang/Util.java#L24 |
| 05:55 | sm0ke | .equals i mean |
| 05:59 | sm0ke | only core dev's can comment on why it doesnt work |
| 06:07 | hyPiRion | sm0ke: exactly. That's why (Boolean. true) is truthy but not true, and why (Boolean. false) is truthy as well |
| 06:07 | hyPiRion | they're compared against nil and Boolean/{False, True} |
| 06:07 | hyPiRion | *{FALSE, TRUE} |
| 06:47 | clgv | lxsameer: there is also "Programming Clojure" (2nd Edition) which I found useful |
| 06:47 | lxsameer | clgv: thanks |
| 07:18 | zarkone | hello all! I've noticed that there's almost no info in the Internet about configuring Clojure view server for CouchDB. Does somebody use it? |
| 07:26 | ggherdov | Hello, I have an algorithm in mind that sounds like this: start with an empty list L, and for each element E in a given collection, concatenate some stuff to L. |
| 07:26 | ggherdov | How do I express that in clojure? A minimal example in python here: https://bpaste.net/show/444bbe7695e7 |
| 07:27 | clgv | ggherdov: via `reduce` |
| 07:27 | ggherdov | clgv: right, thanks |
| 07:28 | clgv | ggherdov: the pattern might look like: (reduce (fn [coll, x] ....) [] given-coll) |
| 07:28 | ggherdov | clgv: ok trying |
| 07:29 | clgv | ggherdov: iterations usally translate to `reduce` or `map`. in special case you might need a custom recursion |
| 07:30 | ggherdov | ok |
| 07:32 | clgv | ggherdov: you got a book or one of the online courses to get a quick start? |
| 07:32 | ggherdov | clgv: yup, "Clojure Programming" o'reilly |
| 07:33 | clgv | ggherdov: that should help you to get started quickly |
| 07:33 | ggherdov | yes, need to study example and get into the mindset |
| 07:33 | ggherdov | s/example/examples |
| 07:39 | hellofunk | ggherdov: and if you are looking for quick, free online clojure tutorial that is fairly comprehensive, go to braveclojure.com |
| 07:39 | ggherdov | cool thanks hellofunk |
| 07:42 | morfeen | Hey, where can I find problems to solve, which will allow me to think in Clojure? I've been learning the syntax and constructs, but I would become confident only if I can solve some problems for excercise. |
| 07:43 | hellofunk | morfeen: 4clojure.com |
| 07:43 | morfeen | hellofunk: cool |
| 08:55 | irctc | \? |
| 08:55 | irctc | \help |
| 08:55 | irctc | \name matt |
| 08:55 | irctc | \name = matt |
| 08:55 | js1 | forward slash |
| 08:56 | irctc | Thanks :-) |
| 09:02 | arrdem | 'morning |
| 09:03 | n0n3such | g'day |
| 09:07 | js1 | good morning! |
| 09:48 | yotsov | Hello. Is there a way to tell leiningen to :aot :all on the command line (without changing project or global config)? |
| 09:49 | clgv | yotsov: use a profile with that configuration, then you can decide on the commandline when to use that profile |
| 09:49 | llasram | yotsov: if you really need that, you can use `lein update-in` |
| 09:50 | yotsov | llasram: clgv: thank you! |
| 10:05 | zB0hs | what happened to the core.async docs at https://clojure.github.io/core.async/ ?? |
| 10:05 | lazybot | zB0hs: Definitely not. |
| 10:06 | arrdem | zB0hs: I'm gonna guess that something's up with the autodoc system right now |
| 10:07 | CookedGryphon | It's based off master and so might not correspond to the code you're using anyway, I like to use https://github.com/jaley/cloc |
| 10:07 | CookedGryphon | lein cloc, generates docs from everything it finds in your classpath |
| 10:07 | CookedGryphon | guaranteed to match the version you're using, searchable and everything |
| 10:08 | H4ns | is there a predefined way to send log message to the cider repl rather than to the nrepl server buffer? |
| 10:08 | zB0hs | thanks CookedGryphon ill check that out. for now i was able to find a cached version |
| 10:08 | arrdem | not gonna lie, Grimoire is converging on being a souped-up version of cloc with a bunch of stuff "in the box" |
| 10:08 | arrdem | H4ns: send a message as in what... print to stdout? |
| 10:09 | H4ns | arrdem: i'm using clojure.tools.logging with log4j2, and i would like to see the logs in the repl, not in the nrepl server buffer. |
| 10:09 | arrdem | H4ns: right. So you need to capture the value of *out* that cider uses somehow. |
| 10:27 | kaiyin | What is wrong with this: (#(map #(str "hi, " %) %&) "newton" "plato") ? |
| 10:28 | arrdem | kaiyin: #() doesn't nest. |
| 10:28 | arrdem | kaiyin: those functions are fine, you just can't use the #() reader sugar like that |
| 10:28 | kaiyin | arrdem: ok. I see. Would be nice it does allow nesting. |
| 10:29 | hipsterslapfight | how would it know what % to use though! |
| 10:29 | arrdem | kaiyin: nice but ambiguous. is %1 in the inner #() a parameter or a closed over parameter? |
| 10:29 | arrdem | I actually dropped #() as a feature in my toy clojure imp'l... it doesn't really buy you anything except reader complexity. |
| 10:29 | kaiyin | arrdem: what is a closed over param? |
| 10:30 | Glenjamin | ,(fn [a] (fn [b] (+ a b))) ; try and write that using #() |
| 10:30 | clojurebot | #<sandbox$eval25$fn__26 sandbox$eval25$fn__26@77b9a19a> |
| 10:30 | arrdem | kaiyin: (fn [x] (fn [y] (+ x y 1))) ;; x is closed over or captured in the inner function. |
| 10:30 | kaiyin | arrdem: i see. |
| 10:31 | kaiyin | arrdem: % in the inner #() is closed over then. It's meant to be applied to each element of %&. |
| 10:32 | arrdem | kaiyin: not the meaning of closed over. your inner % is a distinct function argument, meaning the element of %& being mapped over by the outer #(). |
| 10:33 | arrdem | kaiyin: (fn [xs] (map (fn [x] (str "Hello, " x)) xs)) is what you tried to write |
| 10:33 | arrdem | kaiyin: (fn [xs] (map (fn [x] (str "Hello, " xs)) xs)) is what you just described to me. |
| 10:34 | arrdem | brb coffee refill |
| 10:34 | kaiyin | ok, it's not crossed over. interesting. |
| 10:36 | kaiyin | , ((fn [xs] (map (fn [x] (str "Hello, " xs)) xs)) "newton" "plato") |
| 10:36 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: sandbox/eval53/fn--54> |
| 10:36 | kaiyin | arrdem: it doesn't quite work though. |
| 10:37 | arrdem | Oh. that needs to be [& xs]. my bad. |
| 10:37 | arrdem | &((fn [& xs] (map (partial str "Hello, ") xs)) "Newton", "Plato") |
| 10:37 | lazybot | ⇒ ("Hello, Newton" "Hello, Plato") |
| 10:38 | arrdem | &((fn [& xs] (map (fn [x] (str "Hello, " x)) xs)) "Newton", "Plato") |
| 10:38 | lazybot | ⇒ ("Hello, Newton" "Hello, Plato") |
| 10:38 | kaiyin | cool. |
| 10:41 | kaiyin | &&((fn [& xs] (map (partial str "Hello, ") xs)) "Newton", "Plato") |
| 10:41 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: & in this context |
| 10:41 | kaiyin | &((fn [xs] (map (fn [x] (str "Hello, " x)) xs)) ["newton" "plato"]) |
| 10:41 | lazybot | ⇒ ("Hello, newton" "Hello, plato") |
| 10:41 | arrdem | =D |
| 10:42 | ashtonkem | Morning. |
| 10:43 | ashtonkem | Why thank you. |
| 10:43 | ashtonkem | And now that you mention it, I do want more coffee. |
| 10:53 | arrdem | is ^:no-wiki supposed to be a documentation convention or just an implementation detail for core's autodoc tool? |
| 10:53 | arrdem | I'm thinking either way I should try and respect it.. |
| 10:56 | ashtonkem | I'd just grep for it in the codebase. |
| 10:56 | ashtonkem | And see if it's docced or just used. |
| 10:57 | ashtonkem | Also see if codox cares about it. |
| 10:58 | ashtonkem | https://github.com/weavejester/codox/pull/4 |
| 10:58 | ashtonkem | Relevant, I think. |
| 10:58 | arrdem | http://tomfaulhaber.github.io/autodoc/#adding_documentation_to_your_project |
| 10:58 | arrdem | ashtonkem: nice find! |
| 10:58 | ashtonkem | Did you mean skip-wiki? |
| 10:58 | arrdem | yeah. |
| 10:59 | ashtonkem | Thanks. It looks like it's just for the official wiki. |
| 10:59 | arrdem | I need to read into codox |
| 10:59 | ashtonkem | At least that's what weavejester said. |
| 11:04 | zot | banging my head on this: clojure compiler seems to be referencing a library version that doesn't exist in my repo. i can't figure out where it's coming from, but it's wrong. when i tab-complete in emacs, it also refers to the wrong version, so they're in cahoots. any suggestions on how to track down the source of loaded clojure source jars? |
| 11:04 | arrdem | zot `ein deps :tree` |
| 11:04 | arrdem | *lein |
| 11:05 | clgv | zot: the clojure compiler does not know of dependencies. leiningen does |
| 11:05 | zot | i started there, and it appears to be correct. i also removed the offending incorrect version from my .m2 space, so it's gone from there. |
| 11:05 | ashtonkem | You sure it wasn't in the tree? A lot of times another dependency will pull in the version you don't want. |
| 11:06 | zot | i unzipped the jarfile of the correct version to confirm that it has the version i expect |
| 11:06 | zot | unless something else is registering under the same clojure-loadable-namespace, i don't see where it could be. the incorrect version isn't being re-downloaded, so it still exists somewhere. i just don't know where. or why it's being loaded. |
| 11:08 | ashtonkem | Try 'lein classpath' and see if any surprises hide in there. |
| 11:08 | ashtonkem | Also, you aren't using something like nailgun are you? |
| 11:08 | zot | not familiar with nailgun |
| 11:08 | zot | so, not intentionally :) |
| 11:09 | ashtonkem | It's not auto-setup by anything to my knowledge, so that's a no. |
| 11:11 | ashtonkem | Did you do a lein clean? |
| 11:11 | ashtonkem | Beyond that it sounds like either a running process has the old code loaded (nailgun would do this I think), or you've got a jar hidden somewhere in a cache. |
| 11:11 | zot | don't think so. that seems way too easy. ;) |
| 11:12 | zot | yeah, the cache is my suspicion too, but dunno where it lives. hoped that blowing it out of .m2 would be sufficient. |
| 11:12 | ashtonkem | That's most of it, but if you're doing any AOT or uberjar then stuff can live in target/ |
| 11:12 | zot | that was enough. restarting repls and running lein clean: part of clojure black magic toolkit. |
| 11:12 | ashtonkem | Hence my suggestion to lein clean. |
| 11:12 | zot | thanks! |
| 11:12 | zot | (inc ashtonkem) |
| 11:12 | lazybot | ⇒ 1 |
| 11:12 | ashtonkem | No problemo. |
| 11:13 | ashtonkem | It seems every toolchain has a "Fuck it, I'll just clean the whole thing out and see if that clears it" moment. |
| 11:13 | ashtonkem | I can't count the number of times i've "rake assets:clean tmp:clear" and had my issues go away. |
| 11:13 | arrdem | heh |
| 11:14 | ashtonkem | I call it my "I have a hammer!" moment. |
| 11:14 | zot | lol |
| 11:14 | tcrayford____ | ashtonkem: yeaaaaha hahaha |
| 11:14 | tcrayford____ | fuck a rails assets clean |
| 11:14 | tcrayford____ | my favorite part is working on rails projects with designers |
| 11:15 | ashtonkem | The asset pipeline is my main evidence that the rails designers want to go back to 2008. |
| 11:15 | zot | that's a better hammer than most, if a little bit kludgy. it's a bit sad that dependencies feels like NP-completeness… ethereal, and never to be reached. |
| 11:15 | ashtonkem | Yup. I'm a bit happier with explicit numbers at least. |
| 11:15 | ashtonkem | Ranges have always screwed me. |
| 11:16 | tcrayford____ | ashtonkem: mind if I quote you in an upcoming yeller post about asset pipelines? |
| 11:16 | ashtonkem | Sure thing. |
| 11:16 | tcrayford____ | :D |
| 11:16 | ashtonkem | I'm never quiet about my opinions. |
| 11:17 | ashtonkem | Or afraid to have them attributed to me. |
| 11:17 | tcrayford____ | also I love that twitter's full text index doesn't include me for some reason: https://twitter.com/search?f=realtime&q=from%3At_crayford%20asset%20pipeline |
| 11:17 | tcrayford____ | (I *know* there's a toot there) |
| 11:18 | arrdem | http://i.imgur.com/n0Tu73G.gif someone say hammer? |
| 11:19 | crash_ep | why am I completely unable to find the API doc for core.async |
| 11:19 | arrdem | crash_ep: autodoc seems to have messed up and deleted it. someone else was asking that earlier and the GH page is definitely devoid of content. |
| 11:19 | ashtonkem | They're gone! |
| 11:20 | arrdem | http://conj.io/store/org.clojure/core.async/0.1.346.0-17112a-alpha |
| 11:20 | arrdem | may not be up to date but still alive :p |
| 11:20 | crash_ep | Thankfully there's at least: http://clojuredocs.org/clojure.core.async |
| 11:21 | ashtonkem | In other news, I'm not really sure why my coworkers go nuts over Go. |
| 11:21 | puredanger | http://clojure.github.io/core.async/ |
| 11:22 | ashtonkem | They were talking up a websockets demo in Go that was holding "up to 14k connections" |
| 11:22 | arrdem | puredanger: is that nonblank for you? |
| 11:22 | puredanger | oh, I see what you mean. |
| 11:23 | ashtonkem | Yeah, it's a little emptier than most of us remember. |
| 11:23 | puredanger | I was unaware it was not working. will look at it |
| 11:23 | Bronsa | https://github.com/clojure/core.async/commit/96803979dc1d12bcfa2c7f89e87d00d4ef2154a0 |
| 11:24 | Bronsa | in the meantime http://crossclj.info/doc/org.clojure/core.async/0.1.346.0-17112a-alpha/index.html is up to date and awesome :P |
| 11:27 | puredanger | looks like Tom must have updated his autodoc process or something. certainly doesn't seem to be driven by a commit in the project or anything. |
| 11:30 | puredanger | Tom's on it |
| 11:34 | ashtonkem | Latest Datomic release looks cool. |
| 11:34 | ashtonkem | I'm a bit worried that all these features might muddle the syntax a bit though. |
| 11:35 | ashtonkem | Although all this stuff was super needed. |
| 11:35 | tcrayford____ | ooo |
| 11:36 | ashtonkem | I guess prefix operations make it easy to add syntax after the fact, so that's a good lesson. |
| 11:36 | tcrayford____ | yeaaaahhhhhhh |
| 11:36 | tcrayford____ | "The query engine will make better use of AVET indexes when range predicates are used in the query." |
| 11:36 | tcrayford____ | GOOO TEAM |
| 11:37 | ashtonkem | I look forward to 2 things from Datomic. |
| 11:37 | ashtonkem | 1) Realistic perf. comparison. (I know it's in the EULA, it'd have to come from cognitect). |
| 11:37 | ashtonkem | 2) A Jepsen article on it. |
| 11:37 | tcrayford____ | 3) pagination |
| 11:37 | ashtonkem | I thought pull did that now. |
| 11:38 | tcrayford____ | oh, it can kinda do it, but it's pretty clunky |
| 11:38 | tcrayford____ | afaik |
| 11:38 | ashtonkem | Limit to whatever. |
| 11:38 | ashtonkem | Then grab the last and use that as the minimum for the next page. |
| 11:38 | ashtonkem | It's awkward, but the performance of limit + offset on most databeses is *awful*. |
| 11:39 | ashtonkem | Even on postgres limit + offset is the only way to get good throughput. |
| 11:39 | tcrayford____ | yeah |
| 11:39 | ashtonkem | Although a "paginate on this attribute" would be nice. |
| 11:40 | ashtonkem | It reasonably could be a wrapper. |
| 11:40 | ashtonkem | Because queries compose (hooray!) |
| 11:41 | crash_ep | any core.async gurus? I am having difficulty structuring a pipeline… |
| 11:41 | ashtonkem | In other news, I'm taking my "let's test Ruby in Clojure" thing to the Ruby Rogues podcast. |
| 11:41 | hyPiRion | ashtonkem: Yeah, 1) is a bit of a bummer. Without any perf. comparisons I can't argue to use it for work. |
| 11:42 | ashtonkem | Yeah. |
| 11:42 | ashtonkem | I think the easiest sell would be it after you buy into the Clojure way of doing things. |
| 11:42 | ashtonkem | It's a pretty bad impedence mismatch if you're used to mutability. |
| 11:43 | ashtonkem | But I really want to hear about switch over wins. |
| 11:43 | andyf | Bronsa: Minor question: what was motivation to add \xHH syntax for chars in tools.reader? Is that used in ClojureScript, perhaps? |
| 11:43 | ashtonkem | I think the profession is hungering for more throughput and predictability than RoR + MySQL can give. But it's just so hard to do an apples to apples comparison. |
| 11:43 | hyPiRion | true |
| 11:44 | ashtonkem | And nobody wants to admit their secret sauce. |
| 11:44 | Bronsa | andyf: no, I just added it back when it wasn't yet tools.reader and forgot about it |
| 11:46 | andyf | Just noticed it while looking for differences between t.r and Clojure, and it seemed one of the odder differences. |
| 11:50 | csd_ | Is there any way to create a hash-map whose keys are byte-maps? |
| 11:51 | ashtonkem | Have you tried the hash-map function instead of reader literals? |
| 11:52 | csd_ | ashtonkem: i can create the map OK, but byte-map equality requires using Arrays/equals rather than just = |
| 11:52 | csd_ | so i can't access the map's values |
| 11:52 | ashtonkem | Ah. |
| 11:53 | andyf | csd_: Standard precautionary note: be careful not to mutate keys in a map, or elements of a set, or you won't be able to access them |
| 11:53 | ashtonkem | Then the answer is probably no then. |
| 11:53 | ashtonkem | You'd have to wrap them in something that works well with = |
| 11:53 | csd_ | andyf: good to know thanks |
| 11:54 | csd_ | i'll just store as a vector |
| 11:55 | andyf | csd_: Clojure has immutable byte vectors, created by vector-of |
| 11:55 | andyf | Vector-of can save memory vs using regular vectors, if you have many of them |
| 11:56 | csd_ | oh thats neat |
| 11:56 | csd_ | i don't think ill need that but good to know |
| 12:07 | shinty-six-4 | Anyone have an updated link to David Nolen's article from http://dosync.posterous.com/lispers-know-the-value-of-everything-and-the ? |
| 12:09 | shinty-six-4 | I'm new to clojure and looking for direction on concepts for processing large amounts of data, (eg making a fast prime sieve, Having failed with use of sorted-map for incremental). |
| 12:11 | ashtonkem | How large is large? |
| 12:12 | dagda1_ | anybody know how I update my cider emacs package? |
| 12:12 | ashtonkem | Ooh, you using emacs-live? |
| 12:12 | ashtonkem | I've had this issue. |
| 12:13 | ashtonkem | dagda1_: For in memory stuff transducers are the common answer. They're compact and make fork/join easy. |
| 12:14 | ashtonkem | If it doesn't fit in memory, typically you'll have to reach for mapreduce (and a wrapper like cascalog), storm, or similar. |
| 12:14 | ashtonkem | Plus make sure that you aren't using boxed math. That really eats up the throughput. |
| 12:17 | shinty-six-4 | ashtonkem: let's say, primes below 1 million. So for an incremental sieve, I think there would be 1 million candidates. I was trying to do something like the incremental sieve referenced http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf, using sorted-map to maintain upcoming composites. |
| 12:18 | shinty-six-4 | ashtonkem: thank you for the direction. I would not have gone first to transducers as I knew they were relatively new. I'll read up on them. |
| 12:18 | ashtonkem | Sorted map as in a sorted hashmaps? |
| 12:18 | ashtonkem | Those'll get pretty expensive without mutability. |
| 12:19 | ashtonkem | I think you'll want to think of it as a lazy stream of primes. |
| 12:19 | ashtonkem | With a memoized helper. |
| 12:19 | ashtonkem | As a general rule transducers are more compact that regular map and filter. |
| 12:19 | ashtonkem | Because they produce no intermediate collections. |
| 12:19 | TimMc | shinty-six-4: http://web.archive.org/web/20130511051357/http://dosync.posterous.com/lispers-know-the-value-of-everything-and-the and go donate to archive.org :-P |
| 12:19 | ashtonkem | Hence why they fork/join well. |
| 12:21 | chouser | Clojure's sorted-map is a red/black tree, not a hashmap, fwiw. |
| 12:21 | shinty-six-4 | ashtonkem: ah. As someone new to fp in general, I know mutability is a watchword, so still working out when to embrace it. Thanks for the tips. |
| 12:21 | chouser | So, binary tree instead of 32-way trie. |
| 12:22 | ashtonkem | In general mutability is a mixed bag. |
| 12:22 | shinty-six-4 | TimMc: thanks. And chouser: thanks. I was seeing 'PersistentTreeMap' in stack traces. |
| 12:22 | ashtonkem | It'll always be faster and more compact in a flat line. |
| 12:22 | ashtonkem | But it's less safe, and eliminates interesting optimizations available without it. |
| 12:22 | ashtonkem | Generally speaking mutability is fine inside one function. |
| 12:23 | ashtonkem | If it accepts and returns immuteable objects and uses some muteability inside to make things faster, who cares? |
| 12:23 | ashtonkem | It's when you start passing mutable objects around that the pain starts. |
| 12:24 | chouser | right. Or closing over them, or storing them in refs, etc. |
| 12:24 | shinty-six-4 | good points. very helpful. |
| 12:24 | ashtonkem | So you'll see them used locally in core.async IIRC. |
| 12:25 | ashtonkem | Because some algorithms are painful without it, and if accessibility is limited atoms are too slow. |
| 12:30 | thorwil | hi! it has been a while since i last worked with clojure. where does leiningen put dependencies? if nothing shows up below "classes", is that an issue with my setup? |
| 12:31 | ashtonkem | The m2 directory is where it drops its jars. |
| 12:31 | ashtonkem | Just like maven. |
| 12:31 | andyf | $HOME/.m2 in case Maven is not familiar to you |
| 12:31 | thorwil | ty. so i see everything expected is right there |
| 12:32 | patrkris | hi folks. is there a protocol I can implement, such that I can use my own type as the dp-spec parameter for clojure.java.jdbc/query and friends? |
| 12:32 | ashtonkem | Yeah. In general it'll start littering the classes dir when you start AOTing things. |
| 12:32 | ashtonkem | But that's more of a prod time concern. |
| 12:32 | ashtonkem | If it's working ATM I wouldn't worry. |
| 12:32 | thorwil | not quite working ... |
| 12:33 | ashtonkem | Well, what's the issue then? |
| 12:33 | thorwil | i'm trying to play with quil. i get a compiler exception when defsketch comes up |
| 12:34 | thorwil | with either the example on he quil github, or the one in the template |
| 12:34 | ashtonkem | Put the trace in a pastebin? |
| 12:37 | thorwil | hmm, interesting behavior of that buffer |
| 12:37 | thorwil | https://www.refheap.com/96061 |
| 12:41 | dysfun | how will stm transactions behave around a clojure.core.cache? |
| 12:41 | ashtonkem | Huh, I really can't figure out what's going on there thorwil. |
| 12:42 | ashtonkem | Perhaps I'd recommend opening a bug on the quil github project? |
| 12:43 | thorwil | ashtonkem: thanks for having a look. sure, i will open a bug ... if a bit further investigation doesn't help |
| 12:50 | clgv | dysfun: as usual |
| 12:53 | clgv | dysfun: the caches in core.cache are persistent datastructures |
| 13:40 | instilled | hi. how can i extract the metadata of a function that was passed as a parameter to another function? |
| 13:41 | mi6x3m-alt | instilled: (meta myfn) |
| 13:43 | instilled | can i access the var of that function as well (still within the other function)? |
| 13:44 | mi6x3m-alt | instilled: why not just pass the var? |
| 13:44 | mi6x3m-alt | #'myfn |
| 13:45 | instilled | mi6x3m-alt: that works of course. i just wanted to know if there was another way. …i think i'll then go with passing the var as parameter. |
| 13:45 | instilled | mi6x3m-alt: thanks. |
| 13:46 | mi6x3m-alt | instilled: well if you need the var it makes no sense to go through a function and then back |
| 13:46 | mi6x3m-alt | :) |
| 13:46 | instilled | mi6x3m-alt: absolutely. |
| 13:49 | lodin | instilled: I'm curious. Why do you need the var? |
| 13:56 | instilled | lodin: i'm working with prismatic schema, defnk and the like. validating the input-schema is automatic but i would also like to validate outputs and i've passed these as metadata to defnk (placed on the var, not the fn unfortunately) |
| 14:25 | cespare | has anyone made a ticker for core.async? |
| 14:25 | cespare | implementing it without timeout is fairly error-prone |
| 14:35 | noonian | cespare: whats wrong with using timeout? |
| 14:38 | zanes | I have two transducer pipelines I want to run in parallel, joining the results at the end. What’s the idiomatic way to do that? Does that even make sense? |
| 14:43 | arrdem | that makes sense, but note that "in parallel" is abstract. As of right now, transducers are singly threaded. |
| 14:45 | amalloy | arrdem: aren't transducers divorced from considerations like that? a transducer is a method for transforming some input; where that input comes from, how it gets where it's going, how many threads are used, isn't that all handled outside the transducer itself? |
| 14:46 | arrdem | zanes: so looking at Clojure's map transducer I don't see a way to do that, I was thinking of Haskell arrows which transducers approximate. |
| 14:47 | arrdem | amalloy: maybe. I'm confusing myself the more I think about this. |
| 14:54 | dnolen | arrdem: a transducer pipeline is a function, you can use them today with parallel folds |
| 14:54 | cespare | noonian: as I said, it's error-prone |
| 14:54 | cespare | noonian: I thought about how to make a ticker with timeout in my program, and it took me a while to write the code, and I still had a bug |
| 14:55 | cespare | whatevs, I'll write my own ticker |
| 14:55 | noonian | ah, I thought you meant without using timeout it is error prone |
| 14:55 | dnolen | zanes: that doesn't seem weird to me so far |
| 14:55 | arrdem | dnolen: sure, but how does that interact with stateful transducers like partition? that's what I'm not persuading myself of. |
| 14:55 | cespare | noonian: oops, I meant implementing it *with* timeout |
| 14:55 | dnolen | arrdem: don't use stateful transducers in your pipeline - this is not a real problem |
| 14:57 | zanes | The way I’m doing it right now is by having two transducer’d channels, one for each pipeline. One goroutine feeds both of the channels from the source, and another joins them at the end. |
| 14:57 | zanes | Does that seem like the right way to approach the problem? |
| 15:01 | justin_smith | cespare: OK, timeout + a pub channel, send a "tick" message after each timeout, then loop |
| 15:01 | justin_smith | cespare: or am I missing something here? |
| 15:06 | cespare | justin_smith: nope, that's pretty much it. Unless you care about not skewing, but I don't |
| 15:07 | cespare | justin_smith: just have to do a non-blocking send to avoid getting slowed up by a slow/nonexistent receiver |
| 15:08 | justin_smith | cespare: well for skewing you would just calculate the timeout based on an absolute time, rather than an absolute timeout |
| 15:23 | dnolen | zanes: not sure about one go routine feeding both channels depending on the size of the work |
| 15:24 | dnolen | zanes: perhaps examining how clojure.core.async/pipeline works for some ideas |
| 15:24 | dnolen | s/perhaps/perhaps worth |
| 15:24 | zanes | Will do. Thanks! |
| 15:27 | [blake| | So, I've noticed that my compojure app, when it starts running, immediately goes to the 404 path. Which was weird, but whatever. |
| 15:27 | [blake| | Now I've noticed that it does the same thing when I "lein ring uberwar" which is...problematic. |
| 15:28 | [blake| | What's going on here? Have I done something to make the 404 happen, or is that just a Compojure thing? |
| 15:28 | [blake| | And why does uberwar cause code to be executed? |
| 15:28 | weavejes_ | [blake|: You've done something to make it happen |
| 15:28 | [blake| | weavejes_: Well, that's good news. |
| 15:28 | weavejes_ | [blake|: And compiling Clojure code means evaluating the namespace |
| 15:29 | weavejes_ | I don't know what you mean by "cause code to be executed", though |
| 15:29 | weavejes_ | Or "immediately goes to the 404 path" |
| 15:29 | weavejes_ | Are you talking about the browser? |
| 15:29 | weavejes_ | Or the root path? |
| 15:30 | [blake| | weavejes_: No. My defroutes has a 404 path... (route/not-found...)...and that code is executed when the namespace is evaluated. |
| 15:30 | weavejes_ | [blake|: Well, route/not-found is just a function |
| 15:30 | weavejes_ | If you evaluate a function in Clojure, it's arguments are also evaluated. |
| 15:31 | [blake| | Could it be a side-effect of using (def app (-> (handler/site app-routes))"? |
| 15:31 | [blake| | Right, I'm just trying to figure out WHY it's being called. |
| 15:31 | weavejes_ | It's just because it's a function. If you make a function call at the root level, it's going to execute when the namespace compiles. |
| 15:32 | justin_smith | [blake|: you could add (print (clojure.string/join "\n" (.getStackTrace (Thread/currentThread)))) to the 404 handler and see what is calling it |
| 15:32 | weavejes_ | e.g. (def foo (println "bar")) will print "bar" whenever the namespace is loaded |
| 15:32 | amalloy | [blake|: my first question is, what makes you think the 404 handler is being executed? how do you even know? all it would do most of the time is return something |
| 15:33 | [blake| | justin_smith: Let me try that. |
| 15:33 | [blake| | weavejes_: My defs are all just that app and two empty {} atoms. |
| 15:34 | weavejes_ | justin_smith: It sounds as if [blake| has something like (route/not-found (side-effectful-code)) |
| 15:34 | weavejes_ | [blake|: Is that about right? |
| 15:34 | [blake| | amalloy: Because I noticed it happening earlier. |
| 15:35 | [blake| | weavejes_: Yeah, the app shows a bootstrap navigation bar at the top regardless, so that's called everywhere. |
| 15:35 | weavejes_ | [blake|: Wait... let's back up here. What exactly is happening? |
| 15:36 | [blake| | My app is hitting the database when it's being uberwar'ed. Well, it's trying to. |
| 15:36 | weavejes_ | [blake|: Okay, so you're detecting a side effect |
| 15:37 | weavejes_ | [blake|: And you have something like: (route/not-found (something-that-accesses-the-database)) ? |
| 15:37 | [blake| | Well, stacktrace is not as enlightening as I'd hoped... |
| 15:37 | [blake| | weavejes_: Yeah. The navigation bar looks to the database to populate certain things. |
| 15:37 | weavejes_ | [blake|: Well, that's because route/not-found is a function |
| 15:38 | weavejes_ | It's not a macro |
| 15:38 | crash_ep | Is there a canonical way to detect whether something is a transducer? I'd like to convert a multi-arity function to accept an optional transducer as its first parameter. |
| 15:38 | arohner | crash_ep: not reliably. |
| 15:39 | arohner | crash_ep: transducers are fns, but there's not a good way to determine whether an argument fn is a transducer |
| 15:39 | weavejes_ | [blake|: You're not delaying the (something-that-accesses-the-database). You're telling Clojure to evaluate when the namespace is compiled. |
| 15:39 | crash_ep | Hm, that will probably have to suffice. Thanks arohner |
| 15:39 | [blake| | weavejes_: Not deliberately. =P |
| 15:40 | weavejes_ | [blake|: If you don't want something to execute immediately, put it in a function |
| 15:40 | weavejes_ | [blake|: So (println "foo") would print immediately if evaluated |
| 15:40 | [blake| | weavejes_: Sure. |
| 15:40 | weavejes_ | [blake|: And (defn foo (println "foo")) wouldn't |
| 15:40 | weavejes_ | route/not-found is just a function |
| 15:40 | [blake| | weavejes_: Right. |
| 15:40 | weavejes_ | It doesn't delay evaluating its arguments |
| 15:41 | weavejes_ | It supports static values, or another handler function |
| 15:41 | weavejes_ | So you could write: (route/not-found (fn [_] (access-the-database)) |
| 15:42 | [blake| | weavejes_: OK! So, it's not like an immediate function, it's actually just arguments? |
| 15:42 | weavejes_ | If you don't have (access-the-database) inside a function definition, Clojure will run it when it loads the namespace |
| 15:42 | weavejes_ | [blake|: Right. It's just a function that takes arguments. Not a macro or any special form. |
| 15:45 | [blake| | weavejes_: OK, thanks. That explains it. I was looking at it as being like the difference between calling a function and putting an immediate function in there, e.g. "map a-fn a-coll" versus "map #(inc %) a-coll". |
| 15:45 | [blake| | (i.e., no difference) |
| 15:45 | [blake| | (inc weavejes_) |
| 15:45 | weavejes_ | [blake|: If you wrap it in parentheses, Clojure will evaluate it if it's not in a macro. |
| 15:45 | lazybot | ⇒ 1 |
| 15:45 | weavejes_ | Clojure has a pretty simple evaluation model :) |
| 15:46 | [blake| | heh |
| 15:46 | weavejes_ | Function arguments are evaluated. Macro return values are evaluated. |
| 15:46 | [blake| | Yeah. It's my fault for not "getting" Compojure. I've been treating defroutes as black magic. |
| 15:46 | weavejes_ | Everything evaluates to itself except symbols and lists |
| 15:46 | weavejes_ | [blake|: defroutes is just (def ... (routes ...)) |
| 15:47 | weavejes_ | [blake|: Like how defn is just (def ... (fn ...)) |
| 15:47 | [blake| | weavejes_: Too simple. =P |
| 15:47 | weavejes_ | [blake|: routes is just a function that takes many routing functions and combines them into one |
| 15:48 | [blake| | weavejes_: OK, well, I get that now. Sort of. More than I did. |
| 15:48 | weavejes_ | [blake|: Literally just: (defn routes [& handlers] (fn [request] (some (fn [h] (h request)) handlers))) |
| 15:49 | weavejes_ | [blake|: Basically a route is just a function that takes a request and returns a response or nil if it doesn't match |
| 15:49 | weavejes_ | [blake|: "routes" tries out each routing function in order until it finds a non-nil value |
| 15:49 | weavejes_ | That's basically it. |
| 15:52 | [blake| | weavejes_: In most cases, I'm just returning text to display. |
| 15:52 | [blake| | weavejes_: But obviously there's some session stuff in there, too, right? |
| 15:52 | weavejes_ | [blake|: In Compojure? Nope. That's Ring. |
| 15:52 | weavejes_ | [blake|: Compojure just handles routing |
| 15:53 | weavejes_ | [blake|: What to execute if you get a certain request. |
| 15:54 | [blake| | weavejes_: Fair 'nuff. I'm still unclear on what's being passed around to whom. But now that I have some more real world experience I'm going back to the docs to (hopefully) fill in the gaps. |
| 16:00 | justin_smith | [blake|: I think what that stack trace should have shown is that the function was being called when the definition was being compiled (for the reasons weavejes_ explains) |
| 16:01 | mi6x3m-alt | if a library you are developing depends on another library |
| 16:01 | mi6x3m-alt | would you specify it only as a dev dependency? |
| 16:01 | [blake| | justin_smith: It probably did. I was looking for some indirect reference in my code, but it was just a pile of "Invokes". |
| 16:05 | justin_smith | mi6x3m-alt: does it depend on the lib at dev time or run time? |
| 16:05 | justin_smith | if at run time, make it a regular dep |
| 16:05 | mi6x3m-alt | justin_smith: roger |
| 16:05 | mi6x3m-alt | mostly runtime here |
| 16:06 | justin_smith | if your code misbehaves because of a lib you use but don't specify a runtime dep for, people will be annoyed (for good reason) |
| 16:08 | TimMc | mi6x3m-alt: dev-dependencies are strictly for deps that are used for generating documentation, running tests, etc. |
| 16:08 | dagda1_ | anybody know how I can get rid of this warning from the emacs package cider https://www.refheap.com/96068 |
| 16:09 | TimMc | mi6x3m-alt: If you don't specify :dependencies for things that are used at runtime your code will break and people will be mad. |
| 16:09 | mi6x3m-alt | indeed |
| 16:15 | mavbozo | dagda1_: use cider-nrepl 0.9.0-snapshot |
| 16:15 | mavbozo | dagda1_: the instruction is here https://github.com/clojure-emacs/cider-nrepl |
| 16:15 | dagda1_ | mavbozo: yes but it advises 0.8.2 |
| 16:16 | mavbozo | dagda1_: there's a quote "if you're using CIDER 0.x.y-SNAPSHOT, you should be using cider-nrepl 0.x.y-SNAPSHOT, etc" |
| 16:16 | dagda1_ | mavbozo: works for me! |
| 16:17 | mavbozo | dagda1_: so, what cider version what works for you? 0.8.2 or 0.9.0-SNAPSHOT ? |
| 16:17 | dagda1_ | mavbozo: I mean the the quote works for me |
| 16:18 | mavbozo | dagda1_: great! |
| 16:35 | koreth_ | I am trying to understand how Piggieback works. Does anyone here know how its dynamic vars like *cljs-repl-options* are used? The (set!) calls on them appear to work, but they are never named in a (bindings) that I can see. I thought any var declared ^:dynamic was required to be bound before it could be set; is my understanding wrong? |
| 16:35 | koreth_ | Err, never named in a (binding), that is. |
| 16:37 | chouser | Ugh. Class file name is too long. Single largest contributor is "state_machine__1177__auto____22923". That's core.async, right? |
| 16:38 | puredanger | yeah |
| 16:38 | puredanger | that doesn't look very long though |
| 16:39 | amalloy_ | chouser: state_machine__1177__auto____22923 isn't even that long. what's the whole classname? |
| 16:40 | hiredman | $fn$fn$fn$fn |
| 16:40 | hiredman | so fun |
| 16:41 | puredanger | chouser: any chance you're using 1.7.0-alpha3? class name length regressed there, was fixed in alpha4. |
| 16:47 | chouser | no, that's nested inside a couple anonymous fns which are nested inside a couple named fns, and then there's another anonymous function on the inside... |
| 16:49 | cespare | hmm. Why is the :default expr always evaluated inside an alt! ? |
| 16:55 | cespare | puredanger: well, I would say that it's a bug, except that the documentation doesn't even say whether the exprs are supposed to be evaluated |
| 16:55 | chouser | oh actually, googling around a bit it looks like some languages without macros have this same problem. *ahem*scala*ahem* |
| 16:55 | cespare | puredanger: the non-default exprs that aren't chosen aren't evaluated though |
| 16:55 | puredanger | those seem like reasonable questions that should have definitive answers |
| 16:57 | amalloy_ | man, the netsplits today. must be some bad weather on the information highway |
| 16:57 | turbofail | it was planned. an inside job, if you will |
| 16:57 | justin_smith | amalloy_: there was a wall about it |
| 16:57 | amalloy_ | weather planning? |
| 16:58 | justin_smith | or global notice, or whatever they call it |
| 16:58 | turbofail | -mquin- [Global Notice] We are about to start rehubbing the network ahead of planned maintenance work. This will cause some netsplits, but should ... |
| 16:58 | cespare | okay, so now i'm on jira. I'm supposed to make an account on a non-HTTPS website? |
| 16:58 | cespare | and, more offensively, use jira? |
| 16:58 | puredanger | sigh |
| 16:58 | puredanger | yes |
| 16:59 | amalloy | wow, and it actually doesn't switch to https for account creation. i had guessed that something as enterprisey as jira would do that |
| 17:00 | puredanger | it does on newer versions, this one is ancient |
| 17:00 | puredanger | it doesn't actually support https |
| 17:00 | amalloy | brb changing my jira password before someone sniffs it |
| 17:00 | puredanger | if someone steals your jira auth, I'll refund your money |
| 17:01 | arrdem | amalloy: NSA's got you already |
| 17:01 | cespare | only took 3 tries to get through the captcha |
| 17:01 | amalloy | puredanger: well uh...password reuse. not gonna lie |
| 17:01 | cespare | you're a bad bad man |
| 17:01 | puredanger | for the record, I am acutely aware of the myriad ways in which this particular JIRA version sucks |
| 17:02 | amalloy | i made my jira account before i started caring at all about password hygeine |
| 17:02 | chouser | ah, apparently ubuntu encrypted home directory has a somewhat low limit on filename length. mount -o bind to the rescue |
| 17:02 | puredanger | as a finite resource, you can choose between having new Clojure versions or having new JIRA versions |
| 17:03 | pmonks | brb coding a replacement for JIRA in 200 lines of Clojure |
| 17:04 | arrdem | (inc pmonks) |
| 17:04 | lazybot | ⇒ 1 |
| 17:05 | puredanger | can I inc contingent on delivery? |
| 17:05 | justin_smith | (delay (inc pmonks)) |
| 17:05 | arrdem | unfortunately lazybot does not support contract based incs... however I suppose Etherium integration is possible... |
| 17:06 | llasram | puredanger: Is that strictly true? Aren't there people Cognitect could pay to upgrade Jira who you wouldn't necessarily want to work on Clojure? |
| 17:07 | puredanger | yes and no |
| 17:08 | puredanger | yes there are people to pay to upgrade jira, but also someone needs to responsible for the overall effort and the greater decisions around where to even host it in the first place. everything is complected. |
| 17:13 | [blake| | OK...I have my nifty clojure program that has all this cool immutability. So cool it allows me to "undo" really easily. Then the user saves his work and quits the app. When he comes back, all that cool undo stuff is gone. |
| 17:15 | justin_smith | [blake|: the solution is to explicitly save and store (some amount of) the history |
| 17:15 | [blake| | justin_smith: Doesn't seem so "free" any more. =P |
| 17:15 | justin_smith | [blake|: once it's loaded, things are exactly like before |
| 17:16 | justin_smith | the only difference is the save/load |
| 17:16 | justin_smith | which should be identical to how you save / restore anything else |
| 17:16 | [blake| | Maybe I need to look at an example. |
| 17:17 | arrdem | &(empty? {1 2}) |
| 17:17 | lazybot | ⇒ false |
| 17:18 | amalloy | [blake|: okay, so in order to get undo really easily, you must have a pointer to old versions of an object, right? |
| 17:18 | cfleming | I have a question about line numbers in generated classes - are these generated from the :line and :column metadata in the read forms? |
| 17:18 | amalloy | cfleming: yes |
| 17:18 | cfleming | amalloy: So can I override those if I'm using nREPL? |
| 17:18 | [blake| | amalloy: Right. |
| 17:18 | amalloy | uhhhh, i don't understand the question anymore, cfleming |
| 17:18 | cfleming | amalloy: And relatedly, can I set the source file name if using nREPL? |
| 17:19 | [blake| | amalloy: Or, you're in a loop and you pop out of one level back to the previous? |
| 17:19 | amalloy | [blake|: so, when you want to save stuff, you save the current pointer by printing it (say), and you save any number of previous pointers in the same way |
| 17:20 | cfleming | amalloy: Here's the problem - I'm working on the debugging support in Cursive. Once a form has been evaluated in the REPL, the debugger no longer works for it since the source file is now form-xxxxxx.clj and the line and column numbers are now relative to the start of the form, and not to the start of the file |
| 17:20 | cfleming | amalloy: This makes sense for forms directly entered in the REPL, but when I'm sending forms from my editor I'd like to be able to set the source/line/column information correctly |
| 17:21 | amalloy | cfleming: i am far from an nrepl expert. i really have no idea what your options are there, i'm afraid |
| 17:21 | cfleming | amalloy: Thanks |
| 17:21 | cespare | puredanger: s |
| 17:22 | cespare | puredanger: http://dev.clojure.org/jira/browse/ASYNC-113 |
| 17:22 | [blake| | amalloy: OK, so let's say I have a sokoban game with a set containing locations, and each move creates a new map, a new set... |
| 17:23 | [blake| | Dumping the map I'm in is easy. I can unroll back level by level saving each set until I'm at the starting point. |
| 17:23 | cfleming | amalloy: Do you know where the form-xxxx.clj name comes from? I can't find it in clojure.main/repl, and LineNumberingPushbackReader doesn't add it either |
| 17:23 | [blake| | But if I did that, I'd end up with something different. |
| 17:23 | justin_smith | [blake|: to recover history, I would replay all the steps - that ensures that you get the same structural sharing you started out with |
| 17:24 | justin_smith | it's not like the state transitions should be anything expensive |
| 17:24 | [blake| | justin_smith: Yeah, so I save the initial map and then all the operations that created the new map. |
| 17:24 | amalloy | cfleming: from nrepl or lein, i think |
| 17:24 | justin_smith | right |
| 17:24 | [blake| | Interesting. |
| 17:24 | puredanger | cespare: thx |
| 17:24 | [blake| | Would I be saving the actual clojure code? Like, with assoc and conj and what-not? |
| 17:25 | justin_smith | [blake|: either that, or define your game update so it can be run forward or backward, and only load the undo as needed |
| 17:25 | [blake| | justin_smith: Yeah, seems like you'd want fluidity both ways. Hmmm. Prince of Persia, anyone? |
| 17:25 | justin_smith | [blake|: I would store edn that describes the move (and have the game code sturctured to be driven by the edn) |
| 17:25 | amalloy | cfleming: eg, leiningen.core.eval contains (File/createTempFile "form-init" ".clj") |
| 17:26 | amalloy | i dunno if those are the same files as the ones you're seeing; maybe nrepl does something similar |
| 17:26 | justin_smith | and if designed right, you could have an "apply" and an "unapply" to move either direction across a series of moves |
| 17:26 | [blake| | justin_smith: OK, cool. I'll look into that. |
| 17:26 | [blake| | Thanks! |
| 17:27 | cfleming | amalloy: I can't find anything in the nREPL source |
| 17:28 | justin_smith | [blake|: one thing to watch out for though is that some things which are illegal for a player to do may have been implicitly so (because there was no code that could do that) and may need to change to explicitly enforced rules |
| 17:28 | cfleming | amalloy: but that code appears to be what Leiningen uses for executing forms, not REPL evaluation |
| 17:28 | justin_smith | since you are adding new powers to the game engine if doing it this way |
| 17:28 | kaiyin | https://gist.github.com/kindlychung/a65bdf1cb4b0ef598d64 What went wrong with this implementation of reduce? |
| 17:29 | justin_smith | kaiyin: what are "correct" and "current" - is one of them a typo? |
| 17:29 | [blake| | justin_smith: Not sure I follow. |
| 17:29 | justin_smith | also, hanging braces are very wrong :) |
| 17:30 | justin_smith | kaiyin: oh, currect even :) clearly that should have been current |
| 17:30 | kaiyin | justin_smith, cool. got it. |
| 17:31 | justin_smith | kaiyin: also, the destructuring can happen in the loop binding |
| 17:31 | amalloy | cfleming: do you think repl evaluation is different from executing forms? i mean, it might be, but i wouldn't start from that assumption |
| 17:31 | cfleming | amalloy: That appears to be the code used by lein to set up the trampoline. I just used no.disassemble to check - all forms from a single REPL appear to use the same file, which I guess is the file used to actually start the REPL |
| 17:31 | justin_smith | kaiyin: then you don't need a let block |
| 17:32 | cfleming | amalloy: Once nREPL is up and running, lein really doesn't have anything to do with it any more |
| 17:32 | cfleming | amalloy: It's just used in the initialisation of nREPL, not in each eval |
| 17:32 | justin_smith | kaiyin: (loop [result initial [current & rest] remaining] ...) |
| 17:33 | kaiyin | justin_smith, nice. |
| 17:33 | joobus | does anyone use clojure for scripting? I made an alias to java -cp clojure-*.jar clojure.main $arg1, and have been trying to write quick scripts a la python. I've found if I can't use clojure for many things, I won't learn it. |
| 17:33 | justin_smith | kaiyin: add a check for 'reduced?' for completeness perhaps as well |
| 17:33 | kaiyin | Anyone knows how to strip an outer pair of parentheses in Cursive? |
| 17:34 | kaiyin | justin_smith, what is that for? |
| 17:34 | amalloy | bleh, i wouldn't bother with reduced. it's an odd quirk of clojure's reduce impl, not terribly useful for learning how to fold |
| 17:34 | cfleming | kaiyin: Edit->Structural Editing->Splice sexp |
| 17:35 | kaiyin | cool. |
| 17:37 | justin_smith | amalloy: fair enough |
| 17:38 | cfleming | amalloy: nREPL load-file uses clojure.lang.Compiler/load, which allows you to set the source file etc - interruptible-eval doesn't. I guess I'm going to have to create a file for each form load which places the form at the right position in an otherwise empty file for this to work. |
| 17:38 | kaiyin | I just accidentally deleted a parenthesis and can't find out where to add it ... |
| 17:39 | [blake| | kaiyin: lol...been there...guessing you're not using paredit? |
| 17:39 | cfleming | kaiyin: You can temporarily turn off structural editing in the status bar at the bottom of the editor window |
| 17:39 | cfleming | kaiyin: Where it says Structural: on |
| 17:39 | kaiyin | I am using cursive with intellij, [blake| |
| 17:39 | cfleming | kaiyin: You can turn that off if things get unbalanced and you just want to fix them up. |
| 17:40 | kaiyin | cfleming, ok, I will do that. |
| 17:40 | [blake| | kaiyin: Me, too. I turn off the structural editing, which makes it easy to delete a paren without its twin. |
| 17:41 | [blake| | This, I presume, is why the pros use it and have mastered all the slurping/spitting/disgusting bodily functions needed. |
| 17:41 | cfleming | kaiyin [blake|: I usually just use cut/paste, but both work |
| 17:42 | cfleming | kaiyin [blake|: It's surprising how little you need to do it once you get the hang of paredit though |
| 17:42 | joobus | also *rant*: I experimented with scheme last weekend, and at the end of the day I can't figure out why anyone uses it. There about a million different flavors, almost nothing is interoperable, and there is very little community, support, or documentation. The reason I looked at it was for functional programming outside of the jvm |
| 17:43 | [blake| | cfleming: Yeah. I =will= get the hang of it. You've got the "normal" keybindings around somewhere now, right? (Just in case I have to use Emacs at some point.) |
| 17:44 | cfleming | [blake|: Yeah, you can set up some emacs-ish keybindings under Settings->Clojure->Keybindings |
| 17:44 | kaiyin | Finally fixed it. :-) |
| 17:44 | justin_smith | joobus: for fp outside the jvm I would have gone with OCaml, Haskell, or F# |
| 17:45 | cfleming | [blake|: It's a fairly confusing UI though, check the doc here https://cursiveclojure.com/userguide/keybindings.html and also https://github.com/cursiveclojure/cursive/issues/552#issuecomment-60475268 for some info that hasn't made it into the doc yet |
| 17:46 | cfleming | [blake|: I'm hoping to make an interactive paredit tutorial at some point, sort of like a touch typing tutor |
| 17:46 | [blake| | cfleming: Thanks. So far I'm enjoying just making my own simple things like "Alt+L" to load and "Alt+T" to test. =P |
| 17:46 | [blake| | cfleming: Oh, that would be cool. |
| 17:47 | justin_smith | [blake|: as a long time emacs user, there is nothing "normal" about emacs keybindings |
| 17:48 | amalloy | cfleming: as an avid paredit user, i have to say be careful: an interactive tutorial might make you a god among men |
| 17:48 | cfleming | justin_smith: I didn't want to say anything, but... |
| 17:49 | joobus | justin_smith: thanks, i'll check out ocaml. I've played with haskell briefly, and as far as I know F# is mainly a windows thing, but I don't run windows. I know there was some cross compatibility work similar to mono for F#. |
| 17:49 | cfleming | amalloy: I shall rule my subjects fairly, as long as they obey my every whim |
| 17:49 | cfleming | amalloy: Otherwise it'll be the vengeful wrathful god |
| 17:50 | justin_smith | joobus: f# works anywhere via mono, but if you don't use windows OCaml will likely be more rewarding, yeah |
| 17:50 | [blake| | justin_smith: Heh. Yeah. Poor word choice. "Standard"? =P |
| 17:50 | amalloy | "intuitive", obviously |
| 17:50 | justin_smith | lol |
| 17:51 | amalloy | there's nothing more intuitive than playing your keyboard like a piano |
| 17:51 | cfleming | justin_smith: I guess with .net being open source and cross platform, that's not such an issue. The good dev tools will only be on windows, though |
| 17:51 | [blake| | amalloy: "Intuitively obvious to even the most casual observer." |
| 17:51 | justin_smith | right - but I don't know if .net really has good cross platform support yet |
| 17:51 | cfleming | "intuitive" once you've had your brain reconfigured by 10 years of Emacs use |
| 17:52 | cfleming | justin_smith: I'm not sure either, but MS seem to be taking it seriously and they have a lot of resource to make it happen |
| 17:52 | justin_smith | cfleming: decade of emacs use, still not intuitive, just memorized |
| 17:52 | joobus | lol, just went here http://www.tryfsharp.org/Learn/getting-started "Silverlight is required...". This is going well... |
| 17:52 | justin_smith | cfleming: well that's cool |
| 17:52 | [blake| | "The Little Schemer" seems like an easy intro to FP. It's got that going for it. |
| 17:52 | amalloy | [blake|: i remember one of my math professors allowing IOTTCO as a step in proofs |
| 17:52 | Frozenlock | cfleming: is there anything intuitive in computers? |
| 17:52 | [blake| | amalloy: Ha! Yeah. I heard that first from my dad, who got it from his math teacher. |
| 17:52 | Frozenlock | Office's ribbon? :-p |
| 17:53 | justin_smith | they keyboard is pretty damned intuitive - hit the key with an "a" on it to send "a" |
| 17:53 | justin_smith | it all goes downhill from there |
| 17:53 | [blake| | a |
| 17:53 | [blake| | justin_smith: No good. It says "A" but it makes an "a". |
| 17:53 | iwilcox | Took a while to get there. The ZX Spectrum was in keyword mode by default.. |
| 17:53 | joobus | justin_smith: but it will be easier to play some of the 10 key Chopin or Debussy chords. :D |
| 17:53 | turbofail | yeah, as soon as you try and type a b you find out some joker has changed it to dvorak |
| 17:55 | Atarian | Does anyone know why the read-line in this function appears to run before everything else in the function? |
| 17:56 | Atarian | (defn display-menu |
| 17:56 | Atarian | [menu-list] |
| 17:56 | Atarian | (dotimes [i (count class-list)] |
| 17:56 | Atarian | (printf "%d: %s\n" (+ i 1) (nth class-list i))) |
| 17:56 | Atarian | (printf "Please make a selection: ") |
| 17:56 | Atarian | (read-line)) ; Why does this run before the printf?! |
| 17:56 | iwilcox | Maybe you need a (flush) |
| 17:56 | amalloy | Atarian: also pls refheap.com or gist.github.com or something |
| 17:56 | Atarian | Cheers iwilcox, where would I put the (flush), just before the (read-line) |
| 17:57 | Atarian | amalloy: What are they, pastebin type things? Sorry |
| 17:57 | amalloy | yes |
| 17:57 | [blake| | cfleming: That bulk setting is very useful, whatever nays the naysayers say. |
| 17:58 | justin_smith | yeah, (flush) would go just after the last printf |
| 17:58 | cfleming | [blake|: Oh, it's definitely useful, it's just a confusing UI |
| 17:58 | Atarian | amalloy: Will do in future, sorry for the fubar |
| 17:59 | Atarian | (thanks chaps, that worked perfectly) <- I can't believe I put that in brackets, that's enough lisp for tonight lol |
| 18:00 | andyf | Atarian: printf is running before the read-line, but printing is buffered by default so data is in some non-displayed mem buffer until it is flushed, either manually, reaching the bug size, or calling a fn like println that calls flush for you |
| 18:00 | andyf | S/bug/buf/ |
| 18:01 | Atarian | IC, thanks for the explanation, I was just wondering that |
| 18:02 | mavbozo | Atarian: there is a note about that in clojure docs https://clojuredocs.org/clojure.core/printf#example_542692d4c026201cdc327038. just noticing about it myself. |
| 18:03 | Atarian | Stap me, so there is. I did a google search, but didn't check the official docs |
| 18:05 | andyf | ClojureDocs site isn't exactly official, and some examples are wrong, but on average it is pretty good |
| 18:06 | andyf | I wrote that note about printf, so I will vouch for it :) |
| 18:06 | Atarian | I've learned alot tonight :) |
| 18:06 | mavbozo | (inc andyf) ;; for the flush note in printf docs |
| 18:06 | lazybot | ⇒ 24 |
| 18:09 | kaiyin | (partial func a) makes a partially applied function, with the first arg fixed right? |
| 18:09 | kaiyin | What if I want to give it the second arg instead of the first? |
| 18:10 | amalloy | kaiyin: what if you wanted to write (partial func a), but weren't allowed to use partial? |
| 18:11 | kaiyin | ,(fn [b] (func a b)) |
| 18:11 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: func in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 18:11 | kaiyin | ,(fn [b] (str a b)) |
| 18:11 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 18:11 | amalloy | kaiyin: indeed. and you can do the same thing if b is what you want to fix |
| 18:12 | amalloy | partial is an alternative way of writing it, if you want to fix the first N arguments, but you don't *need* it for anything |
| 18:12 | kaiyin | amalloy, thanks. |
| 18:32 | dysfun | is there a protocol or interface that allows you to overload 'conj'? |
| 18:33 | amalloy | dysfun: clojure.lang.IPersistentCollection |
| 18:33 | dysfun | ta |
| 18:33 | amalloy | it's the cons method |
| 18:33 | dysfun | finding which one of these different things fall under is a chore |
| 18:33 | dysfun | i'm mostly resorting to github search |
| 18:34 | dysfun | but something like 'conj' is impossible |
| 18:35 | justin_smith | dysfun: here's how I found it: (clojure.repl/source conj) followed by google for clojure.lang.RT, C+f "conj" which gives me IPersistentCollection |
| 18:35 | justin_smith | that first jump because source of conj clearly shows a call to RT/conj |
| 18:35 | dysfun | oh, i forgot about source |
| 18:37 | justin_smith | aha - I also could have done (javadoc clojure.lang.RT) |
| 18:45 | dysfun | can you do binary search against a sorted-map? |
| 18:45 | arrdem | $grim clojure.core/conj |
| 18:45 | lazybot | http://grimoire.arrdem.com/1.6.0/clojure.core/conj |
| 18:46 | arrdem | yessssss didn't even break that :D |
| 18:47 | justin_smith | dysfun: as opposed to the existing "get" ? |
| 18:47 | justin_smith | or I guess I mean, how would this be differentiated from get? |
| 18:48 | dysfun | justin_smith: i'm using a sorted-map-by, but the key |
| 18:48 | dysfun | is not lookupable directly |
| 18:49 | dysfun | it's an interval tree |
| 18:49 | amalloy | dysfun: subseq |
| 18:49 | dysfun | each key in the map is a bounded, they're ordered by minimum bound and don't overlap. given a key, i can tell if it matches |
| 18:50 | _1_fuengxactivo | hola desde Fuengirola |
| 18:50 | dysfun | amalloy: with the index of the mid-point? |
| 18:50 | amalloy | dysfun: with whatever key you are looking for |
| 18:50 | amalloy | don't do the binary search yourself |
| 18:51 | dysfun | oh, i see |
| 18:51 | dysfun | that's brilliant |
| 18:51 | justin_smith | dysfun: you can get a Spliterator via the java.util.Set interface, maybe? just a guess though |
| 18:51 | justin_smith | but I think a Spliterator does what you want |
| 18:52 | justin_smith | or use amalloy's suggestion, that is likely better |
| 18:52 | amalloy | justin_smith: that is like...a java 8 addition to java.util.Set? i'm quite sure clojure's implementation of Set doesn't include any of that newfangled nonsense |
| 18:54 | justin_smith | amalloy: oh, yeah, another point toward your solution then :) |
| 18:54 | amalloy | what on earth even is a spliterator? i should read https://docs.oracle.com/javase/8/docs/api/java/util/Spliterator.html but there are so many words |
| 18:55 | justin_smith | amalloy: like an iterator, but over a tree |
| 18:55 | justin_smith | so for directly doing the binary search as he mentioned |
| 18:59 | mtraven | Having an :aot problem, any experts handy? |
| 19:00 | amalloy | ~anyone |
| 19:00 | clojurebot | anyone is anybody |
| 19:00 | amalloy | i hate you, clojurebot |
| 19:00 | arrdem | not sure anyone understands aot either... |
| 19:02 | mtraven | Sigh...oh well. I am getting errors like this: Caused by: java.lang.Exception: namespace 'fresser.spark' not found after loading '/fresser/spark' from a file that has no obvious problems. I am assuming something is going wrong when it is compiled and the error is being eaten somewhere... |
| 19:05 | justin_smith | mtraven: what is the ns declaration in that file? |
| 19:05 | justin_smith | mtraven: that error usually means a file was loaded via require, but did not define the ns that require expected of it based on its path |
| 19:12 | mtraven | justin: it's nothing obvious like that. The files compile OK normally but fail during :aot |
| 19:14 | justin_smith | mtraven: that error will not make compilation fail |
| 19:14 | justin_smith | but it will make require fail, because the ns required is not present |
| 19:14 | andyf | A file can compile without errors if it has mismatched namespace / file name, but you should get that error if you try to require it with or without AOT |
| 19:16 | justin_smith | mtraven: try running eastwood, and see if it gives you a hint of what might be wrong (after double checking that the file src/fresser/spark.clj starts with (ns fresser.spark ...)) |
| 19:16 | andyf | We wouldn't harp on it like that if it didn't happen to some Clojure developer every day :) |
| 19:17 | justin_smith | I've done it myself enough times... |
| 19:17 | andyf | If that is not the problem, aot experts are uncommon |
| 19:19 | justin_smith | and setting aside everything else, that is literally what that error is intended to mean (though some other root problem with the codebase could cause that problem as a side effect on rare occasions) |
| 19:22 | mtraven | thanks, trying eastwood now (new thing to me) |
| 19:24 | akkad | Clojure: because I don't want to learn Emacs |
| 19:25 | andyf | akkad: Free light saber for everyone who learns Emacs, though. Pretty cool. |
| 19:25 | justin_smith | mtraven: also, does require of that ns work from a repl? |
| 19:25 | justin_smith | (try eastwood first though, it's great) |
| 19:27 | amalloy | i just ran eastwood for the first time. lint result: "jeez, you idiot, your code doesn't even compile" |
| 19:27 | justin_smith | haha |
| 19:28 | andyf | Wow, I must have forgotten and left that harsh err msg in there by accident :) |
| 19:28 | amalloy | andyf: feature request: more abusive lint errors |
| 19:28 | amalloy | like the sudo insult options you can compile with |
| 19:28 | justin_smith | andyf: iirc it was an easter egg that specifically checks for "amalloy" as the current logged in user name |
| 19:29 | andyf | I actually did that once for a program as an undergrad. A few days later, the user (my boss and often professor) came and said: "first of all, I am not a numbskull. Second, ..." He was pretty cool about it |
| 19:30 | justin_smith | andyf: custom translation files for languages like "dumbass" |
| 19:30 | andyf | Hmm, maybe lines from Clint's films ... |
| 19:30 | justin_smith | oh that would be a good one |
| 19:31 | justin_smith | one could make it a pluggable edn based config |
| 19:31 | andyf | i18n ftw |
| 19:32 | justin_smith | andyf: "so about now you are probably asking, is this the root cause of the exception, or is there another exception left?" |
| 19:32 | andyf | This bug could blow your head clean off |
| 19:37 | justin_smith | "It's a hell of a thing, killing a Thread. You free all the resources it ever had, and ever could have." (not strictly true) |
| 19:40 | andyf | Github issue created. Not high priority |
| 19:43 | kenrestivo | you know, i watched the youtube clip of that scene from the first dirty harry movie, and now i'm embarassed for ever having quoted it. |
| 19:44 | kenrestivo | haven't seen it in like 30 years, and... it did not age well. |
| 19:48 | [blake| | "Swell." |
| 19:49 | hellofunk | lol justin_smith adding inline footnotes to your own movie quote variations |
| 19:50 | iwo | hey, does anyone know if there's a good pattern for 'single item filter'? I dont mean (first (filter ...)) i mean (if (pred x) x nil) |
| 19:53 | iwo | or basically (when (pred x) x) |
| 19:54 | amalloy | iwo: pattern? just define that as a function, and then use that function |
| 19:54 | iwo | I guess (when (pred x) x) is already close to the shortest form that this could take |
| 19:54 | iwo | I suppose I'm looking for (f pred x) |
| 19:55 | amalloy | you'd need a pattern if you needed to repeat this over and over, but with higher-order functions you can just define a function |
| 19:55 | amalloy | (defn f [pred x] (when (pred x) x)) |
| 19:55 | andyf | iwo: #(= % x) |
| 19:55 | amalloy | andyf: i don't think that's it at all...? |
| 19:56 | andyf | Maybe I'm confused by mention of filter |
| 19:56 | iwo | amalloy: sorry, pattern was the wrong word, I just mean a function in clojure.core |
| 19:56 | iwo | I realise I can create a hof for this :) |
| 19:56 | amalloy | iwo: there's nothing in clojure.core |
| 20:08 | pmonks | Potentially silly question - any good reason why the REPL doesn't provide the source for a function that was defined in that REPL session? |
| 20:10 | amalloy | because it can't |
| 20:10 | amalloy | (potentially silly answer) |
| 20:10 | pmonks | ;-) |
| 20:10 | pmonks | I don't see why it can't, though the current impl apparently can't do it. |
| 20:11 | amalloy | pmonks: because functions don't know their source |
| 20:11 | amalloy | they only know a file and a line number |
| 20:11 | pmonks | I guess that's my point - why not store the source with the compiled fn? |
| 20:11 | pmonks | (at least in the REPL) |
| 20:13 | pmonks | I haz a sad after runnng (source my-fn) on an fn I'd been experimenting with for a while. Had to go back through the scroll buffer and find the defn. |
| 20:13 | [blake| | pmonks: Heh. Try it some time after your defn has scrolled out of the buffer. That is a sadz. |
| 20:14 | pmonks | ouch |
| 20:14 | pmonks | (inc sad) |
| 20:14 | amalloy | [blake|: C-r? |
| 20:14 | pmonks | lazybot doesn't like me today :-( |
| 20:14 | [blake| | amalloy: Я не говорю Emacs. |
| 20:14 | amalloy | that's just expensive, pmonks. clojure's vars are already heavyweight and add substantially to startup time, which causes people a lot of problems |
| 20:15 | pmonks | I (mostly) don't care about that in the REPL. |
| 20:15 | pmonks | Going to classpath for "real" fns is fine. |
| 20:15 | pmonks | Just saying it'd be nice if fns hand-rolled at the REPL were special cased. |
| 20:15 | [blake| | amalloy: How could it impact the startup time if it only applied in the REPL to things defined in the REPL? |
| 20:17 | [blake| | (Not that I particularly care. It only happened in my early experiments, when working code was precious.) |
| 20:17 | gfredericks | making things special in the repl is a little tricky |
| 20:17 | gfredericks | buuuuuttt |
| 20:17 | [blake| | That is a big but. |
| 20:18 | pmonks | I LIKE!!!1 |
| 20:18 | gfredericks | I can imagine a piece of repl tooling that wrote each line to its own file and eval'd it from there and that would probably get you what you want and everybody would hate it and nobody would use it |
| 20:18 | [blake| | Perfect! |
| 20:18 | arrdem | gfredericks: that's hillariously close to how CIDER works |
| 20:18 | arrdem | iirc |
| 20:19 | arrdem | but everyone hates that and nobody uses it |
| 20:19 | arrdem | (inc bbatsov) |
| 20:19 | gfredericks | :) |
| 20:19 | gfredericks | bbatsov inc'd my nrepl commit the other day |
| 20:19 | pmonks | <n00b warning> Seems like a REPL-rolled fn var could just have additional metadata that (source) could be sensitive to. |
| 20:20 | pmonks | Though I guess that means the REPL wouldn't be using the "real" reader - it'd need it's own with defn redefined. |
| 20:20 | gfredericks | could use the same reader |
| 20:20 | gfredericks | pmonks: you know what actually |
| 20:20 | gfredericks | what I would recommend |
| 20:21 | gfredericks | this might still get the scorn of everybody else but that's okay |
| 20:21 | gfredericks | is |
| 20:21 | amalloy | ready the scorn cannoncs |
| 20:21 | arrdem | fork clojure and add a *repl* context to Compiler.java? |
| 20:21 | gfredericks | an nrepl middleware that wraps your code in (macrolet [defn ...] ... your code ...) |
| 20:22 | rhg135 | Blasphemy! |
| 20:22 | gfredericks | I don't know how to get the string source from that but there might be a way |
| 20:22 | gfredericks | (as opposed to the post-reader source) |
| 20:22 | arrdem | that's... significantly less evil than I was expecting |
| 20:22 | gfredericks | you could easily get the entire eval'd msg |
| 20:23 | gfredericks | and the reader probably adds metadata that you could use the same way clojure.repl/source does |
| 20:23 | gfredericks | I need to stop thinking about this or I'll end up writing it myself |
| 20:23 | hiredman | nrepl middleware that snapshots vars before and after eval, compares, then throws the string source on to new or changed vars |
| 20:23 | gfredericks | I think hiredman is just trying to out-scorn me |
| 20:23 | pmonks | hmm......I was just looking at the source for defn itself, and wondering if you could just redefine that (and source), in the REPL itself.... |
| 20:24 | arrdem | can you put watches on a var? |
| 20:24 | gfredericks | totes |
| 20:24 | arrdem | so do that and you escape hiredman's snapshotting |
| 20:24 | gfredericks | you can't put watches on yet-to-be-created vars |
| 20:25 | gfredericks | so you'd still have to iterate over the world |
| 20:25 | gfredericks | Just In Case |
| 20:25 | arrdem | or you could look at the nREPL return message and see if it's a var |
| 20:25 | arrdem | but that assumes single defs... |
| 20:26 | rhg135 | That's pretty fragile imo |
| 20:26 | arrdem | could you put a watch on *ns*? |
| 20:27 | arrdem | nope. |
| 20:29 | gfredericks | if somebody comes up with a good name for this library I will write it right now. |
| 20:29 | pmonks | defning |
| 20:30 | pmonks | Apologies - it was the first pun that pooped into my head. |
| 20:30 | andyf | I like it. Stning |
| 20:30 | gfredericks | is that another pun |
| 20:31 | gfredericks | how about it-makes-source-work-on-defns-from-your-repl |
| 20:31 | pmonks | andyf: "Software Transaction Ning"? |
| 20:31 | andyf | I don't think so, but my condition may be advanced enough that I can't tell any more. |
| 20:31 | andyf | I simply meant stunning. |
| 20:32 | cfleming | I'm certainly stunned |
| 20:58 | gfredericks | okay fine I will write this and call it defning |
| 21:02 | amalloy | all right, guys, gfredericks has given in. we can stop silently applying peer pressure now |
| 21:05 | andyf | Oh, we were doing it silently? I had my bots sending him private msgs every 5 secs |
| 21:06 | amalloy | (inc andyfbot) |
| 21:06 | amalloy | i think lazybot got lost in the netsplit |
| 21:07 | gfredericks | man I hate writing nrepl middleware |
| 21:07 | amalloy | peer pressure! quick! |
| 21:07 | amalloy | he's more resilient than we ever imagined |
| 21:07 | gfredericks | protip: #'clojure.tools.nrepl.middleware.interruptible-eval/*msg* is a magical wonderland |
| 21:08 | gfredericks | go poke that in your repl and see what happens |
| 21:09 | gfredericks | e.g. try this |
| 21:09 | gfredericks | (:code clojure.tools.nrepl.middleware.interruptible-eval/*msg*) |
| 21:11 | gfredericks | wait a minute |
| 21:12 | gfredericks | how can I get clojure.repl/source to work with this just by adding metadata |
| 21:13 | gfredericks | I take it all back this is completely impossible I give up |
| 21:16 | amalloy | gfredericks: more metadata |
| 21:16 | amalloy | er, more middleware |
| 21:17 | amalloy | add a middleware that replaces calls to clojure.repl/source with calls to your hijacked function. what could go wrong? |
| 21:17 | gfredericks | I can't stomach the idea of macroletting source because I use (./source ...) myself |
| 21:18 | gfredericks | ~what |
| 21:18 | clojurebot | what is http://gist.github.com/306174 |
| 21:18 | gfredericks | ~what |
| 21:18 | clojurebot | what is this |
| 21:18 | amalloy | $what |
| 21:18 | lazybot | It's AWWWW RIGHT! |
| 21:23 | gfredericks | if only all vars were dynamic again |
| 21:23 | gfredericks | let's ask rich if he can revert that real quick |
| 21:24 | justin_smith | gfredericks: since the point of using this would be to get enhanced source, I don't think expecting someone to call sourcening instead of source is so onerous |
| 21:25 | gfredericks | you can't make me make a separate dep called sourcening |
| 21:25 | justin_smith | OK, but your dep could define sourcening |
| 21:44 | Travisty | can anyone think of some device that has about 65kb of memory? |
| 21:44 | gfredericks | Nintendo 65 |
| 21:44 | Travisty | Heh, did the n64 have 64 bytes? |
| 21:44 | gfredericks | I don't think that was funny I retract the joke |
| 21:44 | Travisty | er, kb |
| 21:52 | exaptic_ | 65 is a weird amount of memory to have, given it's not a power of two |
| 22:05 | gfredericks | ~65 is a power of 65 |
| 22:05 | clojurebot | Ok. |
| 22:07 | justin_smith | Travisty: I have a tandy 102 with 64k total storage (ram+rom), and many other computers from its era had the same |
| 22:07 | gfredericks | back in the 50's the Committee On Deciding What A Bit Is had to choose between two proposals, one that would have a 2-valued bit, and the other a 65-valued bit. The committee ended up choosing the latter because "it sounded more gooder" |
| 22:07 | gfredericks | and that's why today so many elements of computing involve powers of 65 |
| 22:09 | gfredericks | there isn't a programmer alive who hasn't committed the number ##(apply * (repeat 65 65N)) to memory |
| 22:09 | lazybot | ⇒ 6908252164760920851405538694468286082230378724259454186289117297729987129104901877330036086277686990797519683837890625N |
| 22:12 | Travisty | lol |
| 22:40 | mmitchel_ | i'm using clojure.tools.logging - is there anyway to configure the log level at runtime, without an additional library? |
| 22:41 | exaptic | haha |
| 23:01 | justin_smith | mmitchel_: not that I know of, timbre makes it straightforward enough |
| 23:01 | mmitchel_ | justin_smith: cool, does timbre use java logging like log4j etc.? |
| 23:04 | justin_smith | yeah, it just adds runtime config (via a global atom iirc) |
| 23:19 | Methodical | I am successfully using environ locally for test and dev postgres connections. I have a heroku app with the postgres addon. I have the env variables set up and available in the heroku app. Yet the app blows up with PSQLException: Connection refused. Any heroku users aware of a gotcha I am overlooking? |