2014-10-12
| 00:00 | squeedee | oic |
| 00:00 | squeedee | boy had to think about that |
| 00:01 | squeedee | thats multiply. |
| 00:01 | justin_smith | right - composed of N additions :) |
| 00:01 | squeedee | So im not 'dumb', but learning a new language, the jargon and domain around the language certainly slows me down |
| 00:02 | squeedee | on top of that, 4mg of hydromorphone every 3 hours |
| 00:02 | justin_smith | right, anyone who knows clojure, having gone through a less impaired process, will understand that |
| 00:03 | justin_smith | also, I have been teaching myself haskell, so I feel your pain (the mental half...) |
| 00:03 | squeedee | i started on haskell last week |
| 00:03 | squeedee | went 'nahhhh' and came back to clojure |
| 00:03 | squeedee | and not because i find it any more mentally challenging, i just find it really ugly |
| 00:37 | catern | in an alternate world, #haskell |
| 00:38 | catern | "i started on clojure last week", etc. |
| 00:52 | devasia | instead of mapping a function to a list of values, how do I map a value to a list of functions? |
| 00:52 | justin_smith | ((juxt inc dec) 1) |
| 00:52 | justin_smith | ,((juxt inc dec) 1) |
| 00:52 | clojurebot | [2 0] |
| 00:53 | justin_smith | ,(map #(% 1) [inc dec]) |
| 00:53 | clojurebot | (2 0) |
| 00:59 | devasia | justin_smith: thank you! |
| 00:59 | justin_smith | np |
| 01:00 | justin_smith | ,((apply juxt [inc dec]) 1) |
| 01:00 | clojurebot | [2 0] |
| 01:00 | justin_smith | as you see, it is actually possible to use juxt even if the functions arein a collection |
| 01:00 | justin_smith | though map is better if you need laziness |
| 01:01 | justin_smith | ,(map #(% 1) (map #(fn [x] (* x % %)) (range 10))) |
| 01:01 | clojurebot | (0 1 4 9 16 ...) |
| 01:23 | kenrestivo | playing around with manifold... looking for a way to convert a stream back to a core.async channel, doesn't appear to be any way to do it, it's a one-way trip from channel -> stream |
| 01:28 | justin_smith | kenrestivo: what about using stream->seq |
| 01:28 | kenrestivo | locks up my repl real good :- |
| 01:29 | justin_smith | also, there is an extension of Sinkable for channels https://github.com/ztellman/manifold/blob/master/src/manifold/stream/async.clj#L157 |
| 01:29 | kenrestivo | i guess that's a blocking operation :-/ |
| 01:29 | noonian | kenrestivo: it looks to me like you should be able to do (let [c (chan), sink-chan (->sink c)] and c will get values from the stream |
| 01:29 | noonian | https://github.com/ztellman/manifold/blob/master/src/manifold/stream/async.clj |
| 01:29 | kenrestivo | ok, will try that, thanks |
| 01:32 | kenrestivo | one more dumb question: is there any kind of standard way to turn an inputstream into a channel? |
| 01:33 | kenrestivo | this was a naive attempt, didn't work: https://www.refheap.com/91606 |
| 01:34 | dagda1_ | what does the arrow mean in this method declaration defn- options->jsparams |
| 01:35 | noonian | dagda1_: its just part of the name, usually used to denote converting things into different forms of data |
| 01:35 | noonian | its not special syntax |
| 01:35 | dagda1_ | noonian: so it is jut a convention |
| 01:35 | noonian | yup |
| 01:35 | dagda1_ | k, thanks |
| 01:35 | noonian | np |
| 01:37 | justin_smith | ,(let [-crazy'?-‽-name☃ 42] -crazy'?-‽-name☃) |
| 01:37 | clojurebot | 42 |
| 01:37 | justin_smith | ,(def 💩 "Scala") |
| 01:37 | clojurebot | #'sandbox/💩 |
| 01:38 | noonian | lol |
| 01:38 | justin_smith | ,💩 |
| 01:38 | clojurebot | "Scala" |
| 01:38 | justin_smith | sorry, that was immature |
| 01:39 | kenrestivo | what is that char? it shows up as a question mark inside a diamond |
| 01:39 | kenrestivo | irssi doesn't do unicode, i guess |
| 01:39 | justin_smith | "pile of poo" |
| 01:39 | kenrestivo | oh, the famous U+PILEOFPOO |
| 01:39 | Jaood | kenrestivo: works for me in irssi |
| 01:40 | Jaood | check your terminal encoding |
| 01:40 | scottj | kenrestivo: are you running screen? |
| 01:40 | kenrestivo | yes |
| 01:40 | scottj | kenrestivo: someone the other day said that was the problem for them |
| 01:41 | kenrestivo | i can't imagine runnign irssi without screen. but yeah, it might need special tweezing to do unicode properly |
| 01:41 | kenrestivo | http://savannah.gnu.org/bugs/?26723 |
| 01:42 | kenrestivo | bug open since 2009 :-0 |
| 01:42 | justin_smith | with my current setup the symbol won't actually print, but I can insert any unicode based on its name / see the name of a unicode whether it prints or not (erc inside emacs) |
| 01:44 | Jaood | funny how it shows with a brown color |
| 01:44 | amalloy | fwiw, my client renders most silly characters okay, but not the three-byte supplementary characters like the ones justin_smith is always typing |
| 01:44 | Jaood | amalloy: what client are you using? |
| 01:45 | amalloy | pidgin, baby's first irc client |
| 01:45 | Jaood | oh man |
| 01:46 | Jaood | still active surprisingly |
| 01:47 | amalloy | i used it when it was still gaim |
| 01:48 | Jaood | amalloy: are you on linux? last time I heard it was being replaced by empathy in gnome |
| 01:48 | justin_smith | oh, gaim became pidgin? I remember using it for a short time when it was still gaim |
| 01:49 | kenrestivo | i still use it occasionally for jabber, and probably still have yahoo and ao-hell accounts in its account list somewhere |
| 01:49 | amalloy | kenrestivo: yeah, i find it convenient to have my irc, aim, and google talk all in one client |
| 01:50 | kenrestivo | for linux i think it's the most mature/featureful of the chat clients. |
| 01:50 | kenrestivo | last i checked anyway |
| 01:50 | amalloy | Jaood: i am not a willing upgrader |
| 01:50 | amalloy | if it worked eight years ago, it probably still works now |
| 01:52 | Jaood | amalloy: did that with bitlbee :) had irc, gtalk and msn in irssi |
| 01:52 | Jaood | BitlBee brings IM (instant messaging) to IRC clients. It's a great solution for people who have an IRC client running all the time and don't want to run an additional MSN/AIM/whatever client. |
| 01:52 | amalloy | sure, and that's fine too |
| 01:54 | Jaood | *looked |
| 01:55 | Jaood | whatapps has taken over the world |
| 02:07 | justin_smith | I just checked, my phone version is just one version too old for whatsapp |
| 02:08 | justin_smith | the fact that they even support symbian is surprising |
| 02:08 | Jaood | justin_smith: yeah, that was the key to their success, platform support |
| 02:10 | Jaood | and the no setup necessary |
| 02:36 | dagda1_ | can anyone explain what when-let is doing here (when-let [{:keys [tabId changeInfo tab]} (<! ch)] |
| 02:38 | amalloy | dagda1_: why don't you try explaining it, and someone will fill in the bits that are missing or wrong |
| 02:39 | dagda1_ | amalloy: it is destructuring what is taken from the channel? |
| 02:39 | amalloy | that is certainly a true statement |
| 02:40 | dagda1_ | amalloy: but why is it using when-let, why would it be null? |
| 02:40 | amalloy | when do channels return nil? |
| 02:41 | dagda1_ | amalloy: ok so it might return nil |
| 02:42 | numberten | is there a literal for the byte array class? |
| 02:42 | numberten | [B doesn't seem to work >.> |
| 02:43 | ambrosebs | numberten: try "[B" |
| 02:43 | amalloy | there aren't literals for any classes at all, numberten: String is a symbol which, when *evaluated*, produces the class java.lang.String, not a literal Class itself |
| 02:44 | amalloy | depending on the context in which you are trying to use this, there are different ways to get at the class of a byte array |
| 02:44 | numberten | alright |
| 02:44 | numberten | i've just been using |
| 02:44 | numberten | ,(type (byte-array "")) |
| 02:45 | clojurebot | [B |
| 02:45 | numberten | but it seems kinda hacky :) |
| 03:43 | kenrestivo | wait... whatsapp just got bought for... 19 BILLION dollars? |
| 03:46 | TEttinger | numberten: bytes? |
| 03:46 | TEttinger | ,(bytes [0 1 2]) |
| 03:46 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to [B> |
| 03:46 | TEttinger | ,(bytes (byte-array[0 1 2])) |
| 03:46 | clojurebot | #<byte[] [B@1dd98e> |
| 03:47 | TEttinger | ,(bytes (int-array[0 1 2])) |
| 03:47 | clojurebot | #<ClassCastException java.lang.ClassCastException: [I cannot be cast to [B> |
| 03:47 | TEttinger | hm |
| 03:47 | TEttinger | I know you can type hint with ^bytes |
| 04:59 | jphx | so, how can i replace "a b" to "a\ b" ? |
| 04:59 | jphx | i'm working with file paths with spaces in them |
| 05:16 | By_Tor | is this the problem you're running into: |
| 05:16 | By_Tor | ,(clojure.string/replace "a b" #" " "\\ " ) |
| 05:16 | clojurebot | "a b" |
| 05:21 | TEttinger | ,(clojure.string/replace "a b" #" " "\\\\ " ) |
| 05:21 | clojurebot | "a\\ b" |
| 05:21 | TEttinger | hm |
| 05:21 | TEttinger | I'm guessing clojurebot escapes what it prints |
| 05:21 | TEttinger | ##(clojure.string/replace "a b" #" " "\\ " ) |
| 05:21 | lazybot | ⇒ "a b" |
| 05:22 | TEttinger | ##(nth (clojure.string/replace "a b" #" " "\\ " ) 1) |
| 05:22 | lazybot | ⇒ \space |
| 05:22 | TEttinger | ##(nth (clojure.string/replace "a b" #" " "\\\\ " ) 1) |
| 05:22 | lazybot | ⇒ \\ |
| 05:25 | By_Tor | I think it's the replace fn |
| 05:25 | By_Tor | ,(println "\\ A") |
| 05:25 | clojurebot | \ A\n |
| 05:25 | jphx | hehe |
| 05:25 | jphx | yep, i've had this headache |
| 05:25 | jphx | i can use replace to get "a\\ b" but not "a\ b" |
| 05:25 | jphx | that's as far as i got |
| 05:26 | TEttinger | err, \\ probably is the \ you want |
| 05:26 | TEttinger | ##(nth (clojure.string/replace "a b" #" " "\\\\ " ) 2) |
| 05:26 | lazybot | ⇒ \space |
| 05:26 | jphx | touch "a\ b" ; ls "a\\ b" doesn't work |
| 05:26 | TEttinger | ##(vec (clojure.string/replace "a b" #" " "\\\\ " )) |
| 05:26 | lazybot | ⇒ [\a \\ \space \b] |
| 05:26 | jphx | tet, let me try that out |
| 05:32 | By_Tor | ,(apply str [\a \\ \space \b]) |
| 05:32 | clojurebot | "a\\ b" |
| 05:33 | By_Tor | it doesn't like a single backslash, lol |
| 05:36 | TEttinger | By_Tor, it just prints single backspaces like that |
| 05:37 | By_Tor | ah yes, I think you're right |
| 05:37 | By_Tor | ,(println (apply str [\a \\ \space \b])) |
| 05:37 | clojurebot | a\ b\n |
| 05:38 | TEttinger | since it also escapes newlines (it can't print them in a one-line IRC message) |
| 05:39 | Phonatacid | Hi. Im trying to use state monads with clojure.algo.monads. After a do-monad statement, I get a [result new-state] vector. If the last step in my domonad stmt is a fetch-val, the returned value ends up as 'result' in my vector. How can I get this result from outside a domonad stmt elegantly, i.e. without applying 'first' to this returned vector ? |
| 06:16 | kenrestivo | the real fun is when you have to do regexps in elisp \\\\\\\\\\\ |
| 06:34 | LauJensen | Gents, I've written a small cljs app, which compiles fine with "lein cljsbuild once", but evaling something like (defn ^:export test []) in Lighttable breaks with "Unexpected identifier". Im on the latest versions of both LT and CS - Anybody know whats up? |
| 06:39 | TEttinger | ,(defn ^:export test []) |
| 06:39 | clojurebot | #<CompilerException java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)> |
| 06:39 | TEttinger | ,(defn test []) |
| 06:39 | clojurebot | #<CompilerException java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)> |
| 06:40 | TEttinger | ,(defn test1 []) |
| 06:40 | clojurebot | #'sandbox/test1 |
| 06:40 | TEttinger | ,(defn ^:export test1 []) |
| 06:40 | clojurebot | #'sandbox/test1 |
| 06:40 | TEttinger | huh4 |
| 06:40 | TEttinger | I didn't know you could omit the body |
| 06:40 | TEttinger | ,(test1) |
| 06:40 | clojurebot | nil |
| 06:45 | wei | how do you use the [com.facebook/react "0.11.2"] dependency? do you have to do anything more than putting it in the project.clj file? |
| 06:46 | LauJensen | Its not very useful to know :) |
| 06:48 | wei | LauJensen: why not? |
| 06:49 | TEttinger | ~Om |
| 06:49 | clojurebot | It's greek to me. |
| 06:50 | TEttinger | ~om |
| 06:50 | clojurebot | Titim gan éirí ort. |
| 07:05 | dysfun | ooh, i've just discovered a neat trick. #(= some-var %) can be shortened to #{%} |
| 07:06 | dysfun | er #{some-var} |
| 07:11 | Gina97 | ciao |
| 07:11 | Gina97 | !list |
| 07:31 | sveri | Hi, I have a jenkins running and a job that runs lein midje configured to produce junit reports in target/surefire-reports. I see that the job runs lein midje, without any error, but it does not generate the junit reports, any ideas why that may be? I moved that jenkins instance to different server, before I moved it that junit generation did work and I don't have a clue what might be different now |
| 07:32 | sveri | running lein midje from the console as the jenkins user works as expected -l.- |
| 07:33 | engblom | Is fireplace still the a plugin most vim-users should use? |
| 07:34 | engblom | s/a // |
| 07:36 | dysfun | sveri: that sounds more like a jenkins question to be honest. it might be seeing a different environment, for example. i've had some interesting jenkins adventures in the past |
| 07:39 | sveri | dysfun: hm, jenkins user might say its something clojure related, it's hard to tell what exactly is wrong -.- whatever, which build server do you use now? |
| 07:40 | dysfun | ostensibly jenkins, but i don't get paid for clojure work so most of my code is only being tested while i work on it |
| 07:41 | dysfun | i do have some stuff being tested using midje under jenkins though |
| 07:53 | sveri | hm, any problems with it? |
| 07:53 | john2x_ | how do I use lein-ancient on my profiles.clj file? |
| 08:32 | borkdude | where can I find a kind of timeline of what came when in clojurescript? |
| 08:33 | borkdude | June 2011: first version of clojurescript. |
| 08:33 | borkdude | what other interesting marks in time are there? ;) |
| 08:37 | gfredericks | August 2017: support for method_missing |
| 08:38 | borkdude | lol |
| 08:47 | Rhainur | I've been working on the problems at 4Clojure for a bit, and I'm getting a bit worried about code readability |
| 08:47 | Rhainur | I feel like if I came back to this code after a few months I'd have no idea what was going on in there |
| 08:48 | AimHere | Comment it |
| 08:51 | LauJensen | Gents, I've written a small cljs app, which compiles fine with "lein cljsbuild once", but evaling something like (defn ^:export test []) in Lighttable breaks with "Unexpected identifier". Im on the latest versions of both LT and CS - Anybody know whats up? |
| 09:00 | hellofunk | with compojure.handler/site how does it work that a #'var can be passed, as well as just the unquoted var, and both work? most clojure functions don't allow you to swap one for the other. for example (keys #'some-map) fails |
| 09:08 | dagda1 | why is :keys used in this (destructuring when-let [{:keys [added removed]} (<! ch)] |
| 09:09 | hellofunk | dagda1 what is taken off the channel is no doubt a map, thus you are binding to items in the map |
| 09:10 | dagda1 | hellofunk: so :keys must be used to get items from a map? |
| 09:10 | hellofunk | there areother ways, but the :keys form is a map destructuring form as a shortcut to access map data |
| 09:11 | hellofunk | lookup "clojure destructuring" -- it is like a mini language to help make stuff like this more effecint. it is not necessary to use it, but it makes code tighter |
| 09:12 | mearnsh | dagda1: :keys helps avoid repetition |
| 09:12 | dagda1 | thanks |
| 09:15 | mearnsh | dagda1: https://www.refheap.com/91612 |
| 09:16 | dagda1 | mearnsh: that completely clears it up, thanks |
| 09:16 | mearnsh | np |
| 10:55 | clj-learner | sometimes in clojure functions source they have multiple arity calls instead of just using [& args], why is that? (ex: complement source https://www.refheap.com/91614) |
| 10:56 | Bronsa | clj-learner: efficiency reasons |
| 10:56 | Bronsa | clj-learner: apply and & have some overhead |
| 10:56 | Bronsa | clj-learner: so the most used arities are unrolled |
| 10:56 | clj-learner | ok, that makes sense |
| 10:57 | hellofun` | with compojure.handler/site how does it work that a #'var can be passed, as well as just the unquoted var, and both work? most clojure functions don't allow you to swap one for the other. for example (keys #'some-map) fails |
| 10:57 | clj-learner | thanks |
| 10:57 | Bronsa | clj-learner: it's not something you should to in your code btw, that's a micro optimization |
| 11:14 | technomancy | hellofun`: it only works for functions |
| 11:14 | technomancy | vars call their contents when called |
| 11:15 | justin_smith | ,(#'+ 1 1) |
| 11:15 | clojurebot | 2 |
| 11:15 | hellofun` | technomancy you mean for function arguments that are passed var names? |
| 11:15 | hellofun` | oh, not arguments, actual functions themselves |
| 11:15 | justin_smith | hellofun`: eventually, that function is placed in the calling position - that's when it has to work |
| 11:15 | justin_smith | and it does |
| 11:16 | hellofun` | interesting |
| 11:16 | justin_smith | ,((fn [x] (x 1 1)) #'+) |
| 11:16 | clojurebot | 2 |
| 11:16 | justin_smith | I pass in a var, it gets called |
| 11:17 | hellofun` | so the var is not evaluated at compile time, but rather at runtime? |
| 11:17 | hellofun` | i'm curious behind the scenes how (+ 1 1) differs from (#'+ 1 1) -- at which point does the #'+ become + |
| 11:18 | technomancy | hellofun`: you're passing a var around; they are first-class at runtime |
| 11:18 | technomancy | its contents aren't looked up till it's called |
| 11:19 | hellofun` | that's interesting. for example (def a 5) and then (+ #'a 1) does not work, I wonder why it is different for a function. there is an extra level of lookup with all functions? |
| 11:22 | justin_smith | hellofun`: I think it's more that var implements IFn |
| 11:23 | justin_smith | ,(isa? (type #'+) clojure.lang.IFn) |
| 11:23 | clojurebot | true |
| 11:23 | justin_smith | and implementing IFn means you can be called like a function |
| 11:23 | hellofun` | ah, that's quite cool |
| 11:23 | pdk | does clojure have #' now |
| 11:23 | zwer | what is #'? I thought I was in #lisp for a second. |
| 11:23 | justin_smith | ,'#'+ |
| 11:23 | clojurebot | (var +) |
| 11:23 | hellofun` | yes #' is a way to quote a var and have it namespaced automatically |
| 11:24 | justin_smith | not namespaced automatically |
| 11:24 | justin_smith | any more than anything else is |
| 11:24 | hellofun` | justin_smith 'a vs #'a -- the latter adds the namespace |
| 11:24 | hellofun` | actually, that was a bad example |
| 11:24 | justin_smith | ,'#'a |
| 11:24 | clojurebot | (var a) |
| 11:24 | hellofun` | 'a is not a var |
| 11:24 | justin_smith | nope |
| 11:25 | justin_smith | ` namespaces, maybe that's what you are thinking of |
| 11:25 | hellofun` | i am confusing it with backquote |
| 11:25 | hellofun` | my bad |
| 12:34 | gfredericks | hi. |
| 12:37 | mmeix | ji |
| 12:37 | mmeix | hi |
| 12:38 | justin_smith | ∿∿∿∿∿∿∿∿∿∿ |
| 12:39 | gfredericks | anybody know of a jvm library that does exact arithmetic with algebraic numbers? |
| 12:39 | mmeix | {I'm to much a newbie to answer that question} |
| 12:40 | mmeix | I would like to see rational number support in cljs though :-) |
| 12:40 | gfredericks | I made a library for that |
| 12:40 | mmeix | ah! |
| 12:40 | gfredericks | $google github gfredericks clj-numerics |
| 12:40 | lazybot | [gfredericks/four · GitHub] https://github.com/gfredericks/four |
| 12:40 | gfredericks | that is not it |
| 12:40 | gfredericks | https://github.com/gfredericks/cljs-numbers |
| 12:41 | mmeix | I'm plannung on wtiting some music software, and that would be really handy to have |
| 12:41 | mmeix | thanks for the link! |
| 12:42 | gfredericks | np |
| 12:43 | Bronsa | justin_smith: were you waving at gfredericks there? :) |
| 12:43 | gfredericks | Bronsa: oh no I bet he was |
| 12:44 | justin_smith | Bronsa: indeed! |
| 12:44 | justin_smith | it was a sine wave |
| 12:44 | gfredericks | a sign wagv |
| 12:44 | Bronsa | (inc justin_smith) |
| 12:44 | lazybot | ⇒ 90 |
| 12:45 | gfredericks | what a joke to make right before I ask about algebraic numbers |
| 12:45 | Bronsa | that was pretty good |
| 12:47 | arrdem | Bronsa: random branfiring... I can replace half this shit by just aliasing tejvm/-emit and redefining select methods, right? https://github.com/oxlang/oxcart/blob/master/src/main/clojure/oxcart/emitter/jvm/emitter.clj |
| 12:47 | arrdem | Bronsa: just seeing your activity in the last few days and thinking about minimizing bit rot |
| 12:47 | arrdem | also maybe breathing life back into that... |
| 12:48 | arrdem | bah multimethods are mutable |
| 12:49 | gfredericks | except for their dispatch function :P |
| 12:49 | Bronsa | arrdem: yeah |
| 12:49 | arrdem | why on earth is this the case... an immutable multimethod and a swap! on the var would work fine T_T |
| 12:50 | Bronsa | arrdem: want to talk about extend implemented via alter-var-root? :P |
| 12:50 | arrdem | Bronsa: you have my axe |
| 12:51 | Bronsa | (also why is alter-var-root not alter-var-root!, I mess this up everytime) |
| 12:51 | arrdem | Bronsa: because it was alter-var-root first and name changes are breaking |
| 12:51 | Bronsa | (defn alter-var-root [& args] (println "DEPRECATED") (apply alter-var-root! args)) |
| 12:51 | arrdem | yeah that's what I'd do too, but neither of us is Rich so... |
| 12:52 | arrdem | damnit I was motivated for a minute there and now all I see is warts again |
| 13:04 | vladh_ | Hey guys. Just a quick question - in a namespace, is it bad practice to initialize variables and call functions when the namespace is loaded? Or should I have some mutable variables which are initialized when functions in the namespace are called from the outside? |
| 13:05 | arrdem | vladh_: imperative initialization using load time code execution is usually bad news bears |
| 13:05 | vladh_ | arrdem: thought so, but isn’t mutability bad too? |
| 13:05 | arrdem | vladh_: sure, but I personally find mutability excusable in some situations. we've spent what... eighty years? developing cleaver mutable algorithms. we'd be fools to discard them out of hand. |
| 13:06 | arrdem | vladh_: IMO you want some sort of (construct-state) function that builds a _value_ with all your state in it, and then you pass that around everywhere rather than binding those mutable bits to say dynamic vars or atoms. |
| 13:06 | justin_smith | vladh_: something that requires a stateful initialization, will be a pain in the ass as soon as a client wants to of them if it is global - consider making a "factory" |
| 13:07 | arrdem | ^ justin_smith use the f word but same idea |
| 13:07 | justin_smith | s/to/two |
| 13:08 | arrdem | Ex. (let [connection (connect-to-db config)] (run-query connection "SELECT * FROM USERS;")) |
| 13:08 | arrdem | rather than having a connection var that you swap or whatever |
| 13:09 | vladh_ | arrdem: that makes a lot more sense than just mutating the value in the namespace - thank you! |
| 13:09 | vladh_ | justin_smith: thank you as well |
| 13:17 | mmeix | Very basic question: how do I create a map out of a vector of keys with a default val for each, for example [:a :b] --> {:a [] :b []} ? |
| 13:17 | bbloom | ,(into {} (map vector [:a :b] (repeat []))) |
| 13:17 | clojurebot | {:a [], :b []} |
| 13:18 | mmeix | ah - thanks! |
| 13:18 | bbloom | mmeix: but you may not actually need to do that if you're going to operate on the map later with update-in or whatever, you can also use something like fnil |
| 13:18 | bbloom | ,(update-in {} [:x] (fnil inc 0)) |
| 13:18 | clojurebot | {:x 1} |
| 13:19 | luxbock | fnil is a very handy tool to have |
| 13:19 | mmeix | I'm trying to solve http://www.4clojure.com/problem/63 and maybe just need a tiny hint ... |
| 13:19 | arrdem | fnil is the top function I underuse |
| 13:19 | mmeix | (thanks for fnil tip) |
| 13:21 | mmeix | Which brings me to a typical beginnner's problem: finding the right functions out of the big vocabulary of Clojure |
| 13:22 | bacon1989 | Hey guys, i'm trying to structure my project so that it incorporates tests |
| 13:22 | bacon1989 | I made a separate folder in my source folder called test, and created a sub-namespace called database with a file core.clj |
| 13:23 | mearnsh | mmeix: kibit can help a bit |
| 13:23 | bacon1989 | src-clj/test/database/core.clj , (ns test.database.core (:use clojure.test)) (deftest (is (= 5 4))) |
| 13:23 | luxbock | bacon1989: are you using leiningen? |
| 13:23 | bacon1989 | luxbock: yeah |
| 13:23 | bacon1989 | I run lein test, and it won't find this test |
| 13:23 | bacon1989 | if I run (run-all-tests) |
| 13:23 | bacon1989 | no problem |
| 13:24 | justin_smith | bacon1989: it looks for tests under test/... not src/... by default |
| 13:24 | bacon1989 | justin_smith: yeah, I figured, but I couldn't get it to work under tests/, it complained about missing files |
| 13:24 | Bronsa | (inc fnil) |
| 13:24 | lazybot | ⇒ 1 |
| 13:24 | Bronsa | no love for fnil :( |
| 13:24 | bacon1989 | i'll try looking throuhg the lein docs |
| 13:24 | gfredericks | ((fnil inc 0) fnil) |
| 13:25 | justin_smith | bacon1989: if you have src/myproj/core.clj the test should be in test/myproj/core-test.clj |
| 13:25 | justin_smith | bacon1989: not in the same src/, and not in src/tests/ - unless you reconfigure to look for tests there I guess |
| 13:26 | bacon1989 | justin_smith: yeah, my project is a clojure+clojurescript project, so i've been changing things around |
| 13:26 | bacon1989 | i figured lein test would also do what (run-all-tests) does, but I guess not |
| 13:27 | justin_smith | bacon1989: run-all-tests is called by lein test |
| 13:27 | arrdem | (inc gfredericks) |
| 13:27 | luxbock | mmeix: I don't know if this is the best way to solve that problem but I would use reduce wrapped in a function |
| 13:27 | lazybot | ⇒ 92 |
| 13:27 | gfredericks | bacon1989: I think run-all-tests only works because you've already loaded the test file manually |
| 13:27 | gfredericks | leiningen doesn't know to load the file since it doesn't know where it is |
| 13:27 | justin_smith | bacon1989: but run-all-tests only works if the namespaces with the test definitions are loaded first |
| 13:27 | justin_smith | run-all-tests does not namespace loading at all |
| 13:28 | bacon1989 | hmm I see |
| 13:29 | justin_smith | bacon1989: the issue here is telling lein how to find your test namespaces. |
| 13:29 | mmeix | luxbock thnx |
| 13:29 | bacon1989 | yeah, i'm trying to find the project.clj example, where it shows all of the different options available |
| 13:29 | bacon1989 | so I can go change the tests folder |
| 13:32 | justin_smith | https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L277 |
| 13:32 | justin_smith | :test-paths |
| 13:33 | bacon1989 | yeah, I just found it :P |
| 13:33 | bacon1989 | thanks |
| 13:33 | bacon1989 | i'm probably going to try and get clojurescript tests working as well, hopefully that's not too difficult |
| 13:34 | arrdem | technomancy: if I wrote a way to add profile based dependency replacement, would you take it? |
| 13:34 | bacon1989 | justin_smith: that did the trick, thanks |
| 13:35 | justin_smith | cool |
| 13:39 | mmeix | fnil is a cool beast indeed, I'm just learning |
| 13:40 | arrdem | was there a hack somewhere for finding multiple aliased files on the classpath? So say finding all resources "/manifest.ed" |
| 14:05 | gfredericks | hugod: is it purely a coincidence that my lein 2.5.0 does not use the repl profile and you have post-2.5.0 commits messing with repl profiles? |
| 14:06 | justin_smith | arrdem: iirc I saw amalloy_ show a snippet for doing that - maybe it had something to do with iterating over all the the items in the classpath and asking each one for the resource? |
| 14:08 | gfredericks | I'm trying to do (System/exit 0) in my repl init code and for some reason this hangs |
| 14:08 | justin_smith | (shutdown-agents) |
| 14:08 | gfredericks | (not-very-related to my prior statement) |
| 14:08 | gfredericks | justin_smith: bah of course I bet that's it |
| 14:08 | gfredericks | or actually |
| 14:08 | gfredericks | it might be a timeout in the leiningen process |
| 14:08 | ogdenn | is anyone able to help me come up with an enlive selector? |
| 14:09 | gfredericks | it quit hanging quicker than 60sec I think |
| 14:10 | ogdenn | I need to select all inputs with a name that is one of a set of names |
| 14:12 | ogdenn | I basically need the selector predicate (attr-in :attr-name #{possible values}) |
| 14:22 | gfredericks | new user profile tactic for keeping the classpaths & deps trees clean |
| 14:22 | gfredericks | instead of :plugins [[lein-try "0.4.1"]] |
| 14:22 | gfredericks | do :aliases {"try" ["with-profile" "+lein-try" "try"]} |
| 14:23 | gfredericks | and make a separate profile called :lein-try with the plugin |
| 14:24 | borkdude | lein plz <alias> is nice, but it would be nice if the alias would also work with lein try :) |
| 14:24 | borkdude | lein plz add <alias> I mean |
| 14:24 | borkdude | what a co-incidence, I didn't see gfredericks talk about lein try |
| 14:25 | justin_smith | now we need lein kthx |
| 14:28 | borkdude | uuh... https://www.refheap.com/91622 |
| 14:30 | ogdenn | Agh, sorted. Need to use (apply attr-has :attr-name possible-values) just incase anyone is interested. |
| 14:44 | gfredericks | oh man trying to figure out this leiningen repl profile problem is spooky |
| 14:45 | gfredericks | anybody know if this is a reasonable thing for a leiningen plugin to do? https://github.com/greglook/whidbey/blob/master/src/whidbey/plugin.clj#L28-47 |
| 14:48 | hyPiRion | gfredericks: Better to create the profile :whidbey.plugin/profile and merge it into the project map. |
| 14:48 | gfredericks | hyPiRion: "merge it into the project map"? |
| 14:49 | gfredericks | I'm getting super weird results using this |
| 14:49 | gfredericks | especially if I put my own :repl profile in ~/.lein/profiles.clj |
| 14:50 | gfredericks | I will get only one of the two repl profiles active at any point, but different ones depending on how I start the repl |
| 14:50 | gfredericks | `lein repl` is different from `lein with-profile +user repl` even though the difference between the two should be a noop |
| 14:50 | gfredericks | I will have to figure out again how to build my own lein to debug this |
| 14:50 | hyPiRion | gfredericks: like, enable through merging (-> project (assoc-in [:profiles ::profile] my-profile) (leiningen.core.project/add-profiles [::profile])) |
| 14:51 | gfredericks | well I think what the plugin is trying to pull off here is not not have its code "enabled" unless the :repl profile is also |
| 14:52 | hyPiRion | hrm |
| 14:54 | gfredericks | what's the easiest way to build and/or run a custom leiningen? |
| 14:57 | gfredericks | hey it's easy |
| 14:57 | gfredericks | just edit the leiningen source and run the bin/lein script in the project instead of the normal installed one |
| 14:58 | hyPiRion | gfredericks: yeah, but you'd have to bootstrap and compile first |
| 14:58 | gfredericks | I bootstrapped; did not compile |
| 14:58 | gfredericks | it's still running the custom code |
| 14:58 | hyPiRion | gfredericks: right, but it'll blow up if you try to search |
| 14:58 | gfredericks | if I try to what |
| 14:58 | gfredericks | is leiningen a search engine? |
| 14:59 | justin_smith | that sounds like a jaden smith tweet |
| 14:59 | hyPiRion | gfredericks: `lein help search` |
| 15:01 | gfredericks | :aliases {"hepl" ["help"]} |
| 15:02 | gfredericks | hyPiRion: I stopped using lein search after like a year ago when it seemed to never ever return |
| 15:02 | hyPiRion | gfredericks: I don't use it either |
| 15:03 | gfredericks | so my guess is going to be that the profile merging is happening before the middleware is running |
| 15:03 | gfredericks | wait I take it back |
| 15:04 | gfredericks | urm |
| 15:06 | gfredericks | hyPiRion: would the whidbey middleware be bad because it can shadow an existing :repl profile from profiles.clj? |
| 15:07 | gfredericks | it seems to expect that any existing :repl profile is in the :profiles key of the project, but I'm thinking that's not the case for ~/.lein/profiles.clj |
| 15:07 | gfredericks | presumably those are in the metadata somewhere |
| 15:08 | hyPiRion | no, they should be in the project map |
| 15:08 | hyPiRion | pretty sure at least |
| 15:12 | gfredericks | hyPiRion: I'm looking around this call: https://github.com/technomancy/leiningen/blob/master/src/leiningen/repl.clj#L285-287 |
| 15:12 | gfredericks | beforehand my profiles.clj :repl profile is not in the project proper, but it is in the project's metadata under [:profiles :repl] |
| 15:12 | gfredericks | afterward it is in the project proper and appears to have clobbered the whidbey stuff |
| 15:14 | hyPiRion | gfredericks: There has been some new functionality popping into profile merging, not sure what profiles-with-matching-meta does (although I guess it fetches the ones with ^:repl tagged). |
| 15:14 | gfredericks | so I'm going to just conclude this isn't a supported way to customize leiningen and whidbey should do something else |
| 15:15 | gfredericks | I bet there's not a real downside to just modifying the project map directly |
| 15:15 | gfredericks | or calling merge or something |
| 15:17 | gfredericks | I need to write myself a lein plugin for deploying a random commit of a random project to clojars under a fork group-id |
| 15:20 | gfredericks | hah calling merge gets me a stack overflow |
| 15:36 | amalloy | justin_smith, arrdem: no, you're thinking of someone else |
| 15:38 | gfredericks | fun use of dynamic vars -- preventing recursion: https://github.com/gfredericks/whidbey/blob/c380535d08b40737c3c452dc6ee05170a2a49a7d/src/whidbey/plugin.clj#L28-39 |
| 15:39 | louissmit | Hi all, I’m new to clojure and wondering about the identity functions in reducers: https://gist.github.com/louissmit/4ec16497e74bc07da012 |
| 15:39 | louissmit | here it never calls the identity function of the reducing function while it should do that for every partition, right? |
| 15:47 | mi6x3m | hey clojure, I am writing a macro defexample taking 4 parameters |
| 15:48 | mi6x3m | title description show-src? and form |
| 15:48 | mi6x3m | so an examle looks like |
| 15:48 | mi6x3m | (defexample "foo" "boo" true/false (println "bla")) |
| 15:48 | mi6x3m | any better way to structure the arguments? |
| 15:48 | mi6x3m | or this one is good enough |
| 15:54 | gfredericks | um |
| 15:54 | gfredericks | mi6x3m: "better" according to what? it's not clear what you're trying to accomplish |
| 15:55 | mi6x3m | gfredericks: create a semantically more intuitive way then setting up meta data on my example constructors manually :) |
| 15:55 | mi6x3m | a example is actually a defn with ^{:example {:title "foo" :desc "boo" :show-src? true/false}} |
| 15:57 | gfredericks | you missed the name of the var then, eh? |
| 15:57 | gfredericks | same as the title? |
| 15:57 | mi6x3m | gfredericks: you are right, it was supposed to be (defexample simple-example "foo" "boo" true/false form) but this is arguably better than the manual meta.... |
| 16:00 | gfredericks | it's at least less prone to keyword typos |
| 16:00 | mi6x3m | gfredericks: true, but still ugly |
| 16:01 | gfredericks | you can also write a function that adds stuff aftewards |
| 16:02 | gfredericks | (defn set-example-data [the-var title desc ...]) |
| 16:03 | mi6x3m | gfredericks: hm? using a defn? |
| 16:04 | gfredericks | yeah, it would just call alter-meta! on the var |
| 16:04 | gfredericks | look ma, no macros |
| 16:05 | mi6x3m | gfredericks: but ma, then the example and it's meta would be split. nah i'll just use the ugly macro |
| 16:05 | mi6x3m | who'll be there to see |
| 16:05 | mi6x3m | oh, it's open source, myeah |
| 16:11 | gfredericks | it's surprisingly difficult to alter nrepl's default printing behavior cleanly |
| 16:13 | amalloy | mi6x3m: the problem with (defexample blah "foo" "boo" whatever else) is that you have a bunch of positional arguments that all look the same, and it's easy to forget which is which |
| 16:13 | amalloy | taking a map of options somewhere in there would help a lot, by placing reminders in the user's code: (defexample blah {:thing "foo" :message "boo" :cleanup? false} form) |
| 16:18 | mi6x3m | amalloy: yes in the end that's what's going to happen |
| 16:18 | mi6x3m | I just can't bear the thought of having named arguments with macros |
| 16:19 | mi6x3m | (defexample blah :title "foo" :desc "boo" :show-src? true form) perhaps |
| 16:19 | mi6x3m | ok i'm off thanks everyone :) |
| 16:43 | mxr1o1 | hi |
| 16:43 | mxr1o1 | so i have a bit of embarrasing question.. |
| 16:44 | gfredericks | put more parens on it |
| 16:44 | mxr1o1 | my code is built as a hierarchy of functions where top level functions call other functions and they call more functions |
| 16:44 | mxr1o1 | the questions is about writing tests |
| 16:45 | mxr1o1 | writing tests is a requirement of the project |
| 16:45 | mxr1o1 | now, i wonder how should i approach it |
| 16:45 | mxr1o1 | would it be a good practice to test _every_ function? |
| 16:45 | mxr1o1 | or should I only test the highest level (end to end) functions? |
| 16:46 | asQuirreL | mxr1o1, I would test all the public functions in each namespace |
| 16:46 | gfredericks | what do you have to test to be confident that it's working and that you can refactor it without unknowingly breaking anything? |
| 16:46 | mxr1o1 | or rather only the lowest level functions.. |
| 16:46 | amalloy | (inc gfredericks) |
| 16:46 | lazybot | ⇒ 93 |
| 16:47 | mxr1o1 | gfredericks: i guess to be "confident" i have to test each and every function |
| 16:47 | mxr1o1 | ... |
| 16:47 | mxr1o1 | or what?! |
| 16:47 | mxr1o1 | :) |
| 16:47 | mxr1o1 | (inc inc) |
| 16:47 | lazybot | ⇒ 11 |
| 16:48 | asQuirreL | (doc inc) |
| 16:48 | clojurebot | "([x]); Returns a number one greater than num. Does not auto-promote longs, will throw on overflow. See also: inc'" |
| 16:48 | gfredericks | mxr1o1: well if you can test the higher level functions and infer that your code is working from that... |
| 16:49 | asQuirreL | (deref 'gfredricks) |
| 16:49 | gfredericks | mxr1o1: I feel like the answer becomes obvious once you're not testing just because you're supposed to, and are instead testing because you want an automated way to check that the code works the way it's supposed to |
| 16:49 | mxr1o1 | gfredericks: but then.. comes a new programmer, removes the top level functions and writes something different using the bottom more generic functions - which don't have tests - maybe in the process he even changes some of these generic functions.. |
| 16:50 | mxr1o1 | i.e regression.. |
| 16:50 | gfredericks | mxr1o1: and then your tests break with "these top level functions no longer exist", so that programmer will be able to tell that he needs to think things through |
| 16:50 | gfredericks | I don't think "someday the code might be restructured so that these tests become valuable" is a good reason to write tests today |
| 16:51 | cheater | hi |
| 16:51 | gfredericks | hello |
| 16:51 | cheater | i'm trying to understand this transducers library and i've got this function that takes transducers and runs them on a list |
| 16:51 | mxr1o1 | gfredericks: yeah.. i tend to agree - otherwise this testing orgy feels like a waste of time after a certain threshold.. |
| 16:52 | cheater | (this is in haskell) |
| 16:52 | gfredericks | mxr1o1: tests aren't free |
| 16:52 | cheater | and it ends up looking like this: (ftrans (t1 . t2 . t3)) [1..5] |
| 16:53 | cheater | and it looks to me like ftrans applies t1, then t2, then t3 to the list... however that's the opposite direction as if you'd do (f1 . f2 . f3) [1..5] |
| 16:53 | cheater | why is that so? |
| 16:53 | mxr1o1 | gfredericks: sure.. i'm trying to resolve the best practice of this where tests give more value than they cost to write/maintain |
| 16:53 | cheater | are transducers somehow contravariant or something like that? |
| 16:54 | Bronsa | cheater: http://clojure.org/transducers |
| 16:54 | Bronsa | cheater: "Composition of the transformer runs right-to-left but builds a transformation stack that runs left-to-right (filtering happens before mapping in this example)." |
| 16:54 | cheater | Bronsa: yeah, but why is that? |
| 16:57 | platz | cheater because the outer transducer 'wraps' the inner transducer |
| 16:57 | Bronsa | cheater: https://www.youtube.com/watch?v=6mTbuzafcII&t=25m30s |
| 16:58 | cheater | platz: hmm.. |
| 16:58 | platz | so the outer one gets eval'd first, but it's just returning a closure which wraps the inner one |
| 16:58 | cheater | platz: makes sense kind of |
| 16:58 | platz | so the data actually gets run through the inner one first |
| 16:59 | platz | it's just normal function composition |
| 16:59 | platz | but made to look wierd because all of the closure returning |
| 16:59 | kenrestivo | kind of like ring handlers in a way |
| 17:07 | cheater | platz: hmm |
| 17:08 | platz | cheater: http://youtu.be/6mTbuzafcII?t=25m30s |
| 17:08 | cheater | platz: Bronsa just linked to that |
| 17:16 | cheater | thanks for the help guys |
| 17:16 | cheater | cya! |
| 17:33 | justin_smith | hiredman: were you the one that had a code snippet to get multiple resources with the same path from the classpath? |
| 17:36 | rurumate | I'm confused about this stack trace: https://www.refheap.com/91623. Why does it come to Compiler.java:6361 twice? Why does the analyzeSeq call succeed the first time, but not the second. Anyone? |
| 17:38 | tavoe | Easy question. How do I check what my present working directory is with clojure? |
| 17:38 | justin_smith | ,(.getCanonicalPath (java.io.File. ".")) |
| 17:38 | clojurebot | #<SecurityException java.lang.SecurityException: denied> |
| 17:38 | tavoe | thank you. Cool |
| 17:39 | justin_smith | rurumate: just guessing - it's recursing, "(x y)" analyzes fine, it's getting the contents of "x" that blows up |
| 17:40 | rurumate | I don't know how to debug clojure. It's not a lein project. How to start a repl? |
| 17:41 | justin_smith | rurumate: it's much easier with lein, but you can get a repl with java -jar your.clojure.version.jar |
| 17:42 | rurumate | ok but how to debug the java parts, like Compiler.java? |
| 17:43 | rurumate | how did rich do it, did he use a debugger or what |
| 17:43 | justin_smith | I think he used eclipse or idea |
| 17:50 | rurumate | micrypt: just trying to find out things about the compiler, from the repl. Making it go boom, like (nil 5), creates interesting stack traces, but how to see more exactly what's happening? I don't like the thought, but maybe will have to use eclipse soon |
| 17:55 | rurumate | this would be the java version: (clojure.lang.Compiler/eval (clojure.lang.RT/readString "(nil 5)")) |
| 17:56 | rurumate | so that's a java program, it can be debugged. it seems there is no other way |
| 18:04 | rurumate | where are the unit tests in clojure core? |
| 18:04 | gfredericks | you mean these? https://github.com/clojure/clojure/tree/master/test/clojure/test_clojure |
| 18:05 | rurumate | so they are all in clojure? that means, rich has been developing the java code, using a clojure repl? |
| 18:06 | rurumate | I'm looking for tests for the java parts specifically, like LispReader and Compiler |
| 18:07 | gfredericks | why can't you test those from clojure? |
| 18:08 | rurumate | dunno, have to look at it first |
| 18:09 | rurumate | it's just I would expect to find more java unit tests, because at first there is only java, can't test from the repl while developing the repl |
| 18:09 | gfredericks | it's not too hard to bootstrap a lisp |
| 18:10 | gfredericks | and writing tests in java is somewhat unpleasant |
| 18:10 | rurumate | yes, but what about bugs? also Compiler.java has some 8000 lines of code |
| 18:10 | gfredericks | I'm sure it didn't at first |
| 18:10 | rurumate | isn't is bad style to let it grow so large? |
| 18:11 | gfredericks | probably |
| 18:12 | rurumate | how would I start a repl to hack these tests? there's no project.clj |
| 18:12 | gfredericks | good question |
| 18:13 | gfredericks | if you just want to play with the tests using a released version of clojure, you could um |
| 18:13 | gfredericks | I don't imagine you use cider or fireplace or anything? |
| 18:14 | rurumate | I would like to make experimental changes to the java code too, it's ok to restart the repl, but a real emacs repl would be nice |
| 18:14 | rurumate | yes cider |
| 18:14 | gfredericks | okay well with cider you can just open any of those test files and start evaling things |
| 18:14 | rurumate | really? doesn't it need to connect to a repl server first? |
| 18:16 | gfredericks | playing with the java code is trickier |
| 18:16 | gfredericks | you can start a minimal repl from a compiled jar |
| 18:16 | gfredericks | starting an nrepl server would be more work |
| 18:16 | gfredericks | (for the former, run the clojure.main class) |
| 18:17 | rurumate | ok, I see. I think I will just write some JUnit tests for now |
| 18:19 | justin_smith | gfredericks: wait, are you saying cider can work with a direct repl not using nrepl / sockets? |
| 18:19 | rurumate | really I'd like to see the workflow rich used when writing this |
| 18:20 | gfredericks | justin_smith: nope |
| 18:21 | oskarkv | rurumate I might not have understood what you meant, but https://github.com/zcaudate/vinyasa#reimport |
| 18:21 | rurumate | oh my. there's not even junit in the pom. |
| 18:23 | rurumate | oskarkv: yes that looks cool, I will look into it |
| 18:23 | slester | any ideas for finding the largest contiguous shared substring given two strings? I'm totally stumped. :( |
| 18:25 | rurumate | slester: have you tried brute force yet? |
| 18:25 | oskarkv | slester http://en.wikipedia.org/wiki/Longest_common_substring_problem |
| 18:25 | micrypt | rurumate: Thanks for your help. |
| 18:26 | slester | rurumate, nope, I was trying to find an idiomatic way to do it |
| 18:26 | slester | oskarkv, oh! nice! I didn't think to check Wikipedia |
| 18:27 | oskarkv | slester i just googled what you said, more or less :P |
| 18:27 | slester | oskarkv, well, I'll blame startpage then, all I found was rosetta code that had shared noncontiguous substrings |
| 18:27 | oskarkv | hehe |
| 18:28 | justin_smith | suffix tree building is more straightforward to do in clojure than dynamic programming (since our default data types are immutible) |
| 18:48 | gfredericks | lol elisp is weird |
| 18:49 | gfredericks | I'm using defadvice to monkeypatch things and it works exactly the opposite of doing alter-var-root in clojure -- running defadvice has no immediate effect, but once you go eval the original function the monkeypatch becomes active |
| 18:50 | cfleming | Hi all - I'm using with-redefs in my tests. I just switched my tests to run on the Swing EDT and with-redefs no longer seems to be taking effect - any ideas why? |
| 18:51 | cfleming | These tests worked previously, I can now debug and I see the original functions being called. |
| 18:56 | justin_smith | cfleming: that's weird - and it only happens in that specific thread? |
| 18:57 | cfleming | justin_smith: It seems to. But it's not like the EDT is magic or anything. |
| 18:57 | cfleming | justin_smith: Actually, perhaps I spoke too soon. Since I just ported all my tests to the EDT, I don't know if it would also happen on other threads - I do know it used to work. |
| 18:59 | justin_smith | right, just wondering if you tried the same tests in a normal thread, that would potentially narrow down the issue |
| 18:59 | cfleming | There seem to be some problems with with-redefs and concurrency, but they're mostly around multiple threads binding the same vars simultaneously |
| 18:59 | justin_smith | it could be an error introduced by refactoring (which would be less scary and baffling) |
| 18:59 | cfleming | Unfortunately un-porting them is non-trivial. |
| 18:59 | cfleming | An error in my code?!?! |
| 18:59 | justin_smith | what about just making the thread a parameter? |
| 18:59 | cfleming | Inconceivable. |
| 19:00 | cfleming | Well, it's tricky - I can't pass the thread in as a parameter since to execute on the EDT I have to use invokeLater |
| 19:01 | justin_smith | a runner abstraction? |
| 19:01 | cfleming | I could pass in a function which abstracted that, though. |
| 19:01 | cfleming | I'll take a look - it's tricky because this is all set up in test fixtures. |
| 19:03 | ben_vulpes | does aset-byte not alter the underlying byte array? |
| 19:04 | ben_vulpes | i'm doing (let [inits (byte-array 12)] (aset-byte inits 0 (byte 0xF9)) inits) and getting back an apparently bare array of bytes (all 0's) |
| 19:04 | justin_smith | ,(let [a (byte-array (map byte [1 2 3 4 5]))] (println (into [] a)) (aset-byte a 1 (byte 42)) (println (into [] a))) |
| 19:04 | clojurebot | [1 2 3 4 5]\n[1 42 3 4 5]\n |
| 19:07 | Bronsa | cfleming: http://sprunge.us/UAiV?clj might be what's happening |
| 19:08 | Bronsa | cfleming: i.e. if you're using the redefed value in a different thread, the with-redefs might be restoring the previous var root before your thread gets to deref the var |
| 19:08 | cfleming | Bronsa: I'm not quite sure what I'm looking at there. |
| 19:08 | cfleming | Ah, right. |
| 19:09 | Bronsa | cfleming: the easy fix is to await the termination of the other thread before exiting the with-redefs |
| 19:09 | justin_smith | right, you want to call with-redefs inside the other scope |
| 19:09 | justin_smith | or that... |
| 19:09 | cfleming | Bronsa: That could be the case since the call to the redef'ed function happens in a Swing invokeLater - however I thought that was executed immediately when called from the EDT. |
| 19:10 | cfleming | If anything, I would have expected problems like that previously, when this code was not run from the EDT and cross-thread issues definitely come into play. |
| 19:11 | Bronsa | cfleming: dunno, just sleep for a bunch of ms before exiting with-redefs and see if the problem goes away :) |
| 19:12 | Bronsa | in my repl even without sleeping, (with-redefs [+ 2] (future (reset! a +))) sets a to #'+ instead of 2 |
| 19:12 | cfleming | Ohhh, looks like I was wrong - that's almost certainly what is happening - thanks. |
| 19:12 | Bronsa | np |
| 20:09 | corecode | my instaparse grammar is amazingly slow |
| 20:09 | corecode | i wish i knew why |
| 20:09 | tavoe | If I want to do http routing in clojure, I think the cannonical tools are "ring" and "compojure". Where can I find directions on using those tools? I'm finding lots of unfinished documentation, but nothing actionable. It's driving me a bit batty |
| 20:10 | weavejester | tavoe: The Ring and Compojure sites have wikis of documentation. Presumably you’ve found that not enough or confusing? |
| 20:13 | ambrosebs | corecode: have you checked it for ambiguities? |
| 20:14 | corecode | i am trying to |
| 20:14 | corecode | there seem to be internal ones, or at least there were |
| 20:14 | corecode | but it is difficult to find them |
| 20:17 | mikefikes | tavoe: LispCast has a video covering Ring and Compojure |
| 20:17 | amalloy | corecode: my experience has been that anything you can do with instaparse is quite slow, but you can try profiling it to see what's taking all the time |
| 20:18 | tavoe | mikefikes: thank you. I probably shouldn't have asked. I just need to take a step back, breath, and move more slowly. |
| 20:20 | mikefikes | tavoe: I've felt the same way. It'd be nice if there were books covering some of these libraries. |
| 20:20 | corecode | amalloy: :/ |
| 20:21 | tavoe | mikefikes: It seems like a lot of the tutorials I find were written ~2011, and the libraries have changed since then. |
| 20:21 | raspasov | there is this project which a nice starting point for a whole suite of libs for Clojure dev, especially web development https://github.com/priyatam/ringo |
| 20:24 | raspasov | tavoe: I've also found the http-kit documentation page to have good examples for Compojure integration http://http-kit.org/server.html |
| 20:28 | ben_vulpes | how would i assert that an argument to a function is of class [B in a pre-map? |
| 20:29 | weavejester | ben_vulpes: I think you have to do something like: (def byte-array-class (class (byte-array []))) |
| 20:30 | weavejester | ben_vulpes: (instance? byte-array-class x) |
| 20:31 | ben_vulpes | ,(= (Class/forName "[B") (class (byte-array 10))) |
| 20:31 | clojurebot | true |
| 20:31 | ben_vulpes | yikes |
| 20:31 | ben_vulpes | mwell thanks weavejester |
| 20:31 | weavejester | I would not have expected that to work :) |
| 20:32 | ben_vulpes | i don't know what to expect anymore, but that seems fine for now |
| 20:33 | dbasch | ,(= (str (class (byte-array [1 2 3]))) "class [B") |
| 20:33 | clojurebot | true |
| 20:33 | dbasch | ugly though |
| 20:33 | ben_vulpes | that's probably safer. |
| 20:34 | ben_vulpes | er |
| 20:34 | ben_vulpes | hang on |
| 20:34 | ben_vulpes | maybe i'll just use the class of the output of byte-array |
| 20:34 | ben_vulpes | the output of (class (byte-array 0)) |
| 20:34 | ben_vulpes | still, kinda floppy. |
| 20:37 | raspasov | you know about {:pre [] :post []} construct? |
| 20:45 | ben_vulpes | yeah, and using it raspasov. |
| 20:45 | sineer | f |
| 20:47 | corecode | hmm, my java regex pattern produces a stack overflow |
| 20:48 | corecode | maybe i don't know how java does its regex parsing |
| 20:50 | raspasov | ben_vulpes: are you developing a type checker of some sort? |
| 20:53 | gfredericks | is there something I'm supposed to set in my project.clj so that `lein deploy` goes to clojars? |
| 21:04 | gfredericks | corecode: you're building a regex programmatically? |
| 21:08 | corecode | no |
| 21:08 | corecode | i'm just trying to find the speed issue in my grammar |
| 21:09 | corecode | regexp matching all takes 10 ms, regexp matching all command-by-command takes 10 ms (now without stack overflow), regexp matching command + instaparse doing the repetition = 160 ms |
| 21:10 | corecode | that's a lot of overhead |
| 21:10 | ben_vulpes | raspasov: that'd be far over my pay grade :P |
| 21:10 | ben_vulpes | raspasov: no, i just want a little bit of rigidity around function inputs and outputs. |
| 21:11 | raspasov | haha ok :) |
| 21:11 | raspasov | yea, makes sense |
| 21:11 | ben_vulpes | i played with haskell for the past three weeks and now all new functions that i write come complete with :pre conditions at the very least :D |
| 21:11 | ben_vulpes | ,(.toByteArray (bigint 60002)) |
| 21:11 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: toByteArray for class clojure.lang.BigInt> |
| 21:12 | dbasch | ,(.toByteArray (biginteger 1)) |
| 21:12 | clojurebot | #<byte[] [B@c9bbcb> |
| 21:12 | dbasch | ,(class (bigint 1)) |
| 21:12 | clojurebot | clojure.lang.BigInt |
| 21:13 | dbasch | ,(class (biginteger 1)) |
| 21:13 | clojurebot | java.math.BigInteger |
| 21:14 | ben_vulpes | thanks, dbasch |
| 21:16 | ben_vulpes | ,0x0000ea62 |
| 21:16 | clojurebot | 60002 |
| 21:16 | ben_vulpes | man |
| 21:16 | ben_vulpes | i have no idea what i'm doing |
| 21:17 | ben_vulpes | i think that i want to write a function that takes in bigintegers like 60002 and then returns a byte array that will serialize to 62ea0000 over tcp |
| 21:17 | corecode | intbuffer |
| 21:17 | corecode | ? |
| 21:19 | corecode | or does biginteger serialize like you want? |
| 21:23 | dbasch | java bigintegers can have arbitrary length |
| 21:23 | dbasch | integers and longs are fixed |
| 21:23 | dbasch | 4 and 8 bytes respectively |
| 21:25 | ben_vulpes | it looks like using .putInt into a bytebuffer and then getting the contents of that bb into a buf will work |
| 21:25 | ben_vulpes | but it's the wrong endianness |
| 21:25 | ben_vulpes | :( |
| 21:25 | ben_vulpes | oh well, pick it up again later i suppose |
| 21:26 | corecode | you can change the endinaness of a buffer |
| 21:26 | corecode | java with binary data sucks |
| 21:27 | ben_vulpes | so im learning |
| 21:33 | yedi | is there a function to replace all occurrences of a specific substring in a string to to a different string |
| 21:34 | corecode | clojure.string/replace |
| 21:40 | corecode | :/ this regexp is way faster than the parser... i might have to write a parser manually :( |
| 22:02 | TEttinger | well clojure just helped me solve the NPR sunday puzzle |
| 22:03 | TEttinger | Name a certain country. Change one letter in its name to a new letter and rearrange the result to name another country's capital. Then change one letter in that and rearrange the result to name another country. What geographical names are these? |
| 22:09 | yedi | corecode: ty btw, im pretty dumb |
| 22:16 | squeedee | justin_smith: thanks again man. I really like this solution https://github.com/squeedee/lsystem/commit/04fa8e077b8f13e9d9fad80be24e55608b76c8e0 |
| 23:57 | havenwood | just a silly aside, but a Ruby FizzBuzz with Transducers: https://gist.github.com/havenwood/c5c5b48bd96b77bea53d |