#clojure logs

2016-02-22

03:50CStormhow do i set a environment variable on unbuntu which environ can get? ive tried putting it in /etc/environment but no luck.
04:49hyPiRionCStorm: You probably need to restart/logout then login again for it to be reflected
05:53Kah0onasolatis: I'm currently working on a nice green-field freelance solo project for a company in Tilburg until like May-June, but when it's done, we probably need to talk ;-) (I'm Dutch, freelancer, Den Haag based.)
05:54Kah0ona(if i read correctly that you are hiring that is)
05:54Kah0onakinda skimmed over the cats discussion
05:55Kah0onaI have two cats too ;-)
05:56Kah0onaAnyway; in summer I have another fairly large clj project added to my portfolio. working on it now
06:06TEttingerhaha
06:06TEttingercats
07:13aurelianhi there... what's the idea with lein creating an empty folder called dev-resources ?
07:13aurelianhow do I get rid of it?
07:16ridcully{:profiles {:dev {:resource-paths set?
07:17aureliandoesn't look like
07:17aurelian :profiles {:uberjar {:aot :all}})
07:17aurelianit's a standard lein new project
07:17aurelianusing app template or wtv the default is
07:18aurelianoh. upgraded lein and now is gone.
07:18aurelianmind me
07:19aurelianI was on 2.5.something
07:37hyPiRionaurelian: yeah, sorry about the empty folders. They should be gone with 2.6.x
07:37aurelianit's ok, thanks!
07:37aurelianconfirmed they're gone
07:58timvisheri'm logging from a background thread that updates an atom that i dereference. everytime i dereference the atom a log message comes out but if i don't dereference the atom no message comes out. is there any way i can force those exceptions to be logged without having to dereference the atom?
08:21TimMctimvisher: Dereferencing an atom should not cause side effects. Do you have lazy seqs or something in there?
08:26timvisherlaziness…
08:26TimMc~laziness
08:26clojurebotlaziness means not traversing anything twice
08:26TimMc~laziness
08:26clojurebotlaziness means not traversing anything twice
08:26TimMcoh well
08:27TimMctimvisher: So yeah, sounds like you need a dorun or doall in there somewhere. :-)
08:27timvisheranyway yeah. one `map → mapv` transformation later and boom
08:39TimMcCould I get some advice/rubber ducks on a concurrency mechanism for serializing writes to a cache?
08:40TimMcThe code is currently sending ~50 writes per second (luxuriously few, given that writes are 1-2 ms) and I was thinking of just dumping them into a dropping or sliding queue and spinning a thread to pick them up at the other end and put them in the cache.
08:42TimMcI'm thinking simple 'n' robust is better, because we rely on the cache being up, and if we stop updating it, there's going to be trouble.
08:42TimMcAny constructs I should be looking at in particular?
08:47TimMcAgents are out, as usual. I've never ended up finding a good use for them.
08:50jamesturnbullhi all - I have a collection [var1 var2] that I am trying to join. var2 may sometimes be nil. I want to ensure a separater is present if there are two elements but not if there is one. (clojure/string.join "." [var1 var2]) becomes var1. if var2 is nil.
08:50hyPiRionTimMc: I think just a Thread and a BlockingQueue would work fine. Then you can use .offer to insert values which may be dropped.
08:50hyPiRionI am no guru on concurrency mechanisms though
08:50TimMcAnd just a try/catch in the thread is probably sufficient to make sure it never dies?
08:51TimMcI'll monitor the length of the queue, of course.
08:51hyPiRionYeah.
08:51TimMchmm, also need shutdown mechanism
08:51TimMcChannels feel like maybe they're relevant here, although I hesitate to introduce *yet another* concurrency mechanism or structuring principle to this codebase...
08:54hyPiRionTimMc: It depends on how you'd like to shut down. I like to just use .interrupt and catch InterruptExceptions
08:59TimMchiredman: That... sounds perfectly reasonable, actually.
08:59TimMcoops
08:59TimMchyPiRion, rather
09:01TimMcjamesturnbull: They're both strings already?
09:03TimMcI'd probably go with something simple like (cond-> (str v1) v2 (str "." v2))
09:03jamesturnbullTimMc: yeah both strings. thanks will try that!
09:04TimMc(that handles them not being strings, but not if v2 can legitimately be the boolean false)
09:04dysfunwhat's the function called that turns '_BANG_' etc. into '!' in a name?
09:04TimMcdemunge?
09:04dysfunthat's the one, ta
09:04TimMcbut I think it's only in clojure.repl
09:05TimMcand has a bug, IIRC
09:05dysfunthat's acceptable for this, this module is meant for during development
09:05dysfunoh :/
09:05TimMcsomething about double underscores
09:06dysfunhaha, and the literal word 'BANG' probably
09:07TimMchmm, I think I'm thinking of a bug in pst around extracting munged fn names
09:13jamesturnbullTimMc: thanks - works perfectly - didn't know about cond-> - neat.
09:15dysfunTimMc: so demunge is fine?
09:15dysfun(to the best of your knowledge)
09:16TimMcdysfun: Yeah, and I found the original (fixed) bug: http://dev.clojure.org/jira/browse/CLJ-1083
09:17dysfunaha
09:18dysfunof course if you're a java programmer and you're writing _BANG_, you need your head looking at
09:20ridcullystatic final String LOL_BANG_LOL seems not so far out that head inspection is needed? ;P
09:20TimMcProbably true, but that kind of argument never sits well with me.
09:22TimMcThis is why we have problems like not having any way to escape characters in a <script> block in HTML. "Just don't write </script> in your script, ever, OK?" Fast forward a decade and we've got user data being plunked down in JSON into script blocks and no end of trouble.
09:22TimMcUniversality is good for security and correctness.
09:23TimMc(I gave a talk on this at work. I should turn it into a blog post.)
09:24dysfuni'd read it
11:27justin_smithTimMc: agents are when you want a mutable container and retries on update are out of the question
11:28justin_smith(in my experience, they probably also have other uses)
11:28justin_smithTimMc: as such they are the only clojure mutable container that it's safe to put actual mutable objects inside
11:31sineerHi! if I have a (let [foo "bar"] (if foo (let [foo "baz"]))) is there a nicer way to reassign my foo var without requiring yet another let?
11:31justin_smith,(let [foo "bar" foo (if foo "baz" foo)] foo) ; sineer
11:32clojurebot"baz"
11:32justin_smithsineer: and it is not "reassigning" anythign, it's shadowing
11:32justin_smithbut that's good enough (unless a previous binding used the value, then it's clear it was just shadowing)
11:33sineerright (about shadowing). it feels wierd... I'll try it
11:33justin_smithsineer: it's the same thing the nested let would do
11:33Bronsajustin_smith: care to expand on "agents are the only clojure container that it's safe to put mutable object inside"?
11:34justin_smithBronsa: no retries
11:34justin_smithretries fuck with mutable things
11:34Bronsaah, gotcha
11:34justin_smithI mean yeah you could put a mutable thing inside and promise not to mutate it in swap! or alter calls...
11:34BronsaI'd feel so safe doing that
11:36justin_smithoh, there's vars too of course
11:36justin_smithbut that's only for top level things
11:36justin_smithso for example when I use stuartsierra/component I put my system inside a var or an agent (neither retries) instead of an atom or ref
11:57TimMcIf the actions on the mutable thing are idempotent it might be OK.
12:01justin_smithTimMc: sure, maybe, but still, if what you have is a thing containing maybe some clojure data and some mutable stuff that isn't concurrency safe that you need to punch in unsafe ways, agents are a decent way to manage that state
12:01justin_smithbecause the actions sent are guaranteed to be one at a time, no retries, etc.
12:02justin_smithsimpler than wrangling locks anyway
12:06TimMcjustin_smith: What's an example of something you've used an agent for?
12:07justin_smithTimMc: stuartsierra/component system object (I don't want retries just because something else tried to start it)
12:08justin_smithTimMc: various cases where I was using core.async but realized all I needed was one queue and I could send it functions
12:09justin_smithand I would use it if I needed to use a mutable object unsafe for concurrency that had namespace level scope, but that hasn't come up remarkably
12:10TimMchmm
12:13justin_smithTimMc: if you have a simpler solution for those cases feel free to offer, of course
12:17justin_smithof course the canonical thing with a component is a var, but that doesn't cover overlapping calls as nicely I don't think?
12:20justin_smithactually I can't tell if this retries or not? https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Var.java#L302
12:25sineerclojure.lang.ExceptionInfo: Cannot recur accross try ... I can't try/catch inside a go loop if I must recur ?
12:25justin_smithsineer: you need to move the try/catch to not surround the recur
12:25justin_smithsometimes this requires a promise or delay for the value propagation to work (sadly)
12:26sineerso inside the go block but before the (loop ) ?
12:26sineerotherwise if it's outside the go block then it won't work correct?
12:26justin_smithor inside the loop but not surrounding the recur
12:26justin_smithdepends what needs catching
12:27justin_smithsineer: (loop [x 1] (let [res (promise)] (try .... (deliver res v) ... (catch ... (deliver res nil)) (recur @res)) ; if you need to use a value created inside the try in your recur
12:28justin_smithif you don't need to use any value from inside the try in your recur call, that's much simpler of course
12:28sineerk, thanks!
12:31justin_smithsineer: actually there should probably be a deliver in the finally clause in the above, to guarantee you don't do a blocking deref that won't be fulfilled inside the recur call
15:04mpinghi guys
15:27gfredericksI need some names for things in test.check
15:27TimMcfred
15:27gfredericksto be more specific
15:27AimHerefred smith
15:28TimMcthe third
15:28gfredericksI need to differentiate a test run from a single trial
15:28gfredericksbut "test run" sounds too much like running your whole test suite
15:28gfredericksI don't know which of the two "trial" sounds like
15:28{blake}"single trial" seems pretty clear
15:28gfredericksthis is for things to go under the :type key in a map passed to a callback function to let you know what's going on
15:29gfredericksso event names I guess
15:29gfredericksmaybe :start-test, :trial, :end-test, that sort of thing
15:29gfredericksi.e. I think "test" is a decent name for the larger chunk of work
15:29gfredericksGREAT thanks everybody
15:30gfrederickscfleming: hi
15:50TimMcgfredericks: Yes, trial sounds right.
15:50TimMcor even probe, but trial is better
15:50TimMcchcek :-P
15:50TimMc*check
15:51gfredericksnaming is one of the 94 hard problems in computer science, along with cache-invalidation and off-by-91-errors
15:52TimMc*71
16:10andyfI know a gentleman from India whose last name is "Furniturewala". Yes, the English word "furniture" followed by "wala", with no space.
16:11andyf"wala" means "maker", so he is named for one of his recent ancestors being a furniture maker, after English was reasonably common in India, but before surnames were common, so the surname was created after that.
16:12andyfThat was one of my top all time favorite names, until this weekend, when I heard a similar but even more awesome name: "Sodabottleopenerwala"
16:12andyfI am not joking
16:15andyfSorry, no application to your naming question, gfredericks, although I would suggest putting 'wala' in constructor names whenever you can :-)
16:16justin_smithandyf: beats Factory for sure
16:16zipperHey guys, I need some clojurescript help. I can get it here, right?
16:17andyfIf all planets line up properly, then yes.
16:17hiredmanmaybe, depending on the nature of the help required, there is a #clojurescript channel I think too
16:18gfredericks~andyf is a walanamewala
16:18clojurebotIk begrijp
16:19{blake}A propos of which, I'm having reagent timing issues.
16:19{blake}I have a reagaent component that renders a table full of controls.
16:19{blake}After rendering, I want to attach some Jquery to the controls.
16:20{blake}I dutifully used with-meta and :component-did-mount, which I wrapped my rendering function around.
16:20{blake}The code is called. I know, because it starts a timer.
16:20{blake}But the attempt to collect all the controls of a class fails. (I'm collecting, e.g., currency controls to apply MaskMoney to.)
16:21{blake}If I put the collection code into the timer code, it works, I presume because that stuff fires long enough for everything to have settled.
16:21{blake}er, late enough
16:21amalloyMaskMoney is the account bruce wayne sets aside for batman-related activities
16:22{blake}And I suppose I could create a timer event to fire JUST to set this Jquery code. But that seems cheesy, and wrong.
16:22{blake}He must go through masks like crazy.
16:23amalloyfwiw andyf, we have lots of names like that in english already, we're just used to them because we've had them so long
16:24amalloyplenty of masons, smiths, thatchers, coppersmiths, and so on
16:24gfredericksandyf: the clear conclusion is that you need to come to clojure/west this year
16:24hiredman{blake}: sounds like you need the js equiv of swing's invokeLater, which I guess would be a zero second settimeout
16:25{blake}hiredman: Mebbe. It's gotta exist. No way people =aren't= doing this exact thing. But it can be hard to find info.
16:25{blake}(Or in this case, figure out where I've gone wrong, because if :component-did-mount isn't for this, what IS it for?)
16:27hiredmanhttps://facebook.github.io/react/docs/component-specs.html#mounting-componentdidmount it does sone like that is what it is for
16:27hiredmansound
16:27{blake}Hmmm. Immediately after initial rendering occurs.
16:27andyfgfredericks: The thing I found interesting was the *combination* of words from two languages in a single name.
16:27zipperSo since the clojurescript channel isn't full of life. I will ask here too.
16:28zipperSo in this code https://www.refheap.com/115084#L-2 The Line 2 fails. I am trying to rewrite whatever is from L12 since that regex fails to work for () and |
16:28andyfgfredericks: Kids still in college, and on top of that there is big hardware/software product release coming up this April, but maybe the hubbub will be over by the Conj.
16:29hiredmanzipper: you are qouting the regex and not the list
16:30hiredmanzipper: so you are invoking the regex as a 0 arg function, you should be seeing errors in the error console and possibly at compile time
16:30hiredmanzipper: if you do quote the list, you local 'regex' in the let is being bound the result of the if, which is a list containing a regex, not a regex
16:31hiredmanoh, I guess you only care about the second
16:31andyfamalloy: Sorry, meant to send one of my recent comments to you. Senior moment.
16:32hiredmanzipper: what does "fails" mean? a compilation error, a runtime error, or it fails to match what you want?
16:32zipperhiredman: Yes I am seeing an error in the JS console
16:32hiredmanfor which snippet?
16:33zipper hiredman `Uncaught TypeError: /\/[\-\[\]\\/\{\}\(\)\*\+\?\.\\\^\$\|]\/gi/.call is not a function`
16:33zipperhiredman: I assume it comes from L2
16:34zipperI can see that because it tries to call that regex.call
16:34zipperplus it ends with /gi
16:34hiredmanzipper: right, so A. you don't need to quite the regexes B. don't call them as zero argument functions
16:34hiredmanto quote
16:35zipperhiredman: How do I avoid calling it if not using '
16:35zipper?
16:35hiredmanyou have the ' and are still calling
16:35hiredman(foo) is a function call
16:35hiredmanyou have (some-regex)
16:35hiredmanthat is trying to invoke the regex as a 0 argument function
16:36hiredmanyou use of ' does nothing in this case, because regexes are literals that evaluate to themselves
16:37zipperOkay so I get rid of the () and have that read as; `#"/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/gi"`
16:37hiredman'(foo) would mean it is a quoted list, not a function call, but then you would have a list containing a regex, not a regex
16:37gfredericksandyf: is going to conferences more difficult when your kids are in college?
16:37zipperThat's a regex now
16:37hiredmanzipper: yes, that is
16:38zipperhiredman: Trying it out
16:38zipperMy chest hurts, it's so cold :(
16:38{blake}component-did-update does the trick.
16:39andyfgfredericks: Only in that I feel budget tightness more than before then. I should splurge on a Conj before they are done, though.
16:40gfredericksandyf: are you telling me college is going to cost *money*??
16:40hiredmanif there was money in the future, instead of just hugs
16:41andyfgfredericks: I fully believe that it will become common-place for some cheaper alternative to traditional 4-year degree to be acceptable for more jobs than they are now. Not sure when that will happen. Maybe a decade or 2 from now?
16:42SomelauwHow to quickly run a clojure.clj file interactively which is not part of a project?
16:43SomelauwIs lein repl, (source filename) the only way?
16:43gfredericksandyf: I need a proposal on my desk by 14 years from now
16:43hiredmanhttp://clojure.org/reference/repl_and_main
16:43hiredmanSomelauw: source doesn't run anything
16:48amalloyyou know, i read "that's a regex now" as "that's a regret now", and it seemed even more apt, given that the subject is #"/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/gi"
16:48gfredericksa programmer has a regret, and thinks, "I know, I'll use a regular expression!" ...
16:48hiredmanamalloy: also, it is being used to edit a string, that is then being turned into a regex
16:49hiredmancrazy
16:49SomelauwRunning 'java -cp clojure.jar clojure.main' says 'Error: Could not find or load main class clojure.main' I just want to run a single script without turning this script into a project.
16:50hiredmanSomelauw: because you picked a random jar instead of the jar that contains clojure
16:50hiredmanclojure.jar doesn't, in this context, mean some jar with your clojure code in it, it means the jar containing the clojure runtime
16:52Somelauwso clojure.jar should be the full path to the clojure.jar that lays somewhere deep in ~/.m2
16:53hiredmanor whereever, you can download the jar from the website
16:53hiredmanhttp://clojure.org/community/downloads
16:54Somelauwso that is ~/.m2/repository/org/clojure/clojure/1.8.0/clojure-1.8.0.jar
16:56SomelauwI'll just write a wrapper for it
16:57SomelauwI only miss autocompletion in my repl that lein has
16:58ridcullydon't forget to put rlwrap -m -M .clj -C clojure around it :)
17:01Somelauwridcully: ehm, do I replace clojure by 'java -cp clojure.jar clojure.main'?
17:04ridcullySomelauw: no. it's just a name used for the history file
17:04ridcullySomelauw: this will use ~/.clojure_history then
17:05andyfgfredericks: My iPhone calendar actually lets me schedule events 14 years in advance. Huh. Not sure whether the event I just created will get copied to whatever device I am using to remind me of calendar events then.
17:06Somelauwridcully: I'm not sure at what place of your command to insert the whole 'java -cp clojure.jar clojure.main'
17:09ridcullySomelauw: i use it like this (some var with the version involved): rlwrap -m -M .clj -C clojure java -cp ~/.m2/repository/org/clojure/clojure/1.8.0/clojure-1.8.0.jar clojure.main
17:10ridcullySomelauw: the -m gives you multine capabilities - so you can open your $EDITOR with ctrl-^. the -M tells it to put a .clj on that "file" to open so your $EDITOR behaves nicely
17:27Somelauwridcully: thanks, that works well, although it would be preferable to still use lein somehow
17:30ridcullySomelauw: you can always run a `lein repl` from anywhere
17:30spuzIs there a function that combines filter and first? I.e. it returns the first element of a sequence that matches a predicate?
17:30ridcullySomelauw: add the `try` plugin for it and you can also fetch some deps right into it
17:31Somelauwridcully: I know I can run lein repl from anywhere, just not how to run it with a script that is not part of a project.
17:31amalloyspuz: incredibly, there is not
17:33Somelauwlein repl filename doesn't work for me
17:33andyfspuz: Some Clojure 'utility libraries' include such a thing, e.g. find-first in Medlay: https://github.com/weavejester/medley/blob/master/src/medley/core.cljc
17:33Somelauwthen it says unknown subcommand
17:33andyfspuz: er, Medley, even.
17:34spuzandyf, thanks
17:35Somelauwbut filter is lazy, so first-filter should already be fast
17:49justin_smithridcully: cool rlwrap tricks
17:56leraxSomeone knows a good lib for pt-br natural lang processing?
18:03ridcullySomelauw: mhm i might have put you on the wrong track then. i only saw your "have to wrap it" bits and tought you just want to have a faster repl
18:15ImBadAtClojureIs there a way to convert a clojure vector of java objects into a java List<java object's type>?
18:15hiredmanthat is a generic, those don't actually exist
18:16ImBadAtClojureSo it's impossible?
18:16hiredmanno, you don't need to
18:16rhg135generics are only a delusion that javac enforces
18:17hiredmanjavas generic types exist in the java (the language) compiler, once you have bytecode running on the jvm, they don't exist (this is called erasure and I am sure there are like a billion blog posts about it)
18:17hiredmanyou just need something that implements List
18:17ImBadAtClojureso when I send this custom data structure back to java how do I get it into java datastructures?
18:17hiredmanif you pull up the java docs for List, there are links to few handy implemntations of that interface
18:18hiredman,(java.util.ArrayList. (vec (range 10)))
18:18ImBadAtClojureI was just trying to map it directly into POJOs somehow
18:18clojurebot[0 1 2 3 4 ...]
18:18hiredman,(type (java.util.ArrayList. (vec (range 10))))
18:18clojurebotjava.util.ArrayList
18:18hiredmanclojure data structures are java data structures
18:19hiredmanso depending on what interfaces java requires and what methods it calls, you can just pass in clojure data structures
18:19ImBadAtClojureFair enough, so just pass it back in a simple array list then map into my pojos on the java side?
18:19hiredmanImBadAtClojure: I am not sure what you mean?
18:19hiredmanany java objects you want to construct, you can construct from clojure and pass to java
18:21ImBadAtClojureBut to construct one of my java objects in clojure I need to create a list of a previously constructed java object
18:21ImBadAtClojureClassCastException java.util.ArrayList cannot be cast to [L<myType>;
18:21TEttingeroh
18:21TEttingerthat isn't a list
18:21TEttingerthat looks like an array
18:22TEttinger,(class (make-array java.util.String 2))
18:22clojurebot#error {\n :cause "java.util.String"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.ClassNotFoundException: java.util.String, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.ClassNotFoundException\n :message "java.util.String"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :...
18:22TEttinger,(class (make-array java.lang.String 2))
18:22clojurebot[Ljava.lang.String;
18:22ImBadAtClojurethat would make an array of strings right?
18:22ImBadAtClojureso I can make an array of my java object's type in the same way?
18:23TEttingeryeah, it looks like your exception is caused by passing an ArrayList where it actually wants an array
18:23ImBadAtClojureYeah I was just trying random things since I didn't know how to create a new array with a non primative type
18:24ImBadAtClojureI'll try it, thanks :D
18:24TEttingerarrays are kinda less supported in clojure than other data structures since they can't be made to have the nice features in clojure's immutable data structures
18:24TEttingerarrays are always mutable, fixed-size
18:24hiredmanthat is non-sense
18:25amalloyi like the implication that clojure's built-in structures are immutable but change size all the time
18:25TEttingerheh
18:25TEttingergood point
18:26TEttingerI do have the feeling that arrays are not quite first-class in clojure, at least partly because of the separate amap, areduce, etc. fns for them
18:27hiredmanTEttinger: infact, map and reduce both work on arrays just fine
18:27hiredmanTEttinger: amap and areduce are *extra* support for working on arrays
18:27TEttingerI didn't know that, I guess seq works on arrays
18:27ImBadAtClojureso can I do (make-array <custom java type class> ..)?
18:27TEttingeryeah, then the dimension or dimensions
18:27TEttinger,(doc make-array)
18:27clojurebot"([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."
18:28hiredmanImBadAtClojure: you can, I would recomend looking at the set of clojure functions with 'array' in the name
18:28amalloyyou'd almost certainly prefer to call into-array
18:28ImBadAtClojureawesome, thanks guys
18:28TEttingerright
18:28hiredman,(doc apropos)
18:28clojurebot"([str-or-pattern]); Given a regular expression or stringable thing, return a seq of all public definitions in all currently-loaded namespaces that match the str-or-pattern."
18:28amalloyalthough hiredman's advice is probably better
18:28rhg135what is the best way to shutdown an agent?
18:29rhg135just stop banging on it?
18:31hiredmanI have some projects where object arrays were used more less like a C struct, in clojure, works fine. kind of a pain, if I did it regularlly I would have a nice set of macros that generate setter and getter functions
18:58TEttingeryeah, actually I might need some advice on how to best interop with array-heavy java code. I still need to get some stuff (I think it's setup related) fixed in my installation of cursive, deps still aren't visible in the editor but they are in lein repl
18:59TEttingerbut once I can pull in the java deps, I need to wrap them
18:59TEttingerI don't know if it's an appropriate case for an issue on cursive somewhere
19:13rhg135try telling that to oracle
21:51sineerI'm inside a (go (loop (try .... (catch Exception e e)))) and I try/catch the block that run this go block yet my exception isn't caught by that try/catch block? Clojure 1.8..
21:52justin_smithsineer: I assume you mean (go (loop [] (try ...)))
21:52justin_smithsineer: is the thing thrown a subclass of Exception?
21:53sineerjustin_smith: yeah, it was throwing allright, let me push code on github it'll make our life easier
21:53justin_smithsineer: what I am asking is what the class thrown was
21:53justin_smithis it an Exception or maybe an Error or some other class that catching Exception would not match
21:54sineerNullPtrException
21:54justin_smithyeah, share a paste / github
21:56sineerhttps://github.com/sineer/sort-challenge
21:56sineerline 46 of boot.clj will throw NullPtrException
21:57sineerI believe it catch it and keep running the go blocks until cnt is 0 but the try/catch in -main never catch anything
21:58justin_smithwell, of course, if the try/catch in init-products-from-chan! catches the error, why would -main ever see it?
21:59justin_smithsineer: also you don't need a new let block at line 51, those bindings can be part of the let block right before
21:59justin_smith,(let [a 0 b (inc a) c (inc b)] c)
21:59clojurebot2
22:00sineerI need to run the (if family (assoc info :family family)) before I do the other (let ..
22:00justin_smithwhy?
22:00clojurebothttp://clojure.org/rationale
22:00justin_smithwhy would that matter at all?
22:00sineerI suppose I can do it after..
22:01justin_smithsineer: (if family (assoc family x y)) does not have any side effects
22:01justin_smithyou need to bind the return value, or it is a noop
22:01justin_smithfamily is immutable, assoc does not change it
22:01justin_smiththe correct version of that line is to have, inside your let binding block 'family (if family (assoc family ...))
22:01justin_smithit needs to be a binding or it might as well not exist
22:02justin_smithso you only need one let block
22:02justin_smiththat binding is just the next binding in the block
22:02justin_smithcompare:
22:02justin_smith,(let [a {}] (assoc a :b 1) a)
22:02clojurebot{}
22:03justin_smith,(let [a {} a (assoc a :b 1)] a)
22:03clojurebot{:b 1}
22:03justin_smithsineer: do you see the difference?
22:03sineerI'm just confused now :(
22:04justin_smithsineer: assoc does not mutate its arg, it creates a brand new data structure
22:04sineeroh shit yeah I get it now :(
22:04justin_smithsineer: you don't need two let blocks
22:04sineersorry
22:04justin_smithsineer: don't be sad, I'm trying to help
22:04justin_smithI'm not trying to be mean
22:04sineerI know, I'm sad because I feel stupid having such a hard time with this
22:05justin_smitheverything is hard if you haven't learned it yet
22:05sineeryeah but it shouldn't be that hard else I'm either stupid or it's too damn hard I havne't fully decided which one it is yet
22:06TimMcjustin_smith: throw in some commas
22:07justin_smithTimMc: in the let blocks?
22:07TimMcyeah
22:07justin_smithahh, yeah
22:07sineerI just realized the version I pushed print the exception on line 59, I use to just return it that's why I expected -main to catch it..
22:07justin_smith,(let [a {}] (assoc a :b 1) a)
22:07clojurebot{}
22:07justin_smith,(let [a {}, a (assoc a :b 1)] a)
22:07clojurebot{:b 1}
22:07justin_smithsineer: returning an exception is not the same as throwing it
22:08justin_smithit might look the same with some printing rules, but it's different
22:08sineerok so I need to rethrow inside go block for -main to catch it?
22:08justin_smithyes
22:09justin_smithotherwise you just return an exception, which is a value like any other
22:09justin_smithsineer: in fact you never even consume the channel returned from that go block
22:09sineerno I just assign it so that main don't exit right away
22:10justin_smithright, just saying by returning it from the go block, it might get read if someone consumed the chan
22:10justin_smithbut nobody even does that
22:11sineernow I tried replacing that print on line 56 by throw and I see the exception trace but then my program just hang, it doesn't look like -main is caching the exception
22:11sineerline 59 I mean
22:11justin_smithgo can be kind of weird about exceptions, it's best to catch them before you exit the scope of a go block and handle them best you can
22:12justin_smithbasically what happens is your code is running in one of the threads of the go thread pool, and your exception bubbles up to that thread, not to the -main that launched the go block, so you are at the mercy of the default go block error handler, which is pretty much useless
22:13justin_smithsince it's in a different thread, the exception can't go back up to -main
22:13sineerI thought I read somewhere it did so since clojure 1.6?
22:13sineerI probably missinterpreted something
22:13justin_smithprobably - how would an exception in one thread interrupt another thread?
22:14sineeryeah that doesn't make sense but I thought there was some magic I didn't know about...
23:02solatiswhat do people recommend for mocking stuff in tests?
23:02solatisspecifically, things like message queues
23:03solatisi am in doubt whether to make my tests just /depend/ upon the availability of those, and create ad-hoc queues
23:03solatisbut on the other hand, i could just as well mock the interface to the queue
23:04sineerre
23:04hiredmansolatis: are you using clojure.test?
23:04solatisyep
23:05hiredmanclojure.test has once (per namespace) and each (per deftest) fixtures
23:05solatisyes
23:05solatisso i'm already doing that for my database
23:05solatisbut now i'm depending upon a lot more things (specifically, Amazon AWS services)
23:05solatisand wonder what the best strategy for this is
23:06solatiseither using the actual service (albeit self-contained), or mocking the interface
23:06sineerer sorry. I have a question about how to build a regex.. I want to (let [regex #"foo[-][_]"]) something like that. but using a var instead of "foo". Basically I need a regex that will match myvar with optional - or _ at the end
23:06hiredmanit can get kind of complicated
23:06solatisyes i know, i don't think there is a "magic bullet" for this and it depends on a case-by-case scenario
23:06hiredmanyou can make all your interfaces to aws services pluggable and use some local plugin when testing
23:07solatisi was thinking about this: https://clojuredocs.org/clojure.core/with-redefs-fn
23:07solatisand put that in a fixture
23:07solatisor something
23:09hiredmanyou can do that, but in my experience you end up with a sprawl of things you need to redef, and it is hard to track what a test is actually doing
23:09solatisright
23:09solatisso the answer is, pluggable service
23:10solatisbut then that doesn't test the actual integration with the message queue
23:10solatis*argh*
23:10hiredmanat my previous job we ended up with a macro we called with-var-roots which was written before with-redefs was added to clojure, and when we had the opportunity to green field another project we tried to avoid that again
23:11solatisi can assume so
23:12solatisok, then i think what i want to do
23:12solatis*i think i know what i want to do
23:12solatisjust use the damned message queue
23:12solatisunless it's really impractical not to do so
23:12hiredmanmocking is really painful, but sometimes you have to, because you can't test against the actual service for whatever reason
23:13solatisyes that is true, *however* when you use something like amazon AWS, you have a complete API to create nearly all services ad-hoc and on-demand
23:13solatisso that's just what i'm going to do
23:15solatisok, so, semi-related question
23:15clojurebotI don't understand.
23:15solatishttps://clojuredocs.org/clojure.test/deftest
23:16solatisi am using tests, with fixture
23:16solatisthe fixture generates something i want to pass around to all tests
23:16solatisin this case, a random id for a message queue
23:16solatishow can i pass this argument to all the tests?
23:17solatisthe test function passed to the fixture appears to be a function that does not accept arguments
23:18sineerhow do I create a regular expression and assign it to a var by concatenating strings? something like #(str var "[-_]") but that's not what I expected..
23:19hiredman,(doc re-pattern)
23:19clojurebot"([s]); Returns an instance of java.util.regex.Pattern, for use, e.g. in re-matcher."
23:20sineerthanks!
23:29sineerany clue how to build a regex with a wildcard - or _ anywhere within a string? I need to match "string" "s-tring" "st-ring" ...
23:48solatisohhhh i understand what i need to do with fixtures now to pass around arguments!
23:48solatisand the solution is _not_ pretty