2014-11-13
| 00:00 | danielcompton | ,(require '[clojure.data.fressian :as fr]) |
| 00:00 | clojurebot | #<FileNotFoundException java.io.FileNotFoundException: Could not locate clojure/data/fressian__init.class or clojure/data/fressian.clj on classpath: > |
| 00:53 | kenrestivo | huh, learning interesting things about jna. seems like it just puts the args onto a stack and hopes for the best. |
| 00:53 | kenrestivo | if the types are wrong, oh well. |
| 00:57 | danielcompton | andyf, found another bug here http://dev.clojure.org/jira/browse/DFRS-7 |
| 01:22 | amalloy | danielcompton: your description there of changes you could make to hide the bug is super-unclear: i *think* i know what you mean by "remove a map pair from the map", and "change the vector key [3] for a keyword" is unambiguous but rather difficult to parse |
| 01:39 | rritoch | Are there snapshots released of clojure 1.7 for use with leiningen? |
| 01:41 | justin_smith | rritoch: yes, they are on maven |
| 01:41 | seancorfield | 1.7.0-alpha3 is the latest |
| 01:42 | seancorfield | We're about to push that to production |
| 01:42 | rritoch | Cool, thanks |
| 01:44 | rritoch | Ok, where is the best place to track? https://clojars.org/org.clojure-android/clojure/versions ? |
| 01:44 | rritoch | err, that is definatly the wrong link |
| 01:45 | rritoch | Will they all show at http://mvnrepository.com/artifact/org.clojure/clojure ? |
| 01:45 | swedishf1sh | rritoch: thank goodness it wasn't something else :p |
| 01:52 | rritoch | justin_smith: As a followup regarding subinterfaces, you were right that using $ would allow me to refrence them, but there were still other issues I had to deal with since deftype doesn't support extends... I ended up using gen-class accross-the-board |
| 01:53 | rritoch | https://github.com/rritoch/clj-grid-core/blob/master/src/com/vnetpublishing/clj/grid/lib/grid/webapp/filter_registration.clj |
| 01:54 | justin_smith | rritoch: remember I also mentioned proxy, which does support extending a class |
| 01:54 | justin_smith | http://clojuredocs.org/clojure.core/proxy |
| 01:59 | rritoch | justin_smith: Would proxy have access to private methods of the class that called proxy? |
| 02:00 | rritoch | justin_smith: In javaland it's possible to pass a self variable into proxy-like strucures via a static variable |
| 02:01 | rritoch | justin_smith: The reason I ask is that there are 2 methods being exposed in the servlet wrapper that I would prefer to be private, but these filter registrations need to be able to access them. |
| 02:02 | rritoch | justin_smith: the getFilterMaps and addFilterMap methods |
| 02:05 | rritoch | justin_smith: Well either way, the gen-class's are working for now. Eventually the entire thing is going to be refactored anyhow, right now I'm simply implementing whatever works. |
| 02:24 | rritoch | Anyhow, now that I can implement these subinterfaces there's no need for any java code, and I should be able to use it to deliver static content from OSGi modules. I'm also considering adding a separate servlet for handling .clj script delivery. It would be a short-circuit to bypass all OSGi support code until it's actually needed (as a fallback). |
| 04:46 | kenrestivo | so, using gloss, how might it be possible to convert 0xff to a byte-buffer? i.e. (gloss.core.formats/to-byte-buffer 0xff) |
| 04:47 | kenrestivo | thanks to signedness, 0x7f is the maximum :-/ |
| 04:48 | kenrestivo | ah, nevermind, i can blow off gloss, and use jna/make-cbuf, and it doensn't give me grief. |
| 05:08 | mnngfltg | Turns out I need a nested when-let quite often: (when-let [a (f1) b (f2 a)) -- Is there something people commonly use in this situation? |
| 05:08 | mnngfltg | (To explain: it should short-circuit for each binding-pair if the expression given is nil) |
| 05:19 | raspasov | mnngfltg: this is something I've realized sometimes as well, would be cool to see a macro solution to this! |
| 05:27 | mnngfltg | raspasov, this is quite similar to the idea: https://brehaut.net/blog/2011/error_monads |
| 05:48 | yogsototh | Hi could someone explain me why in the example of kafka consumer here: https://github.com/pingles/clj-kafka |
| 05:48 | yogsototh | there is a "shutdown" function? |
| 05:49 | yogsototh | my google fu is weak concerning (with-resource) |
| 05:53 | mnngfltg | yogsototh, speculation: the `consumer` is to be used only once, so you can pro-actively close the consumer when you're ready? |
| 05:53 | schmir | yogsototh: https://github.com/pingles/clj-kafka/blob/93a89f41bb09b6167d559b3f90ee2053fbb54b43/src/clj_kafka/core.clj#L17 |
| 05:53 | schmir | it's being called after body has executed |
| 05:54 | yogsototh | mnngfltg, schmir: thanks! |
| 05:55 | mnngfltg | schmir, ah that's not really obvious, with-resource needs a doc string |
| 05:55 | yogsototh | I thought with-resource was a basic clojure macro not a clj-kafka one |
| 05:56 | schmir | yeah, when you first look at the code it looks like someone forgot to put parentheses around shutdown |
| 05:57 | mnngfltg | yogsototh, that's the problem with (use ...) |
| 06:18 | pal | hi, any idea why my compojure app returns 500 error on http://localhost:8080/app whereas http://localhost:8080/app/ works fine? is if fixable? |
| 06:22 | rritoch | mnngfltg: Here is a macro that does the when-let recursion for you |
| 06:22 | rritoch | ,(defmacro when-and-let [bnds & body] (loop [a (partition 2 bnds) b (cons 'do body)] (if (empty? a) b (recur (butlast a) (cons 'when-let (conj (list b) (vec (last a))))))) |
| 06:22 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 06:22 | rritoch | ,(defmacro when-and-let [bnds & body] (loop [a (partition 2 bnds) b (cons 'do body)] (if (empty? a) b (recur (butlast a) (cons 'when-let (conj (list b) (vec (last a)))))))) |
| 06:22 | clojurebot | #'sandbox/when-and-let |
| 06:22 | schmir | pal: compojure distinguishes between these two urls |
| 06:23 | rritoch | ,(when-and-let [a "A" b "B" c "C"] (println c)) |
| 06:23 | clojurebot | C\n |
| 06:23 | rritoch | ,(when-and-let [a "A" b nil c "C"] (println c)) |
| 06:23 | clojurebot | nil |
| 06:23 | schmir | pal: you have to explicitly handle both cases |
| 06:24 | mnngfltg | rritoch, great! |
| 06:24 | Kototama | schmir: how to I match the one without a slash? |
| 06:25 | rritoch | mnngfltg: It is lacking any sanity check though, in other words it doesn't verify you passed the correct number of args... It may be a useful improvement to this macro, but either way, it seems to work. |
| 06:25 | Kototama | I have something like (context "app" (GET "/" ... |
| 06:25 | mnngfltg | Kototama, do you proxy the request? |
| 06:25 | Kototama | no |
| 06:26 | Kototama | just running it under tomcat |
| 06:26 | schmir | Kototama: (GET "/app" ....) |
| 06:27 | mnngfltg | Kototama, just remember there is not GET "", the root always has a "/" |
| 06:28 | Kototama | but why do I get an internal server error when not typing / then? |
| 06:31 | mnngfltg | Kototama, maybe it's related to tomcat |
| 06:45 | CookedGryphon | Does the cast function automatically type hint things too? |
| 06:47 | CookedGryphon | I'm having trouble with a function that returns an object (android getService) which you should expect to be of a certain type (in this case AccountManager) |
| 06:47 | CookedGryphon | and I can't seem to fix the reflection warning |
| 06:47 | dysfun_ | what have you tried? |
| 06:48 | CookedGryphon | so I'm using neko which wraps that with a macro, and (.getAccountsByType ^AccountManager (get-service :account) "com.google") gives a warning |
| 06:48 | CookedGryphon | obviously without the ^AccountManager you get the warning too |
| 06:49 | dysfun | *nod* |
| 06:49 | CookedGryphon | then I thought, as it *is* actually returning an Object, perhaps I need to do something more, so I tried (.getAccountsByType (cast AccountManager (get-service :account) "com.google") |
| 06:49 | CookedGryphon | but that gives me a slightly different warning, target class is unknown |
| 06:50 | dysfun | sorry, i have nothing useful to add |
| 07:12 | andyf_ | CookedGryphon: Is get-service a macro ? |
| 07:13 | CookedGryphon | andyf_: yes, it is |
| 07:13 | CookedGryphon | is that the issue? |
| 07:13 | andyf_ | If so, by default Clojure eliminates type hints on macro invocations |
| 07:13 | andyf_ | unless you write the macro very specially |
| 07:13 | CookedGryphon | aha, I was considering removing the usage of this anyway |
| 07:13 | CookedGryphon | and calling it directly |
| 07:13 | andyf_ | workaround: Use a type-hinted let binding around the form, e.g. (let [^Type x (get-service ...)] (form with x in it)) |
| 07:14 | andyf_ | I wouldn?t normally know that, but recently finished writing a linter for Eastwood that would warn about that. |
| 07:14 | andyf_ | (the useless type hint) |
| 07:16 | andyf_ | If it is a Leiningen project, it is pretty easy to try it out. |
| 07:16 | andyf_ | And now, even if it isn't, you can invoke it from the REPL |
| 07:16 | andyf_ | Like just about any lint tool, there will be some useless warnings. |
| 07:16 | dysfun | *nod* |
| 07:18 | dysfun | heh, i have to fix the syntax errors in the code i'm writing first |
| 07:20 | andyf_ | Unlike most lint tools, it doesn't handle syntax errors gracefully |
| 07:26 | dysfun | hrm, 7 warnings |
| 07:26 | dysfun | not too bad |
| 07:27 | dysfun | but then again, the codebase isn't that big (yet) |
| 07:27 | andyf_ | more importantly, are they actually signs of problems in the code, or just noise? |
| 07:27 | dysfun | i'm working through them |
| 07:29 | dysfun | what's "unlimited use" mean? |
| 07:31 | dysfun | oh, i get it, as in (:use |
| 07:31 | andyf_ | simply that there is a :use inside of an ns form that does not do :refer or :only - https://github.com/jonase/eastwood#unlimited-use---use-statements-that-do-not-explicitly-limit-the-symbols-they-refer |
| 07:32 | andyf_ | There are links to more details on each linter (except 1 or 2 of the) here in the docs https://github.com/jonase/eastwood#whats-there |
| 07:32 | andyf_ | I will probably add URLs to the more detailed docs in the warnings themselves at some point. |
| 07:33 | dysfun | well i've just been through the entire list and i don't think any of the recommendations were unreasonable |
| 07:33 | dysfun | people may disagree with the house style, but *shrug* |
| 07:33 | andyf_ | The :unlimited-use thing is a personal preference, really. Some people really don't like them. |
| 07:34 | andyf_ | It has turned up actual bugs in some programs. |
| 07:34 | dysfun | well i don't like it with third party modules, but local stuff where you can just open the file, i think it's okay |
| 07:35 | andyf_ | Linters can be disabled by putting an :eastwood key with an options map in your .lein/profiles.clj file or your project's project.clj file, if you wish. e.g. :eastwood {:exclude-linters [:unlimited-use]} |
| 07:36 | andyf_ | There isn't yet a way to disable individual warnings by annotating source code, but that should be added in a future release. |
| 07:37 | dysfun | what's the non-deprecated ring.middleware.file-info ? |
| 07:39 | clgv | humm, eastwood can't handle the threading macros... |
| 07:40 | dysfun | oh it raised one of those for me, but i took it as more suggestive |
| 07:40 | dysfun | in which case, it has a point |
| 07:40 | clgv | not really |
| 07:40 | dysfun | made me look at it again and mentally verify it |
| 07:40 | clgv | it spams me with warnings inside of threading macros |
| 07:40 | dysfun | i can see that would get annoying after a while though |
| 07:43 | clgv | wasn't there some analyzing tool using tools.analyzer.jvm as well? |
| 07:44 | CookedGryphon | just using eastwood for the first time on my codebase, what's this wrong-tag return type of function on arg vector should be fully qualified or may cause exception if called from another namespace about? |
| 07:44 | clgv | oh eastwood does but does not say so in its project.clj |
| 07:44 | CookedGryphon | is that a clojure bug, or just some non-obvious behaviour |
| 07:44 | andyf_ | sorry, been debugging for a few mins. reading |
| 07:45 | andyf_ | clgv: It does have issues with threading macros and the suspicous-expression linter. Should be able to fix that in the next release |
| 07:46 | clgv | andyf_: that would be great :) |
| 07:46 | andyf_ | clgv: Eastwood does use tools.analyzer.jvm |
| 07:46 | clgv | andyf_: why is it not in the project.clj? |
| 07:46 | andyf_ | CookedGryphon: Links to more docs on all of the linters are here in the readme: https://github.com/jonase/eastwood#whats-there |
| 07:46 | clgv | oh what? "copieddeps ..." :O |
| 07:47 | andyf_ | Click on a [more] link there and you'll see a longer explanation. Some people call it a bug, Rich doesn't. |
| 07:47 | andyf_ | clgv: By doing the copieddeps thingy, it avoids Eastwood's dependencies conflicting with the project's dependencies that you are linting. |
| 07:47 | CookedGryphon | andyf_: ah yes, thanks, sorry I've come to expect READMEs to be uselessly short :P |
| 07:48 | clgv | andyf_: ok, that's a leiningen infrastructure problem, I guess |
| 07:48 | andyf_ | clgv: Before I did that, any project that depended upon a too-different version of core.cache or core.memoize would cause exceptions to be thrown, unrelated to your program |
| 07:49 | andyf_ | clgv: Not really a Leiningen thing -- Eastwood must eval your code in the same JVM where Eastwood is running in order to do its thing |
| 07:49 | andyf_ | At least, that is how it is implemented. It would be a lot more work to *not* eval your code. |
| 07:49 | clgv | andyf_: oh right |
| 07:50 | andyf_ | CookedGryphon: Eastwood's docs are perhaps too long, but hopefully the links to sections on different linters should help. |
| 07:50 | andyf_ | and it might be educational on some deep dark corner of Clojure you've never realized before. |
| 07:51 | andyf_ | clgv: Here is what the dependencies would look like without copieddeps hack: https://github.com/jonase/eastwood/blob/master/copy-deps-scripts/deps/project.clj |
| 07:51 | clgv | andyf_: is listing the licenses of all dependencies mandatory in general? |
| 07:52 | andyf_ | clgv: I was being squeaky clean there. I doubt anyone would raise a stink. |
| 07:53 | clgv | ok ;) |
| 08:07 | clgv | hmmm `apply` should have inline arities... |
| 08:07 | clgv | oh wait, that wont help either |
| 08:26 | Kototama | mnngfltg: having (GET "/app") (context "/app" (GET "/")) may fix the problem, i need to test in tomcat now |
| 08:27 | samflores | how can I make something like a blocking take (<!!) in ClojureScript? |
| 08:28 | samflores | (I know it would freeze my app) |
| 08:28 | agarman | @sam |
| 08:28 | agarman | @samflores how would you ever unblock? |
| 08:31 | samflores | It would block after getting something from the channel, right? |
| 08:31 | samflores | *unblock |
| 08:31 | agarman | on a single thread how does something get put on the channel? |
| 08:31 | agarman | when you're holding the only thread |
| 08:32 | samflores | I was thinking on something diferent than "hold the thread" but achieving the similar results |
| 08:32 | samflores | like a state machine doing nothing (looping forever) until it gets something |
| 08:33 | mavbozo | samflores: like jQuery.ajax{"async" : true} ? |
| 08:33 | samflores | (sorry if it sound stupid, I have almost no idea how core.async works on cljs) :p |
| 08:33 | mavbozo | sorry |
| 08:33 | samflores | yep. something like that |
| 08:34 | clgv | samflores: why does <! not suffice? |
| 08:35 | mavbozo | samflores: for example, set async to false on jquery.ajax request |
| 08:38 | agarman | samflores: are you wanting a general blocking take (not just a synchronous ajax request)? |
| 08:38 | samflores | I'm using chord (https://github.com/james-henderson/chord) to establish a ws connection and I'd like to block (ws-ch) until the server server response arrive (success or fail) |
| 08:39 | clgv | samflores: I guess the proper way is to do this fully async so just use <! inside a `go` block |
| 08:39 | samflores | that's how I'm using it now |
| 08:40 | clgv | and the problem is? |
| 08:45 | samflores | keeping in sync other parts of the application that depends on the connection being established |
| 08:49 | clgv | samflores: you can just use a channel to communicate that the connection was established |
| 08:50 | samflores | clgv, yeah I know that... I was just wondering whether that's the only way. |
| 08:51 | samflores | thanks you all |
| 09:07 | mnngfltg | Kototama, did you find the issue? |
| 09:13 | razum2um | why keywordize-keys slows it down so much? https://www.refheap.com/ebe1d78863a178e23c27da0fa |
| 09:15 | mnngfltg | razum2um, I heard a rumor that creating keywords is a slow operation in clojure |
| 09:15 | mnngfltg | (although one that will be optimized for 1.7) |
| 09:18 | razum2um | mnngfltg: hm, dont see it https://www.refheap.com/fc4cd52ed9a0d2683397df7dc |
| 09:19 | Bronsa | razum2um: that's not the same at all, in the first example you're creating the keywords one time only at compile time |
| 09:19 | perplexa | hmmm i have a (mapv (fn [a] (future ...))) that runs into a race condition on hadoop. so my temporary workaround is to have each future sleep 100msec more than the previous, how would i do that? |
| 09:19 | Bronsa | razum2um: in the second example you're creating them 1e4 times at runtime |
| 09:20 | razum2um | Bronsa: but is there any good way to get records from parsed json which parsed results in stringified keys? I know this keys already |
| 09:22 | Bronsa | razum2um: if you already know the keys, looking up in a {"key" :key" ..} map might be faster than creating a new keyword everytime |
| 09:22 | mgaare | razum2um: the slowness comes from the fact that keywordize-keys calls (keyword ) on all the string keys, which is slow. One way to do what you want, where you know the keys in advance, is replace that with a map lookup |
| 09:22 | clgv | perplexa: race condition? you should probably do some kind of coordination then |
| 09:23 | perplexa | clgv: you would assume that YARN's FairScheduler is safe against race conditions. |
| 09:23 | perplexa | there's nothing i can do about it right now. |
| 09:24 | Bronsa | razum2um: try replacing keywordize-keys with clojure.set/rename-keys |
| 09:24 | clgv | perplexa: but the timeout quickfix seems pretty esoteric |
| 09:24 | CookedGryphon | in cider/emacs, is there something to find what calls this, etc |
| 09:25 | perplexa | clgv: that is true. the scheduler still throws java.util.ConcurrentModificationException and i can't wait until it is fixed in YARN and from the logs i can tell that the futures hammer the application master all at the same msec, randomly causing that exception |
| 09:26 | perplexa | there's already similar bugs in YARN-1692 |
| 09:27 | perplexa | i run on 2.5.0, which is supposed to have the fix, though. so it's most likely still not fixed at some point. but i need a dirty hack around the problem asap. |
| 09:27 | perplexa | i just have no idea how i'd have an incremental value in (map ..) - i probably don't at all, huh? |
| 09:30 | Glenjamin | perplexa: like map-indexed? |
| 09:31 | perplexa | Glenjamin: oh nice! except it is lazy :( mapv-indexed doesn't exist |
| 09:31 | Glenjamin | ,(mapv list [:a :b :c] (range)) |
| 09:31 | clojurebot | [(:a 0) (:b 1) (:c 2)] |
| 09:32 | Glenjamin | map stops at the shortest seq |
| 09:32 | Glenjamin | so (range) will give you a counter |
| 09:33 | perplexa | nice, thanks! |
| 09:33 | perplexa | (inc Glenjamin) |
| 09:33 | lazybot | ⇒ 8 |
| 09:34 | deg | I'm trying to get cider working, and am stuck.. Probably more of an emacs question, but hoping someone here can give me a hand. |
| 09:35 | Glenjamin | there's a cider channel now, but i've forgotten the name |
| 09:36 | deg | Thanks. Looks like it is #clojure-emacs |
| 09:37 | razum2um | Bronsa: rename-keys is twice as slow as the keyworded hash insertion. I just wonder, why isn't there a core macro for fast keywordize-keys based on known keys and lookup |
| 09:50 | Bronsa | razum2um: often keywordizing leads to more problem than it's worth |
| 09:51 | Kototama | mnngfltg: nope |
| 09:53 | Kototama | https://stackoverflow.com/questions/11055608/tomcat-is-not-adding-trailing-slash-to-web-apps-context maybe because the mapping generated by ring-uberwar is /* instead of / ? I need to explore further |
| 10:08 | razum2um | Bronsa: I thought I'd use a value list but it's not working this way (apply Rec. [1 2]) |
| 10:09 | justin_smith | you can't apply a constructor |
| 10:09 | Bronsa | razum2um: use the ->Rec ctor |
| 10:09 | Bronsa | razum2um: "Rec." is meaningless, (Rec. ..) is clojure syntax that macroexpands to (new Rec ..) |
| 10:09 | razum2um | thank, apply to -> works |
| 10:10 | Bronsa | ,(macroexpand-1 '(String. "")) |
| 10:10 | clojurebot | (new String "") |
| 10:10 | justin_smith | ,(macroexpand-1 '(apply String. [""])) ; doesn't work |
| 10:10 | clojurebot | (apply String. [""]) |
| 10:12 | Kototama | mnngfltg: yeah so the solution on the stackoverflow works |
| 10:13 | Kototama | i'll open a ticket on lein-ring |
| 10:13 | mnngfltg | Kototama, looks like a tomcat problem mainly right? |
| 10:13 | mnngfltg | but opening a ticket is useful anyway, for further reference |
| 10:14 | Kototama | i'm not an expert, but it seems lein-ring should generate <url-pattern>/</url-pattern> instead of <url-pattern>/*</url-pattern> |
| 10:14 | Kototama | but maybe they do that for a good reason, we will see |
| 10:17 | mnngfltg | right |
| 10:22 | Kototama | here we go https://github.com/weavejester/lein-ring/issues/139 |
| 10:31 | mdrogalis | bbloom_: I swear GitHub just changed their Clojure syntax highlighting *again* |
| 10:31 | llasram | mdrogalis: Hey, it seems to be mostly working! |
| 10:32 | jeremyheiler | mdrogalis: i noticed that meta maps are grayed out a bit |
| 10:32 | jeremyheiler | thought that was nice |
| 10:33 | mdrogalis | http://i.imgur.com/qbLRsxE.png |
| 10:33 | mdrogalis | What happened to numbers?! D: |
| 10:33 | llasram | Hmmmm |
| 10:33 | jeremyheiler | ew |
| 10:33 | justin_smith | mdrogalis: clearly numbers are very important, and likely errors |
| 10:33 | mdrogalis | My whole program is an error. |
| 10:33 | justin_smith | so they are highlighting them, to let you know you probably used them accidentally |
| 10:33 | llasram | Yeah, and I'm getting some weird highlighting of namespaced symbols which have the same basename as core symbols |
| 10:34 | justin_smith | (inc mdrogalis) |
| 10:34 | lazybot | ⇒ 7 |
| 10:34 | justin_smith | I know that feeling |
| 10:37 | mavbozo | conceptually, Java reference and C pointer are same right? It's just something that points to another thing |
| 10:37 | puredanger | anyone here both know Eastwood well and going to the Conj? |
| 10:37 | puredanger | I think that would be a cool unsession |
| 10:38 | justin_smith | mavbozo: you can use addition to get the "next item" from a pointer |
| 10:38 | justin_smith | mavbozo: I don't think java references provide or support anything like that |
| 10:39 | justin_smith | of course they are implemented as pointers, but loops are implemented as goto, in both cases what we have to work with is more restricted |
| 10:41 | dbasch | also java references are tracked by garbage collectors |
| 10:41 | jeremyheiler | mavbozo: also, java references are pass-by-value, so if you pass a reference into a method, that reference cannot be destroyed. |
| 10:41 | jeremyheiler | by that method |
| 10:41 | andyf_ | puredanger: I guess it wouldn't be so cool if it were done via remote video :) |
| 10:41 | puredanger | that would be harder to arrange :) |
| 10:42 | mavbozo | justin_smith: you can get "next item" from C pointer by addition? Don't you get the next thing in memory address after the thing that is pointed by that pointer? |
| 10:42 | puredanger | andyf_: do you know anyone else that would be a good candidate? you should submit a talk on it for Clojure/West |
| 10:42 | justin_smith | dbasch: indeed, references are a more restricted concept (in a good way) that provide a lot of certainty that a pointer cannot |
| 10:42 | dbasch | (dec pointers) |
| 10:42 | lazybot | ⇒ -1 |
| 10:43 | dbasch | dec pointers should segfault |
| 10:43 | andyf_ | puredanger: Sean Corfield uses it for linting production code. Not sure if he is going. Nicola I'm guessing has class in Italy, but I don't know for sure. |
| 10:43 | andyf_ | Jonas Enlund. hiredman likes to use it. |
| 10:45 | justin_smith | mavbozo: right, the next item in memory, it's an operation defined and frequently used in c, and a reference has no corresponding operation |
| 10:45 | dbasch | mavbozo: the c compiler knows what you declared the pointer to be, so when you do p++ it increments it by the size of the type |
| 10:46 | andyf_ | puredanger: Clojure/West talk sounds like a good idea. Probably not the right time to ask where/when it will be, a few days before the Conj :) |
| 10:46 | puredanger | andyf_: I don't think Sean or Jonas will be there. hiredman= Kevin right? |
| 10:46 | andyf_ | puredanger: Kevin Downey, I believe. |
| 10:46 | mavbozo | so, in general, there are symbols, references, values, and boxes which contain values |
| 10:46 | mavbozo | those concepts are applicable to any programming languages |
| 10:47 | puredanger | andyf_: <unconfirmed>c/w will probably be Portland in mid-April</unconfirmed> |
| 10:47 | puredanger | we are trying to lock down contracts so we can make that official next week at the conj |
| 10:47 | dbasch | a typical error in C is incrementing the pointer when you wanted to increment the pointed value, or viceversa |
| 10:47 | mavbozo | for example, in clojure, "+" is a symbol which names a reference, in this a var + |
| 10:48 | mavbozo | which points to values a function in clojure.core |
| 10:48 | puredanger | hiredman: any interest in leading an Eastwood unsession at the conj? just an idea |
| 10:48 | mavbozo | *which points to a value that is a function + in clojure.core |
| 10:49 | mavbozo | because var in a reference in clojure, var is reference right? |
| 10:49 | andyf_ | hiredman: If it helps at all, I have some slides I could spiff up from a talk almost a year ago, plus add some notes. |
| 10:49 | clojurebot | Pardon? |
| 10:53 | justin_smith | mavbozo: everything in the jvm that is not a primitive is a reference type |
| 10:53 | justin_smith | though there has been talk of implementing value types... |
| 10:59 | justin_smith | mavbozo: and there is some subtlety (and some oddness) to be found in the jvm's model of things. For example everything that is not a primitive is an object (an instance of some class), and every executable method must belong to some object. |
| 11:02 | justin_smith | wait, sorry, the methods only belong to classes |
| 11:03 | mavbozo | justin_smith: and in clojure, we only deal with values and reference types (var, atom, agent, refs) right? |
| 11:03 | justin_smith | in this sense C, which supports function pointers, and does not assign ownership of functions to datatypes, is closer to being a functional language than java is. But we find our way by making "functions" that are classes with .invoke methods |
| 11:04 | justin_smith | mavbozo: local bindings are not any of those |
| 11:04 | justin_smith | ,(let [a 0] a) |
| 11:04 | clojurebot | 0 |
| 11:04 | justin_smith | a is not a var, atom, agent, or ref in that context |
| 11:04 | justin_smith | it is a binding |
| 11:05 | justin_smith | or, basically equivalent: ##((fn [a] a) 0) |
| 11:05 | lazybot | ⇒ 0 |
| 11:05 | justin_smith | once again, a is not any of those reference types |
| 11:06 | mavbozo | justin_smith: wait, there are more reference types? |
| 11:06 | justin_smith | no, a is not a reference type in either of those cases |
| 11:06 | justin_smith | in your code, it is a binding |
| 11:07 | justin_smith | when compiled, it is substituted appropriately, but what it is substituted with is an implementation detail |
| 11:10 | andyf_ | justin_smith: I haven't read enough compiled byte code to be authoritative, but isn't such a binding usually a pointer/reference on the stack or in a register, rather than in a class or object somewhere? (exception: when you successfully type hint the bound name to a primitive type) |
| 11:10 | justin_smith | andyf_: I thought it was a slot in the compiled object that is the function |
| 11:11 | justin_smith | andyf_: I could be wrong |
| 11:11 | stuartsierra | It varies depending on context. |
| 11:11 | justin_smith | so "implementation detail" is safe |
| 11:11 | stuartsierra | Closed-over locals become instance fields in the function's class. |
| 11:12 | stuartsierra | Other locals just become method-local variables in Java bytecode. |
| 11:12 | stuartsierra | Maybe there is some optimization there, I'm not sure. |
| 11:13 | Bronsa | stuartsierra: no that's pretty much it |
| 11:14 | clgv | you get to see a lot final vars when you use a java decompiler ;) |
| 11:14 | puredanger | and locals clearing |
| 11:15 | clgv | yeah locals clearing is the confusing stuff when you see decompiled clojure for the first time |
| 11:15 | justin_smith | clgv: var in the java, not clojure sense, right? |
| 11:15 | gfredericks | (defn ^:public ^:static ^:void main [^String[] args] ...) |
| 11:15 | puredanger | clgv: I find it clearer to read the bytecode itself usually but I may be warped |
| 11:16 | gfredericks | puredanger: and you edit your files with M-x butterfly? |
| 11:16 | puredanger | I use that to edit my butterflies |
| 11:16 | stuartsierra | http://xkcd.com/378/ |
| 11:17 | justin_smith | puredanger: sometimes the reduced ambiguity of a weak language is refreshing |
| 11:17 | puredanger | (inc stuartsierra) |
| 11:17 | lazybot | ⇒ 14 |
| 11:17 | justin_smith | it reduces ambiguity |
| 11:17 | gfredericks | huh. does C-x M-c M-butterfly even make sense? |
| 11:17 | justin_smith | of course not |
| 11:17 | stuartsierra | Try `M-x butterfly` some time though. |
| 11:17 | gfredericks | clojurebot: reduced ambiguity |reduces| ambiguity |
| 11:17 | clojurebot | In Ordnung |
| 11:17 | clgv | justin_smith: yes |
| 11:18 | gfredericks | stuartsierra: I tried it and was too scared to answer the question |
| 11:18 | clgv | puredanger: I am not fluent in bytecode, so I prefer the pseudo java view ;) |
| 11:18 | TimMc | gfredericks: It has side effects either way you answer it! |
| 11:19 | gfredericks | TimMc: C-g |
| 11:19 | TimMc | mu |
| 11:21 | mavbozo | Do you really want to unleash the powers of the butterfly? (yes or no) , I answer no. I am too affraid of the side effects |
| 11:22 | gfredericks | vote NO to unleashing the powers of the butterfly! |
| 11:24 | mavbozo | justin_smith: thank you for your exposition about reference in clojure and java |
| 11:24 | justin_smith | np |
| 11:25 | justin_smith | mavbozo: lucily, most of the time, you can deal with clojure code in terms of immutible values and pure functions, but that other stuff helps when the abstractions leak |
| 11:27 | justin_smith | (big leakages include stack traces, profiling one's code, and random corner cases of the language) |
| 11:28 | hiredman | puredanger: are you thinking BoF sort of unsession or short presentation sort of unsession? |
| 11:28 | puredanger | bof |
| 11:28 | puredanger | well, whatever really |
| 11:28 | puredanger | I just think it would be cool for more people to know about it |
| 11:28 | hiredman | sure, I can facilitate the heck out of that |
| 11:28 | puredanger | can you add a session here? https://github.com/cognitect/clojure-conj/wiki/Clojure-conj-2014-Unsessions |
| 11:29 | mavbozo | justin_smith: i am in a middle of trying to applying my understanding on general notion of symbol, reference, value, and box which contain value |
| 11:29 | mavbozo | justin_smith: to clojure, and java |
| 11:30 | puredanger | mavbozo: you might like this: https://www.youtube.com/watch?v=8NUI07y1SlQ |
| 11:30 | mavbozo | justin_smith: maybe .NET next |
| 11:31 | mavbozo | puredanger: i'll watch it. thx. |
| 11:31 | enn | Hello ... I have a pre-condition check in a clojure.test :each fixture. When it fails, there is nothing in the output to identify which test the fixture was running for. Is there any way to get this information? |
| 11:31 | justin_smith | enn: (test/testing "context of contained code" ...) |
| 11:32 | justin_smith | enn: oh wait |
| 11:32 | justin_smith | that doesn't help in a precondition |
| 11:33 | justin_smith | enn: I would write a precondition test as a function, and call it inside each test to reduce ambiguity |
| 11:33 | justin_smith | enn: alternatively you could try to get a name from the f that the precondition is wrapping I guess... |
| 11:35 | enn | justin_smith: we tried that, the name is nil, unfortunately |
| 11:35 | enn | I guess the answer is "don't use fixtures for that" :) |
| 11:35 | andyf_ | hiredman: Feel free to ask me any questions you might have, here or email is fine, or we could even arrange a phone call if that would help. Then I'll tell you all the stuff that you have to ask Bronsa :) |
| 11:35 | justin_smith | enn: deftest creates a function, you should be able to get *something* from that function or its metadata |
| 11:36 | justin_smith | enn: even the ugly-ass printed version of a function often has something close to its own name inside |
| 11:36 | justin_smith | ,(fn foo []) |
| 11:36 | clojurebot | #<sandbox$eval25$foo__26 sandbox$eval25$foo__26@1a05f56> |
| 11:36 | enn | justin_smith: I think it's an anonymous function, though |
| 11:36 | justin_smith | enn: so was foo |
| 11:37 | stuartsierra | clojure.test generates anonymous functions to wrap fixtures around tests. |
| 11:37 | justin_smith | stuartsierra: ahh, so there would be no meaningful metadata or name hidden in that function value |
| 11:39 | puredanger | stuartsierra: if those anonymous functions had names, their class would also contain the name |
| 11:39 | stuartsierra | Yes but it would always be the same name. |
| 11:40 | puredanger | well that wouldn't help much |
| 11:41 | hiredman | puredanger: done |
| 11:41 | justin_smith | yeah, nothing useful there https://www.refheap.com/93295 |
| 11:42 | puredanger | hiredman: thanks! |
| 11:43 | hiredman | andyf_: those slides you mention would be super, although I vaguely think I've seen an eastwood slide deck somewhere before |
| 11:45 | hiredman | andyf_: oh, yeah, I see you say you gave that talk, so I must have seen them, I am thinking for a bof style session no slides, but I should make sure I know what I am talking about |
| 11:49 | andyf_ | hiredman: Sure. They were hastily constructed, but I could write down a few notes to go with them. |
| 12:13 | lostman | hi all. I'm wondering whether there's such thing in clojure as 'reverse destructuring'. more often than not I have a variable that I want to put in a map under the key that's the same as variable name: (let [x 33] {:x x}). is there any shorthand for that? I don't like spelling things twice |
| 12:14 | llasram | lostman: Not in core, but it's a trivial macro I'm sure has been written many times |
| 12:15 | llasram | lostman: something like https://gist.github.com/llasram/9510281 |
| 12:15 | justin_smith | it is implemented in flatland/useful also |
| 12:15 | llasram | well there you go |
| 12:16 | lostman | cool, thx |
| 12:16 | verma | what do I need to do to get clojuredocs examples stuff to show in lein repl? |
| 12:17 | EvanR | im using prismatic/schema to describe some records defined by some real life committee, and sure seems like "required key by default" is the opposite of what i want |
| 12:17 | EvanR | even the very few fields which are listed as required are in practice possibly missing |
| 12:18 | andyf_ | verma: There is a client that still works here: https://github.com/jafingerhut/cd-client |
| 12:19 | andyf_ | verma: I believe the API that it uses with ClojureDocs.org web site is an old still-supported one, as in the queries still work against the server, but I think it is returning examples from a snapshot in time a month or two ago. |
| 12:19 | verma | andyf_: hmm thanks! |
| 12:19 | verma | andyf_: it integrates with my repl/ |
| 12:19 | andyf_ | verma: There is a Github issue open for ClojureDocs.org to update the data retrieved via this API, but I don't know when that might happen. |
| 12:19 | EvanR | luckily i have a keyboard macro to wrap every field in (s/optional-key |
| 12:21 | andyf_ | verma: It also has instructions for downloading and storing a local 'snapshot' file of all the data (which isn't very big - couple megabytes I think) that you can use with the same commands at the REPL, even without a live Internet connection |
| 12:22 | verma | andyf_: nice! |
| 12:22 | verma | EvanR: ) ;; sorry OCD :P |
| 12:25 | Glenjamin | EvanR: (defn optional-keys [m] (into (empty m) (for [[k v] m] [(s/optional-key k) v]))) |
| 12:30 | EvanR | Glenjamin: good call, always wonder if things like this are acceptable |
| 12:37 | TimMc | ,(+ 1 2))))) |
| 12:37 | clojurebot | 3 |
| 12:42 | Bronsa | andyf_: with the last commit t.a no longer supports clojure 1.4. Is that an issue for eastwood? |
| 12:43 | andyf_ | Bronsa: I haven't tested it with Clojure 1.4 in a while -- some other dependency might be forcing >= 1.5.1 already. |
| 12:43 | Bronsa | ok then I won't worry about that. |
| 12:43 | andyf_ | I'm happy making the next release require 1.5.1 or above |
| 12:44 | Bronsa | andyf_: I needed to use reduced/reduced? and that's a 1.5.0 feature |
| 12:44 | andyf_ | Bronsa: No gray area in that needed<---->wanted zone there? :) |
| 12:47 | Bronsa | andyf_: :P |
| 12:48 | Bronsa | andyf_: I *needed* reduced/reduced? to implement a feature I *wanted* |
| 12:50 | EvanR | is it possible to write a schema which is like sch1 OR sch2 |
| 12:51 | EvanR | either |
| 12:57 | bbloom_ | mdrogalis heh, they did |
| 12:57 | bbloom_ | seems like the identifier pink is less bright |
| 12:57 | bbloom_ | slightly less ugly, but slighly worse contrast |
| 12:57 | bbloom_ | weeee |
| 12:59 | bbloom_ | mavbozo: not really |
| 12:59 | bbloom_ | mavbozo: you can also differentiate a pointer from a pointee, you can't differentiate a reference from a referand |
| 12:59 | bbloom_ | justin_smith: they absolutely do not |
| 12:59 | bbloom_ | not the least of why is b/c the GC can move them on you |
| 13:00 | justin_smith | bbloom_: what do not what? |
| 13:01 | justin_smith | oh, something about pointers from above? |
| 13:01 | bbloom_ | mavbozo: yes |
| 13:02 | EvanR | what is #' in (recursive #'ExampleRecursiveSchema) |
| 13:02 | mi6x3m | hey clojure, can you suggest some strategy of running acceptance tests with leiningen? |
| 13:02 | justin_smith | ,'#'foo ; EvanR |
| 13:02 | clojurebot | (var foo) |
| 13:02 | EvanR | var eh |
| 13:03 | EvanR | ,(var foo) |
| 13:03 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve var: foo in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 13:03 | EvanR | does not compute |
| 13:03 | EvanR | ,'(var foo) |
| 13:03 | clojurebot | (var foo) |
| 13:03 | justin_smith | ,(var +) |
| 13:03 | clojurebot | #'clojure.core/+ |
| 13:04 | justin_smith | technomancy: estikes is spamming |
| 13:06 | justin_smith | mi6x3m: since an acceptance test is a black box test, couldn't you use a standard clojure.test/deftest with use-fixtures defined for the appriate setup and teardown? |
| 13:07 | mi6x3m | justin_smith: I use leiningen in a separate clojure project currently, yes |
| 13:08 | mi6x3m | justin_smith: I mean I use expectations sorry |
| 13:08 | mi6x3m | but the framework is of no importance at all |
| 13:08 | mi6x3m | I just thought there's some leiningen task like Maven's verify that's dedicated to such actions |
| 13:08 | justin_smith | lein test |
| 13:08 | justin_smith | maybe expectations has its own variant, lein test is for clojure.test |
| 13:09 | justin_smith | or do you mean the specific logic of only deploying if tests pass? |
| 13:10 | mi6x3m | justin_smith: well in a maven lifecycle you have separate phases: "test" and "verify" |
| 13:10 | mi6x3m | test would be for unit and integration tests |
| 13:10 | justin_smith | OK, I'm not familiar |
| 13:10 | mi6x3m | verify for acceptance tests etc. QA tasks |
| 13:12 | EvanR | verify means qa? |
| 13:12 | EvanR | seems like this terminology would be misleading |
| 13:12 | mi6x3m | "verify - run any checks to verify the package is valid and meets quality criteria" |
| 13:13 | mi6x3m | could be, yes, my terms are perhaps unprecise :) |
| 13:13 | EvanR | "its broken" "no, its verified" |
| 13:13 | EvanR | "oh, ok then" |
| 13:14 | EvanR | more like tested again in other ways |
| 13:21 | justin_smith | mi6x3m: I am not sure how this is organized, but a naive thought is to make two different testing targets - :unit and :qa - and then one stage would be "lein test :unit" and the other would be "lein test qa" |
| 13:22 | justin_smith | mi6x3m: see here https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L212 and here https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L323 |
| 13:22 | justin_smith | for a deploy task that depends on a specific test selector, and the definition of selectors |
| 13:23 | mi6x3m | yes this is actually a good idea |
| 13:23 | mi6x3m | have another folder wit htests and run them under a different task |
| 13:26 | jkj_ | i'm having difficulties wrapping my head around building a converyor system on core.async |
| 13:27 | jkj_ | if only i could find examples of systems, not just usage of the library |
| 13:27 | justin_smith | what is a converyor? |
| 13:27 | jkj_ | justin_smith: well.. multiple pieces of code forming a "production line" which the data goes through |
| 13:28 | justin_smith | conveyor? |
| 13:28 | jkj_ | justin_smith: "how to wire the channels together" - i might form the question :( |
| 13:28 | jkj_ | oops |
| 13:28 | jkj_ | :) |
| 13:28 | jkj_ | even |
| 13:28 | Glenjamin | you could have a series of components which all have input & output channels |
| 13:28 | jkj_ | justin_smith: yes. sorry. cannot see my own typos |
| 13:28 | Glenjamin | then some top-level function which wires them together |
| 13:29 | justin_smith | jkj_: ever use max/msp or puredata? the visual patch language is a great metaphor to help think of how a channel using codebase would work |
| 13:29 | engblom | If anyone want to be a "Clojure Lint", please comment on: http://pastebin.com/iig0d3V7 . I would especially want comments on input-move as I think it is ugly in current state. |
| 13:30 | jkj_ | justin_smith: haven't. have to take a look |
| 13:30 | justin_smith | jkj_: blog post with an image of a simple puredata visual program https://nicholasbuer.wordpress.com/category/pure-data-and-arduino-term-3/ |
| 13:30 | jkj_ | justin_smith: thank you |
| 13:31 | justin_smith | jkj_: the boxes are units that do some kind of processing (like a go block), the lines are channels of data (like chan) that come out the bottom of one box, and go into the top of another |
| 13:31 | justin_smith | not that you need to learn puredata before using core.async, but I found the metaphor helped me conceptualize it |
| 13:32 | jkj_ | alright |
| 13:32 | jkj_ | that does help |
| 13:33 | engblom | Is there a good lint tool similar to hlint for Haskell? Kibit is very limited, I hope to find something better. |
| 13:33 | jkj_ | i could be very clear about the different modules in the code |
| 13:33 | justin_smith | engblom: eastwood is pretty good |
| 13:34 | jkj_ | justin_smith: do you think the channels in between should be named and well declared? or should they just be implicit thing when you layer channely things |
| 13:34 | verma | justin_smith: you know if eastwood does cljs? |
| 13:34 | justin_smith | verma: no idea... |
| 13:34 | justin_smith | I don't think so |
| 13:35 | justin_smith | jkj_: channels are useful to have names for in a local scope, indicating how they are used |
| 13:35 | bbloom_ | i know coffeescript has that |
| 13:36 | bbloom_ | i wonder what they call it |
| 13:36 | justin_smith | ie. is it the result channel from a go block, an input queue, a place where you put tasks, an abort message |
| 13:36 | engblom | I get "Subprocess failed" when running Eastwood. Somehow it is not working for my project. It begins, but fails while analyzing. |
| 13:36 | justin_smith | *a source of an abort message (or a startup message, or whatever) |
| 13:36 | bbloom_ | http://coffeescript.org/#try:%7Bx%7D |
| 13:36 | bbloom_ | the docs don't seem to mention it though... |
| 13:37 | justin_smith | engblom: any other context information? my first suspicion is that if eastwood crashes, you are likely doing something very odd in your namespace definitions |
| 13:39 | justin_smith | engblom: this can equally be caused by exceedingly clever code (like core.typed or potemkin) or by sketchy code |
| 13:39 | engblom | justin_smith: "Constant value is discarded inside null: nil (nil value is returned by comment and gen-class expressions)" |
| 13:40 | engblom | The code is the one I linked to a little while ago |
| 13:40 | Bronsa | engblom: which version of eastwood are you using? |
| 13:40 | Bronsa | verma: eastwood does not do cljs yet |
| 13:41 | justin_smith | engblom: so for this namespace, right? http://pastebin.com/iig0d3V7 |
| 13:41 | engblom | Bronsa: 0.1.3 |
| 13:41 | verma | Bronsa: ok, thanks |
| 13:41 | Bronsa | engblom: try 0.1.5 out |
| 13:41 | engblom | justin_smith: Yes |
| 13:41 | verma | most of my clojure dev is in clojurescript, it'd be nice :D |
| 13:42 | justin_smith | engblom: for starters, don't use clojure.string/join directly, require clojure.string (probably with an :as string) - namespaces are available if someone else already required them, but relying on it implicitly is bad form |
| 13:43 | justin_smith | engblom: guessing that eastwood doesn't like the empty :gen-class in the ns decl, does it run OK if you take that out? |
| 13:43 | engblom | Bronsa: 0.1.5 is not crashing. It is working, however it does not complain anything |
| 13:43 | justin_smith | oh, n/m then |
| 13:43 | engblom | justin_smith: The new Eastwood is not complaining |
| 13:43 | justin_smith | right, thus my n/m |
| 13:44 | Bronsa | yeah this was fixed in the new version |
| 13:44 | justin_smith | hmm, I would have hoped eastwood would complain about usage of a namespace that isn't in your :require block |
| 13:46 | kenrestivo | "i know what you're thinking. did he use one namespace, or two? well, in all the confusion i've kind of lost track myself..." |
| 13:47 | justin_smith | do you feel lucky? |
| 13:47 | Bronsa | justin_smith: the problem with that is that once ns is macroexpanded away, it's unrecognizable |
| 13:48 | justin_smith | Bronsa: the usage of clojure.string without requiring it? |
| 13:48 | Bronsa | yeah |
| 13:48 | Bronsa | but maybe andy has already some infrastructure in place for parsing manually the ns form, idk |
| 13:49 | bbloom_ | EvanR: it's worth noting that `either` has some serious problems in terms of understandability of errors |
| 13:49 | bbloom_ | EvanR: if you can, prefer "if" and "cond" (i think they are called) |
| 13:49 | justin_smith | ahh, and because of macroexpansion you could get qualified symbols from namespaces you did not explicitly require |
| 13:49 | Bronsa | justin_smith: right |
| 13:49 | Glenjamin | can you do the check before macroexpansion? |
| 13:49 | EvanR | bbloom_: that sucks |
| 13:50 | justin_smith | Bronsa: a top level superficial analysis could catch x.y/z in the literal form and say you should use :import or :require or :use. Maybe. |
| 13:50 | Bronsa | justin_smith: that has the high risk of reporting false positives |
| 13:50 | justin_smith | absolutely |
| 13:51 | Bronsa | (some-macro x.y/z) where some-macro returns nil |
| 13:51 | Bronsa | justin_smith: not saying it can't be done -- probably by plugging into the macroexpander it could be possible |
| 13:51 | Bronsa | but it's not trivial |
| 13:52 | justin_smith | right |
| 13:52 | Glenjamin | Bronsa: wouldn't that still be reasonable to call an error that a linter should warn on? |
| 13:53 | Glenjamin | even if it doesn't break, it's potentially confusing code? |
| 13:53 | engblom | Now I have slightly changed it. It is passing both kibit and eastwood but still I think the input-move function is very ugly: http://pastebin.com/u4YLNi9e |
| 13:54 | Glenjamin | engblom: i'd extract (and (neg? row) (>= row (count heaps)) into a fn |
| 13:54 | justin_smith | engblom: since the only thing done to create new-heaps is an assoc, I would suggest merging the let clauses and just accepting you do an assoc but don't read the result if the first illegal-move check fails |
| 13:54 | Bronsa | engblom: yeah eastwood can only warn you about wrong/suspicious stuff, it can't really judge the idiomaticity of your code |
| 13:55 | Bronsa | Glenjamin: there are a lot of macros that expand into (some.ns/foo ..) where some.ns is not requried by your ns |
| 13:55 | Glenjamin | Bronsa: does eastwood not lint before macroexpansion? |
| 13:55 | Bronsa | Glenjamin: warning in that case would create a very low signal-to-noise ratio |
| 13:56 | Bronsa | Glenjamin: it does both depending on the linter, but even doing that before macroexpansion has its problems |
| 13:56 | justin_smith | yeah, a linter that reports non-errors undermines its own utility - users get annoyed and stop using it |
| 13:56 | Glenjamin | "this could be misleading" is reasonable for a linter imo |
| 13:56 | Glenjamin | especially since eastwood is easy to confifgure |
| 13:57 | justin_smith | Glenjamin: in my experience, I keep improving until the linter shuts up - if I can't or perfectly good code gets a warnign, I won't use the linter |
| 13:57 | Bronsa | Glenjamin: well open an issueq then I guess, maybe andy has an idea on how to implement this in a reasonable way |
| 13:58 | Glenjamin | I don't really have a stake in this, was just interested in the rationale |
| 13:59 | Glenjamin | justin_smith: If I fail a lint warn I tend to go check the docs to see why it's considered bad, then see if I care |
| 13:59 | Glenjamin | This is learned behaviour from jslint |
| 13:59 | EvanR | jslint, in which most of the time its "i dont care" |
| 13:59 | justin_smith | Glenjamin: yeah, I actually clean up the code until jslint stops warning, maybe that's weird though |
| 14:00 | engblom | justin_smith: By merging the let clauses you might end up in a situation where you use assoc with an index out of range. Do you mean I should wrap it with try-catch? |
| 14:00 | Glenjamin | I once spent half a day doing that, and ended up with something I thought was less readable, threw away the changes and deleted jslint |
| 14:01 | Glenjamin | Nowadays I use eslint with a smallish config |
| 14:01 | Glenjamin | ,(assoc nil nil nil) |
| 14:01 | clojurebot | {nil nil} |
| 14:01 | Glenjamin | No harm done :) |
| 14:02 | EvanR | most of the options in jslint are completely arbitrary stylistic preferences of dcrockford |
| 14:02 | justin_smith | engblom: you can use (delay ...) and then deref it, or define it as illegal (and (neg? row) (>= row (count heaps))) new-heaps (and (not illegal) (assoc heaps row amount)) |
| 14:02 | justin_smith | Glenjamin: I think this is assoc with vector/index |
| 14:02 | justin_smith | ,(assoc [] 1 :a) |
| 14:02 | Glenjamin | Oh |
| 14:02 | clojurebot | #<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException> |
| 14:03 | justin_smith | Glenjamin: I missed that on my first read too |
| 14:03 | Glenjamin | So input-move does IO & validation |
| 14:03 | Glenjamin | And the game loop |
| 14:03 | Glenjamin | Maybe try and split into those separate tasks |
| 14:03 | justin_smith | yeah, that's a good point |
| 14:04 | justin_smith | one function for each of those concerns makes sense |
| 14:07 | jeremyheiler | bbloom_: that was me yesterday... |
| 14:07 | TimMc | :-( |
| 14:07 | TimMc | Is this the fact that you can't just re-eval defmulti? |
| 14:07 | Bronsa | just put a (def foo) before (defmulti foo ..) |
| 14:07 | llasram | (inc Bronsa) |
| 14:07 | lazybot | ⇒ 71 |
| 14:08 | llasram | That's totally what I do |
| 14:08 | kenrestivo | *cough* clojure.tools.namespace.repl/reload *cough* |
| 14:08 | kenrestivo | er, refresh, but yeah, that |
| 14:11 | jeremyheiler | bbloom_: I think if you define the dispatch function separate, and pass it in as a var, it'll re-eval fine. |
| 14:14 | andyf | justin_smith: earlier you said about eastwood: "justin_smith: hmm, I would have hoped eastwood would complain about usage of a namespace that isn't in your :require block" |
| 14:14 | justin_smith | yes, I did |
| 14:14 | andyf | My question: Doesn't Clojure itself fail on such a require? |
| 14:14 | andyf | e.g. if you try 'lein check', assuming Leiningen |
| 14:14 | justin_smith | andyf: he was using clojure.string/join |
| 14:14 | Bronsa | andyf: no, if the namespace has already been loaded by another namespace foo.bar/baz will work |
| 14:14 | andyf | Meaning (:use clojure.string/join) in the ns form? |
| 14:15 | justin_smith | andyf: no, referring to it by its fully qualified name |
| 14:15 | Bronsa | andyf: "(ns foo) clojure.string/join" |
| 14:15 | justin_smith | lein repl already loaded it? |
| 14:16 | justin_smith | maybe clojure.string is a special case that doesn't get caught - I have had this issue with clojure.pprint/pprint though - things work in my repl, then I try to deploy and everything falls apart |
| 14:16 | andyf | If in a REPL then it depends on the complete history and a bunch of other stuff. If you do 'lein check' there are fewer things to differ |
| 14:16 | justin_smith | though maybe lein check would catch that one |
| 14:16 | justin_smith | right |
| 14:16 | bbloom_ | you have to ns-unmap it to redefine the dispatch fn |
| 14:16 | bbloom_ | a behavior for which i see no good reason... |
| 14:16 | bbloom_ | Bronsa: is this just a bug? is there any reason not to *fix* this? |
| 14:17 | andyf | I know there are lint tools that can give better syntax errors than compilers for the same language, but Eastwood is not intended to be such a lint tool. |
| 14:17 | justin_smith | andyf: my thought was, even if you know contextually the other ns is loaded, referring to it by its full name should be worthy of a warning at least |
| 14:17 | justin_smith | andyf: OK |
| 14:17 | Bronsa | bbloom_: no the defonce behaviour of defmulti is intended behaviour AFAIK |
| 14:17 | Bronsa | technomancy: estikes is the usual spammer |
| 14:17 | llasram | One wonders why protocols don't have the same behavior then however |
| 14:18 | justin_smith | andyf: Bronsa did explain how that would be hard to do in practice thanks to macroexpansion, which I had not considered |
| 14:18 | bbloom_ | jeremyheiler: 9 times out of 10 my dispatch fn is a keyword |
| 14:18 | Bronsa | I honestly have no idea *why* that's the case and would prefer if it hadn't defonce semantics |
| 14:19 | Bronsa | it might have to do with defmethod caching |
| 14:19 | llasram | Bronsa: Just make it not defonce in your implementation |
| 14:19 | llasram | :-D |
| 14:19 | clojurebot | Excuse me? |
| 14:19 | Bronsa | llasram: I'm not reimplementing the whole clojure runtime :) |
| 14:19 | andyf | a guideline I've been following is: if the compiler has an error or warning message for it already, consider it done and don't try to duplicate it. |
| 14:19 | hiredman | people complained about the way it was |
| 14:19 | hiredman | so it got changed |
| 14:19 | engblom | I made a new version: http://pastebin.com/85wB7mNF . I still have a slight repeat I would want to get rid of there in input-move |
| 14:19 | andyf | Try to catch things the compiler will not. |
| 14:19 | llasram | clojurebot: :-D is happiness |
| 14:19 | clojurebot | Ik begrijp |
| 14:20 | llasram | Bronsa: I know that you're *starting* small... |
| 14:20 | bbloom_ | Bronsa: why? |
| 14:20 | justin_smith | andyf: so in general I should be running lein do check, eastwood maybe |
| 14:20 | Bronsa | hiredman: give us the names. there's some murdering I need to do |
| 14:21 | TimMc | clojurebot: ☃ is a good check for UTF-8 support |
| 14:21 | clojurebot | You don't have to tell me twice. |
| 14:21 | bbloom_ | hiredman: huh? |
| 14:21 | TimMc | clojurebot: ☃ |
| 14:21 | hiredman | I think the complaint was something like: "hey, if I redef a defmulti and don't reload other namespaces that define methods I don't get my methods" |
| 14:21 | clojurebot | ☃ is a good check for UTF-8 support |
| 14:21 | hiredman | which is crazy |
| 14:21 | andyf | justin_smith: I would recommend that order |
| 14:21 | Bronsa | bbloom_: I'm agreeing with you that the defonce semantics are bad, what are you asking me? |
| 14:22 | bbloom_ | Bronsa: you've answered my questions |
| 14:23 | kzar | Dumb question possibly but how can I access my clojurescrpt namespace from javascript? (I'm trying to debug something in the console) |
| 14:24 | BobSchack | kzar: (ns foo.bar) should be foo.bar in the console |
| 14:24 | kzar | BobSchack: I tried that but it doesn't seem to work |
| 14:25 | BobSchack | what optimization level are you using? |
| 14:25 | kzar | BobSchack: Whatever is the default I think |
| 14:26 | hiredman | google groups are the worst |
| 14:28 | BobSchack | kzar: you should be able to access the namespace directly with out any difficulty if you have the optimizations :none or :whitespace, (possibly even :simple) |
| 14:29 | kzar | BobSchack: Aha, I had an element with the ID of foo so foo returned some kind of React component / HTML element and therefore foo.bar was undefined |
| 14:29 | kzar | HTML element* (I guess that's something kioo does?) |
| 14:30 | hiredman | https://groups.google.com/d/msg/clojure/MXf8zWAv3vI/JTGF1qxWKpMJ here I am repeating what I said, but still can't find the original thread that prompted the change to defonce like |
| 14:30 | BobSchack | Oh HTML element id's are autmatically inserted to the global namespace in broswers |
| 14:31 | kzar | BobSchack: Oh, I did not know that |
| 14:33 | danielcompton | amalloy_: thanks, I'll reword it |
| 14:33 | Bronsa | puredanger: https://github.com/clojure/build.ci/commit/4bf095a16caec1844192d35f1cd167766e114841 I'll need a hudson rebuild when you have time |
| 14:34 | puredanger | Bronsa: ok |
| 14:39 | engblom | What do you think about this: (when (= "y" (prompt "Do you want to play again? y/n:")) (-main) |
| 14:40 | engblom | Is it a problem to recurse in main like this? |
| 14:41 | Bronsa | engblom: no, -main is just a regular function |
| 14:41 | justin_smith | engblom: probably use (recur) unless you want to blow the stack after N games |
| 14:41 | danielcompton | amalloy_: I'd edit the ticket but I don't have permission in Jira |
| 14:41 | engblom | Bronsa: Isn't java having a problem with recursion? As clojure is having loop/recur) |
| 14:42 | justin_smith | engblom: we don't have automatic tco |
| 14:42 | justin_smith | engblom: (recur) works in functions too |
| 14:42 | Bronsa | engblom: yeah use recur as justin_smith suggested |
| 14:45 | engblom | May I get help first with this short function before I try to rewrite -main? I would want to make prompt-int to use loop/recur: http://pastebin.com/THZYdYCN |
| 14:45 | TEttinger | hey engblom |
| 14:45 | TEttinger | I'll take a look |
| 14:45 | engblom | TEttinger: Hello and thanks! |
| 14:45 | justin_smith | engblom: you can't recur inside catch |
| 14:46 | dbasch | I believe what engbloom wants is to recur if the evaluation of the try-catch doesn’t yield an integer |
| 14:46 | justin_smith | engblom: instead (let [input (try (Integer. (prompt msg)) (catch Exception _ nil))] (or input (recur))) |
| 14:47 | justin_smith | dbasch: right |
| 14:47 | justin_smith | just saying that particular point doesn't work for recurring |
| 14:47 | justin_smith | need to recur from outside the catch |
| 14:48 | dbasch | yep |
| 14:48 | justin_smith | the nil there is optional - it would also work with (catch Exception _) but that's a bit odder to read |
| 14:51 | engblom | justin_smith: How is that (or ...) working as it is only having one expression? |
| 14:51 | justin_smith | engblom: it has two |
| 14:52 | justin_smith | ,(or nil :OK) |
| 14:52 | clojurebot | :OK |
| 14:52 | engblom | Yes, you are right |
| 14:53 | justin_smith | another thought - when looping and catching exceptions, you probably want to narrow down and catch the explicit exception type |
| 14:53 | justin_smith | otherwise a program can get stuck sometimes |
| 14:53 | justin_smith | ie. what if you tried to interrupt |
| 14:54 | justin_smith | ,(try (Integer/parseInt "not a number") (catch Exception e (class e))) |
| 14:54 | clojurebot | justin_smith: Cool story bro. |
| 14:54 | justin_smith | that returns java.lang.NumberFormatException |
| 15:01 | engblom | Is it possible to catch two different exceptions with one (catch ...)? |
| 15:01 | engblom | With some kind of (or ...)? |
| 15:03 | justin_smith | engblom: you can have multiple catch blocks in one try |
| 15:07 | dbasch | engblom: you mean two different subclasses of Exception? |
| 15:07 | jkj_ | does saving in http://cljsfiddle.net/ work for anybody? |
| 15:08 | dnolen_ | jonasen: ^ |
| 15:09 | engblom | dbasch: Yes |
| 15:09 | annelies | ¡Hola! |
| 15:09 | engblom | If either of those two exceptions are thrown I want to do the same stuff. |
| 15:10 | jonasen | jkj_: seems not. I get transactor-not-available |
| 15:10 | jonasen | jkj_: I can take a look at this over the weekend but not before unfortunately |
| 15:10 | amalloy | engblom: not with the built-in try/catch, but it's easy to build your own numerous ways |
| 15:11 | amalloy | for example, (letfn [(handle [e] (...))] (try (f) (catch IllegalArgumentException e (handle e)) (catch IllegalStateException e (handle e)))) |
| 15:11 | jkj_ | jonasen: thanks. no worries |
| 15:12 | dbasch | engblom: you can also catch Exception and then see if it’s one of many subclasses |
| 15:12 | justin_smith | amalloy: alternately (try (foo) (catch Exception e (if (contains my-handled e) (handle e) (throw e)))) |
| 15:12 | dbasch | (assuming you want to catch *only* those classes) |
| 15:12 | jonasen | The box I run it on has way too little memory for datomic... |
| 15:12 | justin_smith | where by contains I mean contains? and my-handled is a set of Exception subtypes |
| 15:14 | dbasch | justin_smith: you can leave out the contains? too |
| 15:14 | justin_smith | dbasch: of course, but I like to make it explicit when it's not a set literal |
| 15:14 | amalloy | i saw a gist on /r/clojure from someone (AeroNotix?) to do this sort of thing pretty recently, which you can look at for inspiration, although i would suggest just doing it with built-ins |
| 15:14 | amalloy | justin_smith: dbasch: you also need to call (class e)... |
| 15:15 | dbasch | amalloy: yes, I’d have my-handled be a function |
| 15:15 | amalloy | a downside of that approach is that you have to catch and rethrow exceptions, instead of just letting the jvm do its thing |
| 15:15 | justin_smith | amalloy: ah right, good call, thanks |
| 15:15 | AeroNotix | https://github.com/AeroNotix/crap/blob/master/src/crap/exceptions.clj#L32-L36 |
| 15:15 | AeroNotix | here's a macro to do it |
| 15:15 | justin_smith | yes, definitely a downside |
| 15:16 | dbasch | I never liked checked exceptions. In clojure I almost never use anything other than Exception |
| 15:17 | justin_smith | dbasch: I like knowing the difference between "eof on file" and "out of memory while allocating buffer to read file" - but of course the usage of an "exceptional state" to communicate the former is not uncontroversial |
| 15:19 | justin_smith | dbasch: I thought "checked exceptions" meant the compiler side construct where you get an error if you don't handle specific declared exception types when making a call - thanks to not using javac we don't have to deal with those at all |
| 15:19 | amalloy | AeroNotix: if you are interested in some nitpicking, it is rather strange to have gen-catch take & body, and then have every call to it use apply; just make it take the body as a single argument |
| 15:19 | dbasch | justin_smith: yes, that’s what I meant |
| 15:19 | dbasch | and one of the best things about not using Java |
| 15:19 | justin_smith | right, OK |
| 15:19 | AeroNotix | amalloy: put your comments on github. I'm doing a release right now but I am more than happy to hear your comments. |
| 15:19 | AeroNotix | thanks! |
| 15:19 | justin_smith | dbasch: so I just misunderstood |
| 15:20 | dbasch | I hated it when you had to add a bunch of exceptions to the signature of my methods so that they would compile |
| 15:21 | justin_smith | dbasch: or even worse, when library writers deal with said issue by doing a try/catch and you get an exception caught in a place that is not at all useful to your top level code |
| 15:21 | justin_smith | or worse yet silently ignored so you have no idea what broke |
| 15:22 | justin_smith | s/ignored/discarded |
| 15:22 | dbasch | catch {} is one of the worst programming sins imaginable |
| 15:23 | SagiCZ1 | dbasch: not if you use try catch as control flow.. |
| 15:23 | SagiCZ1 | riiiight? |
| 15:23 | justin_smith | rofl |
| 15:23 | dbasch | ~guards |
| 15:23 | clojurebot | SEIZE HIM! |
| 15:23 | amalloy | speaking of funny checked exceptions, i discovered only the other day that java.lang.AutoCloseable was added in java 7, as like a radioactive version of java.io.Closeable |
| 15:23 | justin_smith | ~gourds |
| 15:23 | clojurebot | SQUEEZE HIM! |
| 15:23 | amalloy | void close() throws Exception |
| 15:24 | SagiCZ1 | why would you call it radioactive? |
| 15:24 | dbasch | throw new Exception(“Don’t close me bro!”) |
| 15:25 | amalloy | SagiCZ1: because it can blow up in all kinds of exciting ways |
| 15:25 | dbasch | class PandoraBox implements UnCloseable |
| 15:26 | SagiCZ1 | amalloy: great! |
| 15:27 | amalloy | SagiCZ1: i actually only thought of the pun after you asked me. i really called it radioactive because it's even more dangerous to handle |
| 15:27 | amalloy | bristles with menacing spines, etc |
| 15:28 | SagiCZ1 | one would think that higher version means safer, better, faster.. |
| 15:28 | justin_smith | amalloy: I think we have our origin story for PLT HULK |
| 15:28 | dbasch | “or to throw no exception at all if the close operation cannot fail.” <- this doesn’t make sense to me |
| 15:29 | justin_smith | https://twitter.com/plt_hulk |
| 15:29 | jkj_ | amalloy: do you get AutoCloseable? the documentation is kinda not clear about it... _Auto_closeable... "A resource that must be closed" |
| 15:29 | dbasch | it’s autocloseable but you can optionally close it yourself? |
| 15:29 | jkj_ | "A resource that must be closed when it is no longer needed."... "must" |
| 15:30 | justin_smith | jkj_: but who carries the weight of that "must" - the runtime? the programmer? the end user? |
| 15:31 | gfredericks | "The Weight of that Must" would be a great name for a Java book |
| 15:31 | jkj_ | ah. actually there is more in the close method docs.. "This method is invoked automatically on objects managed by the try-with-resources statement." |
| 15:31 | hiredman | amalloy: in java 7+ closeable extends autoclosable too |
| 15:31 | amalloy | hiredman: indeed, as well it should if autocloseable is going to exist |
| 15:31 | TimMc | gfredericks: Or wine-making. |
| 15:32 | jkj_ | i have a file handle leak problem with a netflow analyser thing that uses nio and mmap... have to figure out how to make sure things are closed |
| 15:32 | llasram | Oh -- everything that is Closeable is also AutoCloseable? |
| 15:32 | jkj_ | happen to know is this try-with-resources is any ways visible in clojuresphere? |
| 15:33 | jkj_ | +thing |
| 15:33 | llasram | What does it mean for something to be AutoCloseable but not Closeable? |
| 15:33 | stuartsierra | jkj_: no |
| 15:33 | engblom | http://pastebin.com/0svgfzpP <- How do I make that one to throw something not generic, so I still can interrupt with ctrl-c? |
| 15:33 | llasram | Oh, narrows the scope of the checked Exception |
| 15:33 | dbasch | llasram: that you can’t call close it manually I guess |
| 15:33 | hiredman | with-open should just work though, it will reflectively call the autocloseable .close method I think |
| 15:34 | dbasch | but also AutoCloseable doesn’t make sense, it should be AutoClosing |
| 15:34 | amalloy | llasram: if it's autocloseable it can throw any type of exception at all |
| 15:34 | amalloy | closeable can only throw java.io.IOException |
| 15:35 | amalloy | other implementations of autocloseable can be narrowed to further specify what they might throw |
| 15:35 | llasram | amalloy: Got it -- I'd glanced away for the beginning of the discussion |
| 15:35 | llasram | But since any method could really throw any exception *shrug* |
| 15:35 | llasram | It's just being honest! |
| 15:35 | dbasch | llasram: no, only unchecked exceptions |
| 15:36 | SagiCZ1 | i want something like 'every?' but one predicate returning true is enough... is it some? |
| 15:36 | justin_smith | engblom: of you really must use an exception to indicate an illegal move, you could reify Throwable or proxy Exception |
| 15:36 | stuartsierra | SagiCZ1: `some` without the `?` is what you want |
| 15:36 | amalloy | dbasch: no, you can cheat anything in |
| 15:36 | llasram | dbasch: Checked exceptions are a fiction of the Java compiler. Any method you invoke could ultimately reach JVM bytecode which throws any exception |
| 15:36 | dbasch | amalloy: true |
| 15:37 | amalloy | which is what clojure.lang does all over |
| 15:37 | SagiCZ1 | stuartsierra: thanks, thats confusing |
| 15:37 | stuartsierra | yep |
| 15:37 | llasram | The good old "chuck" pattern |
| 15:38 | jkj_ | oh the autoboxin exceptions |
| 15:38 | amalloy | iirc http://james-iry.blogspot.com/2010/08/on-removing-java-checked-exceptions-by.html is the technique clojure.lang uses to throw checked exceptions without declaring them, if anyone is interested |
| 15:39 | stuartsierra | "sneaky throw" in the source |
| 15:39 | justin_smith | engblom: or you could throw an applicable exception - IllegalStateException? dunno about that one though |
| 15:39 | puredanger | danielcompton: yt? afaict you have all the necessary groups to edit jira issues |
| 15:40 | jkj_ | a quick core.async question: how do i (chan 1 FOO) so that [:a :b], [c: :d :e], etc.. become just :a, :b, :c, :d .... |
| 15:40 | jkj_ | or that is more of a trans* question |
| 15:40 | puredanger | (mapcat identity) ? |
| 15:41 | TimMc | The trickier part (shown in the blog post) is *catching* sneaky-thrown exceptions. |
| 15:41 | stuartsierra | jkj_, puredanger: just `cat` should do it |
| 15:41 | puredanger | oh yeah, what he said |
| 15:42 | amalloy | cats are famous for shirking responsibility, though. don't count on what a cat should do |
| 15:42 | engblom | Is there a list of all throw-able exceptions somewhere? |
| 15:42 | jkj_ | stuartsierra, puredanger: thanks... still not quite clear on the detail of mappings and cattings |
| 15:42 | jkj_ | amalloy: :D |
| 15:42 | amalloy | engblom: the set is unlimited |
| 15:42 | justin_smith | $javadoc Exception |
| 15:42 | lazybot | http://docs.oracle.com/javase/6/docs/api/java/lang/Exception.html |
| 15:42 | TimMc | engblom: You mean all subclasses of Throwable in the current JVM? |
| 15:42 | dbasch | engblom: do you mean in the java library? |
| 15:43 | postpunkjustin | engblom: I'm a huge fan of the Slingshot library, which lets you throw whatever you want! |
| 15:43 | stuartsierra | Largely superseded by ex-info. |
| 15:44 | amalloy | stuartsierra: well. i'm a fan of ex-info, but i don't know that i'd say slingshot supersedes it |
| 15:44 | justin_smith | engblom: the above javadoc link has the direct subtypes of Exception that come with the lang, but subclassing (ie. with proxy) is pretty normal, and in clojure slingshot as mentioned above is quite popular |
| 15:44 | amalloy | er, the other way around |
| 15:44 | stuartsierra | Just throw ex-info. |
| 15:44 | dbasch | engblom: what’s the motivation for your question? |
| 15:44 | amalloy | ex-info is a low-level tool for throwing maps; slingshot is sugar around catching them |
| 15:44 | engblom | That javadoc link seem to be what I want |
| 15:44 | stuartsierra | sugar is bad for your teeth |
| 15:44 | amalloy | i don't really care for slingshot, but it provides a lot of stuff that is not in ex-info |
| 15:45 | engblom | dbasch: I need to throw something that do not sound to strange. |
| 15:45 | dbasch | engblom: what’s the context? It won’t sound strange if the context is right. |
| 15:45 | gfredericks | amalloy: stuartsierra: thus I made catch-data |
| 15:45 | gfredericks | much lighter-weight than slingshot |
| 15:45 | dbasch | engblom: e.g. IllegalArgumentException, UnsupportedOperationException, IllegalStateException, all those are self-explanatory |
| 15:45 | amalloy | you can suggest not using slingshot (i do too), but it really is not superseded by ex-info/ex-data |
| 15:45 | amalloy | $google gfredericks catch-data |
| 15:45 | lazybot | [gfredericks/catch-data · GitHub] https://github.com/gfredericks/catch-data |
| 15:46 | stuartsierra | I'm just cranky today. |
| 15:46 | technomancy | amalloy: throw+ is superseded; try+ isn't |
| 15:46 | dbasch | LineUnavailableException sounds ancient |
| 15:47 | gfredericks | PunchCardBentException |
| 15:47 | engblom | dbasch: IllegalStateException is what I want :) |
| 15:47 | justin_smith | AmbiguousAbacusBeadPositionException |
| 15:47 | amalloy | technomancy: welllllll, throw+ includes some misfeatures that are happily not included in ex-info |
| 15:47 | amalloy | it looks like gfredericks has decided to include them in throw-data, though |
| 15:47 | TimMc | "Java is unable to process this integer; it contains too many holes." |
| 15:48 | gfredericks | amalloy: eh? |
| 15:48 | TimMc | amalloy: Locals grabbing? |
| 15:48 | amalloy | gfredericks: locals |
| 15:48 | gfredericks | I added that later; easy to remove, and not the point of the lib |
| 15:48 | amalloy | it is *so bad* to implicitly save all the locals in the exception |
| 15:49 | hiredman | MUST NOT bad or SHOULD NOT bad? |
| 15:49 | amalloy | i guess i would have to say SHOULD NOT |
| 15:49 | engblom | Now I have a new version. Any comments are welcome: http://pastebin.com/F0a6WRVV |
| 15:51 | gfredericks | amalloy: just so I can win this conversation I'm going to go remove that misfeature right now |
| 15:51 | technomancy | nice |
| 15:51 | amalloy | gfredericks: oh interesting, you save them in the metadata instead of the map itself. that is actually only half as bad |
| 15:51 | justin_smith | engblom: I guess the string in (IllegalStateException. "Illegal move") helps as a comment, but due to being right next to the clause that catches it, we can easily see that the string doesn't really <do> anything |
| 15:51 | gfredericks | amalloy: for printing you mean? |
| 15:51 | amalloy | you still have the head-holding issue, but you don't have a printing problem anymore, right |
| 15:51 | {blake} | I always strive to be half as bad. |
| 15:51 | gfredericks | I hadn't thought of that; got lucky I guess |
| 15:52 | amalloy | i remember i had a terrible time tracking down an issue in some code i took over, where i added an infinite seq in the lexical scope of an existing throw+ |
| 15:52 | technomancy | talk about a heisenbug |
| 15:52 | amalloy | and then like...all my exceptions turned into OutOfMemoryError inside of print-method or something |
| 15:53 | technomancy | literally doesn't manifest until observed |
| 15:53 | gfredericks | it'd be cool to have some sort of opt-in where you can list locals you want to include |
| 15:53 | justin_smith | ExceptionInceptionException |
| 15:53 | engblom | justin_smith: Thanks, I removed it. |
| 15:53 | amalloy | gfredericks: oh! the syntax for it could be like (throw-data {:x 1 :locals {:y 2}})! |
| 15:53 | amalloy | er, (throw-data {:x 1 :locals {:y y}}) |
| 15:54 | amalloy | speaking of, a slight endorsement: (flatland.useful.map/keyed [x y z]) expands to {:x x :y y :z z}. a handy tool for any occasion! |
| 15:54 | gfredericks | haha |
| 15:55 | gfredericks | amalloy: your point being it's easy enough that it doesn't deserve any help? |
| 15:55 | amalloy | yes |
| 15:55 | gfredericks | you macro minimalists!! |
| 15:55 | TimMc | :unsyms |
| 15:55 | gfredericks | :unkeys |
| 15:55 | amalloy | unless you make it completely implicit, in which case you run into the problems already mentioned |
| 15:55 | amalloy | TimMc: keyed does that too, actually |
| 15:56 | TimMc | I guess it would be :unkeys |
| 15:56 | amalloy | (keyed :syms [x y z]) |
| 15:56 | TimMc | (keyed :enums [oh god why]) |
| 15:57 | amalloy | (keyed :my-car [those hooligans]) |
| 15:57 | TimMc | technomancy: estikes is spamming :-( |
| 15:57 | amalloy | a kinda weird reverse-polish there |
| 15:58 | TimMc | I don't understand why they have to be in a channel in order to spam... maybe it helps them avoid detection? |
| 15:58 | amalloy | TimMc: to detect active users, i imagined |
| 15:58 | amalloy | "so and so is talking right now, let's PM them" |
| 15:58 | technomancy | that's my guess |
| 15:58 | amalloy | #clojure really just has the one persistent spammer |
| 15:58 | TimMc | Ah, right -- increase the hit rate to reduce total volume. |
| 15:59 | justin_smith | amalloy: I wonder what the clickthrough rate is on that stupid link |
| 15:59 | amalloy | hah, i hadn't looked at the source for keyed in a while: https://github.com/flatland/useful/blob/develop/src/flatland/useful/map.clj#L15-L17 is vintage amalloy, using comp, partial, juxt, and identity all in close proximity |
| 16:00 | TimMc | hiredman and Raynes should get their bots coordinated so that if someone not active in the channel sends both the same link, they are kicked. |
| 16:00 | gfredericks | they could send a fax to technomancy |
| 16:00 | amalloy | TimMc: we'll get right on that as soon as you get someone to give lazybot and clojurebot ops |
| 16:00 | dbasch | programming language channels are terrible targets for spammers |
| 16:00 | Raynes | We'd just fight over who sends the fax and never actually do it. |
| 16:00 | TimMc | amalloy: We need a third bot. |
| 16:00 | Raynes | But he'd have to actually speak to me for that to happen, so none of this is feasible anyways. |
| 16:00 | Raynes | :p |
| 16:01 | amalloy | some sort of technomancer? |
| 16:01 | technomancy | so... how much would it cost to ddos the spammer |
| 16:01 | TimMc | technomancy: They might be stealing service from someone innocent. |
| 16:01 | amalloy | technomancy: in money, or moral turpitude? |
| 16:01 | technomancy | TimMc: then the innocent person would find out |
| 16:01 | kitia_ | maybe just use an aws |
| 16:01 | gfredericks | amalloy: feature removed |
| 16:01 | amalloy | (inc gfredericks) |
| 16:02 | lazybot | ⇒ 103 |
| 16:02 | TimMc | turpitude is the name of my next clojure project |
| 16:02 | danielcompton | puredanger: it's working now |
| 16:02 | gfredericks | speaking of :keys catch-data was a good opportunity to add an additional special key to map destructuring |
| 16:02 | puredanger | danielcompton: good, sorry for the delay. the perms are pretty broad which is why they're not enabled automatically. |
| 16:03 | puredanger | danielcompton: that could probably be adjusted, but the time to make implement and debug that vastly outweighs the manual work required currently |
| 16:03 | danielcompton | puredanger: just working on a post to the mailing list about that now |
| 16:04 | amalloy | gfredericks: you're talking about the :ex key? |
| 16:05 | amalloy | gfredericks: actually, why is throw-data a macro now? it could become a function now that you're not saving locals |
| 16:06 | puredanger | danielcompton: the combination of the defaults + adding groups on CA (which Andy Fingerhut does currently) covers virtually everything. Andy or I make a few additional adjustments occasionally, but it's not worth overhauling the world |
| 16:08 | gfredericks | amalloy: uuuhm |
| 16:08 | gfredericks | amalloy: less stacktrace polution? |
| 16:09 | gfredericks | who on earth is going to use a function like that in a higher-order-way anyhow |
| 16:09 | gfredericks | bring me that person and I shall ask him or her what he or she is up to |
| 16:10 | TimMc | comp |
| 16:10 | gfredericks | (comp launch-missiles throw-data) |
| 16:11 | TimMc | "*then* we launch ze missiles" |
| 16:11 | gfredericks | I try to keep imperative stuff and point-free stuff like totally separate |
| 16:13 | amalloy | gfredericks: for sure it is hard to imagine someone using throw-data not in call position |
| 16:13 | amalloy | (map throw-data list-maybe-containing-errors)? |
| 16:13 | amalloy | obviously terrible |
| 16:15 | TEttinger | technomancy: what is the main class for a lein-generated uberjar? I'm having terrible trouble getting a JRE bundler (libgdx's packr project) to do anything once it bundles an uberjar |
| 16:15 | technomancy | TEttinger: clojure.main if you don't set :main |
| 16:15 | TEttinger | is the main class the same as in Manifest.MF ? |
| 16:16 | dbasch | seeing Manifest.MF always makes me smile |
| 16:16 | technomancy | Manifestfile |
| 16:17 | TEttinger | :main perlin.core.desktop-launcher :aot :all |
| 16:17 | TEttinger | so that would become perlin.core.desktop_launcher , right? |
| 16:23 | danielcompton | Are there three different types of map: PersistentHashMap, PersistentArrayMap, and PersistentTreeMap? |
| 16:24 | dnolen_ | danielcompton: yes, though the concrete implementations shouldn't matter for most code |
| 16:24 | danielcompton | dnolen_: I'm working on fressian encoders so I wanted to make sure I got all of them |
| 16:25 | amalloy | danielcompton: there are arbitrarily many though, of course |
| 16:25 | dnolen_ | danielcompton: then I would check for IPersistentMap |
| 16:25 | amalloy | anyone can implement that interface |
| 16:25 | amalloy | every defrecord creates a new thing that's a map |
| 16:26 | puredanger | danielcompton: presuming Zach's unrolled collections stuff makes it into 1.8, there will be many concrete impls of the collections |
| 16:33 | donbonifacio | is there a func to compare keywords and strings? like (= "p1" :p1) |
| 16:34 | puredanger | I think name handles both? |
| 16:34 | puredanger | ,(name "abc") |
| 16:34 | clojurebot | "abc" |
| 16:34 | puredanger | ,(name :abc) |
| 16:34 | clojurebot | "abc" |
| 16:34 | donbonifacio | yes, but I don't want to be calling name. wel, I'll just create my own that wraps name |
| 16:37 | annelies | Stop calling me names! |
| 16:43 | Glenjamin | Is the truffle/graal stuff useful for clojure at all? |
| 16:47 | amalloy | huh. the clojure compiler's interaction with synthetic bridge methods surprised me. background: hbase has an interface Query, containing: public Query setFilter(Filter f), and a class Get which implements that while narrowing the return type: public Get setFilter(Filter f) |
| 16:48 | amalloy | if you write (.setFilter ^Get g f), you get a reflection warning: there's actually two methods with the same name and args, one of which is "synthetic". but if you change it to (.setFilter ^Get g ^Filter f), the compiler is perfectly content, even though that didn't actually narrow things down at all: there are still two exact matches |
| 16:49 | amalloy | furthermore, it's happy with (.setFilter ^Get g nil) |
| 16:51 | amalloy | there's always more to learn. i never did really understand bridge methods |
| 17:03 | stuartsierra | No one understands bridge methods. |
| 17:04 | stuartsierra | E.g. http://dev.clojure.org/jira/browse/CLJ-1243 |
| 17:04 | amalloy | stuartsierra: after reading a few unhelpful blog posts, i found http://stackoverflow.com/a/5007394/625403 fairly helpful |
| 17:13 | ro6 | I want to do something a bit unusual with nREPL and I'm wondering if anyone can help me figure it out. I need to remote debug an application running on a remote machine where I don't have control over what ports are open... |
| 17:15 | ro6 | we use Pubnub for communicating with the client applications normally, because that works over the standard ports and I'm wondering if there might be some way to use the nREPL protocol over a Pubnub channel |
| 17:15 | puredanger | I have been working off and on for a while on improving vec and comparing its performance vs (into []) in the scope of CLJ-1546 |
| 17:16 | puredanger | I just dropped a comment there that might update the folk wisdom of "into is faster than vec" for 1.7 http://dev.clojure.org/jira/browse/CLJ-1546?focusedCommentId=36428&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-36428 |
| 17:17 | puredanger | assuming the patch makes it into 1.7, which I do expect |
| 17:18 | puredanger | I should probably write about a blog about this and share some of the data and other info I have, but I don't have time so I am just dropping it here :) |
| 17:18 | cfleming | puredanger: That's interesting, thanks. I was wondering about that after seeing that Kibit suggests converting (into [] ...) into (vec ...) |
| 17:19 | puredanger | I don't think that advice was unambiguously true even before this patch |
| 17:19 | cfleming | puredanger: I'm hopeful that a lot of these small optimisations, and things like ztellman's unrolled collections, will improve Clojure's speed pretty significantly for common use cases. |
| 17:20 | cfleming | puredanger: No, it seemed like slightly overenthusiastic advice to me, I must admit. |
| 17:21 | puredanger | I think Zach's stuff is far more important than this, which is unlikely to be felt until IReduce things are more common. but I do think his can make significant changes. I am excited to dive into it for 1.8. |
| 17:22 | hiredman | puredanger: it would nice to have a blog post or something clarifying or just describe the intent behind all the Reduce interfaces and protocols |
| 17:22 | hiredman | like, should people still use CollReduce? |
| 17:22 | puredanger | maybe post-conj I'll have time to do some of that |
| 17:23 | puredanger | absolutely, you should use CollReduce. It's the primary open system for reducible collection. |
| 17:23 | hiredman | so what the heck is with Reduce and ReduceInit? |
| 17:23 | puredanger | IReduce is a fast path for things that we can change (thus closed) |
| 17:24 | puredanger | for example, we want ArrayList to be reducible so CollReduce (the protocol) allows to extend to types we don't own |
| 17:24 | puredanger | IReduce is a marker for things we do own, like PersistentList, PersistentVector, Range, etc |
| 17:24 | hiredman | so if I am implementing something I can (and should?) use IReduce (or should I use ReduceInit?) |
| 17:24 | puredanger | if you can implement IReduce, then do so |
| 17:25 | puredanger | IReduceInit and IReduce now split the arities of reduce (with or without and initial value) |
| 17:25 | puredanger | IReduce extends IReduceInit and has both |
| 17:25 | hiredman | I see |
| 17:25 | puredanger | I think Rich regrets combining them originally |
| 17:26 | puredanger | I'm not sure that I have it totally sorted in my head which you should prefer if implementing something right now |
| 17:26 | hiredman | I can imagine, dealing with both when implementing coll-reduce is a drag |
| 17:27 | cfleming | I'd love to see a blog post with some guidance on this, I've never dug into the implementation of all this and it's very confusing from a user POV |
| 17:27 | puredanger | sure, would love to do it |
| 17:28 | hiredman | http://www.youtube.com/watch?v=PHVeyo4W18U |
| 17:28 | hiredman | or the opposite or whatever |
| 17:29 | nickmbailey | whats the idiomatic way to do a non lazy (concat…)? just (apply conj…)? |
| 17:30 | puredanger | hiredman: more the opposite I think :) |
| 17:31 | dnolen_ | nickmbailey: into works pretty well |
| 17:31 | dnolen_ | nickmbailey: assuming you have vectors off course |
| 17:31 | nickmbailey | ahh |
| 17:31 | dnolen_ | nickmbailey: if you have seqs, there's no option beyond concat |
| 17:32 | nickmbailey | well, apply conj still works with seqs right? |
| 17:32 | hiredman | nickmbailey: why not just use concat and doall? |
| 17:32 | puredanger | you could transduce a cat right? |
| 17:33 | puredanger | (I realize that sounds like a bad intro to a joke) |
| 17:33 | dnolen_ | ,(conj '(1 2 3) 4) |
| 17:33 | clojurebot | (4 1 2 3) |
| 17:33 | annelies | > Transduction is the process by which DNA is transferred from one bacterium to another by a virus. |
| 17:33 | dnolen_ | nickmbailey: ^ |
| 17:33 | annelies | puredanger: out of luck; cats aren't bacteria |
| 17:33 | nickmbailey | hiredman: that would work too, but into works in this case |
| 17:34 | puredanger | ,(transduce cat conj '((1 2 3) (4 5 6) (7 8 9))) |
| 17:34 | clojurebot | [1 2 3 4 5 ...] |
| 17:36 | dnolen_ | puredanger: oh heh, yeah now that conj returns [] for arity zero - hadn't thought of that |
| 17:36 | dnolen_ | ,(conj) |
| 17:36 | clojurebot | [] |
| 17:36 | puredanger | you can get a list too if you like |
| 17:36 | puredanger | ,(transduce cat conj '() '((1 2 3) (4 5 6) (7 8 9))) |
| 17:36 | clojurebot | (9 8 7 6 5 ...) |
| 17:36 | puredanger | ha :) |
| 17:37 | dnolen_ | ah right |
| 17:37 | puredanger | ,(transduce cat conj #{} '((1 2 3) (4 5 6) (7 8 9))) |
| 17:37 | clojurebot | #{7 1 4 6 3 ...} |
| 17:37 | puredanger | conj is fun |
| 17:38 | annelies | What's the difference between transduce cat conj and into? |
| 17:38 | dnolen_ | annelies: into will try to use transients |
| 17:39 | annelies | lemme google that |
| 17:39 | dnolen_ | annelies: into is now actually defined in terms of transduce |
| 17:39 | dnolen_ | well the arity where given an xform anyway |
| 17:39 | annelies | Ah, I see. |
| 17:45 | annelies | I'm gonna sleep. Byebye! |
| 17:46 | danielcompton | puredanger: thanks for your feedback on the list, I wasn't trying to disrespect Rich's wishes, just trying to offer other ways to create a patch |
| 17:47 | mikerod | Would it be considered safe/fine to embed a var object into code generated during macroexpansion? |
| 17:48 | mikerod | e.g. say the macro is: (defmacro embed-var [x] `(list ~(resolve x))) |
| 17:48 | mikerod | called like: (embed-var my-testing-var-name) |
| 17:49 | mikerod | seems fine in returning: (#'user/my-testing-var-name) |
| 17:50 | mikerod | I'm contrasting this to the embedding something like (Object.) into the code returned from macroexpansion |
| 17:50 | mikerod | which doesn't have a clean reader-literal format |
| 17:54 | tuft_ | does anyone know where i can get the user/clojuredocs function mentioned here: https://github.com/technomancy/leiningen/issues/594 ? |
| 18:02 | verma | I am writing a 3D engine for a specific purpose using clojurescript (displaying point clouds for next iteration of http://plas.io), what the engine renders is completely controls by a state, which is a hash-map, indicating, what cameras are loaded, what point clouds are loaded, what the eye position is, where the camera is looking and other things needed for a scene to render. |
| 18:03 | verma | the user sends down a state, which I convert into a runtime-state |
| 18:04 | puredanger | danielcompton: no worries :) |
| 18:04 | verma | basically the user says, I want buffer x to be added to the scene, this buffer X translates to an action which downloads the buffer and adds it to the scene. |
| 18:04 | verma | whenever the runtime state changes a re-render is triggered. |
| 18:05 | muck | hi |
| 18:05 | verma | since buffer loads are async, I have a cursor (loosely based on om cursors), which can be transacted into, which casuses the re-render |
| 18:05 | danielcompton | puredanger: The Clojure community really does appreciate your work, thanks for everything you do |
| 18:06 | verma | there may be renders queued up for rendering while I am changing things with the run-time state, which will reflect during the next render cycle |
| 18:07 | verma | now, underneath all this, the calls eventually go to webgl, the problem is that some state updates delete buffers |
| 18:08 | verma | but the state already queued up for rendering may still refer to it |
| 18:08 | hiredman | sounds like you get to write a gc! |
| 18:08 | verma | :( |
| 18:08 | hiredman | a simple mark and sweep is easy as pie |
| 18:09 | hiredman | https://github.com/hiredman/kvgc/blob/master/src/com/manigfeald/kvgc.clj |
| 18:09 | verma | checking |
| 18:10 | verma | hiredman, nice! |
| 18:11 | verma | hiredman, "Because one day my processes will loose these bonds of physical machinery, to compute using transcendent nominal mechanics outside the boundaries of electrical components so cruelly referred to as being random access, and it seems like having a garbage collector when that happens would be nice." |
| 18:11 | verma | nice! |
| 18:11 | hiredman | :) |
| 18:11 | verma | ok, I can probably use that as inspiration to write something similar |
| 18:12 | verma | thanks! |
| 18:12 | hiredman | yeah, I very pleased with how it turned out, I ended up using it to do gc of stuff out of embedded sql databases for another project |
| 18:12 | hiredman | but I guess I never pushed the releases to clojars or something |
| 18:14 | verma | (inc hiredman) |
| 18:14 | lazybot | ⇒ 61 |
| 18:15 | hiredman | https://github.com/hiredman/graph/blob/master/src/com/manigfeald/graph/gc.clj using the protocol there to gc parts of representations of graphs out of a derby database |
| 18:25 | amalloy | mikerod: i wouldn't recommend it, even if it does happen to work. why would you want to? |
| 18:26 | mikerod | amalloy: I'm just trying to decide if it was a good or acceptable practice or not |
| 18:26 | mikerod | if an object has a reader printable representation then it is acceptable in generated code though I take it |
| 18:26 | mikerod | ? |
| 18:27 | mikerod | In this case specifically, I was reviewing some code that was wrapping resolved vars into function calls (they were bound to functions) |
| 18:27 | mikerod | so like (defmacro call-var [var-sym] `(~(resolve var-sym))) |
| 18:27 | mikerod | it was not this simple. I just ripped off all the rest of what happened there. |
| 18:28 | mikerod | The resolved vars are used elsewhere in the macro, but I wasn't sure if the suggestion should be to leave the var-sym as-is and not call the resolved var in the code returned. |
| 18:28 | mikerod | e.g. (defmacro call-var [var-sym] `(~var-sym)) |
| 18:29 | amalloy | i would much prefer the latter of those two |
| 18:29 | amalloy | if nothing else, what if var-sym is a macro? |
| 18:29 | amalloy | that is, it resolves to a macro |
| 18:31 | amalloy | eg, compare ##[(or 1 2) (#'or 1 2)] |
| 18:31 | lazybot | ⇒ [1 nil] |
| 18:33 | mikerod | amalloy: ah yes, I've seen that before due to the "hidden" first 2 args |
| 18:33 | mikerod | So it is bad to call a macro by its acutal var then |
| 18:33 | mikerod | actual* |
| 18:33 | mikerod | Compiler can't detect it I suppose? |
| 18:34 | mikerod | I see it is just returns the var and then the var is invoked as a fn. |
| 18:34 | amalloy | detect what? maybe you call the macro through its var on purpose; it shouldn't stop you. instead, just don't write code that does things you don't want to do |
| 18:35 | kzar | Is it possible to transform an element based on it's one of it's attributes using kioo? |
| 18:35 | kzar | I want to assign a class if a attribute has a certain value |
| 18:36 | kzar | Oh I guess I could just have two transforms, one to remove the class for all the elements and one to add the class in for the elemnt with the attribute I'm looking for... Sorry - dumb question |
| 18:37 | mikerod | amalloy: So macros should be called only through their symbols is what I'm saying |
| 18:37 | mikerod | for normal behavior |
| 18:37 | amalloy | yes |
| 18:38 | mikerod | interesting |
| 18:38 | razum2um | can I manually resolve an url to get matching compojure's handler? |
| 18:38 | mikerod | well thanks for the ifo! |
| 18:38 | amalloy | functions really should too; vars do some things that would surprise you |
| 18:38 | mikerod | info |
| 18:38 | mikerod | hmm I see |
| 18:38 | mikerod | makes sense then |
| 18:38 | amalloy | mikerod: for fun, try this: (defn foo [& args] (first args)) (apply foo (range)) (apply #'foo (range)) |
| 18:39 | amalloy | (i have a patch filed to fix this behavior, which IMO is a bug, unlike the macro var thing that i consider a feature) |
| 18:41 | amalloy | speaking of which, if this behavior bothers anyone, go upvote http://dev.clojure.org/jira/browse/CLJ-1423 |
| 18:54 | {blake} | OK, I'm going cuckoo trying to figure out how to make compojure routing work with a context. |
| 18:54 | {blake} | I've got a simple example: https://www.refheap.com/93325 |
| 18:54 | {blake} | And I think I understand what's happening (as explained there) but not why, or how to fix. |
| 19:00 | amalloy | {blake}: wrap-context does "hide" the context, because that's the only way it would be useful at all; i think you have to emit a link that contains the context in it. ie, instead of /linked, you have to emit a link to /hello/linked |
| 19:01 | gfredericks | or "linked" might work too? |
| 19:01 | amalloy | gfredericks: sure, relative links will be fine |
| 19:01 | amalloy | assuming you never need an absolute link |
| 19:01 | {blake} | amalloy: OK, so, I clearly don't know what's what. Because I want my code to be agnostic as to where it is. |
| 19:01 | mikerod | amalloy: that is interesting |
| 19:01 | mikerod | I'll have to look closer at the Compiler to see what is going on there |
| 19:02 | {blake} | I started with relative links, but maybe I screwed them up. |
| 19:02 | amalloy | {blake}: indeed, you should be agnostic; you can *find out* where it is by looking at the :context of the request, or something like that |
| 19:02 | {blake} | Because that's the obvious handing. |
| 19:02 | amalloy | mikerod: it's not the compiler; it's c.l.Var |
| 19:02 | verma | swap! says that the passed function should be free of side effects, I get that, if I am holding a pointer to a resource and I want to transactionally release it, what's the best way? |
| 19:02 | {blake} | amalloy: Yeah, I went that route, too: Wrapping the route in the context. |
| 19:02 | amalloy | {blake}: huh? |
| 19:03 | amalloy | that's fine for handling requests, but you have to also look at what the context is before you emit any absolute links |
| 19:03 | {blake} | amalloy: Created a middleware that took the context and prepended the uri with it. |
| 19:03 | gfredericks | verma: agents are okay for side-effects |
| 19:03 | gfredericks | I don't quite understand what you're doing though |
| 19:04 | amalloy | verma: you can swap with a function that doesn't actually do side effects, but instead returns whether it's okay to do side effects |
| 19:05 | verma | gfredericks, I want to release a webgl texture which is a part of a state controlled/driven 3D engine |
| 19:05 | verma | amalloy, hmmm interesting |
| 19:05 | amalloy | something like (let [r (swap! resource (fn [r] (if (:cleaned? r) (dissoc r :okay-to-clean) (assoc r :okay-to-clean true, cleaned? true))))] (when (:ok-to-clean r) (cleanup! r))) |
| 19:06 | amalloy | this guarantees that no matter how many threads are running this code at once, exactly one of them gets the ok-to-clean signal |
| 19:06 | amalloy | modulo awful typos like okay/ok |
| 19:07 | hiredman | ,(doc compare-and-swap!) |
| 19:07 | clojurebot | eval service is offline |
| 19:07 | hiredman | jerk |
| 19:07 | hiredman | (doc compare-and-swap!) |
| 19:07 | clojurebot | Titim gan éirí ort. |
| 19:07 | mikerod | amalloy: I still don't understand why `(macroexpand-1 '(#'or 1 2))` ;= ((var or) 1 2) |
| 19:08 | verma | amalloy, makes sense, thanks |
| 19:08 | mikerod | When digging through some Compiler#analyzeSeq |
| 19:08 | hiredman | (doc compare-and-set!) |
| 19:08 | clojurebot | "([atom oldval newval]); Atomically sets the value of atom to newval if and only if the current value of the atom is identical to oldval. Returns true if set happened, else false" |
| 19:08 | mikerod | ohhh |
| 19:08 | amalloy | oh, hiredman is probably right. CAS makes more sense than my swap nonsense |
| 19:08 | amalloy | although mine is clever |
| 19:09 | mikerod | I do understand it now |
| 19:09 | mikerod | and for the apply thing, I'll look at c.l.Var |
| 19:10 | verma | amalloy, I do feel your case applies more for my case, I wouldn't know what the oldval is, I need to figure what it is going to be, so I need a function instead of an old val |
| 19:10 | amalloy | verma: well, the idea with CAS is you deref it first |
| 19:11 | amalloy | deref, construct a candidate new value, and then attempt to CAS it |
| 19:11 | amalloy | if the CAS succeeds, you go ahead with your side effects |
| 19:11 | amalloy | if it doesn't, someone else must have gotten to it |
| 19:11 | verma | nice |
| 19:12 | {blake} | OK, so I now have "/" GET "linked" and another "/linked". |
| 19:12 | {blake} | That is I took out the slash before "/linked" in the HREF. |
| 19:12 | {blake} | This works locally. |
| 19:13 | {blake} | It creates this HTML: <a href="linked"> click</a> |
| 19:14 | {blake} | With the deployed WAR, it's still looking for "localhost:8080/linked" instead of "localhost:8080/hello/linked". |
| 19:15 | {blake} | (I started by deleting the slash in (GET "/linked") but that doesn't work locally. |
| 19:26 | erikcw | I have a tree shaped data structure that I need to walk until I find a specific branch (identified as a map containing the key :id). I’ve played with clojure.walk, but can’t seem to make it stop and return the branch when it is found (it just keeps going to the bottom of the tree) — am I using the wrong tool? |
| 19:27 | dbasch | erikcw: what’s wrong with recursively traversing the tree yourself until you find it? |
| 19:28 | erikcw | dbasch: Nothing — just wanted to know if it was possible with clojure.walk.* or zippers, or some other Clojure goodie… |
| 19:28 | dbasch | btw, if you need to traverse the tree perhaps that’s the wrong structure for what you have |
| 19:28 | hiredman | sure zippers will do it |
| 19:28 | hiredman | clojure.walk not so much |
| 19:28 | cfleming | justin_smith: You're working on updating lazybot, right? |
| 19:29 | NoCreativity | Hello |
| 19:29 | erikcw | hiredman: Thanks — I’ll go read up |
| 19:29 | justin_smith | cfleming: I patched lazybut up to work with clojure 1.7, and the latest irclj, yes |
| 19:29 | cfleming | justin_smith: Are you accepting feature requests? |
| 19:29 | amalloy | ~lazybot is a lazybut |
| 19:29 | clojurebot | 'Sea, mhuise. |
| 19:29 | dbasch | although it may be harder with zippers than just traversing the tree yourself |
| 19:30 | NoCreativity | I'm having some problems trying to consume a :edn type request. does anybody has samples of a POST|PUT request that consumes :end? Thanks in advance |
| 19:30 | justin_smith | cfleming: well, feel free to submit on noisesmith/lazybot if you like (or on raynes/lazybot and I will likely find it there too) |
| 19:30 | cfleming | justin_smith: There's a ton of useful information in here, which never makes it out and isn't really archived in any useful form. |
| 19:30 | justin_smith | or discuss here less formally of course :) |
| 19:30 | Raynes | cfleming: Well, we're all accepting feature requests. |
| 19:30 | Raynes | Lazybot isn't an abandoned project. |
| 19:30 | erikcw | dbasch: I’m stuck with a tree. It is actually a Reagent “component” data structure |
| 19:30 | cfleming | I know it's logged, but trawling through there is a pain. |
| 19:31 | justin_smith | cfleming: ahh, publishable knowledge db |
| 19:31 | Raynes | :) |
| 19:31 | cfleming | Raynes: Great :) |
| 19:31 | amalloy | i am accepting feature requests but just proxying them to Raynes |
| 19:31 | Raynes | I'm accepting feature requests and proxying them to justin_smith. |
| 19:32 | Raynes | We have a knowledge database thing that sucks. |
| 19:32 | cfleming | I think it would be useful to have a command to give a range of timestamps, and perhaps the people involved in the conversation and a subject line, and take those items and publish them somewhere. |
| 19:32 | justin_smith | amalloy: I assume that thing with privmsg triggers wasn't solved |
| 19:32 | amalloy | justin_smith: i didn't touch it, no |
| 19:32 | technomancy | Raynes: hm; how do you teach lazybot facts? |
| 19:32 | amalloy | $learn technomancy super-smart |
| 19:32 | lazybot | My memory is more powerful than M-x butterfly. I won't forget it. |
| 19:32 | amalloy | $whatis technomancy |
| 19:32 | lazybot | technomancy is super-smart |
| 19:32 | Raynes | Excuse me. |
| 19:32 | Raynes | By knowledge base, I mean: "key value store" |
| 19:32 | technomancy | cool. can that be invoked inline like eval can? |
| 19:33 | Raynes | No. |
| 19:33 | Raynes | Adding inline invocations is harder than adding commands. |
| 19:33 | amalloy | technomancy: once upon a time, there was a feature that any lazybot command could be invoked inline |
| 19:33 | Raynes | And more likely to cause painful plugin interactions. |
| 19:33 | technomancy | sure, and more likelihood of accidental triggering |
| 19:33 | cfleming | Might get a little unwieldy, something like /store 13:27:58 13:32:17 justin_smith cfleming Raynes amalloy "lazybot archiving" |
| 19:33 | justin_smith | amalloy: I got that fixed, but it is not yet re-enabled I don't think |
| 19:34 | cfleming | Maybe it could just publish gists or something |
| 19:34 | Raynes | justin_smith: Oh, I can reenable that. |
| 19:34 | Raynes | cfleming: We don't do gists here son. |
| 19:34 | amalloy | justin_smith: the embedded plugin is enabled right now |
| 19:34 | justin_smith | Raynes: amalloy: that's just a question of including the plugin in the config, yeah |
| 19:34 | justin_smith | amalloy: oh! |
| 19:34 | justin_smith | OK |
| 19:34 | Raynes | You in the wrong place |
| 19:34 | cfleming | Raynes: refheaps, I mean. |
| 19:34 | Raynes | Damn right. |
| 19:34 | Raynes | This guy knows what's up. |
| 19:34 | cfleming | Don't know what I was thinking. |
| 19:35 | cfleming | Anyway, I think that would be really useful - there's a lot of knowledge dumped here that never gets out |
| 19:35 | dbasch | Raynes: github is making refheap seem prettier every day :P |
| 19:35 | technomancy | oh maaaaan. I saw some pretty hideous clojure highlighting earlier today |
| 19:35 | Raynes | I haven't updated refheap's pygments in like two years. |
| 19:35 | technomancy | red background on numeric literals; just the worst |
| 19:36 | technomancy | Raynes: like a google groups competitor, not getting worse over time may be all you need for a competitive advantage. |
| 19:36 | amalloy | technomancy: i can't imagine what rule they're applying that makes that seem like a good idea |
| 19:36 | justin_smith | does $#ping#$ work? |
| 19:36 | anybot | justin_smith: Ping completed in 0 seconds. |
| 19:36 | justin_smith | @part #clojure |
| 19:36 | anybot | Bai! |
| 19:37 | justin_smith | Raynes: do you have a different symbol setup for embedded commands? |
| 19:37 | Raynes | Do I? Good question. |
| 19:37 | amalloy | i don't think it's even configurable |
| 19:38 | dbasch | Raynes: I was thinking exactly what technomancy said |
| 19:38 | justin_smith | amalloy: you're totally right, it isn't |
| 19:38 | technomancy | like when librelist came out I was like "what is the point of this; who needs it" and then google groups got worse with every passing year, and now I'm like "this is so cool" |
| 19:38 | Raynes | justin_smith: It isn't configurable. |
| 19:38 | Raynes | Just to be clear. |
| 19:39 | justin_smith | right |
| 19:40 | technomancy | https://github.com/technomancy/atreus/blob/master/atreus.rkt#L157 |
| 19:41 | technomancy | red background on *brackets* |
| 19:41 | hiredman | hah, oh lord |
| 19:41 | technomancy | http://p.hagelb.org/sound-of.gif |
| 19:42 | amalloy | i wonder if the red brackets are the styling for "syntax error" and they're just no good at parsing clojure |
| 19:42 | technomancy | amalloy: well |
| 19:42 | technomancy | that's not clojure |
| 19:42 | technomancy | but yeah |
| 19:47 | justin_smith | Raynes: amalloy: weird, git tells me that your embedded.clj is the same as mine, but it clearly is not working with lazybot |
| 19:48 | dbasch | technomancy: it looks much better if you tell them it’s clojure, I wonder why they have such crappy highlighting for Racket. https://gist.github.com/dbasch/0a45cae2409e5e965641 |
| 19:49 | technomancy | truly inscrutable |
| 19:59 | kenrestivo | ##(doc compare-and-swap!) |
| 19:59 | lazybot | java.lang.RuntimeException: Unable to resolve var: compare-and-swap! in this context |
| 20:00 | catern | librelist is cool thanks for mentioning it |
| 20:00 | amalloy | compare-and-set! |
| 20:00 | technomancy | catern: it's got its problems, but it's much better than the alternatives |
| 20:00 | catern | well, i host my own mailing lists :) |
| 20:01 | catern | but it looks like something i can recommend to others |
| 20:01 | technomancy | catern: the main problem is you can't have a "welcome" type page explaining what the mailing list is about and how to join |
| 20:01 | technomancy | which is pretty annoying, but |
| 20:01 | technomancy | at least it's not google groups |
| 20:03 | catern | technomancy: as in you don't want to have to throw that page up somewhere yourself? because surely most open source projects already have websites |
| 20:03 | catern | (oh wait, they have github pages now. well, anyway) |
| 20:03 | kenrestivo | *cough* gnu mailman *cough* |
| 20:03 | technomancy | catern: well, you can't just point someone at the archives without some explanation |
| 20:04 | technomancy | you need one page to explain it and a separate page for the HTML archives. having them in one place would be better, or at least the ability to link from the archives to the primary web site |
| 20:04 | technomancy | kenrestivo: I don't trust myself with port 25 |
| 20:04 | catern | ah. hmm. true. |
| 20:06 | technomancy | catern: also it's abandonware, but that is not as bad a problem as you'd expect |
| 20:06 | danielcompton | cfleming: why did you decide to host the cursive list yourself? |
| 20:06 | danielcompton | curious |
| 20:06 | cfleming | danielcompton: Because I pretty much hate Google groups |
| 20:07 | danielcompton | cfleming: bahaha |
| 20:07 | cfleming | danielcompton: Plus, control your data etc etc |
| 20:07 | dbasch | google groups have become what yahoo groups used to be |
| 20:07 | cfleming | danielcompton: I'm gradually degooglifying my life |
| 20:07 | technomancy | (dec google) |
| 20:07 | lazybot | ⇒ 1 |
| 20:08 | cfleming | danielcompton: I looked at librelist but it explicitly states it's for OSS projects only |
| 20:08 | catern | opinions are divided it appears |
| 20:08 | cfleming | danielcompton: I like the look of Lamson (which LL is based on) but I couldn't get it working when I tried. |
| 20:09 | danielcompton | they all look like a bag of hurt to run yourself |
| 20:12 | cfleming | In the end I settled on mlmmj, which I really like |
| 20:12 | cfleming | Does everything I want, and nothing that I don't. |
| 20:12 | dbasch | you could have a subreddit, I think you can have a subreddit for anything |
| 20:12 | technomancy | heh |
| 20:12 | dbasch | even things that should not exist |
| 20:12 | amalloy | subreddits are as cheap as uh...core.async channels |
| 20:12 | cfleming | Actually, I'd like a web archive, but I'll roll that myself one day. |
| 20:13 | technomancy | https://www.reddit.com/r/MenonUnstableLadders/ |
| 20:13 | technomancy | https://www.reddit.com/r/bezels |
| 20:13 | dbasch | technomancy: http://www.reddit.com/r/ooer |
| 20:13 | cfleming | "Too much champher, not enough bezel?" |
| 20:13 | cfleming | I thought I had first world problems. |
| 20:14 | amalloy | dbasch: http://www.reddit.com/r/wowthissubexists/ (no guarantees about whether this is safe for work, although it claims to be) |
| 20:14 | technomancy | dbasch: O_O |
| 20:15 | danielcompton | NOT GOOD WITH SOCKS PLZ HALP??? |
| 20:15 | lazybot | danielcompton: Yes, 100% for sure. |
| 20:15 | cfleming | lazybot is so obliging. |
| 20:15 | dbasch | http://www.reddit.com/r/shittyprogramming |
| 20:17 | danielcompton | Just add this line at the beginning of main():double speed;that will tell the compiler that you want it extra fast. It should produce a notable improvement in execution speed. |
| 20:18 | amalloy | danielcompton: long time; since i heard that joke |
| 20:18 | kenrestivo | in cisco, land, there was "> ip enable more bandwidth", IIRC |
| 20:19 | danielcompton | http://i.imgur.com/Me04jVB.jpg |
| 20:21 | dc_ | danielcompton: lmao |
| 20:22 | dc_ | if i'm using java interop and i want to import java packages, how to i ensure that they're in my classpath when i run my code? |
| 20:23 | dc_ | i've imported a library with lein that uses these same java packages |
| 20:23 | kenrestivo | it may pull them in transitively. try lein tree and see? |
| 20:23 | TimMc | danielcompton: ... |
| 20:23 | TimMc | It's brilliant. |
| 20:24 | TEttinger | dc_: how are you running your code? lein uberjar should pack those java packages into the jar |
| 20:24 | dc_ | and the JAR that contains these packages is referenced in my :resource-paths and :jvm-opts in project.clj |
| 20:24 | dc_ | kenrestivo: k, i'll try that |
| 20:24 | danielcompton | dc_: lein tree :deps to show the transitives |
| 20:24 | amalloy | lein deps :tree |
| 20:24 | danielcompton | lein derps :tree |
| 20:24 | danielcompton | what amalloy said |
| 20:27 | dc_ | TEttinger: `lein uberjar` successfully compiled the classes and packed them into a jar, but i'm still having trouble running the repl |
| 20:28 | dc_ | or actually, it ran in the console |
| 20:35 | dc_ | also, i'm working with the aparapi-matrix library, which integrates with the java aparapi lib for matrix ops using the GPU. but when i enter the REPL and enter my namespace, none of the methods i've defined are recognized. |
| 20:36 | dc_ | instead i get a wierd error that says i have a compilation error in a temp file |
| 20:36 | dc_ | like this one: /private/var/folders/tv/cj4wg9x57xjbd2w91cp5r77c0000gn/T/form-init8574980338355462022.clj:1:1062 |
| 20:36 | dc_ | what does that mean? |
| 20:38 | dbasch | dc_: refheap the whole error |
| 20:39 | amalloy | dc_: (ns foo) doesn't load any of the code defined in foo; that's the job of (require 'foo). it just puts you into the namespace foo so that you can start defining it |
| 20:40 | dc_ | dbasch amalloy: it started working. using `lein uberjar` and `lein run` must have done something. now i can access the methods in my core namespace inside the repl |
| 20:41 | dc_ | thanks for helping though |
| 20:43 | dc_ | this aparapi-matrix library seems awesome though |
| 20:44 | dc_ | so far it seems to be working well with core.matrix, but i haven't tried much more than the aparapi-matrix examples |
| 23:37 | smnirven | this probably isnt the appropriate forum for this question, but does anybody know what happened to clojure-fill-docstring in clojure-mode? |
| 23:37 | justin_smith | smnirven: if nobody here knows, you may want to try #clojure-emacs |
| 23:38 | smnirven | perfect |