2015-10-08
| 00:50 | nXqd | !help |
| 00:50 | nXqd | ,(def a "something") |
| 00:50 | clojurebot | #'sandbox/a |
| 00:51 | nXqd | a bit offtopic, how is this clojurebot created ? it's pretty neat |
| 00:51 | justin_smith | nXqd: it's a repl with a whitelist and sandbox, the source is easy to find on github |
| 00:52 | justin_smith | nXqd: made by hiredman |
| 04:27 | sm0ke | is there something like doseq which returns list instead of side effect? |
| 04:28 | wmealing | dorun ? |
| 04:28 | schmir | sm0ke: doall |
| 04:28 | sm0ke | ,(for [x (range 10)] (inc x)) |
| 04:28 | wmealing | isnt what is returned.. what you want ? |
| 04:28 | clojurebot | (1 2 3 4 5 ...) |
| 04:28 | sm0ke | i guess i can use `for` |
| 04:29 | sm0ke | i always seem to forget about `for` in clojure |
| 04:30 | sm0ke | its such an underrated expression in clojure tbh |
| 04:33 | patrkris | /part/part |
| 04:33 | borkdude | sm0ke for, or map |
| 04:34 | borkdude | sm0ke but for is more similar to doseq, with a fancy binding and :let, :when |
| 04:34 | borkdude | sm0ke possibly multiple bindings yielding a cartesian product |
| 04:37 | sm0ke | yes multiple bindings is also unique about `for` compared to a map |
| 04:38 | sm0ke | a single map in short can be an equivalent of chains of map filter |
| 04:38 | muhuk | suppose (unique? [1 2 3]) => true & (unique? [:x :x]) => false, what should (unique? nil) or (unique? []) do? |
| 04:38 | borkdude | I never realized that doseq also supports multiple bindings until now |
| 04:39 | sm0ke | ,(doseq [x [1 2] y 3] (prn (str x "," y))) |
| 04:39 | clojurebot | #error {\n :cause "Don't know how to create ISeq from: java.lang.Long"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: java.lang.Long"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.core$seq__4116 invokeStatic "core.clj" 137]\n [clojure.co... |
| 04:39 | sm0ke | ,(doseq [x [1 2] y [3]] (prn (str x "," y))) |
| 04:39 | borkdude | sm0ke 3 should be [3] there |
| 04:39 | clojurebot | "1,3"\n"2,3"\n |
| 04:39 | sm0ke | nice i didnt knew this either |
| 04:40 | sm0ke | does it also supports :when ? |
| 04:40 | sm0ke | heh |
| 04:40 | borkdude | hmm |
| 04:40 | sm0ke | oh it does |
| 04:40 | sm0ke | "with bindings and filtering as provided by "for"" |
| 04:41 | borkdude | yes, it does! |
| 04:41 | borkdude | wow |
| 04:41 | sm0ke | ,(doseq [x [1 2] y [1 3]] (prn (str x "," y)) :when (= x y)) |
| 04:41 | clojurebot | "1,1"\n"1,3"\n"2,1"\n"2,3"\n |
| 04:42 | sm0ke | huh |
| 05:18 | TEttinger | ,(doseq [x [1 2] y [1 3] :when (= x y)] (prn (str x "," y))) |
| 05:18 | clojurebot | "1,1"\n |
| 05:18 | TEttinger | sm0ke: ^ |
| 05:19 | sm0ke | heh thanks TEttinger |
| 05:19 | TEttinger | no prob, those :when and :while etc. are handy |
| 07:51 | bordeltabernacle | Hi! I'm new to Clojure (and IRC!) and just thought I'd introduce myself and "join in the conversation" y'know. |
| 07:53 | dstockton | hey bordeltabernacle |
| 07:53 | dstockton | welcome |
| 07:53 | bordeltabernacle | Hi dstockton, thanks. |
| 07:53 | bordeltabernacle | feel kinda high school goofy! |
| 07:55 | dstockton | things seem quiet today |
| 07:56 | snowell | Welcome, bordeltabernacle! |
| 07:57 | bordeltabernacle | Thanks, snowell! |
| 08:07 | noncom | what's the most idiomatic way to update all values in a {} by a function? (except for reduce, if possible) |
| 08:07 | noncom | or is reduce the most idiomatic one? |
| 08:08 | dstockton | i'd say its fine noncom, or you can (into {} (for [kv] ... |
| 08:08 | dstockton | there is also https://clojure.github.io/algo.generic/clojure.algo.generic.functor-api.html#clojure.algo.generic.functor/fmap |
| 08:08 | dstockton | user=> (fmap inc {:a 1 :b 3 :c 5}) |
| 08:08 | dstockton | {:a 2, :b 4, :c 6} |
| 08:09 | noncom | oh wow |
| 08:09 | dstockton | this uses the into (empty m) version |
| 08:09 | noncom | right |
| 08:09 | noncom | interesting! |
| 08:09 | dstockton | https://github.com/clojure/algo.generic/blob/aa028f7467d193a5cfad0626b324f4c682b91c15/src/main/clojure/clojure/algo/generic/functor.clj#L29 |
| 08:10 | dstockton | there was a whole load of discussion here yesterday about it |
| 08:11 | noncom | gotta read that from the archive |
| 08:11 | noncom | dstockton: is it going to be in the core sometimes? |
| 08:12 | dstockton | don't know, actually i didn't catch all of the discussion yesterday either |
| 08:13 | noncom | well, good that the bots are taking care of logs |
| 08:16 | dstockton | most of it was about type systems and haskell |
| 08:21 | noncom | dstockton: yes, i already found it! just yesterday me and a friend of mine were talking about the same thing, also mentioning haskell, but we did not see it here. what a synchronicity! |
| 08:36 | taharqa | Hi there ! |
| 08:36 | taharqa | I'm new to Clojure as well, what can I say to someone that told me "Clojure is not a Lisp" ? |
| 08:39 | MasseR | taharqa: what was his reasoning? |
| 08:42 | taharqa | MasseR: « a lisp should be a langage built on top of functions that are primitives (atom, quote, eq, car, cdr, cons, cond, lambda, apply, etc ) and should rely entirely on this primitives » |
| 08:44 | opqdonut | well clojure is built on top of the primitives |
| 08:44 | opqdonut | listed on http://clojure.org/special_forms |
| 08:45 | opqdonut | and what does it matter what some guy thinks |
| 08:45 | opqdonut | clojure certainly isn't a very traditional lisp |
| 08:45 | opqdonut | maybe you can settle on calling it lisp-like :) |
| 08:45 | MasseR | Besides, that's the first I've heard of that kind of condition for being a lisp |
| 08:46 | taharqa | opqdonut: the guy in my opinion mix the language and the platform |
| 08:47 | taharqa | opqdonut: the fact that Clojure share with java may seems to them that those are not primitives |
| 08:47 | opqdonut | MasseR: it's quite widely repeated, see e.g. http://steve-yegge.blogspot.fi/2006/04/lisp-is-not-acceptable-lisp.html |
| 08:48 | taharqa | MasseR: yes strange, he points me to http://axisofeval.blogspot.fr/2010/04/why-i-ignore-clojure.html |
| 08:48 | opqdonut | or http://stackoverflow.com/questions/3482389/how-many-primitives-does-it-take-to-build-a-lisp-machine-ten-seven-or-five |
| 08:48 | taharqa | opqdonut: excellent ^^ |
| 08:49 | opqdonut | even axisofeval ends with |
| 08:49 | opqdonut | > Now, go ahead and have fun using Clojure if it floats your boat, but stop whining about how it's a more modern or better Lisp. That doesn't make the slightest bit of sense. |
| 08:51 | noncom | taharqa: clojure is a lisp because it is a list processing language and it is homoiconic. it is not the grahams lisp, however, and it is not scheme and it is not common lisp. it is clojure... |
| 08:52 | noncom | taharqa: it has some jvm interop which may frighten pure lisp people, but this is the reality of jvm and actually a bliss |
| 10:51 | gfredericks | apparently the 4clojure test suite has been broken (uncompileable) for over two years |
| 10:53 | gfredericks | it's made it through six or so commits without anybody noticeing |
| 11:07 | sobel | is there a prettier way to say this: (merge-with (fn [_ s] s) default-config file-config) |
| 11:07 | sobel | specifically the (fn [_ s] s) |
| 11:10 | michaniskin | (comp peek vector) |
| 11:11 | luma | sobel, isn't that just using the value from the second map, so the same as (merge default-config file-config) |
| 11:12 | tdavis | is there any way to expand to a symbol's full namespace a-la syntax quote when inside a quoted list? as in, '(reify SomeClass (foo [bar baz] ...)) i need 'SomeClass' to be 'com.ns.SomeClass' because it's being used in a macro expansion. |
| 11:15 | sobel | luma: thx |
| 11:35 | justin_smith | tdavis: syntax-quote does namespace expansion, not class-name, I think... |
| 11:35 | justin_smith | ,`String |
| 11:36 | clojurebot | java.lang.String |
| 11:36 | justin_smith | oh, never mind :) |
| 11:40 | justin_smith | ,'String |
| 11:40 | clojurebot | String |
| 11:51 | tdavis | has anybody ever gotten "NullPointerException clojure.lang.Reflector.invokeNoArgInstanceMember" just trying to call macroexpand on something? |
| 11:52 | justin_smith | tdavis: no, but if a macro is buggy, it can npe while expanding |
| 11:52 | tdavis | is there any way to debug it? |
| 11:53 | tdavis | i wrote a macro, it works fine, but calling it in a loop from a function is NPE'ing despite the fact that i've confirmed none of the arguments are nil. |
| 11:53 | tdavis | and for whatever reason i can't even expand the call to see what could be wrong |
| 11:54 | justin_smith | maybe try expanding the surrounding loop form? |
| 11:54 | tdavis | i pulled it out of the loop entirely, same result. |
| 11:57 | tdavis | progress, maybe! ClassCastException clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol clojure.core/ns-resolve (core.clj:4216) |
| 11:57 | justin_smith | sobel: michaniskin: I benchmarked a few variants, #(do %2) was the fastest shorthand, (comp second list) was slowest, (comp peek vector) did OK https://www.refheap.com/110425 |
| 11:59 | justin_smith | yeah, that sounds like a macro that is either broken, or being used improperly |
| 12:00 | justin_smith | sorry, beyond expanding things I don't have any good macro writing / macro debugging tips |
| 12:00 | justin_smith | I'm not so great at macros myself, maybe someone else can help |
| 12:01 | tdavis | justin_smith: yeah... once i eliminated all the other macros involved (i forgot, e.g., `let') i'm getting more of a stack trace. might be something to do with (to-array) usage... Constructor.newInstance() usage is convoluted from clojure. |
| 12:11 | tdavis | interesting! i am passing a macro a argument of type java.lang.Class but inside the macro the type is clojure.lang.PersistentList |
| 12:15 | justin_smith | ,(type ''foo) |
| 12:15 | clojurebot | clojure.lang.PersistentList |
| 12:15 | justin_smith | could it be an extraneous quoting / not enough evaluation issue? |
| 12:16 | tdavis | the macro isn't receiving the value just the raw list which i guess makes sense since it's being expanded prior to the calling function being evaluated |
| 12:20 | justin_smith | well, the idea with macros is you want them to get the raw form, and need to explicitly do any level of evaluation needed to get the compile time value they need |
| 12:32 | clgv | Hello, is there an option to set the timeout for an aleph tcp client connection attempt? |
| 12:41 | clgv | ok :bootstrap-transform and setting CONNECT_TIMEOUT_MILLIS is the solution |
| 14:39 | boxed | is there a way to make a macro expand into two forms? in my case I want to output both a defn and another macro from a macro |
| 14:43 | justin_smith | boxed: `(do ...) |
| 14:44 | boxed | ah crap, that was obvious in hind sight, thanks :P |
| 14:44 | boxed | but I guess this only works for outputting two things that are side effect-y right? |
| 14:45 | boxed | (for my case fine, but I’m thinking about the general case) |
| 14:45 | snowell | For multiple return values you can just return a vector |
| 14:45 | justin_smith | boxed: otherise, output a collection containing both results |
| 14:46 | justin_smith | right |
| 14:46 | boxed | well, that doesn’t work in reagent when I want to output say two [:td]s at some point |
| 14:46 | justin_smith | boxed: in that case I use into |
| 14:47 | snowell | You'd return a [:div] with the two [:td]s in it :) |
| 14:47 | justin_smith | (into [:div] (thing-returning-tow-tds)) |
| 14:47 | boxed | snowell: you can’t have a a div randomly inside a tr |
| 14:47 | snowell | Er…what he said |
| 14:47 | snowell | Not with that attitude |
| 14:47 | justin_smith | haha |
| 14:47 | boxed | hah, yea, “works” is a bad attitude |
| 14:48 | boxed | seriously though, I’ll take this as “nope" |
| 14:48 | snowell | I'd take what justin_smith said |
| 14:48 | justin_smith | boxed: I have had good luck using into (or occasionally just conj) to combine stuff in reagent |
| 14:48 | justin_smith | though my literal suggestion above is not correct for that case |
| 14:49 | snowell | ,(into [:div] [[:td :first] [:td :second]]) |
| 14:49 | clojurebot | [:div [:td :first] [:td :second]] |
| 14:49 | boxed | justin: problem with that is that the code ends up really ugly because the internal behavior of the component leaks out.. in that you have to (into) it |
| 14:50 | boxed | snowell: that produces an invalid DOM |
| 14:50 | justin_smith | boxed: that's true, and I wish there were a better solution, maybe using om :P |
| 14:51 | boxed | justin_smith: yep, at least I’m doing the right thing currently :P pity, I would want clojure macros to be just a tiiiny bit more powerful :P |
| 14:51 | justin_smith | boxed: essentially for your case you would need the ability to modify the containing form, and that is just --- eww |
| 14:52 | skeuomorf | How do people do DTLS in Clojure land? |
| 14:53 | skeuomorf | Please don't tell me bouncy castle :( |
| 14:53 | boxed | justin_smith: nah, just the ability for a macro to output several forms. Like C macros can :P |
| 14:55 | justin_smith | boxed: that's a modification of the parent form |
| 14:55 | justin_smith | c macros don't even have a concept of "form", and can clearly modify parent forms at will |
| 14:55 | justin_smith | reified concept of form that is, of course |
| 14:56 | boxed | justin_smith: I don’t see what you’re saying. Changing the contents of the parent form is all that macros do. A macro that can’t modify the parent form isn’t a macro, it’s just a literal |
| 14:57 | justin_smith | no, there is a difference between your form (args to a macro) and the parent form (the thing containing the macro), one aspect of the parent form, which you would be altering, is the argument count |
| 14:58 | boxed | justin_smith: another aspect is the contents.. I really don’t see the big difference |
| 14:58 | justin_smith | it's all the difference |
| 14:58 | boxed | yea, in my case between nice code and eeeeww :P |
| 14:59 | boxed | between useful and not so much |
| 14:59 | justin_smith | boxed: it would mean a much messier compiler |
| 15:00 | boxed | justin_smith: don’t buy that. Instead of “append x” you could do “append x, append y” |
| 15:00 | boxed | “much messier” seems like an exaggeration |
| 15:02 | justin_smith | boxed: I would not be surprised if it doubled the line count - because it makes a bunch of shitty things possible that are not possible in the current design. |
| 15:02 | boxed | “shitty”? didn’t you just above say it would be much nicer? |
| 15:03 | boxed | simplicity of the compiler should not be confused by simplicity of the user code |
| 15:05 | boxed | I guess the big problem is that reagent templating is done in clojure native forms, which just can’t express things cleanly for these cases |
| 15:06 | boxed | oh yea, and another problem is that HTML is shite of course, but that almost goes withouth saying :P |
| 15:29 | daniel__1 | if i write code for someone with no contact and hand it over, do i have any rights over said code? |
| 15:30 | daniel__1 | contract* |
| 15:31 | hiredman | http://copyright.gov/help/faq/faq-general.html#mywork |
| 15:38 | daniel__1 | thanks hiredman |
| 15:48 | Cr8 | in future though, don't do that -- copyright isn't magic, they can't redistribute or make derivative works of the code, but you also can't force them to delete it/not run it |
| 15:49 | boxed | is there some tool that makes developing macros somewhat non-horrible? |
| 16:00 | TMA | daniel__1: even in the common law you do have a contract; however as it is not a written one it is hard to tell what are its terms |
| 16:03 | daniel__1 | im actually not concerned with giving up rights to what i produce, im concerned with contracts i dont fully understand taking rights from things i havent yet but might produce |
| 16:03 | daniel__1 | i think im talking about simple transfer of copyright |
| 16:10 | sobel | actually unless you give them permission to run your code, you can assert copy rights to make them stop using it |
| 16:10 | sobel | it's tricky to prove your copyright if you don't register it properly but that's how the law reads |
| 16:10 | Frozenlo` | sobel: Don't they get the copyright if they hired you to write the code? |
| 16:11 | sobel | it depends on how the employment is arranged |
| 16:11 | daniel__1 | and how complicated does this contract have to be |
| 16:11 | sobel | if the person is hired to do some work, the work product (code) belongs to the employer |
| 16:12 | sobel | e.g. code written as a coder on the clock or on salary |
| 16:12 | sobel | it's different if someone contracts a solution you might dig out of your toolbox of existing solutions, which may be your copyrighted material |
| 16:12 | daniel__1 | i actually meant to start this discussion in another channel, heh |
| 16:12 | daniel__1 | just realised it was clojure |
| 16:13 | daniel__1 | and getting helpful responses anyway |
| 16:13 | sobel | relevant here though |
| 16:13 | daniel__1 | basically, i got given a contract which scares me a bit because its long and i dont understand it |
| 16:14 | sobel | use a real atty if it matters |
| 16:14 | sobel | and beware of giant contracts |
| 16:14 | daniel__1 | yeah, im not sure it does matter that much |
| 16:14 | TMA | for example, there is a special work-for-hire provision in our copyright law that takes precedence over any terms agreed between the parties; however if you are a corporation instead of a naural person, these need not apply |
| 16:15 | daniel__1 | anyone ever worked for two competing business simultaneously? |
| 16:15 | daniel__1 | and how do you handle that |
| 16:16 | sobel | usually the employer has wanted my exclusive service |
| 16:16 | TMA | daniel__1: tricky. you might need the first employer's permission to work for the second |
| 16:17 | daniel__1 | yep, i've been open with both |
| 16:17 | skoude | I make a get request to a web service that returns json document, and I use clj-http.client get function for that.. The problem is that how can I read it to vector in clojure? I I try to use parse-string function in chesire, I get error: PersistenMap cannot be cast to java.lang.String.. |
| 16:17 | daniel__1 | but its still tricky, i don't want to get into conflicts with any contractual obligations |
| 16:17 | hiredman | software engineers are basically the worst people to ask about law and ip |
| 16:17 | daniel__1 | heh hiredman, im sure thats true |
| 16:18 | ane | will and evaluate all its forms or stop at the first falsey? |
| 16:18 | daniel__1 | but maybe it is a case of over-thinking |
| 16:18 | TMA | daniel__1: there is a reason for the lawyers being paid handsomely :) |
| 16:18 | ane | e.g. (and false (expensive-computation)) will it short-circuit |
| 16:18 | justin_smith | skoude: likely clj-http.client is giving you a hash map describing the entire result of the request (including headers), and the :body key will have the actual contents that you can parse or whatever |
| 16:18 | snowell | ane: It will stop at the first falsey |
| 16:18 | snowell | ,(doc and) |
| 16:18 | daniel__1 | TMA: i know, law is incredibly boring |
| 16:18 | clojurebot | "([] [x] [x & next]); Evaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expr. (and) returns true." |
| 16:18 | daniel__1 | i don't envy anyone who has to learn it all |
| 16:19 | TMA | ane: it will stop |
| 16:19 | skoude | justin_smith: thanks.. I will check that.. |
| 16:19 | justin_smith | ,(and false (prinln "expensive$$$$") |
| 16:19 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 16:19 | justin_smith | ,(and false (prinln "expensive$$$$")) |
| 16:19 | clojurebot | #error {\n :cause "Unable to resolve symbol: prinln in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: prinln in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: prinln in t... |
| 16:19 | irctc | Hiya. I'd like to be able to execute a function multiple times in parallel and return the results in a list. Like this: (pmap (fn [_] (myfunc)) (range 10)). Is there a standard function that can do this without the use of range and an underscore parameter? |
| 16:19 | justin_smith | ergh |
| 16:19 | ane | snowell: ok thanks |
| 16:20 | justin_smith | irctc: dotimes |
| 16:20 | justin_smith | well, you would need to create the futures in the dotimes body, so never mind, there isn't a fully pre-baked solution |
| 16:21 | justin_smith | ~pmap |
| 16:21 | clojurebot | pmap is not what you want |
| 16:21 | justin_smith | (also) |
| 16:21 | ane | is there any way of making this a bit simpler (if (and (= @data []) (realized? my-future)) @data @data) i.e. i want it to return @data immediately otherwise wait for my-future to finish (which modifies data) |
| 16:21 | ane | (if data is []) |
| 16:21 | irctc | pmap seemed to have worked but not sure if there is something more straightforward. |
| 16:21 | justin_smith | ane: (do @my-future @data) |
| 16:21 | justin_smith | that returns @data, but only after my-future is done |
| 16:23 | irctc | Does dotimes run in parallel? |
| 16:23 | justin_smith | no, that's why I decided it wasn't a replacement |
| 16:25 | irctc | So I guess the easiest way is the way I already have it then. Can I simplify (fn [_] (myfunc)) ? I tried (constantly #(myfunc)) but it only calls myfunc once and repeats the result. |
| 16:25 | hiredman | ane: that is all a big race condition |
| 16:26 | hiredman | also (if x y y) is y |
| 16:26 | ane | yes, i just want to execute the future if (= @data []) is t |
| 16:27 | ane | otherwise use the currently committed value |
| 16:27 | justin_smith | more like (do x y) - x has a side effect here |
| 16:27 | hiredman | futures are executed when they are created |
| 16:27 | hlolli | Im using lein droid for the first time, and I connect to my android device repl trough port 9999, but changing something in emacs and evaluating does not change my running app on my device. Is this expected behaviour, do you need to do lein droid doall to see every change? |
| 16:27 | ane | hiredman: yeah, i've defined it earlier, but i want the function to block until it's finished if it's empty |
| 16:28 | hiredman | ane: futures have a great built in way to do that called deref |
| 16:28 | justin_smith | so, like I said above, (do @my-future @data) |
| 16:29 | ane | would that block even if @data has something in it? |
| 16:30 | justin_smith | (or (not-empty @data) (do @my-future @data)) |
| 16:30 | hiredman | ane: so other things are writing to data? |
| 16:30 | ane | no, just the future |
| 16:30 | justin_smith | but yeah, still messy |
| 16:30 | hiredman | so why would it have something in it unless the future has a value to produce? |
| 16:31 | justin_smith | wait, are you sure you couldn't just deref the future and get its result and skip the atom? |
| 16:31 | hiredman | you almost certainly want one of the j.u.c queues and not an atom |
| 16:33 | ane | well i'm periodically fetching some data and storing it inside a ref. but i want the actual fetching only to happen every n calls to the function |
| 16:35 | ane | sigh. i've designed this all ass-backwards |
| 16:35 | hiredman | you want to queue up calls |
| 16:38 | ane | what would be the best method for doing that? agents? |
| 16:39 | hiredman | http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/SynchronousQueue.html or core.async channels |
| 16:40 | ane | what about just using add-watch on the counter ref? when it's at every N steps run something in the background |
| 16:41 | justin_smith | ane: when did you switch from atom to ref? |
| 16:41 | justin_smith | or are you using one of these terms "generically" - because they are two different htings |
| 16:41 | hiredman | create a queue, spin up a thread/future/process of some kind that consumes N messages from the queue and then executes the bulk request, and then each message in the queue has another queue or promise that the response can be multiplexed to |
| 16:41 | hiredman | ane: no |
| 16:42 | hiredman | core.async may even have some machinery that would do this already |
| 16:43 | ane | justin_smith: oh i don't think i mentioned atoms, but maybe |
| 16:44 | justin_smith | ane: sorry, poor reading comprehension on my part |
| 16:44 | justin_smith | you didn't mention atoms |
| 16:46 | ane | hiredman: sounds a bit more complicated, but infinitely smarter |
| 16:47 | hiredman | no way |
| 16:47 | hiredman | the STM is way more complicated and you are way more likely to screw up using it |
| 16:47 | ane | hiredman: i just can't figure out what the queue contents actually are at this point |
| 16:47 | hiredman | I do not recommend using refs |
| 16:48 | Jabberz | do folks use visualVM for clojure app memory profiling, or something else? |
| 16:48 | hiredman | ane: the queue contents are the arguments to the function you are batching up (and if you care about getting results back a promise for the results) |
| 16:49 | hiredman | then you have a thread that loops around consuming from the queue and once it has consumed N items, it takes those items and executes a batch, then takes the results from executing that batch and debatches them out to the promises (if you need the results) |
| 16:50 | ane | ah, now i see. well i have no arguments to pass to the function, and i just need the result to be stored elsewhere, not to be returned, like a database or an in-memory ref |
| 16:51 | hiredman | Jabberz: I've used visualvm, there are nicer profiles for the jvm with all kinds of features but you'll have to shell out money for licenses |
| 16:53 | hiredman | ane: in that case you might actually consider an agent or an executor |
| 16:54 | hiredman | if your value can be the value in an agent, you can store a "last-updated" in the value and if a refresh request is sent, ignore it if last-updated is less than whatever time frame |
| 16:55 | hiredman | but in that case you really might just want to consider unconditionally refreshing every time period, and never have explicit refresh requests |
| 16:56 | hiredman | you have an atom containing some value, and a scheduled executor refreshes the value of the atom every time period and clients just deref the atom |
| 16:56 | ane | yeah, that's actually what i was going to implement, using a java timer or some such |
| 16:57 | ane | thought it'd be simpler to initially prototype using just a global variable and simple cache |
| 16:59 | hiredman | a looping future and an atom are very straight forward |
| 17:00 | hiredman | but in your initial discussion you mentioned waiting for the future to be realized, which you wouldn't do |
| 17:00 | ane | indeed |
| 17:25 | hlolli | Still having problem with lein droid and cider. No matter how I change the profiles.clj I always get this error ONLY with droid: WARNING: The following required nREPL ops are not supported: |
| 17:25 | hlolli | classpath format-code format-edn refresh |
| 17:25 | hlolli | Please, install (or update) cider-nrepl 0.9.1 and restart CIDER |
| 17:42 | WorldsEndless | How do I use :rename in my ns declaration? e.g: |
| 17:42 | WorldsEndless | |
| 17:42 | WorldsEndless | (ns mine.styles |
| 17:42 | WorldsEndless | (:require [garden.color :as c :refer [{:rename '{hex->rgb hr}}]])) ;; doesn't work |
| 17:42 | WorldsEndless | I've tried several variation on it |
| 17:42 | justin_smith | don't use ' inside the ns form |
| 17:42 | justin_smith | and I don't think :rename should go inside :refer... |
| 17:43 | WorldsEndless | I can't seem to find any examples, other than the main docs that say :rename can go SOMEWHERE... |
| 17:45 | justin_smith | ,(require '[clojure.string :as s :refer [split] :rename {split schmoop}) |
| 17:45 | clojurebot | #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )> |
| 17:45 | justin_smith | ,(require '[clojure.string :as s :refer [split] :rename {split schmoop}]) |
| 17:45 | clojurebot | nil |
| 17:45 | justin_smith | ,(schoop "hello world" #" ") |
| 17:45 | clojurebot | #error {\n :cause "Unable to resolve symbol: schoop in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: schoop in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: schoop in t... |
| 17:45 | justin_smith | ,(schmoop "hello world" #" ") |
| 17:45 | clojurebot | ["hello" "world"] |
| 17:45 | WorldsEndless | Say, that clojurebot is pretty cool! |
| 17:45 | justin_smith | WorldsEndless: ^ see above, but without the leading ' before the vector in the ns form |
| 17:46 | justin_smith | WorldsEndless: yes, it's a nice feature |
| 17:47 | justin_smith | that's a slightly unintuitive mix when you have refer and rename together, to be sure |
| 17:48 | WorldsEndless | So, It compiles but doesn't work for me |
| 17:48 | WorldsEndless | (ns turbo-tenure.styles |
| 17:48 | WorldsEndless | (:require [garden.color :rename {hex->rgb hr}])) |
| 17:48 | justin_smith | well, you aren't using refer there |
| 17:48 | WorldsEndless | Yeah, took it out for clarity |
| 17:48 | justin_smith | OK |
| 17:48 | justin_smith | so hex->rgb works, but hr does not? |
| 17:48 | WorldsEndless | I'm just trying to rename the ugly function, but hr does not work |
| 17:49 | WorldsEndless | "unable to resolve symbol" |
| 17:49 | WorldsEndless | I guess if I have to I can use "require" outside of the ns declaration, but I was hoping I wouldn't need to do that |
| 17:49 | justin_smith | WorldsEndless: note that it should be :refer [hex->rgb] :rename {:hex->rgb hr} |
| 17:49 | justin_smith | :require runs the same code, so you don't need to do that |
| 17:50 | WorldsEndless | Ah! Beautiful |
| 17:50 | WorldsEndless | Getting the right combo of refer and rename was what I was missing |
| 17:50 | justin_smith | WorldsEndless: that's what I meant about it being unintuitive |
| 17:50 | justin_smith | you ask to refer to the un-renamed version, and you get the renamed |
| 17:50 | WorldsEndless | Thanks, justin_smith (thought you were referring to my code with that) |
| 17:51 | sdegutis | What's the best way to handle text fields in Reagent? |
| 17:53 | WorldsEndless | sdegutis: what are you trying to do? |
| 17:53 | sdegutis | Just create normal forms that can be submitted via AJAX. |
| 17:55 | WorldsEndless | I'm pretty new to reagent myself, but I would think you'd just handle them in the normal DOM way (i.e. give them an id, refer to them) |
| 17:55 | WorldsEndless | ^ sdegutis |
| 17:56 | justin_smith | sdegutis: in reagent, I tie the state of the form elements to some part of an ratom, and read the ratom on submit to build the ajax request |
| 17:56 | sdegutis | I was under the impression that any text you type into it gets squashed as soon as you type if you try to store it in an atom or anything? |
| 17:56 | justin_smith | squashed? |
| 17:57 | sdegutis | Like, the field is tied to ratom, ratom is empty, field is empty, you click the field, type "f", and since the change isn't propagated back to the ratom, it asks the ratom what to display, which is nothing, and the field says "" |
| 17:57 | justin_smith | sdegutis: more specifically, an on-change that modifies the ratom |
| 17:57 | sdegutis | Mainly because during onchange event (or whatever), it --- ooh, so you specifically change the ratom during onchange. |
| 17:57 | justin_smith | sdegutis: I'm not talking about the ratom that renders the component |
| 17:58 | sdegutis | Okay that makes sense. But then how do you handle the cursor always going to the end of the field? |
| 17:58 | justin_smith | something is making redraws happen because you are watching data for rendering that you modify while typing |
| 17:58 | justin_smith | don't do that, and that behavior stops |
| 17:59 | justin_smith | or at least, watch it in a different component, not the same one accepting the input |
| 17:59 | sdegutis | So another component should be responsible for input validation than the input itself? |
| 17:59 | sdegutis | Ah maybe a higher level component, I guess, one that sees both the input and the error field which it should show upon error... |
| 17:59 | justin_smith | sdegutis: insanely simplified version of the problem: you tell joe to follow bob, you tell bob to follow joe, nobody does anything interesting and they walk in circles |
| 17:59 | justin_smith | so don't do that |
| 18:00 | sdegutis | right |
| 18:00 | sdegutis | Thanks, I think I understand enough to solve this now. |
| 18:46 | skeuomorf | Is there a way to write multiline docstrings for functions inside a protocol? e.g. (defprotocol MyProtocol "A protocol which represents an entity." (my-function [this] "multiline docstring here!!")) |
| 18:48 | skeuomorf | argh, had an unescaped `\` in the docstring |
| 18:48 | skeuomorf | which is weird, that I have to escape characters inside the docstring |
| 18:52 | justin_smith | skeuomorf: \ inside strings needs escaping, because \c for most characters c is not valid |
| 18:53 | skeuomorf | ah |
| 18:54 | justin_smith | being the escape string itself, it needs escaping (mind you this is all invalid inside the crazy world of regex) |
| 18:54 | justin_smith | ,#"\a" |
| 18:54 | clojurebot | #"\a" |
| 18:55 | skeuomorf | Yeah, ofc |
| 18:56 | justin_smith | ,"\a" |
| 18:56 | clojurebot | #<RuntimeException java.lang.RuntimeException: Unsupported escape character: \a> |
| 20:24 | skeuomorf | let's say I have a record R which has two "properties", x and y, x is an atom holding a map and y is an int. Let's say we have two instance (def r1 (->R (atom {}) 2)) and (def r2 (->R (atom {:my-key r1}) 3)). Now, what I want to do is change the value of y which is inside r1 which is inside x which is inside r2, what would be the cleanest way to do that? |
| 20:27 | skeuomorf | for the sake argument, assuming "properties" inside records weren't private, what I would want to change is (y (:my-key @(x r2)) |
| 20:28 | skeuomorf | s/sake/sake\ of/ |
| 20:28 | wmealing | well, i've started using specter for that kind of manipulation. |
| 20:28 | wmealing | i'm by no means cool though |
| 20:28 | wmealing | so i'm probablly doing things all kinds of wrong |
| 20:29 | skeuomorf | I'd prefer to use it without external libs though, I could define that y field as mutable but that seems dirty |
| 20:32 | skeuomorf | wmealing: A quick glimpse, I think spectre doesn't work with records? If I were using a regular map, I would've just made a new version with the new value out of the old one, but records' members are private |
| 21:01 | skeuomorf | Screw it, did it with getter/setter :) |
| 21:07 | wmealing | skeuomorf: sorry man had to bail , i had a meeting |
| 21:10 | skeuomorf | wmealing: No worries :) |
| 21:51 | justin_smith | skeuomorf is gone, but he should know you can do everything you can do with maps to record |
| 21:51 | justin_smith | s |
| 21:51 | htmldrum | Anyone got some material on setting up a Ring application on AWS? I'm used to preparing hosts via cloudformation or a provisioning tool like Puppet/Chef but am looking for resources on where to start as a newbie to Clojure/Java web services. |
| 21:52 | justin_smith | htmldrum: it's a lot easier to use elasticbeanstalk |
| 21:52 | justin_smith | you can use lein ring to make an uberwar, hand the uberwar to elasticbeanstalk, and that's it |
| 21:53 | htmldrum | justin_smith: Thank you :) |
| 23:16 | TimMc | justin_smith: Except for call empty or (sometimes) dissoc on them, because then you get a map again. :-P |
| 23:16 | justin_smith | TimMc: you can do those things though! |
| 23:17 | TimMc | True! |
| 23:17 | justin_smith | you just get a different data type back |