2014-11-23
| 00:00 | rritoch | I'm looking for a way to develop and modify classes at runtime, would this be possible if I were to create macros to generate deftypes with a given name to provide specific default functionality, and then use defprotocol + extend-type to add class specific functionality? |
| 00:01 | rritoch | Basically I'm trying to get around the fact that deftype doesn't seem to provide a way to extend a class. |
| 00:02 | rritoch | I know reify does, but these need to be named classes so I can have multiple instances floating around |
| 00:13 | technomancy | https://twitter.com/apontious/status/536355219622211584 |
| 00:14 | sdegutis | Compojure's destructuring syntax conveniently allows for params to be either keywords or strings, literally expanding to (get-in [req :params] :foo (get-in [req :params] "foo")) |
| 00:15 | sdegutis | I was not aware of this. |
| 00:20 | kenrestivo | rritoch: when i found myself in such straits, i ended up using gen-class |
| 00:21 | kenrestivo | then i went AAAAH!! why am i trying to write java in clojure! and ended up dropping the project. |
| 00:25 | rritoch | kenrestivo: Yeah, I'm trying to get away from gen-class because I want something that can be modified at runtime |
| 00:25 | rritoch | Right now I'm just toying with all of the possiblities |
| 00:25 | rritoch | I think I may have finally come up with a viable solution though |
| 00:25 | kenrestivo | rritoch: http://github.com/llasram/shady |
| 00:26 | kenrestivo | tho i think that is compile-time not runtime |
| 00:26 | rritoch | The core of my problem is simply that clojure doesn't provide namespace inheritance |
| 00:27 | rritoch | But I just had the idea that maybe I can get around that issue by providing the "parent" functions which take the namespace as the first argument |
| 00:27 | rritoch | So instead of -parentMethod ... I'd just call a regular function (foo (find-ns 'some-ns) ....) |
| 00:27 | kenrestivo | i don't know what problem you are trying to solve, but there might be a way to rethink it to be more functional and idiomatically clojure-y. |
| 00:28 | rritoch | kenrestivo: I'm trying to take a gen-class based MVC library and change it so it can be modified at runtime |
| 00:29 | rritoch | ex. https://github.com/rritoch/clj-grid-mvc/blob/master/src/com/vnetpublishing/clj/grid/lib/mvc/base/module.clj |
| 00:29 | rritoch | There's a lot of complexity in there that I'd like to keep out of sight |
| 00:30 | rritoch | But I'm thinking now that I can probaly get around this mess, intead of using inheritance, just make functions that take a namespace as the first argument, to apply whatever functionality is needed to the provided namespace. |
| 00:31 | kenrestivo | a kind of a shot in the dark, but this might help: https://github.com/ztellman/scrawl/tree/master/src/scrawl |
| 00:31 | kenrestivo | as an example of how to take something very OOP'ish and java-ish and make it more functional and idiomatic, in three steps. |
| 00:55 | brainproxy | in the sample.project.clj for the cljx library, org.clojure/clojurescript is listed under :dev :plugins |
| 00:56 | brainproxy | is that right? |
| 01:10 | yguan | Get a question on vector: get a value vector like [a1 a2 ... a3] and index [ 3 9 .. 876], how can I get a new vector filled with value correponding to those indexes? like keep-index? |
| 01:13 | rritoch | ,(mapv (partial get ["A" "B" "C"]) [2 0 1]) |
| 01:13 | clojurebot | ["C" "A" "B"] |
| 01:13 | rritoch | yguan: Like that? |
| 01:15 | yguan | rritoch: nice! never notice there is mapv... thanks |
| 01:30 | amalloy | rritoch: (partial get [x y z]) is just the same as [x y z]: vectors are functions |
| 01:31 | rritoch | ,(mapv ["A" "B" "C"] [2 0 1]) |
| 01:31 | clojurebot | ["C" "A" "B"] |
| 01:31 | rritoch | amalloy: Cool, didn't know that |
| 02:47 | kenrestivo | nice, neat alternative to having a kill-chan: use pub/sub |
| 03:24 | afdel | Hello I am new to clojure and I am use emacs with cider. Does anybody know if it is possible to jump to the error source line/function from compilation/runtime error buffers? |
| 03:25 | jack_rabbit | afdel, I do that sometimes. I'm actually not sure what plugin it is that allows this, though. :/ |
| 03:26 | afdel | Ah alright, I couldn't find a keybinding for it on the cider page, but it would be very helpful, especially since I am making a lot of errors right now :) |
| 03:26 | amalloy | afdel: in swank/slime it was v, from the stacktrace buffer. dunno about cider |
| 03:27 | jack_rabbit | afdel, IIRC, I could just scroll over the error in the buffer and hit 'return' to go to the offending file/line. |
| 03:27 | amalloy | and if the compilation buffer is a standard one, M-n or M-p should work? |
| 03:29 | amalloy | those are the keybindings that work in swank, anyway |
| 03:31 | afdel | I am looking for jump to error line. M-n just jumps to the next error in the *cider-error* buffer. It looks like I need a stack trace with the error line included to jump to that line by pressing enter. So if I get a runtime exception, then I can move the point to the stack trace line with my function and press enter to get there. So that solves the runtime part, but the error line does not... |
| 03:31 | afdel | ...show up in a stack trace during compilation. |
| 03:31 | jack_rabbit | cider is a little different, as I recall, but should have something comparable. |
| 03:32 | afdel | I do get a red line under the error line in my source buffer though... hmm. |
| 03:35 | afdel | Thanks for your help. |
| 03:58 | honza | when you start a `lein repl`, how much memory does it consume on average (just having it on)? |
| 04:00 | svteoi | clojure or haskell ? |
| 04:06 | rurumate_ | honza: you can set the maximum heap in the project.clj like this: :jvm-opts ["-Xmx1g"] |
| 04:07 | rurumate | now you can start halving that unit you can't start the repl anymore |
| 04:08 | rurumate | *until |
| 04:09 | honza | rurumate: cool, i'll try that |
| 04:12 | rurumate | honza: try connecting to the running repl and running this, to see if it really has all the memory you're trying to give it: |
| 04:12 | rurumate | ,(int (/ (.maxMemory (Runtime/getRuntime)) 1024 1024)) |
| 04:12 | clojurebot | #<CompilerException java.lang.SecurityException: Reference To Runtime is not allowed, compiling:(NO_SOURCE_PATH:0:0)> |
| 04:12 | rurumate | sorry clojurebot |
| 06:06 | mi6x3m | hey Clojure, what is the way to run a leiningen task every time lein run is executed? |
| 06:06 | mi6x3m | I found :release-tasks for lein release |
| 06:09 | mi6x3m | prep-tasks? |
| 06:17 | sqd | hi! in Om, i can use (get-node owner “myref”) on a (dom/input #js {:ref “myref”}). now i’ve replaced the dom/input with a custom component, that i build with (build my-comp app). is there still a nice way to get the value set in the custom component? |
| 06:19 | sqd | or should i work with callbacks here? |
| 06:19 | mi6x3m | technomancy: any way in leiningen to get the dependency key's contents to pass to a plugin task? |
| 06:24 | justin_smith | mi6x3m: a plugin can see (and even modify) the project map |
| 06:29 | aravindh | hi is there way to load libraries directly in clojure repl from github and work with it? |
| 06:31 | sqd | (worked around my issue by using global state instead of component state) |
| 06:31 | sqd | aravindh: lein-try |
| 06:31 | justin_smith | aravindh: inside a repl that is already running can be done with pallet/alembic |
| 06:32 | justin_smith | but lein-try is good if you want a fresh repl |
| 06:32 | aravindh | lein-try seems to be the one i was looking for. awesome. thank u |
| 06:33 | justin_smith | aravindh: neither one actually loads anything from github |
| 06:33 | justin_smith | btw |
| 06:33 | aravindh | it loads from clojars rights? |
| 06:33 | justin_smith | or maven / sonatype yeah |
| 06:33 | aravindh | cool. that should be enough |
| 06:34 | justin_smith | if something is only found on github, there is also lein install (followed by using lein-try or pallet/alembic) |
| 06:47 | daGrevis | hey! can i somehow unpack inline? something like this (let [x [1 2]] [[a b] x]) |
| 06:49 | justin_smith | daGrevis: ##(let [x [1 2] [a b] x] {:x x :a a :b b}) ; like this? |
| 06:49 | lazybot | ⇒ {:x [1 2], :a 1, :b 2} |
| 06:51 | daGrevis | justin_smith, just without let because i dont have it there. i have something like this (conj pairs [(second people-left) (first people-left)]) and I want to get rid of second and first calls |
| 06:51 | justin_smith | daGrevis: destructuring exists as a feature of let, fn, and loop |
| 06:51 | daGrevis | got it |
| 06:51 | justin_smith | you can write your own macro calling destructure if you like though |
| 06:52 | justin_smith | (destructure being the function that implements destructuring within those macros) |
| 06:53 | justin_smith | ,(conj [] ((juxt second first) [:a :b :c])) ; daGrevis |
| 06:53 | clojurebot | [[:b :a]] |
| 06:53 | daGrevis | cool! |
| 06:53 | justin_smith | juxt is pretty nifty |
| 06:55 | justin_smith | (inc juxt) |
| 06:55 | lazybot | ⇒ 17 |
| 07:05 | rurumate | What are unquote and unquote-splicing doing in core.clj? |
| 07:05 | rurumate | ,(bound? (var unquote)) |
| 07:05 | clojurebot | false |
| 07:06 | justin_smith | ,(resolve 'clojure.core/unquote) |
| 07:06 | clojurebot | #'clojure.core/unquote |
| 07:06 | justin_smith | ,(meta (resolve 'clojure.core/unquote)) |
| 07:06 | clojurebot | {:ns #<Namespace clojure.core>, :name unquote, :file "clojure/core.clj", :column 1, :line 13} |
| 07:08 | justin_smith | rurumate: do you mean, as in "why are they in that namespace?" |
| 07:09 | rurumate | yup, is there any known reason |
| 07:09 | justin_smith | rurumate: clojure, especially the core impl, doesn't really give a shit about information hiding |
| 07:11 | rurumate | I see it's used in LispReader.java |
| 07:14 | rurumate | ,`(unquote unquote) |
| 07:14 | clojurebot | (clojure.core/unquote clojure.core/unquote) |
| 07:14 | rurumate | so unquote is just a verbose way to write a tilde inside a syntax quote |
| 07:15 | rurumate | is there also a verbose way to write the backtick that starts the syntax quote? |
| 07:15 | justin_smith | ,`(a (unquote +)) |
| 07:15 | clojurebot | (sandbox/a (clojure.core/unquote clojure.core/+)) |
| 07:15 | justin_smith | not quite... |
| 07:15 | justin_smith | that didn't actually unquote |
| 07:15 | justin_smith | `(a ~+) |
| 07:16 | justin_smith | ,`(a ~+) |
| 07:16 | clojurebot | (sandbox/a #<core$_PLUS_ clojure.core$_PLUS_@1b1603b>) |
| 07:16 | justin_smith | that's different |
| 07:16 | rurumate | right.. so what is it doing then |
| 07:16 | justin_smith | it's the function used to implement the reader-macro, I believe |
| 07:16 | mi6x3m | rurumate: when you write 'unquote' inside a syntax quote, it's just another symbol |
| 07:17 | mi6x3m | where as ~ is a reader macro and clojure will process it |
| 07:17 | justin_smith | and in processing it, it then uses unquote |
| 07:17 | rurumate | yep, I was just wondering what the reader will do when it encounters unquote.. |
| 07:18 | justin_smith | nothing special, because unquote is not a reader macro |
| 07:18 | mi6x3m | if it encounters the symbol 'unquote it will do absolutely nothing |
| 07:18 | mi6x3m | because that's a symbol |
| 07:18 | mi6x3m | the semantic for symbols inside a syntax quote is to get a namespace prepended, but otherwise to remain unchanged |
| 07:19 | rurumate | apparently it has some meaning for the reader: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L44 |
| 07:19 | mi6x3m | but if it encounters ~ it will unqoute the expression using the "unquote" |
| 07:21 | justin_smith | rurumate: that is used in implementing what the reader macro does, but has nothing to do with what triggers it |
| 07:21 | mi6x3m | rurumate: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L898 |
| 07:21 | justin_smith | or what mi6x3m said |
| 07:21 | mi6x3m | and as you can see https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L89 |
| 07:22 | mi6x3m | only ~ triggers the UnquoteReader |
| 07:22 | rurumate | oh right, it's not registered in the macros[] array |
| 07:24 | rurumate | but now it's even more mysterious, unquote shows up in core.clj AND LispReader.java |
| 07:25 | rurumate | syntax-quote was there too, but got commented out |
| 07:33 | mi6x3m | I need some help |
| 07:33 | mi6x3m | I need to be able to access the contents of the :dependencies leiningen project key |
| 07:33 | mi6x3m | in the leiningen project file |
| 07:33 | mi6x3m | in order to pass them to a template |
| 07:33 | mi6x3m | is it doable? |
| 07:33 | justin_smith | mi6x3m: lein will pass the project data to your plugin |
| 07:34 | mi6x3m | justin_smith: I use an existing plugin which sadly takes only strings |
| 07:35 | justin_smith | I don't think I understand what you are doing |
| 07:35 | justin_smith | there is an existing plugin... |
| 07:36 | mi6x3m | justin_smith: well, I use the filegen plugin |
| 07:36 | mi6x3m | which generates files |
| 07:36 | mi6x3m | https://github.com/ThoughtWorksInc/lein-filegen |
| 07:37 | mi6x3m | what I want to do is to pass the dependencies vector to the plugin |
| 07:37 | justin_smith | and you want to access the rest of the project data, inside the :filegen key? |
| 07:38 | mi6x3m | well, yes |
| 07:38 | mi6x3m | it's what it amounts to |
| 07:38 | justin_smith | mi6x3m: maybe there is a way to do it with ~() - but I don't know what the variable is you would want to refer to |
| 07:38 | mi6x3m | justin_smith: the vector associated with :dependencies |
| 07:39 | justin_smith | mi6x3m: I know that. I mean inside ~() what is the name of the var to use |
| 07:39 | justin_smith | because it may or may not be bound, and I am not even sure of the name it would be bound to |
| 07:40 | mi6x3m | ah, ok I see, when will ~() get expanded? |
| 07:40 | mi6x3m | in the plugin? |
| 07:40 | justin_smith | when lein loads project.clj actually |
| 07:40 | justin_smith | so that may not be useful... |
| 07:40 | mi6x3m | another idea is to submit a short patch to the plugin's authors |
| 07:42 | justin_smith | wacky idea: specify deps in a separate file. use ~(read thatfile) to insert it into project.clj, and ~(slurp thatfile) again inside the :filegen key to also have it available in that context |
| 07:42 | justin_smith | that's weird for anyone trying to read your project.clj though |
| 07:42 | justin_smith | s/slurp/read above, I think |
| 07:42 | justin_smith | actually, probably ~(read-string (slurp "your-deps.edn")) in both places |
| 07:43 | mi6x3m | ehm yeah, that goes beyond sane :) |
| 07:43 | justin_smith | it does what you want though, but yeah, it's super weird |
| 07:44 | justin_smith | it's a classic circular data dependency problem |
| 07:44 | justin_smith | (unless the plugin is changed such that it can help you access the surrounding context, of course) |
| 07:44 | mi6x3m | justin_smith: well actually my end goal is to generate Leiningen projects dynamically from GUI samples I manage in my app |
| 07:44 | mi6x3m | so I need to generate a project.clj file for them |
| 07:44 | mi6x3m | and I want to use 1 such project.clj using the example viewer's dependencies |
| 07:45 | mi6x3m | so for each sample the user can press "Export Lein project", the app collects the dependencies vars, gets their sources, exports a source file and then I include this project.clj |
| 07:46 | mi6x3m | of course it's bloated with dependencies but it's dynamically generated! |
| 07:46 | justin_smith | if I were doing that, I would be tempted to do a dumb template, looping over the dependency coordinates as provided |
| 07:47 | mi6x3m | for what purpose? |
| 07:48 | justin_smith | to simplify the generation of the project file |
| 07:48 | mi6x3m | justin_smith: well the idea is that the project.clj will be pre-generated when lein run is run |
| 07:49 | justin_smith | see, that's the weird part to me, bundling the generation and running in one step seems to be adding unneeded complexity |
| 07:49 | justin_smith | brb, just updated OS, rebooting for sanity |
| 08:14 | robholland | what is returned when I do this in a repl: 'foo |
| 08:14 | robholland | ? |
| 08:14 | robholland | It prints: foo |
| 08:14 | robholland | But I don't really know what that is |
| 08:15 | robholland | or how to find out |
| 08:15 | TEttinger | 'foo is quoted |
| 08:15 | TEttinger | ,(class 'foo) |
| 08:15 | clojurebot | clojure.lang.Symbol |
| 08:15 | robholland | ah |
| 08:15 | robholland | (class ) is exactly what I was after :) |
| 08:15 | robholland | thanks |
| 08:15 | TEttinger | so it's a quoted symbol, and won't get evaluated when it's entered because of the quote |
| 08:16 | TEttinger | there's also type, not sure the difference |
| 08:16 | TEttinger | ,(type 'foo) |
| 08:16 | clojurebot | clojure.lang.Symbol |
| 08:16 | TEttinger | (doc type) |
| 08:16 | clojurebot | "([x]); Returns the :type metadata of x, or its Class if none" |
| 08:16 | TEttinger | (doc class) |
| 08:16 | clojurebot | "([x]); Returns the Class of x" |
| 08:19 | justin_smith | well, that was "fun" |
| 08:19 | justin_smith | haha |
| 08:23 | robholland | dunno about fun, useful ;) |
| 08:24 | TEttinger | robholland: that was referencing [04:49;48] <justin_smith> brb, just updated OS, rebooting for sanity |
| 08:25 | robholland | ah |
| 08:25 | robholland | :) |
| 08:40 | robholland | (defn hello |
| 08:40 | robholland | ([a & more] (str "Hello to this group: " |
| 08:40 | robholland | (apply str |
| 08:40 | robholland | (interpose ", " (concat (list a) more))) |
| 08:40 | robholland | "!"))) |
| 08:40 | robholland | Here the apply is required to compensate for the fact that interpose returns a lazy seq? |
| 08:41 | robholland | (apply f only-one-arg) seems a bit odd |
| 08:43 | justin_smith | robholland: ##(apply + (range 1000)) |
| 08:43 | lazybot | ⇒ 499500 |
| 08:43 | justin_smith | (range 1000) is only one arg |
| 08:44 | justin_smith | better version: (defn hello [a & more] (str "Hello to: " (clojure.string/join ", " (cons a more)) "!")) |
| 08:45 | justin_smith | though without more context, splitting a off at all is silly |
| 08:45 | robholland | the original is polymorphic |
| 08:45 | justin_smith | wat |
| 08:45 | robholland | I edited to ask a more concise question |
| 08:45 | justin_smith | OK |
| 08:46 | robholland | (defn hello |
| 08:46 | robholland | ([] "Hello World!") |
| 08:46 | robholland | ([a] (str "Hello, you silly " a ".")) |
| 08:46 | robholland | ([a & more] (str "Hello to this group: " |
| 08:46 | robholland | (apply str |
| 08:46 | robholland | (interpose ", " (concat (list a) more))) |
| 08:46 | robholland | "!"))) |
| 08:46 | justin_smith | please use a paste bin if it doesn't fit on one line |
| 08:46 | robholland | I think the & more is required to differentiate? |
| 08:46 | robholland | ok, sorry |
| 08:46 | justin_smith | the last one can still just be [& all] |
| 08:46 | justin_smith | it wil lwork |
| 08:46 | robholland | ok |
| 08:47 | justin_smith | anyway, cons is simpler than concat, and should be used in a case like that (except in this case you don't even need cons) |
| 08:47 | justin_smith | and string/join is preferable to making a string out of interpose |
| 08:48 | robholland | It might be demonstrating some use for later exersizes I suppose |
| 08:48 | justin_smith | right |
| 08:48 | robholland | but useful to know, thanks |
| 08:48 | justin_smith | np |
| 08:48 | robholland | did feel a bit weird |
| 08:49 | justin_smith | for that matter, they could be demonstrating [a & more] for pedagogical reasons, despite the fact it makes no sense there |
| 08:49 | justin_smith | ,((fn ([a] a) ([& more] (reverse more))) (range 10)) |
| 08:49 | clojurebot | #<CompilerException java.lang.RuntimeException: Can't have fixed arity function with more params than variadic function, compiling:(NO_SOURCE_PATH:0:0)> |
| 08:49 | justin_smith | err |
| 08:49 | robholland | I would have thought it would be better to use a case where having a and more split was useful though |
| 08:49 | justin_smith | ,((fn ([a] a) ([a & more] (reverse more))) (range 10)) |
| 08:49 | clojurebot | (0 1 2 3 4 ...) |
| 08:49 | justin_smith | OK, I was wrong |
| 08:50 | justin_smith | ,(apply (fn ([a] a) ([a & more] (reverse more))) (range 10)) |
| 08:50 | clojurebot | (9 8 7 6 5 ...) |
| 08:50 | justin_smith | sorry about that |
| 08:50 | robholland | still not understanding apply |
| 08:50 | justin_smith | robholland: apply treats every element of a collection as if it were an individual item |
| 08:50 | justin_smith | *individual argument |
| 08:51 | robholland | ok, so like *args in ruby |
| 08:51 | justin_smith | ,(apply (fn [a b c d e & more] c) (range)) |
| 08:51 | clojurebot | 2 |
| 08:51 | justin_smith | robholland: I think so |
| 08:51 | robholland | It 'unpacks' the collection into arguments |
| 08:52 | justin_smith | you may have thought apply was for applying a function to arguments, but we don't need any such function, as functions are fully first class |
| 08:52 | robholland | yeah, it felt that way, was trying to relate it to map |
| 09:26 | kzar | Is cemerick/austin still the best way to set up a browser repl with emacs? |
| 09:28 | kzar | Also does anyone find that with austin if they evaluate expressions inline with `cider-eval-last-sexp` it always returns nil? (At the nRepl expressions return the expected result) |
| 09:31 | jaaqo | Yes kzar, Mine at least does. I thinks there's an issue raised related to this. |
| 09:32 | kzar | jaaqo: Do you also find that when you first start the repl you sometimes have to refresh the page quit ea |
| 09:32 | kzar | quite a few times in the browser before the repl connects and stuff is sent through to it? |
| 09:33 | jaaqo | Oh, can't say, haven't really noticed such behavior |
| 09:35 | kzar | hmm OK |
| 09:35 | kzar | jaaqo: Know of any way around the nil return value thing? |
| 09:52 | jonh | mooo |
| 10:02 | jaaqo | kzar, https://github.com/clojure-emacs/cider/issues/830 might give answers |
| 10:04 | jaaqo | AFAIK they waiting for @cemerik for a piggieback fix |
| 10:29 | kzar | jaaqo: OK, thanks |
| 10:33 | gfredericks | llasram: ping |
| 10:51 | robholland | I've confused as to why this works: |
| 10:51 | robholland | http://pastebin.com/UB4AQv98 |
| 10:51 | robholland | It feels like it should give me back the collection in the same order, but it does indeed reverse it |
| 10:51 | robholland | What's the best way to figure that kind of thing out? Adding prn statements? |
| 10:52 | robholland | Sorry, wrong paste |
| 10:52 | robholland | http://pastebin.com/uyvc6gFh |
| 10:53 | justin_smith | robholland: cons turns [] into () |
| 10:54 | justin_smith | and it inserts to the front of the collection |
| 10:55 | justin_smith | so it's effectively a stack operation: you keep taking things off the input stack, and putting them on the output stack |
| 10:55 | TEttinger | is conj what we're after here? |
| 10:55 | robholland | The version I wrote blind, so to speak, is my first paste |
| 10:55 | justin_smith | I think he just wanted to know why it worked |
| 10:55 | robholland | The second one looks to me to do the opposite of my one |
| 10:55 | robholland | but they both work |
| 10:55 | justin_smith | and just like in real life, if you restack that way, the items end up in opposite order |
| 10:56 | justin_smith | you can try it with a stack of real objects, it's pretty simple when you see it happen - you take off the top of one, put on the top of the other... |
| 10:56 | justin_smith | when you are done with all the items, the order is reversed |
| 10:57 | robholland | I think I don't understand the order in which things happen |
| 10:57 | justin_smith | ? it's the order they are in the code |
| 10:58 | robholland | let me try it with real things :) |
| 11:04 | kzar | cemerick: Just the person :) |
| 11:10 | mavbozo | i watched rich hickey's conj talk on transducers. there's an interesting part for me, where he said that people use channel as a mean for asynchronous function to return result to its caller. |
| 11:10 | mavbozo | i don't understand what it means. So, I looked up for examples. Is this one kind of that examples? |
| 11:11 | mavbozo | https://github.com/halgari/clojure-conj-2013-core.async-examples/blob/c728e6a8bab8ca9c9cc58c8f4077bd3b0388626e/src/clojure_conj_talk/core.clj#L293-L300 |
| 11:13 | mavbozo | i also find another potential example. https://gist.github.com/martintrojer/5943467#file-nonblocking-kit-clj |
| 11:14 | kzar | mavbozo: So the http-get function returns a channel that gets the response pushed onto it when it arrives |
| 11:27 | rurumate | mavbozo: have you tried the walkthrough? also there's a good intro by tim baldridge |
| 11:27 | rurumate | see https://www.youtube.com/watch?v=enwIIGzhahw and https://github.com/clojure/core.async/blob/master/examples/walkthrough.clj |
| 11:37 | mavbozo | rurumate: yes. but, is the link i gave a good example of using channel to do async rpc call? |
| 11:40 | mavbozo | i still think channel is used like conveyor belt where you just put something in it or just wait something from it. not where you put your request on a conveyor belt and wait the response on another conveyor belt. |
| 11:45 | justin_smith | mavbozo: consider the fact that a go block returns a channel |
| 11:45 | justin_smith | that channel is used to get the result |
| 12:15 | mi6x3m | justin_smith: is it then possible to use the project itself as a plugin by including a :eval-in-leiningen in the project.clj? |
| 12:16 | leandro | hi, having an object like {:ip "192.37.144.188"} how do i println the ip value? |
| 12:17 | justin_smith | leandro: ##(println (:ip {:ip "192.37.144.188"})) |
| 12:17 | lazybot | ⇒ 192.37.144.188 nil |
| 12:18 | justin_smith | other options include ##(println ({:ip "192.37.144.188"} :ip)) |
| 12:18 | lazybot | ⇒ 192.37.144.188 nil |
| 12:19 | leandro | hmm |
| 12:19 | leandro | i go to try it |
| 12:19 | justin_smith | o |
| 12:19 | justin_smith | err... |
| 12:21 | leandro | justin_smith++ :) |
| 12:21 | mi6x3m | leandro: use (inc XYZ) |
| 12:21 | justin_smith | also ##(println (get {:ip "192.37.144.188"} :ip)) |
| 12:21 | lazybot | ⇒ 192.37.144.188 nil |
| 12:21 | justin_smith | we have many ways to say "get" |
| 12:21 | leandro | (inc justin_smith) |
| 12:21 | lazybot | ⇒ 145 |
| 12:22 | leandro | i was doing (println :ip {:ip "192.37.144.188"}) |
| 12:23 | justin_smith | ahh - just missing some parens then |
| 12:23 | leandro | yes, seems that () is mandatory always before println |
| 12:23 | leandro | *after |
| 12:23 | justin_smith | leandro: no #(println "hello" "world") |
| 12:23 | justin_smith | err |
| 12:24 | justin_smith | ##(println "hello" "world") |
| 12:24 | lazybot | ⇒ hello world nil |
| 12:24 | leandro | yes, i guess 'cause clojure doesn't need to evaluate "hello" |
| 12:24 | justin_smith | it's just that () is mandatory for evaluation of functions, so to use :ip as a function, you need to wrap it and its arg |
| 12:24 | justin_smith | it doesn't need to evaluate :ip either - it's just that you wanted it to :) |
| 12:24 | leandro | understood :) i'm very new to this |
| 12:25 | justin_smith | &(println :ip {:ip "localhost"}) is valid, just maybe not expected |
| 12:25 | lazybot | ⇒ :ip {:ip localhost} nil |
| 12:25 | leandro | yeah, that was what i got |
| 12:26 | justin_smith | luckily, the rules for clojure evaluation are extremely simple |
| 12:26 | justin_smith | maybe weird, but simple |
| 12:26 | justin_smith | so there are a few surprises in the beginning, but then things are very straightforward |
| 12:26 | justin_smith | until you hit things like #_ at least... |
| 12:28 | TEttinger | #_ is simple enough, it's like ; but for a form not a line |
| 12:28 | justin_smith | ,(#_#_ + * println #_#_ "hmm" "OK" "sure") |
| 12:28 | clojurebot | sure\n |
| 12:29 | justin_smith | it's the stacking that is weird |
| 12:29 | TEttinger | oh yeah that |
| 12:29 | justin_smith | it's counterintuitive, and nothing else in clojure behaves that way |
| 12:29 | TEttinger | but if you use #_ just normally to comment out one form without returning nil like (comment), it's fine |
| 12:30 | justin_smith | right |
| 12:30 | mi6x3m | justin_smith: remember my dependency issue from earlirer today? what were you suggesting about looping over the dependencies? |
| 12:31 | justin_smith | mi6x3m: I was suggesting that if project.clj top level and your plugin local map should see the dep graph, then you could load it from another source in both places via ~ in both places in project.clj |
| 12:32 | mi6x3m | hm |
| 12:32 | annelies | hindley-milner? |
| 12:33 | mi6x3m | justin_smith: what about using https://github.com/davidsantiago/configleaf |
| 12:33 | mi6x3m | it seems it allows you to see the leiningen settings at runtime |
| 12:41 | justin_smith | mi6x3m: oh, I thought you were doing all this in a plugin, so during lein runtime |
| 12:41 | mi6x3m | justin_smith: no, I actually only needed the dependencies in my project, _somehow_ :D |
| 12:41 | mi6x3m | so I was checking out all the plugins |
| 12:42 | justin_smith | mi6x3m: which is why I also suggested generating the project.clj via a simple template |
| 12:42 | justin_smith | which is not nearly as fancy, but may be a bit more reliable |
| 12:43 | mi6x3m | justin_smith: but I still didnt get how you get the dependencies? |
| 12:45 | justin_smith | mi6x3m: I thought you were generating them... |
| 12:45 | mi6x3m | justin_smith: I extract the dependencies among the _vars_ dynamically in the code |
| 12:46 | mi6x3m | this is to generate the source code |
| 12:46 | mi6x3m | I am trying to generate the project.clj with the dependency projects :) |
| 12:46 | mi6x3m | let me show you how I generate the source code now |
| 12:47 | justin_smith | right, so why can't you use a template to generate the project.clj - perhaps even starting with your existing project.clj loaded via slurp / read-string |
| 12:47 | justin_smith | right, so why can't you use a template to generate the project.clj - perhaps even starting with your existing project.clj loaded via slurp / read-string |
| 12:48 | justin_smith | err, sorry |
| 12:49 | mi6x3m | justin_smith: this is how I output the source http://pastebin.com/YNeDcFZ9 I use example-deps to collect the dependency vars across all namespaces |
| 12:50 | justin_smith | right, so can't you construct project.clj via a similar method? |
| 12:50 | justin_smith | given a basic skeleton of the project file |
| 12:51 | mi6x3m | well the plan now is to use configleaf which writes the project map to a namespace so it's available during runtime |
| 12:51 | mi6x3m | then I will generate the project.clj using a similar method :) |
| 12:52 | justin_smith | aha! |
| 13:03 | kenrestivo | is there an alts! equivalent which works outside of a go? |
| 13:03 | kenrestivo | i'm trying to wait for an event, with a timeout, outside of a go block. |
| 13:09 | mi6x3m | justin_smith: configleaf worked nicely :) |
| 13:09 | mjz | kenrestivo: the go block returns a channel, can't you block on that? |
| 13:09 | kenrestivo | that'd work, thanks. |
| 13:11 | mjz | There's also alts!! |
| 13:26 | drorbemet | Hi, how do I find the right host when starting a repl session using "lein midje :autotest" and then in emacs cider-connect? |
| 13:30 | kenrestivo | alts!! is what i wanted, actually. i was using crossclj and am still feeling my way around its doc browser |
| 13:37 | justin_smith | drorbemet: does lein midje :autotest open an nrepl server? |
| 13:38 | justin_smith | also, the right host should be "localhost" |
| 13:38 | justin_smith | the port is the trickier part |
| 13:39 | drorbemet | justin_smith: I think so , but I am to inexperienced to check for myself |
| 13:46 | pellis_ | hello |
| 13:46 | pellis_ | im trying to get into data wrangling and data sciece recently, from what it seems python dominates that. however since I would like access to the JVM i'm now considering clojure |
| 13:46 | pellis_ | how mature is the data science libraries of clojure? |
| 13:47 | pellis_ | in comparison to python (scikit, pandas, numpy) |
| 13:47 | drorbemet | justin_smith: yes right it's the port that does not autocomplete using cider-connect on a lein midje autotest instance started in a gnome-terminal |
| 13:49 | luxbock | pellis_: check out: https://github.com/clojure-numerics |
| 13:49 | pellis_ | thanks |
| 13:49 | kenrestivo | um, ok, async/filter< etc is deprecated, supposed to use transformers, but no transformers available yet? |
| 13:49 | luxbock | I can't really comment on how mature all of this is compared to the Python data stack though |
| 13:49 | drorbemet | I am still not sure if I should always run two instances of my project. One with midje autotest and the second as a repl in emacs using cider-jack-in? |
| 13:50 | luxbock | but core.matrix is cool in that you can swap your matrix implementation with practically one line of code |
| 13:50 | justin_smith | drorbemet: "lein repl" records its port when started, such that M-x cider automatically finds the port as a default if you run it while looking at anything in the project dir |
| 13:51 | luxbock | there's also Incanter, which I think is waiting to finish its upgrade to 2.0.0 that would integrate core.matrix with its existing functionality |
| 13:51 | drorbemet | Should I try to always run autotesting and interactive development in only one repl instance or should I use multiple at the same time. |
| 13:51 | drorbemet | justin_smith: yes, but why not the lein midje repl? |
| 13:51 | justin_smith | if "lein midge :autotest" opens a repl server, it would be nice if it did the same |
| 13:52 | justin_smith | if not, that's a feature request for lein midje I guess |
| 13:53 | drorbemet | justin_smith: right, this way I can't use it if I have to save some memory by using only one instance. What is the current workflow using leiningen, midje and emacs cider? |
| 13:54 | justin_smith | drorbemet: I have no idea, frankly. maybe someone in #clojure-emacs knows. I don't use midje. |
| 13:55 | leandro | is possible do with clojure windowed applications? like gtk3 or qt? |
| 13:56 | rpaulo | it's funny how "disassembled code" means something completely different when one is talking about clojure... |
| 13:57 | rpaulo | how is this generated: https://gist.github.com/gerritjvv/257f8713622b7ddac9ef ? |
| 13:57 | drorbemet | justin_smith: #clojure-emacs, ah, thanks |
| 13:57 | drorbemet | justin_smith: have a nice day, or evening. |
| 13:59 | rpaulo | ah: https://github.com/gtrak/no.disassemble |
| 14:01 | pellis_ | is incanter as good as R? |
| 14:01 | kenrestivo | define good |
| 14:03 | sooheonkim | incanter doesn't have ggplot2, that's for sure |
| 14:06 | pellis_ | kenrestivo: any company uses it in production to do data science that makes money. that's my definition of good i guess. |
| 14:07 | kenrestivo | people make money off of php in production, does that mean it's good? :-P |
| 14:07 | kenrestivo | seriously, i've used incanter and it seems very powerful. how it compares to R, i dunno, maybe someone's done a post on that somewhere. |
| 14:11 | wink | kenrestivo: now compare number of $ earned per month with php vs haskell and boom, we have a winner |
| 14:11 | kenrestivo | yep. in 25 years, i've found the relation between good and $-making is inverse |
| 14:12 | wink | hm, that's a bit simplistic |
| 14:12 | kenrestivo | there are outlyers :-) |
| 14:13 | wink | take number of clojure programmers and number of php programmers. then distribute over working force. |
| 14:13 | kenrestivo | plot it in incanter and we can see |
| 14:13 | wink | your chance for a working product is probably magnitudes higher in php |
| 14:14 | kenrestivo | i'm feeling silly, sorry. really loving core.async at the moment though. |
| 14:14 | TEttinger2 | php, that true == false language? |
| 14:16 | kenrestivo | incanter does make some cool charts tho. e.g. http://spazradio.bamfic.com/buffer/buffer.pdf |
| 14:16 | wink | that's what === is for. :P |
| 14:17 | sooheonkim | kenrestivo: is that your work? |
| 14:17 | kenrestivo | yes |
| 14:18 | sooheonkim | Nice. so that's with incanter itself, not a package? |
| 14:18 | kenrestivo | where "work" means 27 lines of clojure, using incanter. |
| 14:19 | kenrestivo | sauce: https://www.refheap.com/93830 |
| 14:20 | sooheon | first time i |
| 14:20 | sooheon | sorry. First time i've seen the reference heap |
| 14:20 | kenrestivo | thanks. incanter is easy, i can't take credit for how good it looks |
| 14:23 | TEttinger | sooheon, there's some cool features with refheap regarding lazybot |
| 14:24 | TEttinger | &(repeatedly 1000 #(rand-int 1000)) |
| 14:24 | lazybot | ⇒ (29 25 966 51 351 723 156 809 442 821 995 374 116 10 705 103 888 20 904 105 991 190 58 289 842 751 841 988 184 5 882 246 921 938 872 523 180 195 824 909 441 746 335 697 692 42 82 539 412 915 413 249 879 985 810 729 697 902 225 428 693 296 763 199 312 918 946 414 430 ... https://www.refheap.com/93832 |
| 14:24 | TEttinger | it links to the full output if it's too long |
| 14:24 | sooheon | niiice |
| 14:27 | sooheon | even like the syntax highlighting colors |
| 14:27 | sooheon | should take a look at the github |
| 14:47 | justin_smith | wow, if this is for real it is kind of amazing http://cs.stanford.edu/people/karpathy/deepimagesent/ -- automatically generates captions for images |
| 14:53 | leandro | how can i check if the last character of a sentence is an exclamation mark? (clojure.string/split "hi!" #"!") :/ |
| 14:55 | luxbock | ##(= (last "hi!") \!) |
| 14:55 | lazybot | ⇒ true |
| 14:55 | luxbock | leandro: ^ |
| 14:56 | leandro | :O |
| 14:56 | rhg331 | be in awe to clojure's seq abstraction |
| 15:09 | TEttinger | alternatively, ##(re-find #"!$" "hi!") |
| 15:09 | lazybot | ⇒ "!" |
| 15:09 | TEttinger | alternatively, ##(re-find #"!$" "hi! how are you?") |
| 15:09 | lazybot | ⇒ nil |
| 15:11 | TEttinger | if you want to find if a string ends in ?! or !?, ##(re-find #"(!?)|(?!)$" "what?!?!") |
| 15:11 | lazybot | ⇒ ["" ""] |
| 15:11 | TEttinger | oh right |
| 15:12 | TEttinger | if you want to find if a string ends in ?! or !?, ##(re-find #"(!\?)|(\?!)$" "what?!?!") |
| 15:12 | lazybot | ⇒ ["!?" "!?" nil] |
| 15:12 | danielcompton | (let [str "Wokka wokka!"] (= \! (.charAt str (count str)))) |
| 15:12 | danielcompton | ,(let [str "Wokka wokka!"] (= \! (.charAt str (count str)))) |
| 15:12 | clojurebot | #<StringIndexOutOfBoundsException java.lang.StringIndexOutOfBoundsException: String index out of range: 12> |
| 15:12 | rurumate | ,(.endsWith "abc?!" "?!") |
| 15:12 | clojurebot | true |
| 15:12 | danielcompton | ,(let [str "Wokka wokka!"] (= \! (.charAt str (dec (count str))))) |
| 15:12 | clojurebot | true |
| 15:12 | TEttinger | that too, heh |
| 15:12 | danielcompton | use charAt for the masochistic |
| 15:13 | black_13 | masochist? |
| 15:13 | rurumate | no thanks |
| 15:13 | TEttinger | for getting the last char, last is easier than charAt, is the point, black_13 |
| 15:14 | black_13 | ah |
| 15:14 | black_13 | i am new like a few days new to clojure |
| 15:14 | TEttinger | ah ok |
| 15:14 | TEttinger | it's a fun language |
| 15:14 | black_13 | how lisp is it |
| 15:14 | black_13 | do you have cdr car |
| 15:14 | rurumate | about 50% is lisp, the rest is java |
| 15:15 | black_13 | jisp |
| 15:15 | black_13 | or lava |
| 15:15 | black_13 | i have been trying to install the counterclockwise plugin for eclipse |
| 15:16 | TEttinger | black_13: car and cdr are called first and rest |
| 15:16 | TEttinger | there's a differences from other lisps page on the main site |
| 15:17 | black_13 | would clojure be able to do interop with a c library |
| 15:17 | black_13 | just curious |
| 15:17 | TEttinger | http://clojure.org/lisps |
| 15:17 | rurumate | black_13: in general, you can do all things jvm |
| 15:17 | black_13 | i would like to call the the VISA (National Instruments) |
| 15:17 | TEttinger | it can, but would require JNI or JNA most likely. |
| 15:17 | black_13 | java rmi |
| 15:18 | TEttinger | things that really need C and don't already have a java binding aren't easy |
| 15:18 | TEttinger | if they do have a java binding, it's very easy |
| 15:19 | black_13 | i think there is one |
| 15:20 | black_13 | would this the be appropiate place to ask about using the eclipse plugin |
| 15:20 | black_13 | i am getting the error http://codepad.org/UbwzKhbk |
| 15:21 | black_13 | every time i try to install counterclockswise |
| 15:25 | TEttinger | looks like your internet connection, or CCW's server, is failing when it tries to download CCW |
| 15:26 | black_13 | this make sense i have a crappy connection at sbucks |
| 15:26 | black_13 | is there a way to download all the plugin binaries and then install them |
| 15:29 | danielcompton | black_13: you could try installing the standalone version? |
| 15:32 | black_13 | sbucks network connect is terrible |
| 15:32 | black_13 | i am visiting relatives who do have internet |
| 15:32 | black_13 | sorry DONT have internet i mean |
| 15:36 | black_13 | it was the network connection |
| 15:37 | black_13 | hello clojure script? |
| 15:41 | TEttinger | black_13, what about clojurescript? |
| 15:45 | black_13 | TEttinger: i got eclipse to work! |
| 15:45 | TEttinger | yay |
| 15:45 | TEttinger | now I sleep |
| 15:45 | black_13 | some people left sbucks and the bandwidth went up |
| 15:45 | black_13 | is there an example of a hello world i can use to test eclipse with |
| 15:53 | black_13 | can you set break points ? using the eclipse/clojure |
| 15:54 | csd_ | How can I convert a str from LazySeq to non-lazy? pr-str isn't working for my purposes, and doall doesn't work with strings period AFAIK. |
| 15:54 | gfredericks | csd_: strings aren't lazy |
| 15:54 | SagiCZ1 | black_13: im sorry about that eclipse thing |
| 15:54 | csd_ | gfredericks: I'm trying to map format |
| 15:55 | gfredericks | csd_: I'm not sure what that means |
| 15:55 | csd_ | e.g. (map #(format "%s" %) coll) |
| 15:55 | black_13 | i was able to make a hello world that does run but no break points |
| 15:55 | SagiCZ1 | csd_: what is in coll? |
| 15:55 | gfredericks | csd_: okay; and (doall (map #(format "%s" %) coll)) doesn't do what you want? |
| 15:56 | SagiCZ1 | black_13: if i were you, i would throw eclipse out of the window, seriously (also ran over it with train, just to be sure) |
| 15:57 | black_13 | be a manly man and do everything thing from the command line or something else? |
| 15:57 | SagiCZ1 | black_13: try intellij with cursive |
| 15:57 | csd_ | gfredericks: https://www.refheap.com/93840 |
| 15:57 | black_13 | ok |
| 15:57 | black_13 | i will try anything once |
| 15:57 | SagiCZ1 | black_13: https://cursiveclojure.com/ |
| 15:58 | gfredericks | csd_: and what does it do wrong? |
| 15:58 | danielcompton | leandro: .endsWith take 5 ns vs 420 ns using last |
| 15:58 | danielcompton | ,(criterium.core/quick-bench (= \! (last "Wokka wokka!"))) |
| 15:58 | clojurebot | #<ClassNotFoundException java.lang.ClassNotFoundException: criterium.core> |
| 15:58 | csd_ | gfredericks: it writes to disk, but says LazySeq instead of the string |
| 15:58 | danielcompton | (require '[criterium.core]) |
| 15:58 | danielcompton | ,(require '[criterium.core]) |
| 15:58 | clojurebot | #<FileNotFoundException java.io.FileNotFoundException: Could not locate criterium/core__init.class or criterium/core.clj on classpath.> |
| 15:59 | gfredericks | ,(clojure.string/join (doall (map identity ["hey" "now"]))) |
| 15:59 | clojurebot | "heynow" |
| 15:59 | SagiCZ1 | gfredericks: thats why it matters whats in the coll |
| 16:00 | black_13 | SagiCZ1: i didn't see a download link |
| 16:00 | csd_ | ,(clojure.string/join (doall (map #(format "%s" %) '(foo bar)))) |
| 16:00 | clojurebot | "foobar" |
| 16:00 | csd_ | hrm |
| 16:00 | gfredericks | ,(println-str (doall (map identity ["hey" "now"]))) |
| 16:00 | clojurebot | "(hey now)\n" |
| 16:00 | SagiCZ1 | black_13: https://cursiveclojure.com/userguide/index.html |
| 16:00 | gfredericks | ,(println-str (doall (map identity '("hey" "now")))) |
| 16:00 | clojurebot | "(hey now)\n" |
| 16:00 | gfredericks | ,(clojure.string/join (doall (map identity '("hey" "now")))) |
| 16:00 | clojurebot | "heynow" |
| 16:00 | gfredericks | okay I give up |
| 16:01 | csd_ | its probably compliated by the for statement, because that plays poorly with side effects too |
| 16:01 | gfredericks | yeah I think you just want to try minimizing your example |
| 16:02 | gfredericks | you'll probably end up figuring the whole thing out in the process |
| 16:02 | black_13 | SagiCZ1: downloading |
| 16:02 | csd_ | ok |
| 16:09 | teslanick | I have two go-loops pulling from different channels that I want to stop at the same time. |
| 16:09 | teslanick | Is there a simple way to do that? |
| 16:10 | gfredericks | have them both watch a control channel that closes to signal they should quit? |
| 16:10 | teslanick | That's sorta what I was thinking. Is a mult the way to do that? |
| 16:10 | gfredericks | I think a single channel and alts works fine |
| 16:10 | gfredericks | you don't actually need any messages |
| 16:11 | teslanick | Oh. Duh. |
| 16:11 | teslanick | I totally forgot that everybody gets nil when a channel closes |
| 16:15 | leandro | how to check if a string is uppercase? |
| 16:18 | teslanick | A regex? |
| 16:19 | SagiCZ1 | ,(let [string "HELLO"] (= (.toUpperCase string) string)) |
| 16:19 | clojurebot | true |
| 16:19 | danielcompton | does doall block until the lazy sequence is realised? |
| 16:20 | SagiCZ1 | danielcompton: yes |
| 16:20 | justin_smith | ,(map #(= (.toUpperCase %) %) ["hello" "World" "OK" "nope" "GOOD"]) |
| 16:20 | clojurebot | (false false true false true) |
| 16:20 | justin_smith | ahh, SagiCZ1 beat me to the punch |
| 16:20 | SagiCZ1 | justin_smith: im glad i came up with similar solution |
| 16:20 | justin_smith | heh |
| 16:29 | _alejandro | Any pedestal users around? I'm trying to stream back a lazy sequence in a response, but it always waits until the entire sequence is realized |
| 16:34 | black_13 | how do i run clojure from the command line |
| 16:34 | gfredericks | black_13: with leiningen |
| 16:34 | black_13 | is there an equivalent of ipython? |
| 16:34 | SagiCZ1 | black_13: cursive didnt work? |
| 16:34 | black_13 | still downloading |
| 16:35 | black_13 | starbucks' bandwidth is really terrible |
| 16:35 | SagiCZ1 | i see |
| 16:35 | black_13 | about 5 minutes more |
| 16:35 | SagiCZ1 | they also have terrible coffee |
| 16:36 | black_13 | i am a tea drinker |
| 16:36 | gfredericks | black_13: what do you have? just the clojure jar? |
| 16:36 | black_13 | i did insteall leiningen |
| 16:36 | black_13 | install |
| 16:36 | gfredericks | `lein repl` to get a repl, `lein new hello-world` to generate a project |
| 16:36 | gfredericks | `lein help` to see other things it does |
| 16:37 | black_13 | i installed the windows install |
| 16:37 | SagiCZ1 | black_13: dont forget to add lein to path if you are on windows |
| 16:40 | csd_ | ,(mapcat #(format "%s" %) '(foo bar)))) |
| 16:40 | clojurebot | (\f \o \o \b \a ...) |
| 16:41 | gfredericks | ,(clojure.string/join (map #(format "%s" %) '(foo bar))) |
| 16:41 | clojurebot | "foobar" |
| 16:43 | justin_smith | ,(apply str (map #(format "%s" %) '(foo bar))) |
| 16:43 | clojurebot | "foobar" |
| 16:43 | gfredericks | ,'''''''''''''''(foo bar) |
| 16:43 | clojurebot | (quote (quote (quote (quote (quote (quote (quote (quote (quote (quote #)))))))))) |
| 16:43 | csd_ | My problem was being casued by mapcat apparently |
| 16:43 | gfredericks | interesting |
| 16:44 | csd_ | not particularly sure why |
| 16:44 | gfredericks | ,(print-str (mapcat identity ["foo" "bar"])) |
| 16:44 | clojurebot | "(f o o b a ...)" |
| 16:45 | csd_ | shrug |
| 16:45 | Bronsa | csd_: mapcat is calling concat on "foo" "bar" |
| 16:45 | Bronsa | ,(concat "foo" "bar") |
| 16:45 | clojurebot | (\f \o \o \b \a ...) |
| 16:45 | Bronsa | ,(mapcat #(list (format "%s" %)) '(foo bar)) |
| 16:45 | clojurebot | ("foo" "bar") |
| 16:45 | gfredericks | ,(apply concat (repeat "ha")) |
| 16:45 | clojurebot | (\h \a \h \a \h ...) |
| 16:46 | Bronsa | csd_: concat always returns a seq so you get a seq of chars |
| 16:46 | csd_ | ,(mapcat (fn [x] (format "%s, %s" (first x) (second x))) '(foo bar)) |
| 16:46 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol> |
| 16:47 | Bronsa | not sure why you'd expect that to work |
| 16:47 | csd_ | what's wrong with it |
| 16:47 | Bronsa | you're invoking first on 'foo |
| 16:48 | csd_ | ,(mapcat (fn [x] (format "%s, %s" (first x) (second x))) '((foo bar))) |
| 16:48 | clojurebot | (\f \o \o \, \space ...) |
| 16:48 | Bronsa | csd_: mapcat is like map, would you expect (map first '(foo bar)) to work? |
| 16:48 | Bronsa | csd_: you can't produce a string out of mapcat. |
| 16:49 | Bronsa | map/filter/mapcat & friends return a seq. |
| 16:50 | csd_ | I'm just trying to get it to return a lazyseq, I don't much care at the moment whether it's a str or a sequence of characters |
| 16:50 | Bronsa | csd_: if you want to get a string back either wrap the seq of chars with (apply str ..) or use reduce |
| 16:50 | csd_ | I was trying to reproduce this bug that was confusing me for the past hour |
| 16:51 | gfredericks | ,(str (range)) |
| 16:51 | csd_ | Bronsa: Would you do (map (format ..)) or something else? |
| 16:51 | clojurebot | #<OutOfMemoryError java.lang.OutOfMemoryError: Java heap space> |
| 16:51 | gfredericks | &(print-str (range)) |
| 16:51 | lazybot | Execution Timed Out! |
| 16:51 | Bronsa | ,(str (range 10)) |
| 16:51 | clojurebot | "clojure.lang.LazySeq@9ebadac6" |
| 16:51 | drojas | Hi guys, how do you run tests defined as metadata? |
| 16:51 | Bronsa | csd_: you want to get '(0 1 2 3 4 ..) out of that? |
| 16:51 | gfredericks | Bronsa: I remember this issue confusing me before |
| 16:52 | gfredericks | Bronsa: oh that's right -- it realizes the lazy seq and then gives you the worthless print |
| 16:52 | Bronsa | ,(pr-str (range 10)) |
| 16:52 | clojurebot | "(0 1 2 3 4 ...)" |
| 16:52 | Bronsa | gfredericks: yeah :| |
| 16:52 | gfredericks | I assume there's a patch somewhere |
| 16:52 | Bronsa | gfredericks: there should be a ticket in jira proposing to either change the toString or avoiding the full realization |
| 16:52 | Bronsa | there's no reason for the current behaviour |
| 16:53 | gfredericks | ,(str (Object.)) |
| 16:53 | clojurebot | "java.lang.Object@63acc" |
| 16:53 | gfredericks | yeah |
| 16:53 | gfredericks | ,(str (Object.)) |
| 16:53 | clojurebot | "java.lang.Object@eb2686" |
| 16:53 | gfredericks | hm |
| 16:53 | gfredericks | ,(let [o (Object.)] [(str o) (.hashCode o)]) |
| 16:53 | clojurebot | ["java.lang.Object@db3de8" 14368232] |
| 16:54 | Bronsa | gfredericks: it'd be reasonable if the current toString was that way to avoid realizing the seq but given that it realizes it it has no advantages |
| 16:54 | danielcompton | Is there a way to catch an exception, and rethrow it with exception info? |
| 16:54 | Bronsa | danielcompton: (cath Exception e (throw (ex-info (.getMessage e) {} e))) |
| 16:55 | gfredericks | ~cath is clojure's least known special form |
| 16:55 | clojurebot | You don't have to tell me twice. |
| 16:55 | csd_ | Bronsa: https://www.refheap.com/93843 |
| 16:55 | danielcompton | Bronsa: nice! I was looking at the docs but it wasn't clear what cause needed to be |
| 16:55 | csd_ | The bug was being caused in `polygon` by using mapcat instead of what's there now |
| 16:56 | rurumate | ,(partition 2) |
| 16:56 | clojurebot | #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/partition> |
| 16:56 | danielcompton | rurumate: clojurebot isn't running 1.7 |
| 16:56 | black_13 | SagiCZ1: finally downloaded |
| 16:56 | Bronsa | danielcompton: it is |
| 16:56 | Bronsa | there's no partition transducer though |
| 16:56 | rurumate | ,(map inc) |
| 16:56 | clojurebot | #<core$map$fn__4507 clojure.core$map$fn__4507@7cd052> |
| 16:57 | Glenjamin | ,*clojure-version* |
| 16:57 | clojurebot | {:interim true, :major 1, :minor 7, :incremental 0, :qualifier "master"} |
| 16:57 | rurumate | why is there no partition transducer? |
| 16:57 | Glenjamin | master is pretty vague, is there a way to get a build date / git-ref out of it? |
| 16:57 | danielcompton | oh, my bad. I thought a 1 arg call to partition would return a partition transducer |
| 16:58 | Bronsa | gfredericks: uhm, I can't find a ticket for lazyseq's toString |
| 16:58 | black_13 | SagiCZ1: so what do I install after doing intellij? |
| 16:58 | gfredericks | Bronsa: I remember discussing this before; maybe it was merely on clojure-dev |
| 16:59 | drojas | Hi guys, how do you run tests defined as metadata? |
| 17:00 | gfredericks | ,(doc test) |
| 17:00 | clojurebot | "([v]); test [v] finds fn at key :test in var metadata and calls it, presuming failure will throw exception" |
| 17:00 | gfredericks | I don't know if anybody really uses that, but there it is. |
| 17:01 | gfredericks | clojurebot: #((:test (meta %))) is a super minimal testing framework |
| 17:01 | clojurebot | You don't have to tell me twice. |
| 17:01 | danielcompton | rurumate: I think it's because of the arities that a transducer would require conflict with partition's existing arities. There's partition-all |
| 17:01 | danielcompton | though |
| 17:01 | danielcompton | ,(partition-all 2) |
| 17:01 | clojurebot | #<core$partition_all$fn__6741 clojure.core$partition_all$fn__6741@13ae860> |
| 17:02 | Bronsa | this is another reason why I think putting the transducers & the seq fns in the same var was a bad idea. |
| 17:03 | Bronsa | if the seq fn has more than one arity, the transducer version won't be able to implement them all |
| 17:03 | Bronsa | e.g. the partition-all transducer can't take the `pad` argument |
| 17:04 | Bronsa | err, the `step` argument |
| 17:04 | rurumate | ,(transduce (partition-all 2) conj [] [1 2 3]) |
| 17:04 | clojurebot | [[1 2] [3]] |
| 17:05 | rurumate | does tools.analyzer.jvm support reader macros? |
| 17:05 | Bronsa | tools.analyzer has nothing to do with the reader |
| 17:05 | rurumate | oh right |
| 17:05 | rurumate | I was confused about that |
| 17:08 | Bronsa | rurumate: tools.reader otoh .. |
| 17:09 | rurumate | that's a thing? |
| 17:09 | Bronsa | https://github.com/clojure/tools.reader |
| 17:09 | black_13 | SagiCZ1: still here? |
| 17:12 | rurumate | Bronsa: I'm trying to find out what the :op is. For example, why is :do the :op of (try)? |
| 17:13 | rurumate | for what purpose? |
| 17:15 | Bronsa | rurumate: well I'll explain you why in a second but first, you shouldn't assume specific :ops, all t.a.jvm can guarantee you is that for whatever form you input you'll get an AST that represents a form equal to the one you input in |
| 17:16 | Bronsa | rurumate: so the analyzer will transform (try foo bar baz) in (try (do foo bar baz)), this is where the do comes from |
| 17:17 | Bronsa | rurumate: the analyzer will also omit the try if the try form has neither a catch nor a finally statement so (try (do ..)) -> (do ..) |
| 17:19 | rurumate | amazing, I added a catch and now the :op is :try |
| 17:19 | alpheus | Can I do destructuring binding forms without literals? Or do I have to use macros for that. |
| 17:20 | rurumate | Bronsa: what is the :op field good for if I can not assume specific ops? something is not clear to me |
| 17:21 | alpheus | http://clojure.org/special_forms#binding-forms makes it pretty clear that they must be data structure literals, but did I miss something? |
| 17:21 | rurumate | Bronsa: is there a specification of what the analyzer should do? |
| 17:21 | andyf | rurumate: If you are trying to look through ASTs and correspond them directly with particular source forms, there are the :form and :raw-forms keys that might be of interest |
| 17:22 | andyf | Perhaps we can help more if you described what you are trying to do with the ASTs? |
| 17:22 | rurumate | nothing in particular, just trying to familiarize with the AST format of c.t.a |
| 17:23 | SagiCZ1 | black_13: im back |
| 17:23 | rurumate | I was wondering if some specification exists |
| 17:23 | andyf | there are some docs for it here: https://github.com/clojure/tools.analyzer/tree/master/spec |
| 17:24 | black_13 | i have intellij installed now downloading the cursive plugin |
| 17:24 | black_13 | SagiCZ1: do you have to uninstall lein |
| 17:24 | rurumate | andyf: yes! thanks |
| 17:24 | SagiCZ1 | black_13: great.. look around in intellij, it works similary to eclipse, its just faster and doesnt make you want to kill yourself. |
| 17:24 | SagiCZ1 | i dont think u have to uninstall it |
| 17:25 | black_13 | cool |
| 17:25 | andyf | A similar dir exists for things unique to tools.analyzer.jvm that would not be present, for example, in a ClojureScript version: https://github.com/clojure/tools.analyzer.jvm/blob/master/spec/ast-ref.edn |
| 17:26 | Bronsa | rurumate: there is generally a 1:1 corrispondence between the macroexpanded input and the output AST, but in some cases the analyzer might insert other nodes/do some syntactic transformation to the code that breaks the 1:1 corrispondence |
| 17:27 | Bronsa | rurumate: so for example there's no difference between (try 1) and (do 1) and the analyzer in this case choses to treat the former try expression as the simpler do expression |
| 17:27 | Bronsa | rurumate: this is something that the clojure compiler does too by the way |
| 17:31 | Bronsa | rurumate: here's a better view of the spec that andyf linked http://clojure.github.io/tools.analyzer.jvm/spec/quickref.html |
| 17:31 | rurumate | does tools.analyzer implement macroexpansion? or is it delegating to macroexpand |
| 17:31 | Bronsa | rurumate: t.a.jvm implements its own macroexpander |
| 17:32 | andyf | which can be overridden by the caller if you desire. |
| 17:32 | Bronsa | rurumate: it's quite complex but here it is https://github.com/clojure/tools.analyzer.jvm/blob/master/src/main/clojure/clojure/tools/analyzer/jvm.clj#L86-L176 |
| 17:34 | black_13 | lein is nice |
| 17:36 | gfredericks | (inc lein) |
| 17:36 | lazybot | ⇒ 3 |
| 17:36 | arrdem | (identity leiningen) |
| 17:36 | lazybot | leiningen has karma 7. |
| 17:37 | gfredericks | (- leiningen) |
| 17:37 | arrdem | lazybot should realy feature an aliases table.. |
| 17:37 | gfredericks | (/ leiningen) |
| 17:43 | danielcompton | arrdem: alias scala -> scalable language |
| 17:43 | metellus | (identity lein) |
| 17:43 | lazybot | lein has karma 3. |
| 17:43 | arrdem | danielcompton: hehe I really enjoyed that talk |
| 17:43 | danielcompton | arrdem: good perspective on why fire and brimstone isn't always the best way to evolve a language |
| 17:44 | arrdem | danielcompton: for sure... given appropriate goals of a lang. |
| 17:44 | arrdem | I mean.. fire and brimstone isn't a _bad_ thing if your goal as a lang is to experiment |
| 17:44 | arrdem | but I think that his point that Java as a lang is about stability and the consequent decisions was a valuable one |
| 17:46 | danielcompton | arrdem: yeah. I wasn't so keen on his characterisation of some of his users as unskilled though. It might be true, but I prefer to believe that people can learn new concepts |
| 17:48 | micrypt | arrdem: Sorry to interrupt, but what talk was that? |
| 17:48 | arrdem | danielcompton: sure... but I think we represent a very different crowd than an "average" dev shop even |
| 17:48 | arrdem | danielcompton: I mean... there was a guy in here a while back asking how to use Clojure as a scripting language the same way you would use php or perl |
| 17:48 | danielcompton | arrdem: yeah, I know. That's why I struggle with that idea myself, and I'm not sure what to think |
| 17:48 | arrdem | danielcompton: and the guy rejected all notion of better architecture because it was "too complex" for the guys adminned for |
| 17:50 | danielcompton | arrdem: he rejected it for the people below him in his company? |
| 17:50 | arrdem | yep |
| 17:51 | arrdem | he wanted a way to (load) another file, fast, for side-effects same way you do load in other langs |
| 17:53 | danielcompton | micrypt: https://www.youtube.com/watch?v=2y5Pv4yN0b0&spfreload=10 |
| 17:55 | micrypt | danielcompton: Thanks. |
| 17:58 | danielcompton | arrdem: you TA right? |
| 17:59 | arrdem | danielcompton: ya |
| 17:59 | arrdem | hence last night's ranting... grading time :P |
| 17:59 | danielcompton | do you think there are students that are just unteachable of higher level concepts? |
| 18:00 | arrdem | ugh |
| 18:00 | danielcompton | ugh question or ugh answer? |
| 18:01 | arrdem | ugh question. give me five years, a few million for some real studies and I'll get back to you |
| 18:01 | danielcompton | arrdem: np |
| 18:01 | technomancy | there's no such thing as unteachable, only unwilling |
| 18:01 | arrdem | ^ that |
| 18:01 | technomancy | well, barring mental disorders |
| 18:02 | arrdem | yeah... that's where things get really fun |
| 18:02 | technomancy | where you draw the line on that is really difficult and extremely touchy |
| 18:03 | technomancy | but if you could get rid of all the students who aren't actually interested in learning, you might at least have a shot at getting it right |
| 18:03 | arrdem | that fits nicely with my experience |
| 18:03 | arrdem | there are kids who want a degree and to get on with their lives |
| 18:03 | arrdem | and there are kids who legitimately want to learn something |
| 18:07 | arrdem | technomancy: got a minute? |
| 18:08 | technomancy | arrdem: sure, for a bit |
| 18:08 | arrdem | technomancy: sweet. I'd like you to take a look at the new lein alias based lein-grim. lemme push this so you can see it.. |
| 18:08 | technomancy | oh cool; we talked about this a while ago? |
| 18:08 | arrdem | yeah |
| 18:09 | arrdem | I'm close to having it working, but I think I need some of your magic to finish it. |
| 18:11 | technomancy | all I have left is Magic Missle |
| 18:11 | technomancy | HTH |
| 18:11 | arrdem | technomancy: https://github.com/clojure-grimoire/lein-grim/tree/develop |
| 18:11 | arrdem | so the alias I'm trying to use is right there in the readme... |
| 18:12 | arrdem | https://github.com/clojure-grimoire/lein-grim/blob/develop/src/grimoire/doc.clj#L175-L176 |
| 18:12 | arrdem | That is the function I'm trying to drive with that alias |
| 18:12 | technomancy | so |
| 18:12 | arrdem | unfortunately the alias doesn't seem to be stringing the classpath as I need. |
| 18:13 | technomancy | one solution would be to just use the production profile and scan the classpath for every ns that's not in a jar |
| 18:13 | technomancy | but the production profile doesn't have grimoire |
| 18:13 | arrdem | right |
| 18:14 | technomancy | oh yeah, the group/artifact/version is actually available at runtime with pom.properties now |
| 18:14 | technomancy | provided you don't need pre-2.5.0 support |
| 18:14 | arrdem | do I look like I care about legacy users? I'm 22. ain't got time for that shit. |
| 18:14 | technomancy | good point |
| 18:14 | technomancy | so yeah, do that |
| 18:14 | technomancy | but the source-paths is trickier |
| 18:14 | danielcompton | arrdem: fire and brimstone |
| 18:15 | arrdem | danielcompton: the Grimoire codebase is hell on earth rn |
| 18:15 | technomancy | what happens when you try to pass :project/source-paths as an arg? |
| 18:15 | arrdem | technomancy: string encoding error, I forget the exact stack trace |
| 18:15 | technomancy | arrdem: before it reaches in-project grimoire? |
| 18:15 | arrdem | technomancy: yep |
| 18:15 | arrdem | iirc |
| 18:16 | technomancy | drat |
| 18:16 | technomancy | the solution might be that we need to pr-str all :project/whatever substitutions |
| 18:24 | gizmo385 | How can I import a java file that is in the same directory as my Clojure file? |
| 18:27 | arrdem | technomancy: yeah using :project/source-paths errors out for me |
| 18:27 | arrdem | lein 2.4.3 |
| 18:29 | akos | hi |
| 18:29 | Guest24650 | hi |
| 18:29 | oyvinrob | gizmo385: (import package.name.ClassName) ? |
| 18:30 | Guest24650 | I just started learning clojure and I came up to ask, if you have a good suggestion for an IRC channel for guys learning the language |
| 18:31 | gizmo385 | oyvinrob, tried that |
| 18:31 | gizmo385 | ClassNotFoundException |
| 18:31 | oyvinrob | gizmo385: the class has to be compiled and added to the classpath |
| 18:31 | oyvinrob | gizmo385: are you using leiningen? |
| 18:32 | gizmo385 | No because I'm trying to build a clojure extension to a pre-existing Java project |
| 18:32 | gizmo385 | And reorganizing the entire project structure to fit with leiningen doesn't really seem that practical |
| 18:33 | danielcompton | Guest24650: I think there's #learnclojure |
| 18:33 | rhg331 | ,(java.io.File. "/") |
| 18:33 | clojurebot | #<File /> |
| 18:33 | oyvinrob | gizmo385: hmm, well then you have to make sure that the class you need is being compiled by your existing build system, and added to the classpath that is used when running the clojure ext |
| 18:33 | rhg331 | ok |
| 18:33 | rhg331 | it just bans writes |
| 18:33 | technomancy | arrdem: it might need a change in leiningen |
| 18:33 | technomancy | if :project/foo currently only works with numbers and strings that's lame |
| 18:33 | rhg331 | was woried my own sandbox was being weird |
| 18:34 | gizmo385 | oyvinrob, Is there anyway to add a directory to a classpath with leiningen? |
| 18:34 | arrdem | technomancy: (u_u) |
| 18:34 | gizmo385 | So that I could create src/main/clojure and point it towards the directory with the compiled java classes? |
| 18:34 | rhg331 | not at runtime |
| 18:35 | gizmo385 | Because I tried just changing :java-source-paths and :source-paths and it caused similar issues |
| 18:35 | Raynes | justin_smith: Interestingly, since the integration of new irclj, lazybot has been utterly stable. |
| 18:35 | Raynes | I wonder if my socketing was just dumb in the original version... |
| 18:35 | rhg331 | :resource-paths i think |
| 18:35 | rhg331 | for plain add to classpath |
| 18:52 | arrdem | technomancy: it looks like :source-paths is being str'd as a list, of strings and then eval-string'd somewhere to generate a "str cannot be cast to fn" exception. |
| 18:59 | danielcompton | Does anyone have a cleaner solution to patching a library than this? https://github.com/jonase/kibit/blob/upgrade-deps/src/kibit/check.clj#L1-L26 |
| 19:01 | arrdem | as monkey patches go.. could be worse |
| 19:01 | danielcompton | arrdem: seems preferable than making a clojars fork for a one line change |
| 19:01 | arrdem | agreed |
| 19:02 | arrdem | maybe pull that patch code out into it's own file and (load) that file when you need to? |
| 19:02 | arrdem | (ns kibit.check ...) (load "monkey-patch.clj") |
| 19:02 | arrdem | just so you keep the ns being the first thing |
| 19:02 | arrdem | there isn't an ordering requiremnt I can see between the monkey patch and the ns form |
| 19:03 | danielcompton | arrdem: I'd need to do this everywhere that uses core.logic.unifier right? |
| 19:03 | danielcompton | arrdem: although I think I need to do my current solution everywhere too |
| 19:03 | danielcompton | 'solution' |
| 19:03 | arrdem | technomancy: no... with neither solution do you need to do that everywhere |
| 19:04 | arrdem | oops. danielcompton not technomancy |
| 19:04 | arrdem | just add that monkey patch somewhere at the root of your application. defs are global, and require will never reload unless told to do so |
| 19:04 | arrdem | so that root monkey patch will cover all of kibit |
| 19:04 | arrdem | no need to repeat yourself |
| 19:05 | danielcompton | what if someone never requires kibit.check if they're using it as a library? |
| 19:05 | arrdem | yeck |
| 19:06 | danielcompton | put it in the project.clj hahaha |
| 19:06 | arrdem | if that's the alternative I'd say bug dnolen to get that patch merged with the threat of beer or something |
| 19:06 | arrdem | ew pls no |
| 19:07 | danielcompton | would monkey-patch.clj go outside of the src directory? |
| 19:21 | arrdem | danielcompton: a realization: by changing that def, you're lying about the transitively depended version of core.logic by altering it. If you need that patch, the nicest thing you can do is have the patched fn somewhere you can require it in. altering it in place is a packaging fault. |
| 19:27 | andyf | danielcompton: I don?t know if it is cleaner, but it can be effective to copy a library into your own, and change its namespace names. Then it ?becomes your own code?, and you have no external dependency. You can undo that with a later release if the dependency fixes the problem you need fixed. |
| 19:28 | andyf | Requires compatible licenses, the willingness on your part to do such a thing, and for there to be no need to 'communicate data' between your copy&renamed version and the original (or that they be compatible in that regard) |
| 19:34 | danielcompton | arrdem: do you mean require it in in my own ns? The problem is that prep* is a private function that isn't used directly |
| 19:36 | arrdem | danielcompton: oh ugh. yeah I'd seriously hold off until you can scare up a patched core.logic release. |
| 19:36 | arrdem | which I know is a bad answer... but anything else is worse :/ |
| 19:40 | danielcompton | arrdem: hmmm. Making a fork seems like the cleanest option. It makes the dependency clear, doesn't require copying the project and changing my directory structure e.t.c., and is easily changed later if the patch comes in |
| 19:40 | arrdem | danielcompton: sure if you want to drop a new release right meow that's your best option imo |
| 19:41 | danielcompton | arrdem: I'm heading away to Europe in two weeks and it'd be nice to drop an early christmas present before I go away |
| 19:41 | arrdem | danielcompton: I suspect you can get some act from dnolen in two weeks :P he's pretty good about this stuff. |
| 19:42 | danielcompton | k, I'll give it a week, there's other things to work on in kibit while I wait |
| 19:52 | andyf | This is temporarily the "people who hack on jonase's projects" channel :) |
| 19:52 | arrdem | I mean... |
| 19:52 | arrdem | #clojure is just one big hack :P |
| 19:53 | arrdem | okay lein-grim 0.3.0 ready methinks... |
| 19:53 | amalloy | danielcompton: is there some reason that it matters? |
| 19:54 | andyf | guilt of inefficient use of hardware? |
| 19:54 | danielcompton | amalloy: it just feels a bit horrifying when you unpack a jar and see all of the classes wizz by |
| 19:54 | danielcompton | amalloy: although that's more about how many dependencies a simple project can have |
| 19:55 | amalloy | andyf: sure, but class count specifically? there are plenty of other sins to be thinking about in a jvm program |
| 19:55 | andyf | oh, I have never worried about number of class files. I am simply projecting why he might be concerned :) |
| 19:55 | Glenjamin | think about all those projects that aim to minimise dependencies. and wonder how much they wrote themselves which already existed |
| 19:56 | arrdem | how the hell is this function... |
| 19:57 | dcunit3d | hey guys I've got some questions about generating java classes using clojure. i know that it's possible, but I'm wondering if it's feasible to generate the classes used for Aparapi, java's OpenCL API. |
| 19:57 | arrdem | andyf: :P sorry |
| 19:57 | dcunit3d | here's a gist with a sample Aparapi class: https://gist.github.com/dcunited001/eba5027134089619e703 |
| 19:58 | dcunit3d | there's a few keywords that are specific in there. a few method names that have to match up exactly, etc. |
| 19:59 | dcunit3d | i watched a talk about using Clojure to generate some of the classes used for Hadoop jobs |
| 19:59 | andyf | and here I am guilty of misspelling a commonly said phrase, when that annoys me when I notice someone else doing it. I should have said "bated breath", as in "abated" or "lessened". |
| 20:00 | amalloy | andyf: unless you are in the habit of eating worms or something. then your breath might be baited |
| 20:00 | dcunit3d | by the way, i'm signed in with irssi, is anyone getting my messages? for whatever reason, when i use irssi it seems like i'm on mute or something |
| 20:00 | dcunit3d | i just recently started using irssi again, with SASL |
| 20:00 | danielcompton | dcunit3d: reading load and clear |
| 20:00 | amalloy | dcunit3d: yes, it's fine |
| 20:01 | dcunit3d | danielcompton amalloy: cool thanks, i was just wondering. i was logging in under the name dc_ about a week ago |
| 20:01 | andyf | I don't know if you follow xkcd, or its "what if?" series, but that reminds me of the 2nd of the "alternative universe what ifs" here: http://what-if.xkcd.com/120/ |
| 20:02 | dcunit3d | i might just repurpose some of the examples i saw with hadoop a few weeks ago. just not sure if the classes will match up in a way that works with Aparapi |
| 20:02 | dcunit3d | but if they did, a DSL for generating those AoT classes would be pretty powerful |
| 20:03 | amalloy | andyf: also http://xkcd.com/1268/ |
| 20:03 | andyf | dcunit3d: what are the requirements for the class you want to generate? e.g. it needs to extend class com.amd.aparapi.Kernel? |
| 20:04 | dcunit3d | andyf: it's mostly the @override keyword i'm worried about |
| 20:05 | dcunit3d | andyf: you have to @override the public void run() method |
| 20:05 | dcunit3d | and i think Aparapi takes the bytecode for that method and converts it into a parallelized method that's run on the GPU |
| 20:05 | andyf | Isn't @override in Java just a way to ask the compiler to give you a compilation error if the signature does not match one in the superclass? |
| 20:06 | dcunit3d | i'm not sure how aparapi works |
| 20:06 | amalloy | andyf: yes |
| 20:06 | dcunit3d | andyf: it's actually been a long time since I've written any java, so i don't know |
| 20:07 | andyf | It sounds like the @override isn't necessary to make this work. Just a way to help catch typos in method signatures. |
| 20:07 | dcunit3d | andyf: awesome, so i think this is possible |
| 20:12 | andyf | dcunit3d: I have only read the intro pages of the aparapi project, but it says: "it will attempt to convert the bytecode of the overridden run() method (and all run-reachable methods) to OpenCL? and execute the code on the GPU. If it can?t then the Java? code is executed using a thread pool" |
| 20:12 | andyf | I haven't yet found a description of what conditions the byte code must meet in order to be convertible by aparapi |
| 20:13 | andyf | It is possible you will be able to call aparapi and get correct results, but perhaps only because it used the fallback mechanism of not using the GPU. |
| 20:19 | danielcompton | andyf: this looks like what you're after https://code.google.com/p/aparapi/wiki/JavaKernelGuidelines |
| 20:21 | andyf | dcunit3d: You'll probably want to (set! *unchecked-math* true) on any Clojure code you try this with, do not use any Clojure data structures in the kernels, and hope your GPU supports doubles, because Clojure primitive math defaults to doubles, and I think may not be capable of generating primitive math operations on floats. |
| 20:28 | amalloy | andyf: indeed clojure will not do primitive math on floats |
| 20:29 | danielcompton | is there a function to pull out a keyword from a map, no matter where it is? I was thinking of getting a seq of nested keys but I'm not sure what it would be called |
| 20:30 | danielcompton | ah, zippers might be the key |
| 20:50 | irctc | Hi. Can someone help me figure out how to join vectors the way I want? I'm trying to do the following: |
| 20:51 | irctc | function f takes an arg and returns data like [[1 2 3][4 5 6]] |
| 20:51 | irctc | I'm trying to (mapv #(f %) arg-list) |
| 20:51 | danielcompton | irctc: what do you want the output to look like? |
| 20:52 | irctc | I'd like [[1 2 3][4 5 6][7 8 9][10 11 12]] |
| 20:52 | danielcompton | icedp: what's the input? |
| 20:52 | irctc | I'm getting [[[1 2 3][...]] etc |
| 20:52 | danielcompton | irctc: is that a nested vector of nested vectors? |
| 20:52 | irctc | I'm trying to end up with one 2d vector |
| 20:52 | irctc | yes |
| 20:53 | irctc | each output of function f is a few vectors in a vector |
| 20:53 | danielcompton | ,(apply concat [[[1 2 3] [4 5 6]]]) |
| 20:53 | clojurebot | ([1 2 3] [4 5 6]) |
| 20:53 | irctc | ultimately I want all of the inner vectors to just be in one big series |
| 20:53 | irctc | hmm |
| 20:54 | dbasch | irctc: what does your function do? |
| 20:54 | irctc | ,(apply concat [[[1 2 3][4 5 6]][[7 8 9][10 11 12]]] |
| 20:54 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 20:54 | irctc | ,(apply concat [[[1 2 3][4 5 6]][[7 8 9][10 11 12]]]) |
| 20:54 | clojurebot | ([1 2 3] [4 5 6] [7 8 9] [10 11 12]) |
| 20:54 | irctc | it's complicated what the function does, but it outputs a vector of several vectors |
| 20:54 | irctc | I think this apply concat is what I need |
| 20:55 | Raynes | I herd u liek vectors |
| 20:55 | _alejandro | irctc: mapcat should do it |
| 20:55 | irctc | ok, I'll look that up |
| 20:55 | irctc | thanks for all the suggestions. back in a min |
| 20:55 | _alejandro | ,(mapcat #(repeat 2 %) [[1 2 3] [4 5 6]]) |
| 20:55 | clojurebot | ([1 2 3] [1 2 3] [4 5 6] [4 5 6]) |
| 20:55 | _alejandro | vs |
| 20:55 | _alejandro | ,(mapv #(repeat 2 %) [[1 2 3] [4 5 6]]) |
| 20:55 | clojurebot | [([1 2 3] [1 2 3]) ([4 5 6] [4 5 6])] |
| 20:56 | irctc | ahh |
| 20:56 | dmahanta | what does double square bracket mean defn foo [[a b]] |
| 20:56 | _alejandro | dmahanta: it means destructure the argument |
| 20:56 | _alejandro | dmahanta: so the function takes 1 arg that is a vector with at least 2 items |
| 20:56 | _alejandro | dmahanta: the first item is called a, the second b |
| 20:57 | _alejandro | ((fn [[a b]] (prn "A: " a)) [1 2]) |
| 20:57 | _alejandro | ,((fn [[a b]] (prn "A: " a)) [1 2]) |
| 20:57 | clojurebot | "A: " 1\n |
| 20:57 | dmahanta | got it thanks |
| 20:58 | irctc | mapcat is great |
| 20:58 | irctc | now I just have one more wrinkle |
| 20:59 | irctc | I'd like to "prepend" an array to that array of arrays, such that ["A" "B" "C"] + [[1 2 3][4 5 6]...] => [["A" "B" "C"][1 2 3][4 5 6]...] |
| 21:00 | irctc | so (generate-header-vector) + (mapcat ...) |
| 21:00 | _alejandro | irctc: concat? |
| 21:01 | _alejandro | ,(concat [:a :b :c] (mapcat #(repeat 2 %) [[1 2 3] [4 5 6]])) |
| 21:01 | clojurebot | (:a :b :c [1 2 3] [1 2 3] ...) |
| 21:01 | _alejandro | ,(concat [[:a :b :c]] (mapcat #(repeat 2 %) [[1 2 3] [4 5 6]])) |
| 21:01 | clojurebot | ([:a :b :c] [1 2 3] [1 2 3] [4 5 6] [4 5 6]) |
| 21:01 | _alejandro | ,(cons [:a :b :c] (mapcat #(repeat 2 %) [[1 2 3] [4 5 6]])) |
| 21:01 | clojurebot | ([:a :b :c] [1 2 3] [1 2 3] [4 5 6] [4 5 6]) |
| 21:02 | irctc | I like the results, but I feel like it's going to be really confusing to read my code later |
| 21:03 | irctc | ok, the (cons) is more reasonable without the extra [] |
| 21:03 | irctc | thanks! |
| 21:03 | _alejandro | irctc: yeah, don't know if that's going to help make it understandable :-) |
| 21:03 | irctc | cons I get. I'm just so used to having what seems obvious to me not work, I didn't even try that one! |
| 21:06 | irctc | thanks all, now I can go to bed where my brain has apparently already been for a few hours! |
| 22:00 | seancorfield | just watched rich's Inside Transducers talk from the conj - he talks about educe but that doesn't seem to be in 1.7.0 master yet? |
| 22:01 | gfredericks | is he just making up words now? |
| 22:03 | justin_smith | seancorfield: I think it is something like eduction |
| 22:03 | seancorfield | http://www.merriam-webster.com/dictionary/educe |
| 22:03 | seancorfield | ah yes, thanx justin_smith |
| 22:04 | seancorfield | clojure.core/eduction |
| 22:04 | seancorfield | ([xform coll]) |
| 22:04 | seancorfield | Returns a reducible/iterable/seqable application of |
| 22:04 | seancorfield | the transducer to the items in coll. Note that these applications |
| 22:04 | seancorfield | will be performed every time reduce/iterator/seq is called. |
| 22:05 | seancorfield | and it's in alpha 4 so no need for master |
| 22:05 | justin_smith | Raynes: well, regardless of the reason, it's good news that it stays up now |
| 22:06 | seancorfield | +1 justin_smith |
| 22:06 | seancorfield | heh, used to a bot in another channel |
| 22:06 | seancorfield | (inc justin_smith) |
| 22:06 | lazybot | ⇒ 146 |
| 22:08 | gfredericks | (dec the bot in the other channel) |
| 22:08 | lazybot | ⇒ -1 |
| 22:11 | seancorfield | Curry wins. Variants are not Unions will be dessert. |
| 22:37 | danielcompton | What do people think about a Clojure port of https://github.com/fxn/i-told-you-it-was-private? |
| 22:39 | justin_smith | danielcompton: I wonder if anyone has actually gotten their files removed by that thing |
| 22:39 | danielcompton | justin_smith: only once |
| 22:41 | danielcompton | https://github.com/fxn/i-told-you-it-was-private/issues/4 |
| 22:42 | csd_ | Is it possible for a namespace A to include another ns B's functions such that when I load ns A in the repl that ns B's functions are available to me? |
| 22:43 | gfredericks | csd_: not really; is your motivation about namespace/file structuring, or about repl utilities/convenience, or something else? |
| 22:44 | justin_smith | csd_: you could loop and intern matching vars based on the output of ns-publics - but it seems like a weird thing |
| 22:44 | csd_ | gfredericks: laziness mostly, the one ns is basically wrapping the other and adding some functions. but i can't easily load them both right now because of name conflicts |
| 22:45 | gfredericks | ,'ping |
| 22:45 | clojurebot | ping |
| 22:45 | gfredericks | erc and/or freenode just told me I was banned |
| 22:46 | justin_smith | woah, weird |
| 22:46 | csd_ | it said you were K-lined |
| 22:46 | gfredericks | but here I am back so I guess I'm not? Anyhow if csd_ replied to me I missed it |
| 22:46 | csd_ | gfredericks: laziness mostly, the one ns is basically wrapping the |
| 22:46 | csd_ | other and adding some functions. but i can't easily load them both |
| 22:46 | csd_ | right now because of name conflicts |
| 22:46 | csd_ | i wish erc could copy/paste properly |
| 22:47 | gfredericks | csd_: I assume you know about (require '[foo :as bar])? |
| 22:47 | justin_smith | gfredericks: http://en.wikipedia.org/wiki/IRCd#K-line |
| 22:47 | justin_smith | gfredericks: may want to check you don't have a security issue with your client |
| 22:56 | gfredericks | ...erc? |
| 22:58 | csd_ | are Jaaod and dakrone bots of yours? they were k-lined when you were |
| 22:59 | gfredericks | nope |
| 23:00 | csd_ | i'm guessing its probably some server issue |
| 23:04 | gfredericks | computers are the worst |
| 23:07 | theseb | i'm glad Clojure is ported to CLR and .NET |
| 23:07 | theseb | but |
| 23:07 | theseb | that means if you are addicted to the JVM libraries you lose right? |
| 23:07 | gfredericks | no you win because you keep using clojure on the jvm |
| 23:08 | theseb | gfredericks: my point is when python was ported to JVM i think he dragged along all the libraries.....i dunno if the CLR port actually ported all the JvM libraries...did they? |
| 23:09 | justin_smith | on the other hand, you can do decent native style GUI apps |
| 23:09 | gfredericks | well "is ported to" might be strong language |
| 23:09 | theseb | justin_smith: on CLR port? |
| 23:09 | gfredericks | clojure kind of reinvents itself on each new platform |
| 23:09 | justin_smith | theseb: people don't even use python3 because it has less library support |
| 23:09 | gfredericks | you could think of them as dialects of clojure |
| 23:10 | justin_smith | theseb: yeah, unlike java you can get a decent compatible UI |
| 23:10 | theseb | justin_smith: yes but only for Windoze right? |
| 23:10 | justin_smith | theseb: gnome uses mono for GUI stuff |
| 23:10 | justin_smith | so no, not just for windows, but maybe not for mac? |
| 23:12 | theseb | justin_smith: wait...didn't java make a swing replacement that looked native for different platforms? |
| 23:12 | justin_smith | theseb: which one is that? |
| 23:12 | theseb | dunno....what is the best of the best java gui ? |
| 23:13 | theseb | justin_smith: but regardless...imho...no one uses guis anymore right? they all use html right! :) |
| 23:16 | csd_ | i cant wait until things come full circle and its easy to use command line to use facebook, twitter, etc |
| 23:49 | kenrestivo | there's a twitter commandline client, i used to use it |
| 23:52 | justin_smith | there are irc chans where the bot does semi-automated tweeting |
| 23:53 | justin_smith | they are one of the better things in the web about having an accessible API actually |