2015-04-26
| 00:05 | nbeloglazov | Is there a way in core.typed to check namespace without throwing an error and only printing found issues? |
| 00:05 | nbeloglazov | I'm trying to gradually annotate namespace from emacs and constantly invoking check-ns to test it. |
| 00:09 | allenj12 | test |
| 00:09 | arrdem | nbeloglazov: the #typed-clojure folks will probably know |
| 00:09 | arrdem | offhand I can't say I do |
| 00:10 | nbeloglazov | Thanks. Will try there. |
| 00:10 | arrdem | I think there's a typed clojure emacs plugin that deals with that for you |
| 00:10 | nbeloglazov | Yeah, but I'd rather start with "low-level" :) |
| 00:10 | arrdem | eh tooling exists to be used :P |
| 00:57 | dumptruck | stuck on another koan... "Or use the names of existing functions" (= __ (map nil? [:a :b nil :c :d])) |
| 00:57 | dumptruck | any hints? |
| 00:58 | dumptruck | interestingly... i happened to remove the __ and save and it passed... |
| 00:58 | arrdem | dumptruck: what number is this? |
| 00:58 | arrdem | ##(= 1) |
| 00:58 | lazybot | ⇒ true |
| 00:59 | dumptruck | oh right |
| 00:59 | arrdem | :P |
| 00:59 | dumptruck | it's 08_higher_order_functions |
| 00:59 | dumptruck | 3rd one |
| 00:59 | dumptruck | but |
| 01:00 | dumptruck | ,(nil? nil) |
| 01:00 | clojurebot | true |
| 01:00 | dumptruck | er.. not what i meant |
| 01:00 | dumptruck | ,(nil? :a) |
| 01:00 | clojurebot | false |
| 01:00 | dumptruck | if that's the first mapping |
| 01:01 | dumptruck | how does that not invalidate the test with (= (map nil? [:a :b nil :c :d])) |
| 01:01 | dumptruck | (= false) |
| 01:01 | dumptruck | ,(= false) |
| 01:01 | clojurebot | true |
| 01:01 | dumptruck | oh. |
| 01:01 | arrdem | ∀ x (= x) == true |
| 01:02 | arrdem | ##(map nil? [:a :b nil :c :d]) |
| 01:02 | lazybot | ⇒ (false false true false false) |
| 01:02 | dumptruck | the hint it is giving me is throwing me off |
| 01:02 | dumptruck | "Or use the names of existing functions" |
| 01:03 | dumptruck | is it just referring to nil? |
| 01:03 | dumptruck | i guess so... |
| 01:04 | arrdem | honestly not sure |
| 01:11 | TEttinger | dumptruck: this list of koans? https://github.com/functional-koans/clojure-koans/blob/master/src/koans/08_higher_order_functions.clj |
| 01:12 | TEttinger | I believe that's meant to be a continuation of the previous sentence |
| 01:12 | TEttinger | (= [false false true false false] (map nil? [:a :b nil :c :d])) |
| 01:12 | TEttinger | ,(= [false false true false false] (map nil? [:a :b nil :c :d])) |
| 01:12 | clojurebot | true |
| 01:13 | dumptruck | yeah |
| 01:13 | dumptruck | i mean, that's what i put |
| 01:13 | dumptruck | i thought it was asking me to put a function name |
| 01:14 | TEttinger | I think it was referring to its use of nil? |
| 01:14 | TEttinger | instead of (fn) |
| 01:14 | dumptruck | right |
| 01:15 | TEttinger | you're totally right, it's worded poorly |
| 01:22 | fowlslegs | Is there a way to use a local variable name from function A in function B is function A calls function B? |
| 01:22 | fowlslegs | Let me try to write this clearer. |
| 01:24 | fowlslegs | I want to write something like |
| 01:24 | fowlslegs | ,(defn b [] local-var-from-a) |
| 01:24 | clojurebot | #error{:cause "Unable to resolve symbol: local-var-from-a in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: local-var-from-a in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6543]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: local-var-... |
| 01:25 | fowlslegs | But I won't be able to resolve local-var-from-a. |
| 01:26 | lvh | fowlslegs: there's two ways to do this |
| 01:26 | lvh | fowlslegs: the obvious way is to pass the var as an argument to b |
| 01:26 | lvh | fowlslegs: the less obvious way is ^:dynamic, but I'd be very surprised if that's actually a thing you want to use here |
| 01:27 | fowlslegs | But if function a looks like (defn a [] (let [local-var-from-8 42] (b)) |
| 01:28 | puredanger | The whole point of local vars is to have local lexical scope. If you want it in b, pass it in. |
| 01:28 | fowlslegs | For what I'm doing I can't pass the var as an argument to b. |
| 01:28 | dumptruck | why not |
| 01:28 | fowlslegs | Sorry I should have made that clear. |
| 01:29 | dumptruck | (defn a [] (let [local-var-from-8 42] (b local-var-from-8)) |
| 01:29 | dumptruck | no? |
| 01:29 | clojurebot | no is tufflax: there was a question somewhere in there, the answer |
| 01:29 | fowlslegs | Because I want my file to run with a certain system and to do that I'd have to modify parts of the system that would break it for other files. |
| 01:30 | TEttinger | fowlslegs: there's technically nothing preventing you from running def inside function a |
| 01:30 | TEttinger | it's not at all encouraged |
| 01:30 | arrdem | Oxcart will whine if you try that :P |
| 01:30 | puredanger | Well I'd say this is the wrong overall path, but dynamic vars would give you the dynamic scope you seek |
| 01:31 | dumptruck | can you not overload b? |
| 01:31 | puredanger | Don't use def, bleh |
| 01:32 | TEttinger | fowlslegs: I would say, make a third def at outer scope, an atom or something that you just assign the value from a |
| 01:32 | TEttinger | this way only the most recent call to a matters |
| 01:32 | fowlslegs | Let me explain the structure better. I have full control over b, but not a. a calls b as an anonymous function and gives it exactly |
| 01:32 | dumptruck | like |
| 01:33 | fowlslegs | one argument which is not the argument I need. However, a also defines a variable, which changes as it loops over b |
| 01:33 | fowlslegs | and I want to use that variable. |
| 01:33 | dumptruck | (defn b ([] (b :default-value)) ([a-value] ...)) |
| 01:34 | arrdem | that is in fact the idiom for implicit arguments |
| 01:34 | puredanger | Well, Clojure doesn't work that way |
| 01:34 | TEttinger | if you don't have control over a you can't reach in and and pull out its internal vars without some serious hacks |
| 01:34 | dumptruck | ah |
| 01:34 | TEttinger | it may be possible |
| 01:34 | TEttinger | not a good idea |
| 01:34 | puredanger | You shouldn't want it to work that way :) |
| 01:34 | fowlslegs | TEttinger: Haha indeed. I was hoping the experts here could help me with that. |
| 01:35 | TEttinger | well hm |
| 01:35 | TEttinger | so A is called without your control? |
| 01:35 | fowlslegs | Yes. |
| 01:35 | TEttinger | not even in your lib? |
| 01:36 | fowlslegs | Is there some way I can make b a macro that creates a function that grabs this local-var? |
| 01:36 | TEttinger | I mean you must have access to the source, otherwise you wouldn't know about the loop |
| 01:36 | puredanger | If b was a macro you could prob get to it via &env |
| 01:36 | fowlslegs | TEttinger: I do. I just really, really don't want to change it. |
| 01:37 | puredanger | But to be clear, this is a terrible idea :) |
| 01:37 | fowlslegs | TEttinger: My file will not be accepted to the examples if I modify the system files. |
| 01:37 | TEttinger | examples? |
| 01:37 | clojurebot | examples is api examples |
| 01:37 | fowlslegs | puredanger: I love terrible ideas. |
| 01:37 | fowlslegs | I have about 4-5 per minute. |
| 01:38 | TEttinger | if there's an acceptance process you really really don't want to be hacking local scope that is not your own? |
| 01:38 | arrdem | TEttinger: you left a -? on that bud |
| 01:39 | TEttinger | it's the expression my eyebrows are making, arrdem |
| 01:39 | puredanger | Macros expand in their caller and have access to an implicit &env that includes locals iirc |
| 01:40 | fowlslegs | puredanger: Can you give me an example of how I might do this or point me to relevant documentation? |
| 01:41 | puredanger | No, on my phone sorry |
| 01:41 | arrdem | http://blog.jayfields.com/2011/02/clojure-and.html |
| 01:41 | fowlslegs | Honestly the fact you might be able to do this is not very comforting from a security standpoint. |
| 01:42 | arrdem | aw dnolen is afk |
| 01:45 | TEttinger | ,(defmacro show-form [a b] `(println ~@(next &form))) |
| 01:45 | clojurebot | #'sandbox/show-form |
| 01:45 | TEttinger | ,(let [alpha 1 beta 2] (show-form alpha beta)) |
| 01:45 | clojurebot | 1 2\n |
| 01:48 | arrdem | can I use CIDER to connect twice to the same nrepl instance? |
| 01:48 | TEttinger | ,(defmacro B [] (do (print (keys &env)) 42) |
| 01:48 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 01:48 | TEttinger | ,(defmacro B [] (do (print (keys &env)) 42)) |
| 01:48 | clojurebot | #'sandbox/B |
| 01:50 | TEttinger | ,(loop [a 0] (if (> a 3) (print "Done!") (do (B) (recur (inc a)) ))) |
| 01:50 | clojurebot | (a)Done! |
| 01:51 | TEttinger | ,(defmacro B [] (do (print (vals &env)) 42)) |
| 01:51 | clojurebot | #'sandbox/B |
| 01:51 | TEttinger | ,(loop [a 0] (if (> a 4) (print "Done!") (do (B) (recur (inc a)) ))) |
| 01:51 | clojurebot | (#object[clojure.lang.Compiler$LocalBinding 0x1f5c0126 clojure.lang.Compiler$LocalBinding@1f5c0126])Done! |
| 01:51 | TEttinger | woah |
| 01:52 | TEttinger | ,(defmacro B [] `(println ~@(keys &env))) |
| 01:52 | clojurebot | #'sandbox/B |
| 01:52 | TEttinger | ,(loop [a 0] (if (> a 4) (print "Done!") (do (B) (recur (inc a)) ))) |
| 01:52 | clojurebot | 0\n1\n2\n3\n4\nDone! |
| 01:53 | TEttinger | fowlslegs: there you go, maybe |
| 01:53 | TEttinger | there are caveats galore |
| 01:53 | TEttinger | ,(let [haha "let messes you up"] (loop [a 0] (if (> a 4) (print "Done!") (do (B) (recur (inc a)) )))) |
| 01:53 | clojurebot | let messes you up 0\nlet messes you up 1\nlet messes you up 2\nlet messes you up 3\nlet messes you up 4\nDone! |
| 02:05 | arrdem | Where would you suggest looking to get started with Ring testing? |
| 02:30 | fowlslegs | TEttinger: So really B is calling C and A is calling B, where A has the local var bound in a loop statement as it loops over B among other functions. |
| 02:31 | fowlslegs | Thanks anyway for your examples and suggestions everyone, but I can't get what I'm looking for with &env |
| 02:31 | TEttinger | hm? |
| 06:03 | jaaqo | I'm testing my web application routes and am unable to mock out csrf-protection from my queries. Is it a valid approach to create another handler function just to be used in tests, in which the anti forgery is turned off? |
| 06:08 | Confusionist | I'm not understanding the following: if I execute (require '[clojure.tools.namespace.repl :refer [refresh refresh-all]]) in a repl, I can subsequently call (refresh) and it does it's job. If I put the exact same line in user.clj (which is being loaded, as confirmed by a println), the 'refresh symbol cannot be resolved. Why is that? |
| 06:11 | Confusionist | jaaqo, it's usually easier to just generate a valid csrf token and include it in the request |
| 06:46 | sohalt` | Hi, I'm still wrestling with my clojurescript repl and noticed something. I got the repl working a few times (But only after like refreshing the browser >5 times) in my terminal with lein trampoline run -m clojure.main repl.clj, where repl.clj sets up the browser repl. Now when it works the browser starts sending a first POST to "/" with params {:type :ready, :content "ready", :order 1} and after that starts spammin |
| 06:46 | sohalt` | g POSTs to "/" (~100 or so) until a GET to strings.js returns with a 404 and then follows a last POST to "/" with params {:type :result, :content "{:status :success, :value \"\"}", :order 105} |
| 06:46 | sohalt` | Any ideas, why that could be? Or completely unrelated? |
| 06:47 | sohalt` | When it doesn't work (90% of the time) the browser sends the first POST to "/" and then does nothing and the repl sits there waiting with a "Waiting for broswer to connect ..." message |
| 06:49 | sohalt` | Oh, and now I'm getting nullpointer messages in the repl |
| 06:50 | sohalt` | cljs.user=> Exception in thread "Thread-124" java.lang.NullPointerException |
| 06:50 | sohalt` | at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:26) |
| 06:50 | sohalt` | at cljs.repl.server$read_request.invoke(server.clj:95) |
| 06:50 | sohalt` | at cljs.repl.server$handle_connection.invoke(server.clj:153) |
| 06:50 | sohalt` | at cljs.repl.server$server_loop$fn__4477.invoke(server.clj:164) |
| 06:50 | sohalt` | at clojure.core$binding_conveyor_fn$fn__4145.invoke(core.clj:1910) |
| 06:50 | sohalt` | at clojure.lang.AFn.run(AFn.java:22) |
| 06:50 | sohalt` | at java.lang.Thread.run(Thread.java:745) |
| 06:50 | zol_ | How can I get only the first level of directories inside a directory? like if I have public/images/{a/{1/,2/},b/{1/,2/,3/}, c/{1/}, I want to only get public/images/{a,b,c} as clojure.java.io.File objects |
| 06:52 | sohalt` | whoops, clicked on the wrong request before. The last POST to "/" has params {:type :result, :content "{:status :success, :value \"true\"}", :order 113} |
| 06:55 | dnolen | sohalt`: sounds like a bug but will need more information |
| 06:55 | dnolen | sohalt`: I haven't encountered this problem in Chrome (which is what I use to develop), but I have noticed that Safari & Firefox often need a refresh or two in some cases. |
| 06:56 | zol_ | Looks that it is files-seq that makes the call recursively |
| 06:58 | sohalt` | I sometimes refreshed >10 times and it still didn't get past that first POST. |
| 06:59 | oddcully | ,(.listFiles (new java.io.File "/tmp")) |
| 06:59 | clojurebot | #error{:cause "denied", :via [{:type java.lang.SecurityException, :message "denied", :at [clojurebot.sandbox$enable_security_manager$fn__887 invoke "sandbox.clj" 69]}], :trace [[clojurebot.sandbox$enable_security_manager$fn__887 invoke "sandbox.clj" 69] [clojurebot.sandbox.proxy$java.lang.SecurityManager$Door$f500ea40 checkRead nil -1] [java.io.File list "File.java" 1111] [java.io.File listFiles "... |
| 07:00 | sohalt` | And I didn't get it to work with inf-clojure, only terminal, although that might simply be coincidence, since from my understanding they do essentially the same. (launch the repl.clj with lein tampoline |
| 07:01 | zol_ | Fixed it! .listFiles (io/as-file (io/resource "public/images/courses")) |
| 07:03 | sohalt` | dnolen: is there anything specific I could try to get more info? |
| 07:04 | dnolen | sohalt`: it sounds like a potential server bug |
| 07:04 | dnolen | sohalt`: would be useful to understand why Chrome doesn't have this problem consistently and Firefox does |
| 07:09 | noncom | does usage of more than 4-arity fns in clojure give serious overhead? |
| 07:09 | noncom | or better, what is the additional cost for that? |
| 07:12 | dnolen | noncom: there's nothing specific about any particular arity |
| 07:13 | dnolen | noncom: so the answer to your question - no |
| 07:20 | noncom | okay, thanks. i just remember that there was that issue with defining more functions of primitive types (incl object) than 4 due to the explosion (4 in power 4 is already too many classes) |
| 07:21 | noncom | * correction: ...than it is already dont with arity 4 due to the explosion.. |
| 07:21 | noncom | *done :) |
| 08:17 | gfredericks | noncom: something around there is true, actually; but if you're not intentionally using primitives that doesn't matter |
| 08:25 | Confusionist | Concerning repl workflows: if I start a lein repl and use a user.clj to make some stuff available in the user namespace, is there a way to make it possible to use e.g. (user.str/replace ...) when user.clj contains a [clojure.string :as str]? |
| 08:26 | Confusionist | I'm trying to find a way to make common things easy to do, without polluting the app.core namespace and without having to explicitly wrap everything with a separate function in user.clj |
| 08:27 | Confusionist | So I e.g. make clojure.tools.namespace.repl.refresh available as user/refresh and I could do the same for those aliased namespaces, but it seems like there should be an easier way |
| 08:34 | justin_smith | Confusionist: no, it does not work that way |
| 08:36 | justin_smith | Confusionist: though I think vinyasa has similar goals https://github.com/zcaudate/vinyasa |
| 08:38 | Confusionist | justin_smith, Thanks, that does sound like what I currently think may be useful |
| 09:02 | sobel | i just reload my repl when things get horked up. i could learn a better workflow, but i still build my projects around batch-build ideas, and getting to work in/with a repl is pure gravy |
| 09:04 | sobel | that said, i'll refresh deps in-repl after editing project.clj, but i usually end up with a broken state i need to restore |
| 09:05 | sobel | unrelated: anyone here use irclj? i'm trying to figure out how to capture disconnection. hoping i don't have to inspect the interior socket state. |
| 09:05 | justin_smith | sobel: I've worked on lazybot.... best of luck |
| 09:08 | sobel | that sounds like a 'no' |
| 09:09 | justin_smith | more of an "I don't know" |
| 09:09 | justin_smith | but yeah |
| 09:09 | sobel | figures. irc is still a mutt protocol. |
| 09:11 | sobel | ugh, the java libs are...java |
| 09:12 | Confusionist | sobel, in general you can't reliably determine disconnection from the socket state |
| 09:12 | Confusionist | Without a 'ping' or similar in the protocol, you're basically hosed if the other side doesn't nicely close the socket |
| 09:13 | sobel | Confusionist: understood; i actually mean timeout. |
| 09:13 | sobel | i should have said infer rather than inspect ;) |
| 09:14 | sobel | i might be just clever enough to add clojure to PircBotX |
| 09:46 | JanxSpirit | my team is looking to prototype a project using a full-stack Clojure approach with Om - can anyone direct me to the current most mature stack I should be looking at? |
| 09:51 | sobel | JanxSpirit: i'm looking at http://www.luminusweb.net/ because it looks fairly complete |
| 09:52 | sobel | 'complete' in the application library sense, or "just add database and a scaling strategy if you need one" |
| 09:59 | sveri | JanxSpirit: I put together a template which includes chestnut and luminusweb for code reloading of clj and cljs: https://github.com/sveri/closp However if you only need the cljs part look at chestnut: https://github.com/plexus/chestnut |
| 10:00 | Confusionist | Weird: I have a project with speclj where 'lein spec' passes, but 'lein spec -a' immediately raises 'java.io.FileNotFoundException: Could not locate app/core_test__init.class or app/core_test.clj on classpath' |
| 10:00 | JanxSpirit | Isobel sveri - thank you |
| 10:01 | JanxSpirit | sobel that is |
| 10:01 | sobel | good luck! |
| 10:04 | sveri | yea and come back if you have questions |
| 10:04 | smorgy | Hi all |
| 10:05 | smorgy | What's the most elegent way to read from a channel only when a predicate is met? |
| 10:05 | smorgy | like having one go-loop processing every odd number, another processing the even ones? |
| 10:07 | Confusionist | Ah, eastwood found the problem... but still surprising only the -a trips over it |
| 10:07 | oddcully | smorgy: there is `split` |
| 10:11 | smorgy | ok, what if there's more consumers than that, so I'll up doing a split of a split of a split... |
| 11:15 | catern | dear #clojure |
| 11:15 | catern | I would like to partition something on the basis of a predicate |
| 11:16 | catern | take-while gives me things up to the predicate becoming false |
| 11:16 | brucehauman | group-by |
| 11:16 | brucehauman | catern: I think group-by is what you are looking for |
| 11:16 | catern | :D |
| 11:16 | catern | i think you mean partition-by |
| 11:16 | catern | but yes |
| 11:18 | brucehauman | catern: partition-by is subtle |
| 11:18 | catern | oh |
| 11:18 | catern | yeah |
| 11:18 | catern | so it is |
| 11:18 | brucehauman | catern: group-by actually groups the values |
| 11:18 | catern | hmm, actually, I don't think either of these is what I want |
| 11:18 | catern | what I want is |
| 11:19 | catern | [[true false false false] [true] [true false] [true false false]] |
| 11:20 | brucehauman | catern: yeah that is tough |
| 11:20 | brucehauman | catern: you only want one true per list |
| 11:20 | catern | is there a take-while that does a split? |
| 11:21 | catern | ah |
| 11:21 | catern | https://clojuredocs.org/clojure.core/split-with |
| 11:21 | brucehauman | catern: I dont think that will work either |
| 11:22 | catern | well |
| 11:22 | catern | hmm |
| 11:22 | catern | what I really kind of want |
| 11:22 | catern | is https://clojuredocs.org/clojure.string/split |
| 11:22 | catern | but for lists |
| 11:23 | catern | and with a predicate instead of a regex I mean |
| 12:13 | justin_smith | partition-by? |
| 12:13 | Confusionist | Is there a simple way in core.match to capture the value of an :or match? So I would like to match [(:or 'foo 'bar) 1 2] and I would like to be able to refer to the value 'foo or 'bar. Of course if I matched somevec, I could simple ask (first somevec), but if could capture it directly, like in a regex named group, that would be nice |
| 12:15 | justin_smith | sorry, someone already mentioned that |
| 12:18 | justin_smith | ,(map #(apply concat %) (partition 2 1 (partition-by even? [0 1 3 5 2 3 7 4 9 9]))) |
| 12:18 | clojurebot | ((0 1 3 5) (1 3 5 2) (2 3 7) (3 7 4) (4 9 9)) |
| 12:18 | justin_smith | not quite |
| 12:18 | justin_smith | ,(map #(apply concat %) (partition 2 (partition-by even? [0 1 3 5 2 3 7 4 9 9]))) |
| 12:18 | clojurebot | ((0 1 3 5) (2 3 7) (4 9 9)) |
| 12:19 | justin_smith | catern: ^ I think that's your answer |
| 12:28 | deanman | How can someone go about deleting a parentheses on cursive ? |
| 12:28 | nuwanda__ | you're using structural editing? |
| 12:29 | deanman | nuwanda__: just started using it so I'm not quite sure what that is. I know that I'm using the "cursive" keybinding set |
| 12:30 | justin_smith | deanman: if the pair is empty, you should be able to simple delete them. But structural editing only allows deleting by pairs |
| 12:31 | deanman | So if i ultimately want to move that parentheses around then i should be using some other trick ? |
| 12:31 | justin_smith | deanman: the keyword to look for is "structural editing", their's various bindings for moving things in and out of paren groups |
| 12:32 | gfredericks | hello |
| 12:32 | justin_smith | yo |
| 12:32 | catern | justin_smith: awesome, thanks |
| 12:33 | deanman | justin_smith: Slurp barf etc? |
| 12:33 | justin_smith | yup |
| 12:34 | deanman | justin_smith: Is that something specific to cursive or something lispy? Where can i find more information what do these terms mean and what they do ? |
| 12:35 | justin_smith | deanman: it's a concept a few editors have, cursive has its own key bindings for it |
| 12:35 | justin_smith | and yeah, it only works on lispy stuff, but it's not part of the language at all |
| 12:36 | deanman | justin_smith: thanks for the tip |
| 12:43 | lasergoat | justin_smith: re:https://www.refheap.com/99973. I'm sure you figured it out, but it dawned on me why that fetches an extra item |
| 12:43 | lasergoat | weird, actually, that I didn't see it the first time |
| 12:44 | justin_smith | oh? ztellman mentioned that it was inevitable with core.async being push |
| 12:44 | lasergoat | i mean, i guess that's the general explanation |
| 12:45 | lasergoat | the specifics is just that that (>/>! result (first source)) does `first` and then parks on something pulling from the channel |
| 12:45 | lasergoat | so there's always something waiting in "parked" mode |
| 12:45 | justin_smith | oh, right |
| 12:46 | brucehauman | justin_smith: great answer to catern’s question |
| 12:46 | lasergoat | so you could do something snazzy with an extra channel that signals "back" that you're ready to pull another item off the upstream source |
| 12:46 | lasergoat | but that's sort of ugly |
| 12:46 | justin_smith | hmm... |
| 12:47 | justin_smith | an abstraction could be reused, and it can be as ugly as it needs to be... |
| 12:47 | lasergoat | sure, shouldn't be too hard |
| 12:49 | lasergoat | anyway, i'm off; just dropping in to mention it |
| 12:49 | justin_smith | thanks |
| 12:51 | brucehauman | justin_smith: it was really great meeting you guys |
| 12:51 | justin_smith | it's mutual, it was a fun conference |
| 12:52 | brucehauman | yeah it was. I really liked Portland. More than I expected |
| 12:56 | gfredericks | it's the asheville of the northwest oregon area |
| 12:58 | gfredericks | the dumb thing about conferences is you meet a bunch of people you like and then find out that they live far far away from you |
| 13:02 | mdallastella | namaste |
| 13:04 | brucehauman | gfredericks: I miss you too man |
| 13:04 | brucehauman | ;) |
| 13:05 | brucehauman | gfredericks: actually I’m gonna get up to Chicago sometime this year. I miss that town. |
| 13:06 | gfredericks | doooo it |
| 13:08 | gfredericks | and kidnap toby if you do |
| 13:10 | brucehauman | gfredericks: thats a good idea |
| 13:12 | brucehauman | he’s right next to me |
| 13:13 | gfredericks | see it'd be so easy |
| 13:15 | lucasb | Hello o/, I'm new to clojure. Is there a function in core that returns the index of the first element in a list that is equal to another or nil if it's not there? Let's say I have '(:a :b :c), given ":c", I want 2 as answer. |
| 13:15 | justin_smith | ,(.indexof '(:a :b :c) :c) |
| 13:15 | justin_smith | err |
| 13:15 | clojurebot | #error{:cause "No matching method found: indexof for class clojure.lang.PersistentList", :via [{:type java.lang.IllegalArgumentException, :message "No matching method found: indexof for class clojure.lang.PersistentList", :at [clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 53]}], :trace [[clojure.lang.Reflector invokeMatchingMethod "Reflector.java" 53] [clojure.lang.Reflector invokeI... |
| 13:15 | justin_smith | ,(.indexOf '(:a :b :c) :c) |
| 13:15 | clojurebot | 2 |
| 13:16 | justin_smith | that's jvm clojure only, not clojurescript though |
| 13:17 | lucasb | justin_smith: Thanks! That's it. |
| 13:18 | arrdem | justin_smith: RFC http://conj.io/contributing |
| 13:19 | justin_smith | cool, I'll check that out |
| 13:28 | deanman | ,((fn foo [x] (when (> x 0) (conj (foo (dec x)) x))) 5) |
| 13:28 | clojurebot | (5 4 3 2 1) |
| 13:30 | deanman | I'm having difficulty understanding this snippet. |
| 13:30 | justin_smith | deanman: do you have a specific question about it? |
| 13:30 | deanman | I do undestand it's an inner function that is being passed 5 as the first argument |
| 13:30 | justin_smith | ,(conj '(1 2 3) 0) |
| 13:30 | clojurebot | (0 1 2 3) |
| 13:31 | deanman | So the first time that gets evaluated it creates a list of (<something> 5) |
| 13:32 | deanman | <something> is a call to the same function ? |
| 13:32 | justin_smith | no |
| 13:32 | justin_smith | it creates a list of (5 <something>) |
| 13:33 | justin_smith | see my conj example above |
| 13:33 | deanman | Ok depending its type gets inserted at the beginning |
| 13:33 | justin_smith | depending on what's type? |
| 13:34 | deanman | conj always add at the beginning ? |
| 13:34 | justin_smith | no, it adds at the "natural" position for that collection |
| 13:34 | justin_smith | ,(conj nil 1) |
| 13:34 | clojurebot | (1) |
| 13:34 | justin_smith | that's the innermost thing that happens |
| 13:34 | gfredericks | ,(conj (conj nil 1) 2) |
| 13:34 | clojurebot | (2 1) |
| 13:35 | gfredericks | ,(conj (conj (conj nil 1) 2) 3) |
| 13:35 | clojurebot | (3 2 1) |
| 13:35 | gfredericks | etc. |
| 13:35 | justin_smith | so does this make more sense now? |
| 13:36 | deanman | Yes, it's rather the <something> that troubles me a bit. First time would be (5 <something>) and the <something> is a new call with 4 which returns (4 <something>) right ? |
| 13:37 | justin_smith | right |
| 13:37 | justin_smith | ,(when false 0) |
| 13:37 | clojurebot | nil |
| 13:38 | Cust0dian | ,(conj nil 1 2 3 4 5) |
| 13:38 | clojurebot | (5 4 3 2 1) |
| 13:43 | leifw | is there a thing like this? (with-java-properties {"java.io.tmpdir" "/my/special/directory"} ...forms...) |
| 13:43 | leifw | I'm not sure what it would be called but if anyone knows offhand |
| 13:48 | justin_smith | so you would want lexically scoped java properties? |
| 13:48 | leifw | that would be cool |
| 13:49 | leifw | though I guess they might not be thread local so that's probably not a thing |
| 13:50 | justin_smith | are you using something that needs a property to control its behavior then? |
| 13:51 | leifw | yeah |
| 13:51 | leifw | me.raynes.fs/temp-dir |
| 13:52 | justin_smith | leifw: I see an answer for making properties threadlocal |
| 13:52 | justin_smith | http://stackoverflow.com/a/9580288/2258453 |
| 13:53 | leifw | whoa, that's cool |
| 13:53 | leifw | probably too much machinery for me right now, I'll do something else, but thank you |
| 14:18 | ane | does anyone remember a blog post from this year in which there were implementations for some sort of algorithm in various lisp variants (clojure, scheme, racket etc.) |
| 14:18 | ane | and you could select them from a handy dropdown on the page |
| 14:19 | Temur | ane, this one |
| 14:19 | Temur | ? http://hyperpolyglot.org/lisp |
| 14:21 | ane | no. it was a very bloglike thing |
| 14:32 | gfredericks | how to clojure 1) start a repl 2) check twitter while repl starts |
| 14:34 | gfredericks | #protip |
| 14:36 | delaney | is it just me or is the repl in cursive come up really fast? |
| 14:36 | saik0 | But if clojure starts fast, when will we lay on our hammoks? |
| 14:37 | underplank | hi all. Im using clojure.test and use-fixtures to do setup and tear-down. Is there a way to pass arugments to the test function? |
| 14:37 | justin_smith | delaney: it uses some tricks you can use outside cursive |
| 14:37 | justin_smith | delaney: https://github.com/technomancy/leiningen/wiki/Faster |
| 14:37 | justin_smith | delaney: big ones are trampoline, with fast-trampoline, and not using nrepl |
| 14:37 | arrdem | wait you nerds don't have twitter _in_ your repl? |
| 14:38 | arrdem | nREPL over twitter... |
| 14:38 | arrdem | /s |
| 14:38 | underplank | this doesnt see to work https://www.refheap.com/100065 |
| 14:38 | underplank | *seem |
| 14:41 | brainproxy | in cljs, a (fn ... (recur ...)) boils down to a while loop wrapped in a function, so the recur step doesn't actually call the function again |
| 14:42 | brainproxy | is jvm clj, does something similar happen? |
| 14:42 | arrdem | (recur) compiles to a GOTO yes |
| 14:43 | arrdem | fn and loop generate labels, and (recur) goes to the most lexically local label with new bindings |
| 14:43 | brainproxy | iow, if i can express my function equiv as (fn ... (recur ...) <=> (fn ... (loop ... (recur ...))) |
| 14:44 | brainproxy | there's no reason to prefer the latter for perf reasons |
| 14:44 | arrdem | correct they are AFAIK strictly equivalent |
| 14:44 | brainproxy | thanks |
| 14:44 | arrdem | the latter will generate an unused LABEL statement |
| 14:44 | arrdem | but that's fre |
| 14:44 | arrdem | *free |
| 14:45 | delaney | justin_smith: yeah i'm very very new to clojure, but watch a lot of videos about it before getting started. i kept waiting for the tooling to be more there, seems to be pretty sweet now. |
| 14:46 | delaney | i've been ruined by visual studio |
| 14:46 | brainproxy | delaney: what? Emacs is the ultimate tooling! |
| 14:46 | brainproxy | ;-) |
| 14:46 | arrdem | (inc brainproxy) ;; emacs hivemind |
| 14:46 | lazybot | ⇒ 5 |
| 14:49 | brainproxy | all these parens are yours. use them together. use them in peace |
| 14:51 | arrdem | https://www.dropbox.com/s/pyrjccl5q71mmtu/4bb44752-9c0c-4c2d-b826-18d0369bb0b2.gif?dl=0 |
| 14:51 | arrdem | ^ emacs user handshake |
| 14:54 | brainproxy | nice |
| 14:55 | delaney | brainproxy: i went from vim to visual studio. everytime i tried to do anything in emacs my left pinky went on strike claiming cruel work conditions |
| 14:55 | arrdem | swapping capslock and control makes all the difference |
| 14:56 | delaney | i'm sure with a proper config file emacs is great. |
| 14:56 | gfredericks | don't even swap, who needs capslock |
| 14:57 | whodidthis | poor capslock, on vim capslock is esc, on emacs control |
| 14:58 | cfleming | delaney: Don't listen to the hivemind! |
| 14:59 | cfleming | arrdem: I'm busy right now, but I owe you a mail about RT, I can do that easily in IntelliJ to try it out |
| 15:00 | arrdem | cfleming: copy I was up bloody late hacking on Grim last night so I've spent my f/oss free time for a while no rush |
| 15:01 | cfleming | arrdem: Ok cool. I'll take a look when I get a moment - do you have your previous change in a branch somewhere public? |
| 15:02 | arrdem | cfleming: https://github.com/ox-lang/clojure if memory serves |
| 15:02 | cfleming | arrdem: Ok, will check it out. Mostly wanted a list of the methods to move. |
| 15:03 | arrdem | cfleming: that's one approach the the refactor, not the one I'd take were I to do it again but that fork builds and runs code just fine. |
| 15:03 | cfleming | arrdem: Yeah, I'm going to try to make a minimal patch to see how small it can get |
| 15:03 | arrdem | :+1: |
| 15:04 | brainproxy | arrdem: agreed re: capslock |
| 15:04 | brainproxy | delaney: maybe take a look at bbatsov's prelude, good setup right out of the box |
| 15:04 | cfleming | delaney: If you want a very quick REPL in Cursive to play around with, and you don't need macroexpansion or the test integration, use the clojure.main REPL, starts in a flash. |
| 15:05 | brainproxy | gfredericks: actually, that's true; I simply have capslock be another left-ctrl |
| 15:05 | arrdem | cfleming: oh here it is https://github.com/ox-lang/lib-clojure |
| 15:06 | cfleming | arrdem: Cool, thanks |
| 15:07 | gfredericks | brainproxy: yeah remapping your left ctrl to capslock is bound to only ever be used in error |
| 15:08 | arrdem | cfleming: nope still the wrong repo. This is it. I checked the history :P https://github.com/arrdem/clojure/tree/arrdem |
| 15:08 | arrdem | I should throw away some of these Clojure forks... |
| 15:13 | arrdem | cfleming: the ox-lang/* repos are dead. the arrdem/ repo is the real one. |
| 15:13 | cfleming | arrdem: ok, got it, thanks |
| 15:14 | TEttinger | arrdem, what did you do??? who killed ox-lang???? |
| 15:14 | arrdem | TEttinger: chill brah https://github.com/ox-lang/ox |
| 15:14 | TEttinger | hehe |
| 15:14 | arrdem | I BOUGHT THE WEBSITE OK |
| 15:14 | arrdem | I'M NOT GOING ANYWHERE |
| 15:14 | TEttinger | heh |
| 15:15 | arrdem | one day god willing I'll actually be able to hack on it... |
| 15:15 | delaney | oh i was just saying cursive's repl startup seemed fine to me |
| 15:15 | TEttinger | Made avalable for distribution eh? |
| 15:16 | delaney | its just nice to have a repl in general |
| 15:16 | TEttinger | is that a pun on vals being static and immutable? |
| 15:16 | delaney | though i still certainly don't feel at home compared to js/C# |
| 15:16 | arrdem | TEttinger: not consciously |
| 15:16 | TEttinger | hehe |
| 15:19 | TimMc | arrdem: https://s3.amazonaws.com/lowres.cartoonstock.com/animals-shaking_hands-handshakes-secret_handshakes-octopuses-squid-bve0007_low.jpg |
| 15:19 | arrdem | (inc TimMc) |
| 15:19 | lazybot | ⇒ 96 |
| 15:19 | arrdem | something something carpal tunnel |
| 15:19 | TimMc | Related: http://fc04.deviantart.net/fs71/i/2011/029/8/3/emacs_user_at_work_by_earlcolour-d38aj2x.jpg |
| 15:20 | arrdem | https://github.com/jonathanslenders/pyvim okay slackers where's my emacs in clojure |
| 15:21 | TEttinger | cfleming: I was wondering how if at all you can get javadoc/clj docstrings to show in intellij |
| 15:22 | TEttinger | is there a keybinding for this? some name I should look for? |
| 15:22 | puredanger | Press f1? |
| 15:22 | arrdem | lol |
| 15:22 | TEttinger | puredanger, I'm used to f1 opening a browser in VS, where it displays the docs automatically |
| 15:22 | puredanger | No, seriously :) |
| 15:22 | TEttinger | oh nice |
| 15:23 | gfredericks | didn't somebody have a lib that had enhanced output for clojure.test things? I thought it was jakemcc but can't find anything there |
| 15:23 | TEttinger | (as in, if you press f1 on, say, a for loop in C#, it opens up the MSDN docs for "how does i looping") |
| 15:23 | gfredericks | the thing I want in particular right now is for ex-data to get printed |
| 15:23 | gfredericks | hey speaking of which |
| 15:23 | puredanger | There is a ticket for that |
| 15:23 | gfredericks | ,(Exception.) |
| 15:24 | clojurebot | #error{:cause nil, :via [{:type java.lang.Exception, :message nil, :at [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]}], :trace [[sandbox$eval25 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Compiler eval "Compiler.java" 6792] [clojure.lang.Compiler eval "Compiler.java" 6755] [clojure.core$eval invoke "core.clj" 3079] [clojure.core$eval3$fn__4$fn__14 invoke "NO_SOURCE_FILE" 0] ...]} |
| 15:24 | gfredericks | ,(ex-info "Alex's ticket" {:foo 12}) |
| 15:24 | clojurebot | #error{:cause "Alex's ticket", :via [{:type clojure.lang.ExceptionInfo, :message "Alex's ticket", :at [clojure.core$ex_info invoke "core.clj" 4591]}], :trace [[clojure.core$ex_info invoke "core.clj" 4591] [sandbox$eval49 invoke "NO_SOURCE_FILE" 0] [clojure.lang.Compiler eval "Compiler.java" 6792] [clojure.lang.Compiler eval "Compiler.java" 6755] [clojure.core$eval invoke "core.clj" 3079] ...]} |
| 15:24 | gfredericks | puredanger: ^ is the ex-data not present there? should it be? |
| 15:25 | gfredericks | (I realize this is separate from clojure.test printing behavior) |
| 15:25 | puredanger | Seems like a good idea |
| 15:25 | puredanger | Nothing like that filed |
| 15:25 | gfredericks | I can ticket+patch if you like |
| 15:27 | gfredericks | puredanger: possible downside: I imagine idiomatically ex-data can be arbitrarily large, and therefore not the best for printing by default |
| 15:29 | Bronsa | gfredericks: it used to print it though |
| 15:29 | gfredericks | who did when? |
| 15:29 | gfredericks | (and what?) |
| 15:29 | gfredericks | I have two different topics I'm actively juggling in this conversation |
| 15:29 | puredanger | It used to tostring I think |
| 15:29 | puredanger | But no longer does |
| 15:29 | Bronsa | ExceptionInfo objects, used to print ex-data in their toString |
| 15:30 | gfredericks | we're talking about clojure.test now? |
| 15:30 | puredanger | Nope |
| 15:30 | Bronsa | no |
| 15:30 | gfredericks | dangit |
| 15:30 | puredanger | Just exinfo printing |
| 15:30 | Bronsa | &*clojure-version* |
| 15:30 | lazybot | ⇒ {:major 1, :minor 7, :incremental 0, :qualifier "alpha1"} |
| 15:30 | Bronsa | &(ex-info "foo" {:bar 1}) |
| 15:30 | lazybot | ⇒ #<ExceptionInfo clojure.lang.ExceptionInfo: foo {:bar 1}> |
| 15:31 | puredanger | Ticket welcome :) |
| 15:31 | gfredericks | oh I see, so my possible downside has been active in 1.6 this whole time is what you're saying |
| 15:31 | Bronsa | yup |
| 15:31 | gfredericks | ACK to you both |
| 15:31 | gfredericks | I'll do a ticket thing later today |
| 15:31 | puredanger | Thx |
| 16:36 | cfleming | TEttinger: https://cursiveclojure.com/userguide/documentation.html |
| 16:37 | cfleming | TEttinger: don't mean to RTFM you but, well, it's all there :-) |
| 16:37 | TEttinger | hehe |
| 16:38 | sveri | TEttinger CTRL + Shift + A is a pretty useful command in intellij, you can find most of the things you need there |
| 16:38 | TEttinger | huh, I don't see f1 there |
| 16:39 | sveri | Yea, but if you type documentation you will find "quick documentation" and it's shortcut |
| 16:39 | sveri | not sure if that is enough |
| 16:40 | TEttinger | no it's enough |
| 16:40 | TEttinger | puredanger mentioned f1 but I don't see it in cursive docs, specifically |
| 16:41 | TEttinger | i guess it may be open manual... another rtfm :) |
| 16:41 | cfleming | TEttinger: Looks like F1 does work, I always use Ctrl-J |
| 16:41 | TEttinger | ok |
| 16:41 | cfleming | TEttinger: I don't use the F-keys much for things I use a lot, too far away |
| 16:41 | cfleming | TEttinger: Or Ctrl-P on Win/Linux I think it is |
| 16:42 | TEttinger | yah, agreed. this could be tricky to get used to because I switch so often from VS to IntelliJ now |
| 16:42 | TEttinger | (two simultaneous projects, 3 languages) |
| 16:42 | sveri | ah, context switches, expensive! :D |
| 16:43 | cfleming | TEttinger: Ok, if F1 works in both then that's probably your best option, or you can remap in one or the other of course |
| 16:43 | sveri | TEttinger there is also a keymap option called "Visual Studio" maybe that's ok for you |
| 16:44 | TEttinger | haha wunderbar |
| 17:03 | bbloom_ | delaney: just edit text in vim and switch to VS to click around and use resharper w/ the mouse |
| 18:00 | lodin | Why is there an explicit check "disabling" redefinition in defmulti? Is that a feature that can be relied upon when writing macros that emit defmultis? |
| 18:02 | gfredericks | lodin: I assume it's to prevent redefinition of the dispatch function, which could put existing defmethods in a weird state |
| 18:02 | gfredericks | none of this global-extension-point stuff is very good with reloading :/ |
| 18:04 | lodin | gfredericks: I assume so too, but why check against it? Is there a legitimate use case for emitting several defmultis? |
| 18:04 | gfredericks | I figured it had more to do with reloading than with having several of them in a file |
| 18:04 | gfredericks | those two are indistinguishable in a lot of contexts |
| 18:04 | lodin | Yes, I see your point. |
| 18:10 | lodin | gfredericks: I assume that it is unsafe to rely on this feature from inside the program then, since it's for tooling. |
| 18:11 | gfredericks | lodin: so what are you up to? |
| 18:11 | lodin | gfredericks: Just writing some convenience macros. |
| 18:12 | gfredericks | lodin: and why might they defmulti multiple times? |
| 18:14 | lodin | gfredericks: Because I emit a multimethod, and if the defmulti doesn't exist I should create it, and if it does exist I should only emit the defmethod and extend the multi. |
| 18:15 | gfredericks | what does the macro do? |
| 18:16 | lodin | gfredericks: Don't make me try to explain it in just a few lines on irc. :-) |
| 18:20 | gfredericks | okay then I can't figure out the value judgments you were asking about |
| 18:21 | gfredericks | everything you've said so far is weird enough that I can't extrapolate or ignore details |
| 18:21 | lodin | :-) |
| 18:34 | alexbaranosky99 | anyone out there using leiningen's checkouts feature? I thought all I had to do was create a /checkouts dir, then add symlinks to the local source inside it |
| 18:35 | alexbaranosky99 | but when I do that and run the tests, I get an error message like: "no such var: lib-in-checkouts/my-var" |
| 18:36 | gfredericks | alexbaranosky99: you still have the lib declared in the deps? |
| 18:36 | alexbaranosky99 | gfredericks: yeah, I just took a working project that was pulling from an internal maen repo, and added the /checkouts folder |
| 18:36 | alexbaranosky99 | gfredericks: I wonder if it is a lein version issue? |
| 18:37 | gfredericks | alexbaranosky99: does that var exist in the not-checked-out version? |
| 18:37 | alexbaranosky99 | I'm on leiningen 2.5.0 |
| 18:37 | gfredericks | and does the lib have an unusual source path? |
| 18:37 | gfredericks | (hopefully that last one doesn't actually cause a problem but who knows) |
| 18:38 | alexbaranosky99 | gfredericks: I checked the soruce code -- the var is in there |
| 18:38 | gfredericks | alexbaranosky99: I mean in the version you have declared specifically, not the checkouts version |
| 18:38 | alexbaranosky99 | gfredericks: by unusual source path do you just mean the project structure of the source? IT's pretty standard leiningen template |
| 18:38 | gfredericks | yeah that's all I meant |
| 18:38 | gfredericks | I don't know how checkouts works exactly so if it just adds /checkouts/foo/src to your path that would break easily |
| 18:39 | alexbaranosky99 | gfredericks: I think I have a sound hypothesis going now |
| 18:40 | alexbaranosky99 | the classpath is picking up an old version of that jar... that doesn't have the var in question |
| 18:40 | alexbaranosky99 | because that jar is on the resource path |
| 18:40 | alexbaranosky99 | ok I think that'll fix it let me see |
| 18:40 | whodidthis | needs to also be a -SNAPSHOT and installed to m2 |
| 18:41 | gfredericks | oh yeah I should have asked about `lein classpath` first |
| 19:03 | gfredericks | oh wow I didn't realize clojure now goes out of its way to pretty-print throwables (as data) |
| 19:04 | bbloom_ | gfredericks: yeah, nobody made a big deal about it, but it's awesome |
| 19:04 | gfredericks | puredanger: opinions about key name? :data, :ex-data, :things |
| 19:04 | gfredericks | bbloom_: took me a minute to realize it wasn't my normally-pretty-printing repl |
| 19:05 | bbloom_ | gfredericks: you rocking whidbey/pudget? :-) |
| 19:05 | puredanger | you can also use the new Throwable->map function to get it as data too |
| 19:05 | gfredericks | bbloom_: yeah |
| 19:06 | gfredericks | the worst part about new clojure stuff is you can't go put it in your libs right away because of compatibility |
| 19:06 | puredanger | gfredericks: dunno, I'd probably be overruled regardless :) |
| 19:06 | gfredericks | I keep wanting to make a lib just for throwing new clojure features in when possible |
| 19:07 | puredanger | :data seems ok |
| 19:08 | puredanger | I found it hugely annoying that due to dependency issues, I could not just leverage (pprint (Throwable->map ex)) in the print-method :) |
| 19:08 | gfredericks | ack ack |
| 19:08 | gfredericks | puredanger: huh? print-throwable does call Throwable->map |
| 19:08 | gfredericks | oh wait |
| 19:08 | gfredericks | you mean clojure.pprint/pprint |
| 19:08 | gfredericks | righto |
| 19:09 | puredanger | yeah, had to rebuild a bad version of map printing |
| 19:09 | gfredericks | these are exciting times we live in |
| 19:10 | gfredericks | haha I changed :message to :massage in the printing code and the tests passed |
| 19:11 | puredanger | there aren't any tests for that printing format |
| 19:11 | gfredericks | I'll probably make some :) |
| 19:11 | puredanger | so tedious with all the line numbers and giant strings etc |
| 19:11 | puredanger | if you make some that don't suck, I'd love to have them |
| 19:11 | gfredericks | you could test a roundtrip pretty easily right? |
| 19:12 | puredanger | well... maybe |
| 19:12 | gfredericks | (= (Throwable->map ex) (read-string (print-string ex))) |
| 19:12 | puredanger | except there is no reader for #error |
| 19:12 | gfredericks | right okay so handwave that in there too |
| 19:12 | puredanger | if you make it, I'll take it :) |
| 19:13 | gfredericks | hey guys I just got a blank check to put new things in clojure |
| 19:13 | puredanger | definitely a lot of things written on that check :) |
| 19:14 | puredanger | someone else has to sign it too |
| 19:15 | brucehauman | gfredericks: I’ll sign it |
| 19:15 | gfredericks | sweet we're in business |
| 19:16 | brucehauman | lol |
| 19:16 | gfredericks | first thing is we implement that one ticket to make colons whitespace in map literals so we can all write json |
| 19:17 | brucehauman | I’m totally not signing that crap |
| 19:17 | brucehauman | :) |
| 19:17 | brucehauman | thats not even funny |
| 19:18 | gfredericks | also effective immediately I will take any patch whatsoever for $100,000 each |
| 19:18 | brucehauman | :) |
| 19:20 | puredanger | Ugh that ticket. Been trying to work up the nerve to close that for years :) |
| 19:21 | gfredericks | lol |
| 19:23 | gfredericks | I'm gonna add a ticket for making whitespace be not whitespace so we can write python |
| 19:24 | brucehauman | gfredericks: i didn’t realize your ambitions went so far beyond swerjure |
| 19:25 | gfredericks | I will call it snakejure |
| 19:26 | brucehauman | so the code is animated and you have to box it in to beable to edit it, I get it |
| 19:37 | TimMc | only commas for whitespace |
| 19:38 | gfredericks | ' ' aliases '(' and '\n' aliases ')' |
| 19:38 | gfredericks | feel free to use all four |
| 19:38 | TimMc | Instead of ))))))) you get a big blank area. |
| 19:39 | gfredericks | finally, lisp is solved |
| 19:39 | brucehauman | i can’t believe how easy that was |
| 19:52 | Code_Monk | Hi Everyone, hope all is well! can anyone kindly tell me how to set a default value for a hash-map using fnil, I couldnt get it right. |
| 19:53 | Code_Monk | its two level deep map e.g: {:A {:B 4, :C 3} :B {:A 2} .....} something like that. |
| 19:57 | justin_smith | Code_Monk: do you want a default on lookup, a default when adding to some nested structure, a default on creation? |
| 19:57 | justin_smith | fnil is usually seen when adding to a nested data structure in multiple steps |
| 19:58 | Code_Monk | I'm looking for a default on lookup, it doesnt necessarily have to use fnil. |
| 19:59 | justin_smith | ,(reduce (fn [m k] (update-in m [k] (fnil inc 0))) {} [1 2 3 1 2 1]) |
| 19:59 | clojurebot | {1 3, 2 2, 3 1} |
| 19:59 | justin_smith | ,(get-in {:a {:b {:c nil}}} [:a :b :c] 42) |
| 19:59 | clojurebot | nil |
| 19:59 | justin_smith | err... |
| 19:59 | justin_smith | ,(doc get-in) |
| 19:59 | clojurebot | "([m ks] [m ks not-found]); Returns the value in a nested associative structure, where ks is a sequence of keys. Returns nil if the key is not present, or the not-found value if supplied." |
| 19:59 | justin_smith | aha |
| 19:59 | justin_smith | ,(get-in {:a {:b {:c nil}}} [:a :b :c :d] 42) |
| 19:59 | clojurebot | 42 |
| 20:01 | Code_Monk | great! thanks guys. I appreciate it! |
| 20:02 | justin_smith | Code_Monk: fnil provides an alternate argument to a function if the input is nil, but get-in, get, etc. all take a default arg |
| 20:19 | seangrove | What's the expected way to use tools.analyzer to analyze a file on disk without loading/evaling it? |
| 20:19 | seangrove | Combine with tools.reader? |
| 20:23 | lodin | Bug? |
| 20:23 | lodin | ,(defprotocol P (p [x])) (def p' (comp identity p)) (defrecord R []) (extend-type R P (p [_] :R)) (p (R.)) (p' (R.)) |
| 20:23 | clojurebot | P |
| 20:23 | seangrove | And is there an easy way to read in an entire clojure source file with tools.reader? |
| 20:23 | seangrove | ambrosebs: ^^ |
| 20:23 | lodin | Err. Didn't show what I wanted. |
| 20:23 | lodin | On my 1.6.0 the last form with p' fails. |
| 20:24 | justin_smith | lodin: you need a do if you want separate forms on one line to run with the bots |
| 20:24 | lodin | If I contract defrecord and extend-type then it works. |
| 20:24 | lodin | ,(do (defprotocol P (p [x])) (def p' (comp identity p)) (defrecord R []) (extend-type R P (p [_] :R)) (p (R.)) (p' (R.))) |
| 20:24 | clojurebot | #error{:cause "No implementation of method: :p of protocol: #'sandbox/P found for class: sandbox.R", :via [{:type java.lang.IllegalArgumentException, :message "No implementation of method: :p of protocol: #'sandbox/P found for class: sandbox.R", :at [clojure.core$_cache_protocol_fn invoke "core_deftype.clj" 554]}], :trace [[clojure.core$_cache_protocol_fn invoke "core_deftype.clj" 554] [sandbox$ev... |
| 20:24 | lodin | justin_smith: Thanks. |
| 20:25 | lodin | ,(do (defprotocol P (p [x])) (def p' (comp identity p)) (defrecord R [] R P (p [_] :R)) (p (R.)) (p' (R.))) |
| 20:25 | clojurebot | #error{:cause "only interfaces are supported, had: sandbox.R", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.IllegalArgumentException: only interfaces are supported, had: sandbox.R, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]} {:type java.lang.IllegalArgumentException, :message "only interfaces are supported, had: sandbox... |
| 20:25 | lodin | ,(do (defprotocol P (p [x])) (def p' (comp identity p)) (defrecord R [] P (p [_] :R)) (p (R.)) (p' (R.))) |
| 20:25 | clojurebot | :R |
| 20:25 | lodin | ,(do (defprotocol P (p [x])) (defn p' [x] (identity (p x))) (defrecord R []) (extend-type R P (p [_] :R)) (p (R.)) (p' (R.))) |
| 20:25 | clojurebot | :R |
| 20:25 | lodin | But the first fails. :-/ |
| 20:28 | lodin | I.e., it fails if I deref #'p before I do extend-type. |
| 20:40 | seangrove | "Cannot recur across try" - grr, guess I'll just reach for some state then. |
| 20:42 | amalloy | lodin: if you capture the value of a protocol function, rather than its var, it doesn't get updated |
| 20:44 | gfredericks | seangrove: I think I tried to make a lib that would make that easier |
| 20:44 | gfredericks | it might have been shoddy though |
| 20:45 | seangrove | Is there a reader that knows how to create ISeq from itself? |
| 20:45 | seangrove | gfredericks: Just surprised at how imperative this stuff is, I suppose |
| 20:45 | gfredericks | yeah it was this https://github.com/gfredericks/referee |
| 20:45 | gfredericks | I think I immediately regretted it but can't remember why |
| 20:46 | seangrove | Heh, looks interesting though |
| 20:46 | gfredericks | I guess it probably works |
| 20:50 | lodin | amalloy: Yes, I noticed. :-) |
| 20:51 | lodin | amalloy: It a different behavior from multimethods though, since defmethod doesn't update the var. |
| 20:58 | gfredericks | oh snap should it include the ex-data of all the causes or only the root cause |
| 21:15 | seangrove | Is it not possible to rewind a reader? I'm trying to use tools.reader, but I want to know if there's more to read without consuming the next form |
| 21:21 | justin_smith | seangrove: in fact this is what the "PushBack" in PushBackReader is named for |
| 21:22 | seangrove | justin_smith: Ah, makes sense |
| 21:22 | justin_smith | seangrove: it supports mark and reset |
| 21:23 | justin_smith | seangrove: oh wait, it supports calling mark, but doesn't actually support marking, weird |
| 21:23 | seangrove | justin_smith: any idea why raising an exception is such a popular way of expressing EOF? I'm not sure I really understand the benefit to this approach |
| 21:24 | justin_smith | seangrove: if you are eg. reading a byte, you need some value that is not a byte to indicate the stream is empty. So either you have try/catch or a conditional after your read based on type |
| 21:25 | justin_smith | I imagine this gets messy with primitive values too |
| 21:26 | justin_smith | all that said, an interface that does one thing for a successful read and another for EOF would seem to be the better and unprovided 3rd option |
| 21:26 | gfredericks | is that why the InputStream class uses int instead of byte? |
| 21:27 | justin_smith | gfredericks: could be - also it allows pretending we can do unsigned bytes |
| 21:27 | gfredericks | I like to pretend!! |
| 21:29 | thatguy | Using compojure/ring. is there an idiom for requiring authentication for part of a site, i.e. anything with /admin in the url? |
| 21:29 | justin_smith | thatguy: sure, a middleware that wraps that subtree |
| 21:29 | thatguy | or you just call the same if statement function around all the handler methods? |
| 21:30 | thatguy | yeah, middleware seemed like a good idea, just never made one yet. think something like that exists? |
| 21:30 | thatguy | otherwise it'd be good simple one to start with I'd guess |
| 21:31 | justin_smith | (defn my-middleware [handler] (fn [request] something something handler request something)) |
| 21:31 | justin_smith | typically you end up calling the handler, maybe you alter the request or do something with the value returned by the value returned by calling the handler on the request |
| 21:32 | thatguy | ok. seems easy enough. Think something like Friend would work? probably more than i need right now, but i guess they have their own middleware. thx |
| 21:32 | justin_smith | s/the value returned by the value returned/the value returned/ |
| 21:32 | justin_smith | yes, friend has its own middleware |
| 21:33 | justin_smith | where you plug in your auth stuff |
| 21:37 | gfredericks | ha just had my first bug where I accidentally called map with 1 arg |
| 21:38 | gfredericks | will we ever get to the point where transducers aren't primarily used by accident? |
| 21:46 | gfredericks | woah; my cider repl switched to always returning one result from any eval |
| 21:46 | gfredericks | rather than N |
| 21:46 | gfredericks | so "" evals to nil and "1 2" evals to 2 |
| 21:49 | TimMc | (do %) |
| 21:49 | TimMc | (do ~@stuff) rather |
| 21:50 | gfredericks | ,(do) |
| 21:50 | clojurebot | nil |
| 21:50 | gfredericks | hrmph. |
| 21:50 | gfredericks | as a fuddy-duddy, I object to this change. |
| 21:51 | TimMc | map should also take zero arguments and randomly return one of nil, a string, or an integer. |
| 21:51 | TimMc | This will make debugging more entertaining. |
| 21:54 | gfredericks | ~as |a fuddy duddy,| I object to this change. |
| 21:54 | clojurebot | Ok. |
| 21:54 | gfredericks | ~hrmph || |
| 21:54 | clojurebot | Cool story bro. |
| 21:55 | gfredericks | ~|| hrmph |
| 21:55 | clojurebot | Titim gan éirí ort. |
| 21:55 | seangrove | Can core.match match against lists? I'm not seeing any examples on the wiki |
| 21:58 | seangrove | I guess this kind of handles it http://dev.clojure.org/jira/browse/MATCH-103 |
| 22:04 | seangrove | Seems like it isn't possible to match against nested lists, though? https://www.refheap.com/100081 |
| 22:07 | thatguy | still there justin_smith? |
| 22:13 | thatguy | well.. this is my best at an authorization middleware: any glaring flaws? |
| 22:13 | thatguy | (defn auth-required [handler] |
| 22:13 | thatguy | (fn [req] |
| 22:13 | thatguy | (if (and (not (authorized? req)) |
| 22:13 | thatguy | (.startsWith (:uri req) "/mgr")) |
| 22:13 | thatguy | (redirect "/enter") |
| 22:13 | thatguy | (handler req)))) |
| 22:16 | seangrove | thatguy: Might want to make "/mgr" a vector so you can add a few different prefixes. Nicer to grow into |
| 22:16 | seangrove | e.g. (and (not (authorized? req)) (some #(.startsWith (:uri req)) ["/mgr" "/admin"])) |
| 22:17 | thatguy | ha, was just about to ask, now i know about "some". thx |
| 22:17 | lasergoat | probably need a % in there |
| 22:17 | seangrove | thatguy: What lasergoat said, heh |
| 22:20 | thatguy | thx for the help. guess i should be in #clojure-beginners |
| 22:20 | seangrove | thatguy: I think that kind of question is fine for #clojure |
| 22:21 | seangrove | Not an op though |
| 22:34 | mischov | thatguy: https://www.refheap.com/ is a good place to put code samples you want to show |
| 22:40 | thatguy | https://www.refheap.com/100082 thx mischov. Glad to support clojure sites :) |
| 22:57 | mischov | thatguy: Updated with Sean's answer. https://www.refheap.com/100083 |