#clojure logs

2014-12-17

00:00puredangerthe sorted-set-by seems ok to me too
00:00puredangergiven your constraints
00:01andyfI think union, and probably difference, can be implemented in linear time, with a bit of working out the cases. count and nth should be linear, too, so asympotically probably not the fastest possible, but maybe meets your constraints.
00:01puredangerI've implemented interval libraries like this in the past. they're fun!
00:01gfredericksthe one thing that seemed sketchy was this expression:
00:01fairuzHi guys. I'm starting with swagger and liberator. Have this atm: https://www.refheap.com/95023 . When trying to access the API, I'm getting #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/dummy-resource/fn--20454> . I don't see where I miss an argument in the code.
00:02gfredericks(subseq cs >= entry <= entry)
00:02andyfAh, you want that to work...
00:02gfredericks^ to get the overlaps for an entry not in the set
00:02gfredericksit seems to work so far
00:03gfredericksbut also feels like it relies on unspecified behavior
00:03gfredericksin particular that `entry` might be "equal to" several elements in the set
00:04andyfmaybe do a custom implementation of that expression that first finds the earliest contiguous range that overlaps, and then seqs through the rest until it no longer overlaps?
00:05andyfNot sure, but maybe if you have a contiguous range [a b], you search for [a a] in the sorted-set? Not obvious to me yet if that is always correct.
00:05gfredericksthat sounds like it can work
00:05gfrederickswell
00:06gfredericksI'd have to start with (subseq cs >= entry)
00:06gfrederickswhich seems more likely to work
00:06andyfand then throw on a take-while
00:06gfredericksyeah
00:06andyfbut if entry were always a single-element range [a a], it cuts down the brainpower required to figure out if there are bugs.
00:07amalloyfairuz: what is #(assoc {} :entity {:name "Foo"}) supposed to do? someone is calling that function with an argument, and it doesn't take any
00:07andyfIncreasing one's brainpower is always good, but figuring out ways to decrease the brainpower required can look the same from far enough away :)
00:08gfrederickswhy would entry always be single-element?
00:08andyfAlso, if you do maintain the sets as non-overlapping ranges, the comparator can simply compare left ends of ranges.
00:09puredangergfredericks: http://clj-me.cgrand.net/2012/03/16/a-poor-mans-interval-tree/ in case it's interesting
00:09fairuzamalloy: heh yeah. Missed out that one. Thanks for finding it ;)
00:10gfrederickspuredanger: cool thanks
00:10amalloyfairuz: the exception message tells you exactly where the problem is: an anonymous function inside of dummy-resource
00:10andyfgfredericks: I don't mean that the entries of a set-of-contiguous ranges would be single element, but if you want to search for what ranges overlap with [a b], first finding the first one >= [a a] is a good start.
00:10amalloyif you looked at the stacktrace as well, you would see who is calling that function
00:10gfredericksandyf: good point about the left ends
00:11andyfor something close to that -- probably an off-by-one-bug in the idea as stated.
00:18gfredericksoh crap I need intersection too
00:18gfredericksI can fake that with difference can't I
00:18andyfor write another linear time fn customized for it.
00:20fairuzamalloy: Ok thanks. I always forgot that fn_xxxx something is an anonymous function. My mind is on vacation today
00:21gfredericksha that was fun to write: https://www.refheap.com/95024
00:25andyfSo symmetrical, I think you should find chars legal in Clojure that are visually mirror images in place of charset-1 charset-2 and left right, e.g. < > and d b
00:26andyfsorry, only for left right
00:26andyfI'm sure Unicode can help here
00:28rritochgfredericks: Are these charset-1 and charset-2 the sorted sets you were talking about? If so shouldn't the intersection be at the entry level, it seems your implementation is only going to look for exact matches, but won't intersect [1 5] and [2 6] into [2 5]
00:29gfredericksrritoch: that should get handled correctly by difference & union
00:29gfredericksrritoch: the cute part here is being able to define intersection in terms of difference and union
00:30gfredericksso all the nasty details are in the other two functions
00:32rritochgfredericks: I see, It seems like a good tool for manipulating statistics. Politicians would love this code :)
00:33rritochgfredericks: Being able to find the ideal ranges to get data to look the way you want it to is a common problem in politics. I worked at a marketing research firm for about 5 years so I've seen how ugly statistics can really be.
00:36andyfJust listened to a Cognicast podcast episode with Michael Parenteau where he describes taking a whole day course with Edward Tufts, where one of the things he teaches is not only how to try to make nice visualizations for things, but how to work hard to avoid the possibility of being misleading.
00:41rritochandyf: Lol, that wasn't in my job description. The clients were mostly major pharm. I really can't go into any more detail than that without violating a lifetime NDA. I don't think the contract is even legal but I'd rather not find out.
00:44hydoCan you extend a class and implement another class using proxy, or do you have to use gen-class in that case?
00:46rritochhydo: You can't extend 2 classes, do you mean you want to implement another interface?
00:47hydoYea, sorry, my java knowledge is trying to catch up to my lisp-y knowledge. I'm using gen-class to make a java class that extends class x and implements class y. I'd like to use proxy if possible.
00:48rritochhydo: In java you can extend classes and implement interfaces, you can't implement a class but you can extend an interface.
00:49rritochhydo: That being said, it seems proxy allows (proxy [className InterFace1 InterFace2 ...] ...)
00:52hydoOh hell, I completely missed that in the clojuredocs proxy page. :/ And thanks for clarifying. I thought classes and interfaces were ostensibly the same.
00:53rritochhydo: You can also wrap a class and create an interface that matches the classes methods, though you would probably need to use genclass in that case since you'll probably need to maintain an instance of the wrapped class in the object's state.
00:53rritochhydo: In my opinion it is sad that java never allowed multiple inheritance, but you can "fake-it" by wrapping classes.
00:59rritochAnyhow. I guess this is another case for me to try with andylisp. Adding multiple-inheritance to namespaces. Does clojure have any plans of adding namespace inheritance or is that a "dead" idea?
01:16rritochBefore I go re-inventing the wheel, does clojure have anything similar to "wait-until"?
01:22rhg135rritoch: ns inheritance?
01:24rritochrhg135: Yes, Something that publicly exposes vars from parent namespace(s) in the current namespace. Ex. (ns 'my.ns) (inherit 'clojure.core) would make it possible to call (my.ns/map )
01:25luxbockit's not really the same thing, but https://github.com/ztellman/potemkin allows you to kind of do that
01:26andyfThere are libraries for manually inheriting individual Vars from another namespace into the current one.
01:26luxbockit has a lot of other very useful stuff as well
01:26andyfYeah, potemkin
01:26rritochluxbock: I've looked at potemkin, and that is extremly close
01:28rhg135I think ns-publics + that'd work
01:30rritochAs far as I know, any currently solution isn't automatic, so if you "inherit" and then add new vars to the parent, the child doesn't get them unless they re-import.
01:31rhg135Editing nses once finished shouldn't be encouraged
01:36rritochrhg135: I know what your saying, but loading of namespaces isn't thread-safe, so if you have two threads requiring the same file, the one thread will wait for the requires to load, and the other won't. So the second simultanious thread wouldn't see any vars in the parent namespace when it loads, and it's very possible that some threads will load some requires and not others.
01:36rritochrhg135: So in the case of multiple inheritance, if two parents have the same var, which var gets used in a multithreaded environment would be almost completly random.
01:37rhg135rritoch: you'd add another indirection to namespaces, now it takes code to find vars whereas before it was a lookup
01:38rhg135I see
01:38rritochrhg135: I don't think it would be that bad, it would be a failback to look at the parent namespaces.
01:38andyfNot sure, but I suspect that is the least of one's worries if doing parallel requires of the same namespaces.
01:39rhg135This is what andylisp is for
01:39rhg135Try.
01:40rritochrhg135: I may, but even the first namespace adjustment I made isn't completely functional. Somehow the ns macro breaks out of the isolation environment.
01:41rhg135Okie dokey lokey
01:41rritochrhg135: I may be able to try it on a new branch though, that doesn't have the namespace isolation.
01:42rhg135Git is powerful that way
01:43rritochrhg135: Yeah, it is powerful, but has a price in learning curve, svn is much easier to learn and teach.
01:43rhg135You can code whenever
01:43rhg135Code is power, except when it's not
01:44rhg135I use hg, rritoch
01:44rhg135Too young to have used svn so idk
01:46rritochrhg135: Lol, I guess that means you haven't used cvs either. I've actually never used it myself, I didn't care about version management for a long time. When I finally did subversion was already available.
01:47rritochrhg135: I intend to eventually learn mercurial, so far I've only downloaded mercurial projects, haven't created or written to any.
01:47rhg135More correctly I am old enough just I didn't start programming till '09
01:48rhg135And in python :O
01:48rhg135It makes me sad and ashamed
01:53rritochIs this syntax valid or am I going to break the stack? (defn wait-until [f] (loop [r (f)] (or r (recur (f))))
01:55rhg135It should work
01:56rhg135If or is an if in desguise
02:00justin_smithrritoch: that could be expressed as (while (not (f)))
02:01rritochjustin_smith: Did you see my earlier message about reg_assoc?
02:02cloudsajado we discuss liberator here ?
02:02justin_smithsure
02:02rritochjustin_smith: As for this wait-until, the single arity version will probably never be used, it is a system-killer that will consume all CPU resources without mercy.
02:02justin_smithrritoch: I just took a quick look
02:03justin_smithrritoch: simple enough to shove a (Thread/sleep n) into the body
02:04cloudsajaCan I paste code here, or should I use pastebin ?
02:04justin_smithpastebin please, refheap is good for clojure code
02:04rhg135Refheap
02:04rhg135It's nice
02:08cloudsajaOkay... https://www.refheap.com/95026 <-- why the "ctx" wont have "param" information in side the request ? as in (get-in ctx [:request :params "word"]) always nill... Im sure in curl I put parameters in the GET.
02:09rhg135I enjoy code like a lot
02:09justin_smithcloudsaja: does ctx have :request in it?
02:09cloudsajaTo test it, I did >> curl -v -L -G -d "word=tiger&a=b" GET http://localhost:8080/secret
02:10cloudsajajustin_smith: yes it did... but the param is empty
02:11cloudsajaseems like wrap-params is not working
02:11justin_smithcan you paste the output of (get-in ctx [:request]), or better yet (clojure.pprint/pprint ctx)
02:11cloudsajaOk
02:11cloudsajaIt was
02:11cloudsaja{:ssl-client-cert nil, :remote-addr "127.0.0.1", :params {}, :route-params {}, :headers {"user-agent" "curl/7.35.0", "accept" "*/*", "host" "localhost:8080"}, :server-port 8080, :content-length nil, :content-type nil, :character-encoding nil, :uri "/secret", :server-name "localhost", :query-string "word=tiger", :body #<HttpInput org.eclipse.jetty.server.HttpInput@6d19ddb8>, :scheme :http, :request-method :get}
02:12justin_smithwell, -d sets the body
02:12cloudsajathere are :query-string though
02:12justin_smithnot the request parameters
02:12justin_smithtry (slurp (:body ctx))
02:13justin_smithand you really shouldn't be setting the request body for a GET
02:14cloudsajaThere are nothing on the body... its on the query string.
02:14cloudsaja> GET /secret?word=tiger&a=b HTTP/1.1
02:14cloudsajaThis is what curl did
02:14justin_smithOh, ok
02:14justin_smithnow I see that
02:15justin_smithsorry, I had just never seen curl used that way
02:15cloudsajanp
02:16rhg135Gn .+
02:17justin_smithcloudsaja: yeah, in my experience wrap-params would have caught that query string and made a params map from it - was the above map from ctx or (:request ctx) ?
02:17cloudsaja(:request ctx)
02:17justin_smithcheck ctx itself
02:17justin_smithbecause in my experience wrap-params puts stuff directly in the top level
02:18justin_smithnot under a :request key
02:18cloudsajaoh... ok. let me see
02:28cloudsajajustin_smith: In the ctx, there are tons of information, but they are all looks clueless, something like >> :resource {:existed? #<core$constantly$fn__4085 clojure.core$constantly$fn__4085@71baab36>, :conflict? #<core$constantly$fn__4085 clojure.core$constantly$fn__4085@163ea08f>, :handle-see-other .... and a lot lot more.
02:30justin_smitha trick I use for that is (defonce debug (atom nil)) and inside the handler (reset! debug ctx) then in the repl you can do things like (-> ctx keys) (->ctx :some-key type) etc. etc. etc.
02:31cloudsajaIn so new in clojure, dont know how to do that :(
02:31justin_smitherr, I mean (-> @debug keys) etc.
02:31justin_smithare you starting the server from a repl?
02:31cloudsajayes i did
02:32justin_smithOK, then I just showed you all the code you woudl need. (defonce debut (atom nil)) would go at the top level of your code, (reset! debug ctx) would go inside your handler function, then you would do (-> @debug keys) etc. from the repl
02:33cloudsajaok
02:37cloudsajaOkay... I got it
02:38cloudsajaguestbook.core=> (-> @debug :request)
02:38cloudsaja{:ssl-client-cert nil, :remote-addr "127.0.0.1", :params {}, :route-params {}, :headers {"user-agent" "curl/7.35.0", "accept" "*/*", "host" "localhost:8080"}, :server-port 8080, :content-length nil, :content-type nil, :character-encoding nil, :uri "/secret", :server-name "localhost", :query-string "word=tiger", :body #<HttpInput org.eclipse.jetty.server.HttpInput@239e06d7>, :scheme :http, :request-method :get}
02:38justin_smithright
02:38justin_smithso you can check the keys via (-> @debug keys) and get a key via (-> @debug :params) or whatever
02:39cloudsajaI can see.... (-> @debug :request :query-string) ... shows "word=tiger"
02:39clojurebotGabh mo leithscéal?
02:40justin_smithbut no :params key on @debug itself?
02:40cloudsajaSo inside the query-tring where it goes... but not in the params...
02:40justin_smithwhat is the output of (keys @debug)
02:40cloudsajaNope... (-> @debug :request :params) .. shows {}
02:40cloudsajaempty map
02:40justin_smithno, I did not say :request
02:41justin_smithjust @debug
02:41cloudsaja(keys @debug) .. shows (:request :resource :representation)
02:41justin_smithhmm
02:41justin_smithOK
02:42justin_smithI don't know what liberator is doing here, when I have used wrap-params, it attached :params to the top level, not under a :request key
02:42cloudsajaOoww
02:43justin_smithperhaps you need to use wrap-params differently to make it work with liberator, because it may not be seeing the data it expects (since it is hidden under :request)
02:43cloudsajahmm... been craking my head on this for 3 days. no clues from google what so ever... :( maybe I should parse the :query-string then :(
02:44justin_smithwell, wrap-params definitely expects the stuff you are getting under the :request key to be at the top level
02:44cloudsajaI see..
02:45cloudsajaMaybe my configuration is wrong...
02:46cloudsajajustin_smith : Thanks alot anyway. you teach me how to debug ;)
02:48justin_smithtry changing (get-in ctx [:request :params "word"]) to (get-in ((wrap-params :request) ctx) [:request :params :word]) (it likes to keywordize btw)
02:49justin_smithoh wait, I was using wrap-keyword params
02:49justin_smithso leave it ias [:request :params "word"]
02:49nXqdadsf
02:50justin_smiththis is definitely why wrap-params is not working - its input is not shaped the way it expects, wrap-params does not look under a :request key
02:51cloudsajaUghhh... I do not understand how it works, just a user though... need more and more coding hours... :D
02:51cloudsajaand trouble shooting... and ask questions.
02:52justin_smithonce again - I literally gave you code you can try
02:53cloudsajaworking on it.
02:54justin_smithoh wait, it should be (get-in ((wrap-params :request) ctx) [:params "word"])
02:55justin_smithbut you can do that directly in the repl with (get-in ((wrap-params :request) @debug) [:params "word"]) without restarting the server just to experiment
02:56cloudsajait was nill
02:56cloudsajanil
02:56justin_smithOK
02:57justin_smithwhat about (get-in ((wrap-params :request) @debug) [:params])
02:58cloudsaja((wrap-params :request) @debug) have {:ssl-client-cert nil, :remote-addr "127.0.0.1", :params {}, :route-params {}, :headers {"user-agent" "curl/7.35.0", "accept" "*/*", "host" "localhost:8080"}, :server-port 8080, :content-length nil, :content-type nil, :character-encoding nil, :uri "/secret", :server-name "localhost", :query-string "word=tiger", :body #<HttpInput org.eclipse.jetty.server.HttpInput@60e1f0c0>, :scheme :http
02:59justin_smithwell, that's a start I guess - at least the :params key is there as expected now
03:01cloudsajaBut isn't it the purpose of wrap-params to put things into the :params ?
03:01justin_smithyes, but I think we are hacking this wrong - but we are close
03:02justin_smith((wrap-params identity) (:request @debug))
03:02justin_smiththat should be it?
03:03cloudsajaWoww... it works
03:03cloudsaja{:ssl-client-cert nil, :remote-addr "127.0.0.1", :params {"word" "tiger"}, :route-params {}, :headers {"user-agent" "curl/7.35.0", "accept" "*/*", "host" "localhost:8080"}, :server-port 8080, :content-length nil, :form-params {}, :query-params {"word" "tiger"}, :content-type nil, :character-encoding nil, :uri "/secret", :server-name "localhost", :query-string "word=tiger", :body #<HttpInput org.eclipse.jetty.server.HttpInput@60e
03:03justin_smiththe next step would be to either make a shim so wrap-params would work in the handler definition, or one to use it inside the handler like that
03:03cloudsajaWhat the f have you done ?? it works !!. Explain man.. please
03:04rritochDoes anyone know how to do a parital and? I have tried (partial and 1 2) and (partial apply and 1 2) and theyr'e both throwing macro errors
03:04justin_smithwrap-params takes a handler as an argument, and returns a function that takes a request, adds some data and runs the handler on that modified data
03:04rritochparital=partial
03:05andyfpartial only works on functions, not macros
03:06justin_smithrritoch: #(reduce (fn [_ b] (if-not b (reduced b) b)) %&)
03:06cloudsajaI see.
03:07justin_smithso (wrap-params identity) says "take a request, update the :params key etc, then run identity on it
03:07justin_smithwhich of course just returns it unchanged
03:08justin_smithI missed a " above, sorry
03:09rritochjustin_smith: Thanks. That is exactly what I need. Even if it is far more complex than I hoped.
03:09cloudsajajustin_smith : could I just merge it to the ctx it self ?
03:10justin_smith(or b (reduced b)) would work too, and is a little simpler
03:10justin_smithcloudsaja: yeah, that is what I meant by a shim
03:11cloudsajajustin_smith : thanks a lot man.
03:11justin_smithsomething like (fn [handler] (fn [ctx] (update-in ctx [:request] (wrap-params identity))))
03:11justin_smithand you could use that function in the place of where you have wrap-params in your original code
03:11cloudsajaok
03:11justin_smith(not as a literal, due to how -> works, though)
03:13justin_smithoh wait - it would actually be (defn wrap-in-request [handler] (fn [ctx] (handler (update-in ctx [:request] (wrap-params identity))))) and then use wrap-in-request where you currently have wrap-params
03:13justin_smithor maybe liberator already has some way to adapt normal ring middlewares to use with liberator - it would seem like that would be a common enough thing to want to do --- or maybe they have some fancier way of doing what we do with middleware
04:48m1dnight_guys, what is the name of "(-> ..)"?
04:48m1dnight_For google-purposes
04:48sverim1dnight_: thread macro
04:48sverior threading macro
04:49m1dnight_oh that's a cool one :) thanks guys
04:49m1dnight_incs for everyone!
04:51rritochm1dnight_: Try http://symbolhound.com
04:52m1dnight_oh sweet :)
04:52m1dnight_,(inc rritoch)
04:52clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: rritoch in this context, compiling:(NO_SOURCE_PATH:0:0)>
04:52m1dnight_(inc rritoch)
04:52lazybot⇒ 2
04:52m1dnight_there we go!
04:53rritochm1dnight_: ty
05:00Kneivarritoch: great link, thanks =)
05:12m1dnight_http://stackoverflow.com/a/1879961/1225786
05:12H4nsdoes anyone know the honeysql syntax for calling arbitrary (postgre)sql functions like coalesce()? The manual only speaks about one argument sql functions which have a gross syntax (i.e. :%max.id)
05:12m1dnight_Could anyone tell me why the author would put the result of the thunk in a vector?
05:12m1dnight_(I also asked in a comment, fwiw)
05:31rritochh4ns: I haven't used it but per the documentation you can create your own function handlers https://github.com/jkk/honeysql#extensibility but it's not clear if that will work outside where, such as aggregate functions.
05:32H4nsrritoch: thanks - we've got numerous special purpose functions in the database that i'd like to call, so i'll probably just use sql/raw and be done with it.
06:39joelkuiperSo say I want to write a browser extension that communicates with some external app, would it be advisable to write that external system in Clojure/Java/anything on the JVM?
06:40joelkuiperI'm kinda torn by this. I would like to create some cross-platform thingy that integrates well with Firefox/Chrome ... but doing it in something native seems like a hassle, but the JVM has really gotten a bad rep in doing anything consumer-side
06:42joelkuiperSo I'm thinking "whatever, I'll just do it in the lang I'm most comfortable in, namely Java/Clojure and screw opinion" (which will also limit the option to advertise in app stores) ... or I can write the core functionality in something like C and then go through the motions of writing a GTK/Cocoa/Windows shell
06:42joelkuipermeh. choices.
06:44joelkuiperYou know, I really loved the promise of the Java/JVM. Shame it didn't live up to its full potential
06:51clgvjoelkuiper: "bad rep" is really unspecific. what are your requirements? where do you suspect problems to fulfill your requirements?
06:52joelkuiperclgv: Well I'd like this system to be a deamon which responds to calls from the browser. This would mean a running JVM instance for all users. I fear (although unsubstansiated, mostly) that it will that be a dealbreaker: needing to install a JVM and having a process running
06:54clgvjoelkuiper: well a client side jvm for a browser plugin is not that lightweight as usual browser plugins
06:55clgvjoelkuiper: firefox plugins can be implemented via javascript afair, so you could use clojurescript. a dev setup with fast feedback on changes could be a challenge though
06:56joelkuiperclgv: true, but its not a usual plugin. It will require access to disk and run something like Lucene, for example. By doing the bulk of the work outside the browser the hope is that I don't have to deal with quirks between Chrome/Firefox/Safari/etc
06:58clgvjoelkuiper: well, then the question is: "Is the plugin functionality worth the installation effort?"
06:58joelkuiperclgv: In essence I want a single button that downloads the entire webpage, indexes it, does some named-entity recognition and writes the site as an archive to disk or cloud store. It's bookmarks on steroids, with no dep on something like Pocket (I really want this to be an offline thing)
06:59clgvor "Can you ease the installation effort via an automatic installer?"
07:00dysfunif i add a new dependency to my project.clj, is there a way to make a lein repl put the new lib in its classpath that avoids restarting?
07:00dysfun(such that i can just do lein deps on another terminal tab and then switch back and issue a command in the repl)
07:00clgvdysfun: no.
07:01clgvdysfun: though there is a lib to load the dependency on the repl. but that is not connected to the project.clj
07:01dysfunso i'm right in thinking i should hit ^D, <up>, <enter> then?
07:01joelkuiperclgv: good points, I'm likely overthinking this. AeroFS got away with it for a while. And it's mostly to scratch my own itch anyway. I'll start off in Clojure/Java as a proof of concept
07:02clgvdysfun: you could use pomegranate
07:02dysfunhrm, that's an idea
07:17dysfunis the cost of derefing an atom insignificant?
07:17dysfunlet's say the core runloop of my application relied on it
07:18dysfunshould i be at all concerned?
07:19clgv$source clojure.lang.Atom
07:19lazybotSource not found.
07:20dysfunhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Atom.java
07:20dysfunoh, it's java.util.concurrent.atomic.AtomicReference
07:22clgvdysfun: should be unproblematic since there are no retries involved as for `swap!`
07:22dysfunthat's what i thought. it's probably something like "one more pointer hop" (oh noes!)
07:22clgvyeah, similar to a getter method
07:22clojurebotTitim gan éirí ort.
07:23clgvgetter method
07:23clgvsimilar
07:23clgvstupid bot ;)
07:23dysfunsimilar too foo
07:23dysfunsimilar to foo
07:23dysfun,similar to foo
07:23clgvyeah
07:23clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: similar in this context, compiling:(NO_SOURCE_PATH:0:0)>
07:23clgvmust have been random ;)
07:23dysfunmebbe :)
07:23clgvyeah, similar to a getter method
07:23clgvyep, random
07:25dysfunokay, what if it were a function that were held in an atom? i presume there's some clever optimisations that happen down the line in hotspot that this might prevent
07:27dysfun(there is of course nothing so fun as second guessing what a JIT compiler will do)
07:35clgvdysfun: clojure functions called through clojure variables already prevent some hotspot optimizations
07:36dysfunclgv: *nod*
07:36dysfunthe price you pay for dynamism
07:38Bronsaclgv: I remember puredanger saying that hotspot actually can inline away Var's getRawRoot
07:38clgvBronsa: but then we wouldnt need invoke-dynamic at all...
07:39clgvBronsa: I didn't try it yet.
07:52CookedGryphonhow do i reduce over a collection with a transducer transform now?
07:52CookedGryphonDo I use (reduce f (eduction xform coll))?
07:53CookedGryphonor is transduce the way to do that directly?
08:37siefcahi guys
08:38siefcai need a definition
08:38siefcacould we tell that function arguments (parameters) are lexical bindings, or is this term reserved for let forms?
08:39djcoinWhat does the form {:keys [k1 k2] :or {k1 "foo" k2 "bar" }} get expanded too ?
08:41clgvsiefca: I wouldn't object
08:42siefcaclgv: thx
08:42whodidthiscan you feed instaparse result thingie back to the parser rule to generate some string
08:43stuartsierrasiefca: Function parameters have lexical scope, so that would make sense.
08:44piranhadjcoin: (let [k1 (:k1 arg "foo") k2 (:k2 arg "bar")] ...)
08:44djcoinah yeah, simple, thanks piranha
08:47siefcastuartsierra: thx
09:22clgv,(macroexpand-1 '(let [{:keys [k1 k2] :or {k1 "foo" k2 "bar" }} m] [k1 k2]))
09:22clojurebot(let* [map__27 m map__27 (if (clojure.core/seq? map__27) (clojure.lang.PersistentHashMap/create (clojure.core/seq map__27)) map__27) k2 ...] [k1 k2])
09:22clgvdjcoin: ^^
09:22clgv&(macroexpand-1 '(let [{:keys [k1 k2] :or {k1 "foo" k2 "bar" }} m] [k1 k2]))
09:22lazybot⇒ (let* [map__15998 m map__15998 (if (clojure.core/seq? map__15998) (clojure.lang.PersistentHashMap/create (clojure.core/seq map__15998)) map__15998) k2 (clojure.core/get map__15998 :k2 "bar") k1 (clojure.core/get map__15998 :k1 "foo")] [k1 k2])
09:24dnolen_reiddraper: heh, even the half finished test.check port is already finding ClojureScript bugs
09:30chouserAnyone know how to make transit emit something of my choosing instead of blowing up when it tries to write something that doesn't have a handler installed?
09:33stuartsierrachouser: I don't know specifically, but I expect there's a way to do it.
09:33chouserFressian uses a protocol for handler lookup, so you can do arbitrary resolution. Transit uses java.util.Map, apparently.
09:34stuartsierraMaybe add a write handler for java.lang.Object?
09:35chouserThat approach appears to be specifically excluded.
09:35stuartsierrahuh
09:35stuartsierraMaybe you can't. I know there is a default reader for unknown tags, but there may not be a default writer.
09:36chouserI'll keep looking. We kinda need it.
09:37dnolen_chouser: this use case isn't really supported. Probably should bring it up on the transit-format list
09:37dnolen_chouser: that said, not sure it could work, if there's isn't a handler how do you know how to encode it?
09:37dnolen_s/not sure it could work/not sure how it could work
09:38dnolen_decoding is simpler because you already have representation that you can preserve
09:38chouserI just want to write out something indicating failure at that point, rather than having the entire transit object fail to be written
09:39dnolen_chouser: hrm, Unwriteable tagged type? could be interesting
09:39chouseryes, something to that effect.
09:40chouserThere are clearly cases where a failed attempt to write should be very loud and halt things. But other times, writing *something* is better than blowing up.
09:40stuartsierraLooks like you could modify WriterFactory https://github.com/cognitect/transit-java/blob/5785a91c54174e02f50e48780886a55829959314/src/main/java/com/cognitect/transit/impl/WriterFactory.java#L62 to change the handler for Object.
09:42chouserHm, also: https://github.com/cognitect/transit-java/blob/5785a91c54174e02f50e48780886a55829959314/src/main/java/com/cognitect/transit/impl/AbstractEmitter.java#L20
09:42chouserbase != Object.class
09:44stuartsierraIt's an interesting issue: I've often wanted a printer/reader that prints "unprintable" things as #tag + toString, for things like logging.
09:44chouserlogging. exactly.
09:45mgaareTerrible idea to use clojure.lang.MapEntry directly?
09:45chouserand alternatives like prewalking the log entry are icky
09:45stuartsierraand slow
09:45llasramstuartsierra, chouser: https://github.com/llasram/letterpress
09:45clgvmgaare: depends on what exactly this means
09:46opqdonutstuartsierra: doesn't e.g. pr-str do that?
09:46opqdonut,(pr-str (Object.))
09:46clojurebot"#<Object java.lang.Object@37d586>"
09:46opqdonutor am I missing some context
09:46stuartsierraopqdonut: yes, but you can't `read` that back in without an error.
09:46opqdonutstuartsierra: so should read return something like a special UnReadable object?
09:47mgaareclgv: writing a helper function for mapping over a map, and would prefer for it to return MapEntries rather than vectors or whatever
09:47stuartsierraopqdonut: Not in the general case, no. But it would be useful in some situations, such as analyzing log messages.
09:48clgvmgaare: huh why?
09:49clgv,(reduce (fn [_, x] (reduced (class x))) nil {:a 10})
09:49clojurebotclojure.lang.MapEntry
09:49clgvmgaare: with `reduce` you already have access to the map entrys.
09:50clgvmgaare: you are aware of reduce-kv which is much better suited for maps?
09:50mgaareclgv: no, haven't run into that before. will check it out
09:50dnolen_chouser: I'd bring it up on the transit-format list, you'd probably want the same support everywhere
09:51mgaareclgv: I think that's just what I'm looking for, thanks
09:51chouserdnolen_: where else are you thinking, besides transit-java's writer?
09:54dnolen_chouser: well I guess it just depends on your goal
09:54dnolen_chouser: if you just want to produce an Unwriteable tagged value in Java and you don't care that your JS/CLJS client can't do that than nothing more to do.
10:07dysfunwhat do i use if i actually want an honest-to-$deity lock? i'm intending to hold the lock for hours at a time.
10:08stuartsierradysfun: Hours at a time? ZooKeeper.
10:08dysfunfor what i have in mind, this seems a bit overkill
10:08craigglenniedysfun: Or if you have MySQL and a reliable connection you can get get_lock and release_lock. But stuartsierra’s suggestion is probably better
10:09dysfunif i were going to do that, i'd probably use redis
10:09stuartsierradysfun: There's everything in java.util.concurrent.locks, of course, plus plain old `locking` which is the same as Java's `sychronized`
10:10dysfunyeah, i expect java.util.concurrent has the answer
10:10dysfunthanks
10:12craigglennieIs there an equivalent to Python’s *args? I have a function that takes [x] or [x & rest] and then wants to recur with rest… but that call doesn’t get destructured into x & rest because, I think, rest is passed as a list, and not expanded (sorry if I have the wrong terminology). There’s a paste here: https://www.refheap.com/95046
10:13stuartsierracraigglennie: 2 things. `recur` doesn't cross arities.
10:13stuartsierraBut what you're looking for is `apply`
10:14andyfrecur doesn?t cross arities ? don?t recall running across that before.
10:14craigglenniestuartsierra: `apply` did the trick - thanks
10:15stuartsierra,(defn foo ([x] (recur x 1)) ([x y] (prn x y)))
10:15clojurebot#<CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 1 args, got: 2, compiling:(NO_SOURCE_PATH:0:0)>
10:16stuartsierraEach arity of the function is a separate loop/recur point.
10:17andyfDefinitely sounds like a restriction that makes implementation possible and/or more straightforward. I guess I don't use multi-arity functions often enough to have hit that before.
10:17craigglenniestuartsierra: Would my function be better / more idiomatic if I’d used loop and recur?
10:18andyfcraigglennie: (prn (last x)) perhaps?
10:18stuartsierracraigglennie: I'm not sure what the function in your paste is trying to do, so I can't say.
10:19andyfcraigglennie: But you will definitely get a stackoverflow exception as written for a sequence arg with a few thousand items in it.
10:19andyfif you do not use recur
10:19craigglennieandyf: Ahh, I see
10:20craigglennieSo, generally speaking, it’s better to use recur in a recursive function to avoid overflowing the stack?
10:20craigglennieUnless you know you’ll only be using a short sequence?
10:22reiddraperdnolen_: ha, that's awesome
10:22andyfcraigglennie: There are definitely reasonable use cases for non-recur recursion, e.g. walking tree-structured data like nested maps, data from XML sources, etc., or balanced binary tree data structures. Those are often cases where recur won't work, and the recursion depth is typically much more limited.
10:23dysfunthe other alternative is lazy sequences, if you can rearrange your computation into something that fits into the clojure sequence functions
10:23andyfBut for straight sequences, recur, or using sequence processing functions, are often preferred.
10:25djcoinclgv: sorry I was afk. Thanks a lot for providing a macroexpand explanation of :keys :or
10:45noncomis ther any library that allows templating of clojure data structs?
10:46noncomfor example, if i have (def ds {:key :tag-zzz}) and if i (render-template ds {:tag-zzz "this value be here"}) and get {:key "this value be here"} ?
10:46noncomis there anything close to that?
10:48hellofunknoncom that function render-template would be simple to write, you need a full library for that, or is there more you need?
10:50noncomhellofunk: yeah, maybe i could write a couple of functions for that.. but i thought maybe there is already something..
10:50noncomand yes, templates may be somewhat more complex
10:50noncombut actually these are just json templates
10:51stuartsierranoncom: syntax-quote is often sufficient for simple templates
10:51noncomin the worst case i could go with cheshire+clostaches or cheshire+selmer..
10:51dnolen_reiddraper: yeah almost done, I'll put a patch in JIRA probably later today
10:51reiddraperdnolen_: that was quick :)
10:51noncomstuartsierra: so, i just put 'a-symbol-tag there and replace it ?
10:51noncomdoes edn support quoted symbols?
10:52dnolen_reiddraper: wasn't so hard now that cljs.test is a thing - most of my changes were JVM / perf related
10:52reiddraperright
10:52stuartsierranoncom: no, as in (defn my-template [x y] `[a b c ~x ~@y])
10:52dnolen_reiddraper: partial and comp are kinda slow in CLJS, just getting ridding of that and using function literals was like 5X perf boost
10:52noncomstuartsierra: whoa, got it..
10:53noncombut will edn support that?
10:53reiddraperdnolen_: ha, nice
10:53noncom,(read-string "`{:a ~x}")
10:53clojurebot(clojure.core/apply clojure.core/hash-map (clojure.core/seq (clojure.core/concat (clojure.core/list :a) (clojure.core/list x))))
10:53noncomumm...
10:53dnolen_reiddraper: I still think keyword generator is crazy slow - at some point might be worth thinking how to make all the functional stuff faster.
10:53noncomstuartsierra: ^^
10:54stuartsierranoncom: no, I guess I don't understand the questino
10:54zB0hsanyone have good experience with or examples of porting a javascript react app into reagent? i want to port in pieces not at all at once.
10:54reiddraperdnolen_: yeah it is really slow, don't think it's in master yet but the keyword/string roundtrip test is super slow when it creates 200 character keywords, so i'm gonna just limit that to 25 or something
10:54noncomstuartsierra: i want to have some way to specify a template for json and store it in edn format. then work with it through cheshire
10:55noncomsure i may store the json in json (not edn) string and just use selmer
10:55stuartsierranoncom: OK, then you'll have to invent your own template format and implement it.
10:55noncomi see :)
10:58noncomstuartsierra: look:
10:58noncom,(def x 1)
10:58clojurebot#'sandbox/x
10:58noncom,(let [x 3] (eval (read-string "`{:a ~x}")))
10:59clojurebot{:a 1}
10:59noncomhow?
10:59clojurebotwith style and grace
10:59noncomwhy x is still 1?
10:59justin_smithnoncom: the eval env is not effected by local bindings
11:00noncomjustin_smith: for what sake?
11:04clgv,(let [x 3] (eval `{:a ~x}))
11:04clojurebot{:a 3}
11:05hellofunkthat's quite interesting. read-string is changing the binding environment somehow?
11:05clgvhellofunk: not really
11:06hellofunkclgv: why is x honoring the local binding without read-string, but not with it?
11:07clgv,(pr (read-string "`{:a ~x}"))
11:07clojurebot(clojure.core/apply clojure.core/hash-map (clojure.core/seq (clojure.core/concat (clojure.core/list :a) (clojure.core/list x))))
11:08hellofunk,(let [x 3] (clojure.core/apply clojure.core/hash-map (clojure.core/seq (clojure.core/concat (clojure.core/list :a) (clojure.core/list x)))))
11:08clojurebot{:a 3}
11:08clgvhellofunk: my example works since the expression is constructed outside of `eval` and passed to it
11:08clgvhellofunk: the previous example constructs the expression via `read-string` inside of `eval`
11:09hellofunkinteresting
11:09Bronsa,(let [x 3] `{:a ~x}) ;; maybe this is clearer
11:09clojurebot{:a 3}
11:10clgv,(let [x 3] (read-string "`{:a ~x}"))
11:11clojurebot(clojure.core/apply clojure.core/hash-map (clojure.core/seq (clojure.core/concat (clojure.core/list :a) (clojure.core/list x))))
11:11clgvand that one ^^
11:12clgv,(let [x 3] (eval `(let [~'x ~x] ~(read-string "`{:a ~x}")))
11:12clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
11:12clgv,(let [x 3] (eval `(let [~'x ~x] ~(read-string "`{:a ~x}"))))
11:12clojurebot{:a 3}
11:12clgvwell, that's getting confusing, I guess
11:14noncomanyone used selmer ?
11:14noncomwhy (selmer/render "{{wow}}" {:wow "ha"}) gives IllegalArgumentException Don't know how to create ISeq from: java.lang.Boolean clojure.lang.RT.seqFrom (RT.java:505) ?
11:15noncom*selmer/render -> selmer.parser/render
11:17noncomeven the example form the manual gives the same error: (selmer/render "Hello {{name}}!" {:name "Yogthos"})
11:18noncompassing in a string without a {{}} inclusion, works - it just returns the string back
11:19clgvnoncom: works like a charm via: lein try selmer "0.7.7"
11:19noncomyes, selmer is 0.7.7
11:19yogthoscan't reproduce it here either
11:19clgvnoncom: (require 'selmer.parser/render) (selmer.parser/render "{{wow}}" {:wow "ha"}) ;=> "ha"
11:20clgvnoncom: better restart your repl
11:20noncomyeah, well.. idk, maybe restart repl will work..
11:21clgvnoncom: if that does not work check "lein deps :tree" to see if there is a conflict with respect to Selmer
11:21noncomyes, it did work
11:21noncomweeeeeird!
11:21clgvweird errors always demand a repl restart after an initial check ;)
11:26justin_smithm1dnight_: regarding your question about [(thunk)] upthread: that way even if (thunk) returns nil, it is [nil] which is truthy, so the if-let considers it a success
11:28hellofunkis this a good way to drain all the values that are waiting on a channel? https://gist.github.com/hellofunk/b32c8e0d267ada0cc396
11:29justin_smithdysfun: clgv: alembic has (alembic/load-project) which adds new deps from project.clj into your running repl
11:31clgvjustin_smith: ah ok, I vaguely remembered there was something announced some time ago
11:31vivekramaswamy(defn symetrize-body-parts-reduce [body-parts]
11:31vivekramaswamy (reduce (fn [final-parts part]
11:31vivekramaswamy [let [final-parts (conj final-parts part)]
11:31vivekramaswamy (if (needs-matching-parts part)
11:31vivekramaswamy (conj final-parts part)
11:31vivekramaswamy final-parts)]))
11:31vivekramaswamy [] [body-parts]
11:31vivekramaswamy)
11:31clgv~gist
11:31clojurebothttp://gist.github.com/
11:31clgv~paste
11:31clojurebotpaste is https://refheap.com/
11:32vivekramaswamysorry about that, am new to irc
11:32vivekramaswamyhow does one paste code here?
11:32clgvvivekramaswamy: use one of the above two sites
11:32justin_smithdon't - put it in an external site
11:33justin_smithvivekramaswamy: also, that let is going to be an error, [let ...] is not valid
11:33justin_smith(let ...)
11:34justin_smith[] is for building data, () is for invoking things
11:34vivekramaswamythat is correct, and that is my question, in paraedit how do I replace the whole [let] with (let)
11:34clgvvivekramaswamy: heavily depends on your editor ;)
11:35vivekramaswamyI am using emacs
11:35vivekramaswamy+ paraedit
11:35justin_smithvivekramaswamy: there is no single paredit command that replaces one kind of delimiter with another
11:35vivekramaswamyso basically I am left with deleting that whole stuff or offing paraedit mode
11:36justin_smithwell, you can barf it all out, and slurp it into a new delimiter
11:36Bronsavivekramaswamy: no, just surround the expression in () and remove the [] delimiters
11:36justin_smithor the opposite order, sure
11:36BronsaM-( in front of the [, enter the [ and M-s
11:37Bronsajustin_smith: doing it in the opposite order has the advantages that it will barf the whole expression rather than only the let
11:37clgv"cut and paste" should work in paredit as well right?
11:37justin_smithyeah, it does
11:37justin_smithand cut and paste can "break" paredit easily
11:38clgvjustin_smith: would have been the quickfix for the previous question ;)
11:38vivekramaswamyok let me try, thanks for the quick reply
11:45dysfunjustin_smith: sweet. thanks!
12:25ajmccluskeyIs it possible to use tools.trace to trace a namespace in a library my project is dependent on? I keep getting ClassNotFound.
12:25ajmccluskeyCan require and use the library fine.
12:26justin_smithajmccluskey: "class not found" makes me think you are doing some.ns instead of 'some.ns
12:27justin_smithand yes, you can trace any namespace, regardless of where it came from
12:27ajmccluskeyjustin_smith: d'oh, you're right. Thanks. Was blindly following example in docs that didn't have the quote.
13:14batomsanyone here have any experience with clj-jwt
13:14batomsi'm trying to verify some jwt tokens generated by auth0 but i can't get it to work
13:15batomsi can create a working version in python using the hmac package but i can't get it workin in clojre
13:23OscarZhi.. whats #'app notation doing ?
13:23OscarZ#' part
13:24justin_smith,(macroexpand '#'foo)
13:24clojurebot(var foo)
13:24justin_smithit gets the var
13:24justin_smiththat way, when you redefine app (maybe by reloading the file after an edit) the server which took #'app as an argument uses the new value
13:24OscarZoh.. i thought app already is var.. its defined with defn
13:25justin_smithright
13:25justin_smithbut when you do (run-jetty app) or whatever, then run-jetty sees the fn
13:25justin_smithit never sees the var, which is implicitly dereferenced
13:25justin_smithso it doesn't see your update, because re-running the defn form does not mutate the fn, only the var
13:26OscarZoh.. so i dont have to call run-jetty again.. the new value somehow gets injected in there?
13:26trissso can protocols only be applied to functions with a set number of args?
13:26justin_smith#'app is dereferenced again every time it is used
13:27arrdemtriss: it is possible to construct variable arity protocols, but core does not support doing so.
13:27arrdemI think ztellman has a library that enables this.
13:27justin_smithtriss: every implementation of a protocol function must have the same number of args as the original definition
13:27trissso there's no & args in protocols?
13:27noonianif you define foo with def or defn it creates an instance of Var that holds the value you defined, when you reference your var as foo it looks up the var and then return the value it was holding, not the var itself
13:28arrdemtriss: correct
13:28trisscheers chaps....
13:28trissis it something that should be avoided? does the facility exist in a library somewhere?
13:29arrdemtriss: a common design pattern is to have a normal fn that wraps a protocol method. Most of the time & args are used for an implicit reduction anyway so that works out.
13:29arrdemthe ClojureScript implementation makes heavy use of this pattern as well although mainly for decoupling's sake.
13:30OscarZi still dont understand.. im trying to play with http kit and its used like this: (reset! server (run-server #'app {:port 8080})))
13:30justin_smithOK
13:30justin_smiththat tells it to use #'app as it's handling function
13:30justin_smith,(#'+ 2 2)
13:30clojurebot4
13:30OscarZif app is function, cant it just be passed like "app" in there
13:31justin_smithno, because calling defn again on the same name does not change the function previously created
13:31justin_smithit only changes the var attached to that name
13:31OscarZoh.. ok..
13:31justin_smithso http-kit does not see the change, because the function does not change (functions cannot change, they are immutible)
13:32OscarZi better read up on vars
13:32hellofunkif i'm not mistaken, only functions can be referred to as (var ..) in their place in expressions. (#'+ 5 6) works but not (let [x 5] (+ #'x 6))
13:33justin_smithhellofunk: there are two problems there
13:33justin_smithbindings in let are not vars
13:33hellofunkwell, same issue if def x instead of let x
13:33OscarZbut def does override the var doesnt it?
13:33justin_smithand vars are not implicitly dereferences, vars just do lookup and then invoke when invoked
13:34SagiCZ1when running in REPL exceptions are sometimes (not always) swallowed completely.. any reason why this might happen? could it be Cursive at fault?
13:34justin_smithOscarZ: yes, it changes the var, which is why you pass the var instead of the function
13:34hiredmanlet doesn't make vars
13:34hellofunkjustin_smith: so since functions are always invoked, that's why they work as vars instead, but non-function vars are not invoked, they are only looked-up, is taht what you are saying?
13:35hiredmanvars are things that exist globally, named by a namespace qualified symbol
13:35hiredmanlet creates a local binding of a name to a value
13:36OscarZhmm.. can you suggested some good reading that would explain how it works?
13:38justin_smith&(do (defn a [] 1) (defn b [f] (fn [] (f))) (def c (b a)) (def d (b #'a)) [[(c) (d)] (do (defn a [] 2) :-) [(c) (d)]]) ;; OscarZ - an example
13:38lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
13:38justin_smith,(do (defn a [] 1) (defn b [f] (fn [] (f))) (def c (b a)) (def d (b #'a)) [[(c) (d)] (do (defn a [] 2) :-) [(c) (d)]]) ;; OscarZ - an example
13:38clojurebot[[1 1] :- [1 2]]
13:39llasramOscarZ: If you know Java, check out the Clojure source for the Namespace and Var classes
13:39llasramShould make much clear
13:39justin_smithOscarZ: notice that after I redefine a, d sees the new value, but c does not
13:39OscarZi thought it was something like var func = function() {...} and you could redefine whatever function func points at.. as defn uses def underneath and def can override functions
13:39justin_smithOscarZ: the var is mutable, the function is not
13:39justin_smithjavascript lacks this function / var distinction
13:40SagiCZ1anyone experienced exceptions being swallowed? they happen in a different namespace but still?
13:40SagiCZ1,(zero? (atom 0))
13:40justin_smithSagiCZ1: in my experience, bad code is over-aggressive about what exceptions it catches
13:40clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Atom cannot be cast to java.lang.Number>
13:41llasramOscarZ: I think what you're missing is that a Var is itself a reified thing, an object, a Clojure reference type like an atom or a ref
13:41SagiCZ1this exception is not thrown
13:41justin_smithSagiCZ1: somebody has a try-catch that catches more than it should
13:41SagiCZ1i will try to try catch it in that place and print something, to see if it is thrown at all
13:41llasramOscarZ: For normal Clojure code, the name in the namespace points at a Var, and is never changed to point to a different Var.
13:42justin_smithSagiCZ1: yeah, in general, the solution is your try/catch that is closer in to the site of the error than the other one
13:42llasramOscarZ: The Var itself supports mutation, and recompiling a namespace to "change" a function etc modifies the Var to point to something else
13:42justin_smithSagiCZ1: or, you know, the library author could be less ambitious about which exception types they catch
13:43cflemingSagiCZ1: I see that exception being reported in the Cursive REPL
13:43OscarZllasram, i see.. i thought var was simply a name that points to some thing, like function, and namespace is a container for vars
13:43cflemingSagiCZ1: I just tried it now.
13:43SagiCZ1cfleming: yeah it works in the repl alone
13:43cflemingSagiCZ1: In general Cursive reports all exceptions returned by nREPL.
13:43SagiCZ1is it a problem taht the exception gets thrown in a future thread?
13:43justin_smithOscarZ: a var is a container type, mapped to a name inside a namespace
13:44justin_smithSagiCZ1: yeah, you won't see it until you deref the future
13:44cflemingSagiCZ1: Exceptions thrown in other threads might be missed by nREPL, yeah
13:44SagiCZ1bingo
13:44OscarZi need to put your example into editor and indent it :)
13:44justin_smithOscarZ: yeah, that would likely help
13:45SagiCZ1justin_smith: what if i dont deref the future at all? i just use it to start a new thread, which upon finishing mutates some swing stuff
13:45justin_smithSagiCZ1: then you will never see the exception
13:45SagiCZ1justin_smith: is there any workaround? it really makes debugging hard
13:46justin_smithSagiCZ1: maybe wrap the future body with a try/catch/print
13:46justin_smith,(future (try (f) (catch Exception e (.printStackTrace e))))
13:46clojurebotjustin_smith: Huh?
13:46justin_smithhaha
13:46SagiCZ1ok
13:46SagiCZ1is clojurebot on strike?
13:46justin_smithyou could even add a custom message before the stacktrace to remind you where that future came from / what it was for
13:47justin_smithhe refuses to do try/catch
13:47SagiCZ1i see
13:47SagiCZ1is there any reason why the exceptions in future cant be printed?
13:47SagiCZ1i mean printing is side effect anyways
13:47justin_smithSagiCZ1: they can! but there is no global try/catch wrapping the future thread
13:47justin_smithunlike your main repl thread
13:48justin_smithso you need to make your own, as above
13:48SagiCZ1oh.. i didnt realize that the main repl thread is wrapped in a try catch
13:48SagiCZ1good to know
13:48justin_smithotherwise - first time you get an exception - boom, time to restart
13:48justin_smithso it needs a try/catch
13:49SagiCZ1it works fine.. i will remember this
13:50SagiCZ1im glad it wasnt some weird bug in the ide, that would be a bummer
13:52justin_smithOscarZ: my example above with longer names, properly indented https://www.refheap.com/95052
13:53OscarZthanks, ill check it out.. had a bit of trouble with the earlier :/
13:54OscarZill paste that beast to light table
13:55OscarZwhats :- btw ?
13:55justin_smithjust a placeholder
13:56justin_smithI needed something there, because of how I was constructing the output
13:56OscarZoh ok.. keyword yes
13:56justin_smith,:-
13:56clojurebot:-
13:56justin_smithalso, since it is before a paren, it looks like :-)
13:57OscarZheh
14:00justin_smithhttps://www.refheap.com/95052 OscarZ: updated with a repl transcript, which may be more straightforward
14:01OscarZthanks
14:02OscarZinside run-server function, it #'app looking like just a normal function value?
14:02OscarZis ^^
14:03OscarZi guess it is.. nothing special in your example
14:04justin_smithwell, #'app is a normal var, which should resolve to something callable (likely a fucntion)
14:09OscarZcan it be thought like pass-by-reference instead of pass-by-value ?
14:09amalloyOscarZ: yes. vars are pointers to objects
14:09amalloythey're expected to not change much in production, but while developing you often change them as you refine function definitions or whatever
14:10OscarZok.. cool, i think i get it now.. thanks guys
14:10OscarZok
14:12OscarZwhat is this #' thingy called ?
14:13gfredericks,'#'first
14:13clojurebot(var first)
14:13OscarZok.. these symbols are bit hard to google :)
14:14amalloy$google symbolhound
14:14lazybot[SymbolHound: Search Better. Code Better.] http://symbolhound.com/
14:14amalloybut also, as justin_smith demonstrated, you can desugar some funny symbols by quoting them and seeing how they print
14:14amalloyer, not justin_smith, but gfredericks
14:14amalloygoodness
14:14amalloygood morning, folks
14:14justin_smithamalloy: I showed him the same thing when he first asked about it, way back in the upscroll
14:15justin_smithgood morning, amalloy
14:15OscarZi wouldnt have thought to put "first" in there :)
14:17OscarZi should have read this too: http://clojure.org/vars
14:17pandeirois it possible to do hstore updates with yesql?
14:17OscarZso you can do that per-thread too
14:20RasterBurnI want a namespace to "export" a function named "map" but I don't want to redefine "map" within that namespace. Is there a way to do that?
14:20llasramRasterBurn: Nope
14:21RasterBurnok i'm looking at how core.async does it.... it just defines "map" at the end of the file so it doesn't clash :)
14:21llasramRasterBurn: I doubt that's actually what is happening
14:21RasterBurnhttps://github.com/clojure/core.async/blob/53bf7866f195e6ba247ff7122b99784e66e9f1bb/src/main/clojure/clojure/core/async.clj#L862
14:22llasramRasterBurn: Yeah, but: https://github.com/clojure/core.async/blob/53bf7866f195e6ba247ff7122b99784e66e9f1bb/src/main/clojure/clojure/core/async.clj#L10-L11 and https://github.com/clojure/core.async/blob/53bf7866f195e6ba247ff7122b99784e66e9f1bb/src/main/clojure/clojure/core/async.clj#L307
14:23RasterBurnllasram: good find. hmmmm
14:23RasterBurnjust to suppress the warning?
14:23llasramI guess it prevents the namespace from compiling the first time if you accidentally use bare `map` earlier, but a second go-round will gladly refer to the same var
14:23llasramRasterBurn: Well, to be correct. In the standard Clojure REPL-based workflow you will be repeatedly re-compile namespaces
14:24llasramRasterBurn: Anyway, just follow their lead at least in terms of `:refer-clojure ... :exclude` and refer to core functions with a namespace alias
14:25llasram(I usually use `cc` myself, but whatever floats your boat)
14:25RasterBurnllasram: will do. thanks!
14:34mskoudWhat library should I look into to make a tcp proxy? Aleph?
14:35csd_Would someone be able to help me figure out why this code isnt working? https://www.refheap.com/95060
14:35arrdemmskoud: are you doing this for production or for learning?
14:36arrdemmskoud: if the former there are good C proxies already, if the latter just roll it yourself :P
14:36arrdemcsd_: what's wrong with it?
14:36amalloycsd_: that is a gigantic code dump with no explanation. what is it supposed to do? what goes wrong? is there an exception? do you get output that's wrong somehow?
14:36arrdemamalloy: jinx
14:36llasramcsd_: I don't know. I've never seen someone say much ;-)
14:37csd_It's an attempt to solve the 8 Queens problem of placing 8 queens on a chessboard so that none of them are in check with another
14:37mskoudit should be able to be used in production, though not that high throughput. It'll be doing a feb DNSBL checks.
14:37csd_And I don't receive any errors. I just receive () as my output
14:38noonianmeans your program thinks theres no safe places probably
14:39csd_noonian: i suspect its not generating board positions correctly
14:45csd_This is so odd.. I don't feel like I changed anything but now it's working
14:48arrdem(inc magic)
14:48lazybot⇒ 1
14:48csd_OK the problem was adjoin-position
14:50csd_actually i have no idea
14:51arrdemgit diff
14:52amalloyarrdem: Not a git repository
14:53arrdemif [ -f `which git` ]; then; git init --force; else echo "fuckit" fi;
15:06xemdetia(inc arrdem)
15:06lazybot⇒ 40
15:07amalloyarrdem: docked one point for using an unnecessary semicolon
15:07arrdemamalloy: the one after then or the fi
15:07arrdemI think both are suspect
15:08amalloyokay, two points. i didn't bother reading to the end before i started criticizing
15:08amalloyalso, you probably need one before the fi
15:08kenrestivothen; is probably incorrect
15:08amalloykenrestivo: not incorrect, just unnecessary
15:14xemdetiastill the best chuckle i've had all week
15:14xemdetiathat is the support I needed
15:19dnolen_reiddraper: the splittable PRNG stuff, definitely seems amenable to WebWorkers optimization since the amount of data moving around is quite small (if I'm thinking about this correctly)
15:20reiddraperdnolen_: yes
15:20reiddraperaphyr, gfredericks and i are trying to optimize the jvm version at the moment, too
15:21dnolen_reiddraper: OK swet
15:21dnolen_sweet
15:23trissso if you want to extend a protocol over two different types but the implimentations of there functions are the same you would typically use clojure.core/extend?
15:23amalloytriss: sounds good to me
15:23trissok great.... how the hell do I get at clojure.core/extend?
15:24gfredericksget at it?
15:24trissdo i need to require it?
15:24trissI thought core was whats available by default
15:24arrdemno, it's in clojure.core so you get it for free with (ns)'s implicit (:require [clojure.core :refer :all])
15:25trissso extend should be defined and ready to go?
15:25amalloyyes
15:25arrdem$grim clojure.core/extend
15:25lazybothttp://grimoire.arrdem.com/1.6.0/clojure.core/extend
15:26arrdemneed to patch that..
15:26trisshang on I'm in clojurescript.....
15:27trissshould that make a difference?
15:28arrdemso it looks like it's cljs.core/extend-type but I'm no clojurescript expert.
15:30amalloycljs doesn't have extend?
15:31arrdemdidn't see it looking on crossclj
15:31kenrestivoit has extend-protocol and extend-type
15:31amalloythat's a weird omission
15:32amalloywhat about "specify"? that looks like it might be related
15:35dnolen_amalloy: yeah doesn't have extend, specify is still pretty static
15:35amalloyohhhh, it's because extend is supposed to work at runtime or something?
15:36dnolen_amalloy: pretty sure it does
15:37amalloysure, on the jvm it definitely does
15:37dnolen_amalloy: it could probably be made to work in ClojureScript but it's a fiddly bit of work
15:37dnolen_and I think most folks get away with what's there just fine which is probably why we haven't gotten an enhancement patch yet
15:51kenrestivowait, is boot not open source?
15:52kenrestivoi see some plugins for it which appear to be, but boot itself seems to be a closed-source executable, AFAICT.
15:53michaniskin_kenrestivo: it's EPL, same as CLojure
15:54kenrestivocouldn't find it on github
15:54michaniskin_kenrestivo: https://github.com/boot-clj/boot/blob/master/LICENSE
15:54michaniskin_and in the README https://github.com/boot-clj/boot#license
15:54kenrestivoah, there it is, thanks https://github.com/boot-clj/boot
15:56tuftdoes boot have anything to help with startup time for its shebang scripts?
15:56tufte.g. some background process like gretch
15:56tuftseems like a useless feature without
15:56michaniskin_tuft: boot doesn't implement anything like that
15:57michaniskin_not everything is super sensitive to a 2s startup time
15:57timvisheris there a way to turn off :pre/:post assertions in clojurescript? *assert* doesn't seem to be bound to anything
15:57michaniskin_especially things like docker container entry points, things like that
15:58michaniskin_tuft: it's useful to be able to have a runnable clojure application that is distributed as a single text file
15:58michaniskin_i mean it's somewhat niche, but when you need it it's handy
15:59tuftmichaniskin_: for sure, i've been wanting something like that to start replacing python scripts, but startup time is pretty huge for iterating
15:59michaniskin_you an iterate in the REPL, of course
15:59tuftgretch + boot could be a thing
15:59michaniskin_*can
15:59michaniskin_anything you can do on the command line with boot you can also do from the REPL
16:00michaniskin_which eliminates the startup time when developing things
16:01tuftsure, my python dev process is pretty repl oriented, but usually i'm building up a larger script i want to run over and over until it's correct
16:02tuftplus lots of interactive applications can shell out as an extension point, which requires fast startup too
16:04tuftthere are so many great tools in clojure land for hot reloading code and deps, you'd think you could have a daemon like gretch plus these boot self describing scripts to solve for these other use cases pretty effectively
16:04michaniskin_tuft: you could accomplish it with pods if you wanted to
16:04michaniskin_boot provides these
16:04tufthmm, i'll read, thanks
16:05michaniskin_we actually experimented with runnign boot as a server
16:05michaniskin_and made a golang client for it
16:05michaniskin_the client is still in the repo i think
16:05michaniskin_but in the end there were annoying issues, like the JVM current working directory can't be changed
16:06michaniskin_which is pretty damning for the scripting environment situation
16:06tuftyeah that's the worse =\
16:06tufts/worse/worst/
16:06michaniskin_but if you can work around that problem you're good to go
16:07michaniskin_boot will happily eval scripts in isolated clojure runtimes all day long
16:07tuftseems like all jvm libs need to deal with that somehow
16:07tuftvery cool, thanks
16:09didiI am sorry, I am not familiar with Clojure, but I am curious about a design decision and I wonder if there is something written about it: Why (conj coll x & xs) and not (conj coll & xs)?
16:12justin_smithdidi: good question, many of clojure's varargs functions have a truncated version so that one can use them in apply or reduce...
16:12justin_smitheg. ##(= :x)
16:12lazybot⇒ true
16:13didijustin_smith: Using `apply' is precisely what I have in mind.
16:15justin_smithconsider into
16:15justin_smith,(into [0 1 2] [])
16:15clojurebot[0 1 2]
16:15justin_smith,(into [0 1 2] [3 4 5])
16:15clojurebot[0 1 2 3 4 ...]
16:16justin_smiththat is pretty damn close to (apply conj x), with the behavior you want
16:17justin_smithactually, apart from the empty coll behavior (which is what you want changed) it should be identical to (apply conj x)
16:17justin_smitherr, (apply conj x coll) of course
16:18didijustin_smith: Hum. My lack of understanding of Clojure is showing. (apply conj coll (list 4 2)) => (conj coll 4 2) , right?
16:19justin_smithright
16:19didiOK, cool.
16:19justin_smith,(into [1 2] (list 4 2))
16:19clojurebot[1 2 4 2]
16:19justin_smithso you want into, is what I am saying
16:19didijustin_smith: Oooh. I see.
16:20didi,(into (list 4 2) (list))
16:20clojurebot(4 2)
16:20didiRight.
16:20tuftinto probably performs better too, no?
16:21didiI still wonder about (apply conj coll (list)) tho.
16:21justin_smithdidi: it should work, but won't
16:21justin_smithbut at least into does the right thing
16:21justin_smithshould as in, "I think it would be better if it did"
16:21didiThank you, justin_smith.
16:22justin_smithinto is helpful for when you want to preserve collection types as well
16:22justin_smithnp
16:22justin_smith,(map #(into (empty %) (map inc %)) [[1 2 3] (1 2 3) #{1 2 3}])
16:22clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
16:22justin_smith,(map #(into (empty %) (map inc %)) [[1 2 3] '(1 2 3) #{1 2 3}])
16:22clojurebot([2 3 4] (4 3 2) #{4 3 2})
16:25m1dnight_Would any emacs users here know if there is something like an outline for clojure? A list thingy that gives you the names of all functions in the file, for quick navigation
16:25m1dnight_atm I'm coping with isearch
16:26arrdemm1dnight_: I use folding... just keep the whole thing folded and do selective expansion.
16:26m1dnight_oh, does that exist?I was wondering about that as well
16:26m1dnight_you mean like any regular IDE has, collapse functions?
16:26m1dnight_What is the package name?
16:26arrdemyeah. lemme look at my dots
16:27arrdem(add-hook 'clojure-mode 'hs-minor-mode)
16:27arrdem(add-hook 'clojure-mode 'hs-hide-all)
16:27justin_smithm1dnight_: there is also speedbar, I wonder if anyone has extended speedbar to recognize clojure definitions for navigation
16:28dnolen_reiddraper: boom, https://github.com/clojure/test.check/compare/cljs-port-patch
16:28dnolen_gfredericks: also ^
16:28nullptri personally just use occur w/"defn"
16:28dnolen_reiddraper: gfredericks: let me know what you want me to change before submitting a JIRA patch that y'all can apply.
16:29dnolen_also dropped ClojureScript 0.0-2496 w/ dog-fooded cljs.test - testing on both CLJS itself and the development of the test.check port
16:30reiddraperdnolen_: amazing, thanks for all of the hard work
16:30justin_smithm1dnight_: in C or javascript mode speedbar gives you a menu to jump to function definitions, but one would need to make a semantic module for clojure for that to work (I see things on github but not in elpa, and I don't know if they are any good)
16:30gfredericksdnolen_: will this be a single maven artifact or two?
16:30dnolen_gfredericks: single, same as core.async
16:31gfredericksdnolen_: so if we expect them to lag, should we keep separate changelogs too?
16:31dnolen_gfredericks: later when Feature Expressions land, some of these should probably become .cljc files and you will see less divergence
16:32dnolen_gfredericks: even so I think expecting them to say perfectly in sync will be difficult for stuff easier on the JVM, like parallel rose tree
16:32gfredericksotherwise the cljs stuff is second-class, right? can't infer much about the cljs features from the version?
16:32m1dnight_arrdem: Do I need to install anything in particular? I've added the two lines to my .emacs file and reloaded it but nothing changed
16:32dnolen_gfredericks: could keep separate from cljs stuff, but I don't see the point really
16:32dnolen_gfredericks: for stuff that's portable it's a copy and paste affair
16:33gfredericksokay cool
16:33arrdemm1dnight_: hideshow has been built in since emacs 20
16:33arrdemm1dnight_: but those two literal lines probably won't "just work".
16:33gfredericksdnolen_: thanks for pulling that together
16:34dnolen_gfredericks: at the moment *everything* is supported except generators for JVM types
16:34gfredericksnice
16:34m1dnight_oohhhh, I just discovered the occur function
16:34m1dnight_that helps a lot
16:38shemm1dnight_: there's also helm-semantic-or-imenu
16:39m1dnight_that looks good too
16:40m1dnight_I'll have a look
16:40m1dnight_I'm a bit of a noob with emacs, so it looks too advanced for me tbh :p
16:42eriktjacobsenCan anyone think of a simple strategy to only memoize a stateful function if a value is not nil? Right now I’m using core.memoize and checking the return to issue a “memo-clear!” if its nil. Because memo expects a function I’m having a hard time coming up with a strategy where I don’t basically reimplement a lookup table like memo does.
16:43justin_smitheriktjacobsen: memoizing anything stateful seems like a bad idea, on the face of it
16:44eriktjacobsenOf course. I’m using the core.memoize TTL to keep it to 10 minutes, and I also have a redis cache for a bit longer than that… want to avoid the redis socket connect when it isn’t needed
16:45eriktjacobsenIf the function returns a value, it should be good for several hours. In the cases it returns nil, I want to keep checking because it might work the next call
16:45justin_smithOK, have you looked at core.cache - because this sounds more like caching than memoizing
16:46justin_smithhttps://github.com/clojure/core.cache
16:46eriktjacobsenNope. Interesting those look like a lot of the same function definitions and underlying CacheProtocol usage as core.memorize
16:47eriktjacobsenmemoize*
16:47eriktjacobsenWill look at it, thanks
16:52klyed2don't know much clojure myself, and as justin_smith said it wouldn't be the right thing to do, but you could create a new function that will call the memoized version of the function if not nil, or the function directly if nil...
16:59dnolen_reiddraper: gfredericks: let me know what tweaks you guys would like - I hope most of the port is non-controversial. Most of the file additions are around development testing and handling both browser & Node target - noisy for the repo, but doesn't make a difference for the artifact.
17:00reiddraperdnolen_: yeah, i hope to play around with it this evening, unlikely i'll have much to say, just want to 'see it work' on my box
17:01dnolen_reiddraper: ok cool! `lein cljsbuild auto node-dev` is all you need if you got Node.js installed
17:04eriktjacobsenklyed2: yes, but that would result in it never getting memoized, as the memoized version would solely be nil and it would just always call the function. This is similar to my current solution of checking the value and clearing the memo if nil. I suppose I could combine both and clear it before returning the function itself, just seems clunky. Thanks though
17:05EvanRcan i define new java subclasses in clojure
17:07TimMcEvanR: Not "Java subclasses" exactly -- JVM subclasses.
17:07EvanRhow
17:07TimMc$google cemerick flowchart
17:07lazybot[Flowchart for choosing the right Clojure type definition form | cemerick] http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/
17:08TimMcEvanR: ^ It's kind of messy and depends on what you need.
17:08EvanRbasically gen-class ?
17:08TimMcIn the worst case.
17:09TimMcOr I guess direct bytecode generation would be even worse, but I've never needed that. :-)
17:11TimMcHmm, I never did figure out a better way to organize that flowchart. I really thought I was going to be able to propose something with fewer loops. :-)
17:11amalloyTimMc: even worse than that, generating java source files at runtime and compiling those
17:12TimMcThat's worse than ASM?
17:12TimMcI guess it turns it into a build tool problem, which *is* pretty bad...
17:17hiredmanactually you can do that pretty easily with lein
17:21EvanRthe class im trying to subclass is actually auto generated, but thats another story
17:25justin_smithEvanR: according to the flowchard linked above, I think that means proxy
19:13rhg331is there a core fn that takes (fn [x y] ...) to work on [x y] besides apply?
19:14joegallowhy do you ask?
19:14justin_smithyeah, what do you need that apply doesn't do?
19:14arrdemwhy is apply out? That's exactly what it does.
19:14amalloyrhg331: why would there be one in addition to apply?
19:14amalloy(partial apply f)
19:15gfredericksHey amalloy what's your guess for (re-matches "[^[x]]" "x")
19:15amalloyugh. you and your nested character classes
19:15amalloyi'd guess no, but i don't really know anything about how these things are defined to work
19:16gfredericksyeah that was my guess too
19:16gfredericks&(re-matches #"[^[x]]" "x")
19:16lazybot⇒ "x"
19:16rhg331amalloy: because apply is way more general but it does work so it's good just curious
19:16amalloyrhg331: how is it more general? the only thing it does is exactly what you asked for
19:17rhg331apply works on any seq
19:18justin_smithso you were considering like (fn [v] (g (v 0) (v 1)))
19:20rhg331yeah i wanted somn to basically un-juxt but in retrospect juxt accepts an arbitrary num of fns
19:22rhg331the stdlib never ceases to amaze me
19:29arrdemreally? I find that for, ->, ->> and the other threading macros are the only really "hey man hold my beer watch this" awesome features. Everything else is just... really solidly done.
19:31amalloyarrdem: it all dovetails together in subtle ways you might not even notice, though
19:31amalloylike -> and ->> wouldn't be very impressive without the consistent order that functions take their arguments in
19:32arrdemexactly.
19:32rhg331now i wonder how to break brains with comp, juxt, partial and apply
19:32arrdemIMO juxt is overrated. partial and apply are fun tho.
19:32arrdemas is comp
19:33arrdem(update-in .... (comp ...))
19:33amalloyand that order isn't *just* for ->. for example, update-in, swap!, all that stuff
19:34arrdemrhg331: check this -> out https://github.com/arrdem/spitfire/blob/master/src/spitfire/whac.clj#L461
19:34rhg331juxt is fun, it bends your mind :)
19:34amalloy(swap! x update-in [a b] dissoc q) ;; <3
19:34amalloy~juxt
19:34clojurebotjuxt is usually the right answer
19:34arrdemclojurebot is a pit of lies and deceit
19:34arrdems/pit/font/g
19:35rhg331goodness arrdem
19:35rhg331i feel happy and sad
19:35arrdemI know right
19:35arrdemPart of me thinks that's awesome code, the rest of me doesn't even know.
19:36rhg331its 100+ loc
19:36dbaschI’ll take higher order functions for 200, amalloy
19:37amalloyarrdem: it looks rife with duplication
19:37rhg331arrdem: you'd make a good js dev
19:37justin_smithis that shade? I think he was throwing some shade
19:37arrdemamalloy: there's probably a good macro in there, data wise I don't think there's duplication to be leveraged but I'd be happy to be shown wrong.
19:38arrdemalso a toy project not real code so w/e
19:38amalloyarrdem: look at https://github.com/arrdem/spitfire/blob/master/src/spitfire/whac.clj#L567-L577, for example. this should be a reduce over the seq [:frost :electrical :corrosion :fire]
19:39amalloyand :immunity_fire should be a nested key or something, [:immunity :fire] so you don't have to type all that junk out twice
19:40amalloyall of https://github.com/arrdem/spitfire/blob/master/src/spitfire/whac.clj#L518-L549 should be a reduce over a seq of pairs like [[:terror w.m/terror?] [:stealth w.m/stealth?]]
19:40arrdemreally? I thought about doing that and came to the conclusion that it wasn't a net savings.
19:40rhg331reduce is actually the usual right way
19:41arrdemhum. got some grading to do but I could get motivated to refactor that.
19:42rhg331~clojurebot
19:42amalloyi mean, that's 40 lines of repetition. it'd be awfully hard to write a reduce so bad that you can't get a net savings
19:42clojurebotclojurebot is http://images2.fanpop.com/images/photos/3000000/Arrowed-teen-girl-squad-3099521-570-420.jpg
19:42rhg331hmm
19:43justin_smiththat Arrowed-teen-girl-squad pic would be better for threading macro factoid
19:43arrdemamalloy: I feel like I've gotten so used to being corrected and criticized by you that I've become flippant about it, but thank you for the time and criticism. I probably wouldn't have picked up Clojure without your and the rest of the channel's help.
19:44amalloyjustin_smith: it's probably a derived factoid from something that makes actual sense
19:44arrdemnow back to our regularly scheduled sarcasm.
19:45amalloyarrdem: you're welcome. as for myself, i occasionally realize i've become a little uh...abrasive. less gentle with my feedback. i generally think people don't take that too seriously, but i should be more careful
19:47amalloywhaaat. why is deferent not in chrome's spellcheck dictionary
19:47justin_smithamalloy: in all fairness, it was quite level headed of you to suggest a helper function hidden in metadata made you want to puke, the bodily functions that would actually be called for wouldn't be appropriate for describing on S.O.
19:48amalloyhaha. no, i don't feel bad about that one at all, justin_smith. colorful imagery helps drive home the point without having to threaten bodily harm
19:49arrdemKILL IT WITH FIRE
19:49rhg331lately i've noticed things like #(some-fn % 'an-arg) is this advised?
19:50justin_smithrhg331: what's the issue with that?
19:50arrdemyeah since there isn't a better way to partial the "last" arg.
19:50rhg331kinda like partial but not
19:50rhg331ok
19:50justin_smitharrdem: I prefer #() over partial even when fixing early args, unless I need the result to be varargs
19:51arrdemhum... I feel like there's a better way to write "partial-last" than that..
19:51rhg331me too
19:51arrdemjustin_smith: really? I'll usually go for the partial... mainly because I have editor rewriting to make it pretty.
19:52arrdem("\\(partial\\)[[:space:]]" . "Ƥ")
19:52justin_smitharrdem: the #() is shorter (I don't have the rewriting) and why pay for varargs you don't need? it's not like #() is obfuscated
19:52rhg331it complects what and how
19:52arrdemin my head it's a partial, so I'd rather type partial
19:52arrdemthan type out the resulting papply function
19:53arrdembut w/e they both do the same thing.
19:53rhg331until it doesnt
19:53rhg331theres power in conveying intent
20:04schonehello #clojure
20:04rhg331show stuff like '(partial apply juxt inc (comp first str pos?))' to c(++) devs and watch their brains implode
20:05schonei’m a new comer to clojure and i’m trying to read some code and understand. Can someone help me understand where the “id” variable is assigned or set, the one used in this code https://github.com/apache/storm/blob/master/storm-core/src/clj/backtype/storm/daemon/executor.clj#L508
20:05schone?
20:05schoneMessageId is a normal java object
20:05arrdemrhg331: be nice otherwise they may never join us :P
20:05rhg331variables arent set
20:05arrdemschone: that's a reference to a static method.
20:06schonearrdem: what static method?
20:06schonei dont undersand
20:06arrdemMessageId.makeRootId
20:06amalloyprobably in https://github.com/apache/storm/blob/master/storm-core/src/clj/backtype/storm/daemon/executor.clj#L506, schone
20:06rhg331theyre either named constants are atoms that can be pointed to another value
20:07rhg331s/are/or/
20:07amalloybut it's hard to know for sure without the definition of fast-list-iter
20:07schonei seriously don’t understand…. makeRootId is a static method that takes two params… one is given in root-id… but what is the id variable used there?
20:07rhg331arrdem: theyre not nice to anyone
20:07rhg331and this is nice
20:08amalloyschone: yeah, i don't understand the other answers you got. they don't seem to be addressing your question at all
20:08arrdemI spent a summer after learning Clojure writing embedded C... not having a real macro system and first class functions made for some really bad days.
20:08schoneamalloy: but i just raelized what you told me and you are right
20:08schonei cant believe i didnt notice it was right there in front of me
20:09schonethank you!
20:09schoneamalloy: =^
20:09amalloyschone: i didn't notice it either, until i searched for "id"
20:09amalloyscrolled all the way to the top of that function looking for it :P
20:09rhg331arrdem: not nice would be breaking into their house and modifying their code to make the pc blow up when run
20:09dbaschschone: fast-list-iter sets it https://github.com/apache/storm/blob/413a6952c2acabdb97a9e4d68eaa774faafc120b/storm-core/src/clj/backtype/storm/util.clj#L921
20:10rhg331im not crazy i promise
20:10schoneamalloy: where does fast-list-iter gets it?
20:10schonefrom
20:11dbaschout-ids
20:11amalloyschone: fast-list-iter takes some bindings
20:11timvisheri have a single channel that's receiving keyup events, and i'm trying to filter it for 2 different kinds of commands. of course, because the go-loops responsible for reading from the channel are taking turns reading from the channel. https://github.com/timvisher/nhss-cljs/blob/undo/src/cljs/nhss/ui.cljs#L82-L97
20:11schoneamalloy: what does that mean that it takes some bindings?
20:11joegallothink of it like this (for [x (range 0 10)] ...) <--- the x is being set there, it's not coming from anywhere. :)
20:11amalloyit's like (for [x xs] ...). where does the x "come from"? nowhere; it's the name you specify when using for
20:11dbaschschone: it’s iterating over out-ids, from what I understand
20:11timvisherother than adding a new listener that publishes each keyup event once to 2 different channels, how do you go about doing this?
20:12schoneah i see
20:12schoneso you guys are saying out-task is an individual item in the list out-tasks and id is an individual element in the out-ids list
20:12schone?
20:12timvisherschone: that's what it looks like to me
20:12schonegot ya
20:12timvisheri've never heard of fast-list-iter though. might be defined in that project
20:13rhg331so succint amalloy now i can better explain it, thx
20:13amalloyrhg331: explain what?
20:13rhg331locals
20:14schonethanks guys! appreciate your help amalloy dbasch and timvisher
20:17justin_smithrhg331: re "variables aren't set, theyre either named constants..." - vars are mutable. local bindngs are immutable, but they aren't vars either
20:18rhg331justin_smith: oops i meant locals
20:19justin_smithrhg331: fair enough, yeah, "variable" is tricky in clojure because we don't have anything that acts strictly like a normal variable, but vars get close (and their names almost match...)
20:19rhg331i like to pretend vars are only mutable when developing
20:20rhg331it prevents nasty bugs
20:21timvisherah. looks like split is what i want
20:23crack_userhey guys
20:23crack_userwhere is the bot sourcecode
20:23justin_smithcrack_user: which bot?
20:23justin_smithboth are on github
20:23justin_smith$google github lazybot
20:23lazybot[Raynes/lazybot · GitHub] https://github.com/Raynes/lazybot
20:23crack_userclojurebot
20:23dbaschhttps://github.com/hiredman/clojurebot
20:23justin_smith$google github clojurebot
20:23lazybot[hiredman/clojurebot · GitHub] https://github.com/hiredman/clojurebot
20:23crack_userthe irc bot
20:23justin_smithwe have two
20:23justin_smithboth were just linked
20:24crack_usercool
20:24arrdemjustin_smith: lazybot patch inc.
20:25justin_smithI paint a picture, and do they call me a painter? no. I build a bridge, and do they call me a bridge maker? no. But you patch a lazybot one time...
20:25arrdemI mean... Raynes doesn't do shit and amalloy scares everyone
20:25arrdemso...
20:26Rayneshuh
20:26arrdemRaynes: <3
20:26RaynesWhat did I do now
20:27rhg331...
20:28RaynesI mean, it's accurate.
20:28RaynesI do, in fact, not do shit and amalloy is pretty terrifying.
20:31gfredericksit's no coincidence that "amalloy" can be rearranged to spell "pretty terrifying"
20:31arrdemjust need some bit shifting in that arrangement....
20:32TEttingerI like all them lazybot devs
20:32sevvie<3 #clojure. nini.
20:33rhg331what magic is this
20:33TEttingeroh yeah, Raynes and justin_smith: nice work on the latest update
20:33TEttingerI just updated my lazybot fork-ish that I host to use your latest commit, and it seems good. still doesn't reconnect on some netsplits
20:34TEttingerI didn't even lose any lucene history, which is nice
20:34justin_smithTEttinger: yeah, I don't think there is any netsplit handling code in fact
20:34dbaschamalloy also spells “yo, llama” backwards which is pretty terrifying too
20:35justin_smithhttps://www.youtube.com/watch?v=zRozKfYGFVc bone-chilling
20:36TEttingeroh geez, shouldn't have anagrammed that http://wordsmith.org/anagram/anagram.cgi?anagram=alan+malloy&amp;t=1000&amp;a=n
20:37justin_smithhaha
20:37TEttingerall anomaly is good
20:38justin_smithone of the few that isn't insulting
20:38gfredericksI dunno if this helps but Alan is my middle name
20:38TEttingerhey, when your first name is an anagram of "anal" you're bound to have problems with any anagram
20:39gfredericksoh crap I never noticed my middle name was an anagram of anal
20:40TEttinger... A Dick Enlarger Frays
20:41TEttingeryour first name is Gary right?
20:41dbaschTEttinger: we’ll take your word for it :P
20:42justin_smiththin mints jungles
20:43TEttingergary fredericks is an anagram for fridge sky racer
20:43justin_smithnth jesting muslin
20:43TEttingerGritty Memento for Tommy Ettinger
20:44timvisheri am confused about core.async/split i think. i have a predicate which is clearly filtering the right messages into the true channel, because they're not appearing in the false channel, but what i have set up to read from the true channel isn't getting any messages…
20:44rhg331mine isnt too bad
20:45justin_smithtimvisher: does it have backpressure if one of the channels is not consumed?
20:45timvisherjustin_smith: well, it's not a buffered channel, so yes?
20:45rhg331nvm
20:46justin_smithtimvisher: OK, was just a guess that maybe some messages weren't being read, but rereading your question it looks like you are consuming both sides anyway
20:47rhg331timvisher: is anything else consuming it?
20:47timvisherjustin_smith: yeah. what's weird is that i'm consuming the false side for sure but i don't appear to be getting anything from the true side
20:47timvisherrhg331: trying to figure that out now. :)
20:48rhg331its a pita for sure
20:51timvisherif anyone has a sec, a second pair of eyes on this would be helpful. :) https://github.com/timvisher/nhss-cljs/blob/undo/src/cljs/nhss/ui.cljs#L82-L96
20:52timvisherumm… nevermind. it's working now…
20:52timvisher^_^
20:52arrdem:shipit:
20:54rhg3310.o
20:55gfredericksoh dear
20:55gfredericks,(re-matches #"[^[x]]" "x")
20:55clojurebot"x"
20:55gfredericks,(re-matches #"[^[x]x]" "x")
20:55clojurebotnil
20:56arrdemgfredericks: whaaaa
20:56gfredericks,(re-matches #"[^[x]x]" "y")
20:56clojurebotnil
20:56gfredericksI'm not sure how to interpret this one
20:57rhg331(juxt brain-melting cool)
20:57gfredericksit's the "[^[x]x] doesn't match anything" rule of regexes
20:57rhg331i know
20:58gfrederickshalp
20:58rhg331its weird why its there though
20:59rhg331thats (and x (not x))
21:00gfredericksshould be (or x (not x)) if anything
21:00rhg331oops yes
21:01rhg331now im more confused
21:02gfredericksI think I can throw an "ambiguous expression" exception or something here
21:05rhg331regex analysis usually leads to tears ime
21:09gfredericksI always feel like I'm almost there
21:13kenrestivojava interop always leads to tears for me
21:13rhg331^
21:14kenrestivoi love example code doing "import foo.*;" leaving me trying to scramble to figure out where all these classes and constants in the example code come from.
21:16rhg331import foo.*; import bar.*; import baz.*; //have fun
21:16kenrestivothank FSM most clojure code has the courtesy to require :as foo or :refer []
21:16amalloykenrestivo worships finite state machines?
21:16kenrestivo(inc amalloy)
21:16lazybot⇒ 206
21:16rhg331apparently
21:17kenrestivohttp://en.wikipedia.org/wiki/Flying_spaghetti_monster
21:17amalloyi guess we all do, really. we let these computers tell us what to do, schedule our lives around what they say, and by gosh if they aren't finite state machines
21:17amalloykenrestivo: i know. i like my way better
21:17justin_smithhallowed be his inputs and his transitions, may our sequences be accepted, amen
21:18rhg331i suppose tis be true
21:20justin_smithkenrestivo: I bet there is something in intellij idea, or maybe even eclipse, that takes import foo.*; and tells you exactly the set of classes that matches
21:20kenrestivoyeah, i thought of that, firing up intellij and making it do the dirty work. or i might just clone the library's repo and try to build javadocs for it
21:20justin_smithin the name of the acceptor, the recognizer, and the sequence detector
21:21weiis there a shortcut for (fn [x] (and (not (some? x)) (empty? x)))
21:21kenrestivo~fsm
21:21clojurebotGabh mo leithscéal?
21:21justin_smithkenrestivo: I know all too well, but these finite state machine as deity riffs are too fun
21:23rhg331oh FSM
21:24gfredericksjustin_smith: the concept of an infinite state machine is heresy
21:25amalloyuhhhhh, isn't that function just nil?, wei?
21:25kristofThat's what I was thinking
21:25amalloyyou're asserting that it's not anything other than nil, and is also empty
21:25weiamalloy: i think you’re right, I wrote the function wrong
21:25kristoflol
21:26justin_smithgfredericks: that reminds me of that thing where certain sects of American protestants don't accept any 20th century mathematics, because to them god=infinity so multiple infinities is clearly heretical
21:26weiwhat I’m looking for is not nil or empty (e.g. “”)
21:26rhg331there are infinite finite state machines too
21:26wei*nil or empty
21:26amalloywei: and does this function need to handle non-sequential objects like :keyword?
21:27weiamalloy: yup.
21:27gfredericksjustin_smith: I haven't heard that, but I suppose it's not surprising
21:27gfredericksat least for a small enough sect
21:27amalloyand you want to treat "" as falsey? you sure are in for a treat
21:27justin_smithwei (and (not (some? x)) (empty? x)) is just (some? x) because only nil is (not (some? ...)) and nil is always empty
21:28amalloyjustin_smith: we already did that part. but you got it backwards; it's nil?, not some?
21:28andyfgfredericks: Anagram possibilities are so much greater if you can permute the bits of a binary representation! Hmm
21:28justin_smithoh, right, never mind
21:28gfredericksandyf: gee whiz man
21:29weiamalloy: i’m parsing form params, and unfortunately there’s no nil
21:29andyfBehind on reading. I don't think I am suffering from bbloomitis
21:29amalloywei: if you're parsing form params, then you only have to deal with strings!
21:30justin_smithwei: all's fair in love, war, and parsing http data
21:30rhg331andyf: oh FSM thatd be fun
21:30gfredericksandyf: you're not, you just nearly nerd-snipe me. I'm resisting though.
21:30amalloyin which case your function is just seq
21:30weifair enough. that’s good enough for me, thanks guys
21:31gfredericksmy typing has gotten a lot more error-filled lately; I must be olding
21:31andyfYeah, I should be more careful offering drinks to alcoholics
21:31rhg331hmm olding
21:32kenrestivoi thought Foo/bar is the right way to access a static method in java interop, right?
21:33justin_smithkenrestivo: yes, works with or without parens, for hysterical raisins
21:33kenrestivobecause, it's not letting me do that. Foo$bar isn't working either.
21:33justin_smith,(Math/PI)
21:33clojurebot3.141592653589793
21:34kenrestivoi've imported Foo. i can access it. i can access static fields in it, no problem. but static methods? no dice.
21:34rhg331static methods otoh...
21:34rhg331,(Math/PI 3)
21:34clojurebot#<CompilerException java.lang.IllegalArgumentException: No matching method: PI, compiling:(NO_SOURCE_PATH:0:0)>
21:35justin_smithright, sorry, that's a field, not a method
21:35amalloykenrestivo: then you're probably calling the method with the wrong arguments
21:35rhg331its illogical that syntzx
21:35kenrestivoi'm just trying to access it in the repl at the moment
21:35justin_smithrhg331: yes, it's a field, but it accepts parens, most uillogical
21:36rhg331ikr
21:37kenrestivoah, works.
21:38kenrestivoi have a bad habit of executing stuff in the repl to make sure it's "there" and it's "real" (i.e. i correctly imported or required it). works with clojure functions and vars, works with java interop classes, works with java interop static fields, does not work with java interop static methods. my bad.
21:39amalloykenrestivo: what? yes it does
21:39kenrestivonot in this case it don't
21:39amalloykenrestivo: you are inventing some false cause. something else is going wrong
21:39justin_smithamalloy: I think he means just standalone, without parens
21:39amalloyoh, i see
21:39amalloyyou are just writing Math/log
21:39kenrestivoright. i.e. nrepl-eval-last-expression
21:40amalloythat doesn't work in the repl *or* in real life
21:41kenrestivo,conj
21:41clojurebot#<core$conj__4079 clojure.core$conj__4079@e75b0a>
21:41kenrestivoyeah it does :-P
21:41justin_smith,Math/log
21:41clojurebot#<CompilerException java.lang.RuntimeException: Unable to find static field: log in class java.lang.Math, compiling:(NO_SOURCE_PATH:0:0)>
21:41justin_smithkenrestivo: not for static methods
21:41justin_smith,(Math/log 10)
21:41clojurebot2.302585092994046
21:41kenrestivoright. i just rediscovered that. sorry for the noise.
21:41rhg331methods arent values*
21:42justin_smithexactly
21:43kristofif only!
21:43kristofbut Java 8 has lambdas now
21:43rhg331which are objects
21:43rhg331not methods
21:44kristofThe mental leap that methods should be objects, too, is not a hard one to make.
21:45gfredericks~clojure is expected to require Java >= 8 by roughly 2023
21:45clojurebotIk begrijp
21:45rhg331kristof: Methods are, methods arent
21:46kristofrhg331: reflection is weird.
21:46kristofAnd slow!
21:47rhg331yup and sorta
22:07gfrederickshey who uses instaparse and do you name your grammar nodes with CamelCase and why do you do that and do you have regrets.
22:09bbloomgfredericks: c'mon man, just pick a casing and go with it. don't worry about it
22:10gfredericksbbloom: I feel gross when the weird cases leak too far into the clojure code
22:10gfredericksso then I feel like I need a translation layer and then I'm like why is this important and wish I was just using kebabs everywhere in the first place
22:10bbloomgfredericks: i'd rather you feel gross than i have to feel the bugs you will create trying to hyphenize, camelize, keywordize, etc
22:11bbloomunless that translation later is itself a complete parser, you're likely to try to automate some mappings & you're sure to create a maintenance nightmare later
22:11bbloomif you want to use kebabs, use them
22:11bbloomif it doesn't work, just camel case it
22:11bbloomjust pretend it's a JVM library or something :-P
22:24andyfPossible TIL moment: kebabs?
22:25ddimagfredericks: still taking apart javax regex engine? ;)
22:25justin_smith$google clojure github camel-snake-kebab
22:26bbloomandyf: -the-line-through-this-looks-like-a-kebab-
22:26bbloompersonally, i think you need an o-prefix-too-
22:27gfredericks
22:27gfredericksddima: totes
22:27amalloybbloom: core-logic-kebab-o?
22:27gfredericksddima: I'm about to declare victory
22:27ddimaheh
22:27ddimasorry for interrupting anways ;)
22:29bbloomamalloy_: works for me
22:29gfredericksthe cost so far has included discovering a new instaparse bug and rolling my own interval set data structure thing
22:31ddimaI've not followed it too closely, but I've read abot your weird 'backtracking' discovery 1-2 weeks ago, late at night (CET), tried at, shat my pants, went to sleep. still amazed something like this actually is in a pretty mature implementation. lots of computering-linguist friends would die laughing ;)
22:32gfredericksandyf: did you see what I found today
22:34andyfNested character sets are outside of my happy place
22:34andyfIf that is what it is
22:36ddimaheh, I think that's about how I handle it aswell
22:37gfredericks~nested character sets |are| outside of my happy place
22:37clojurebotIk begrijp
22:40gfredericksis this list of unsupported features small enough to be useful? https://github.com/gfredericks/test.chuck/tree/regexes-2#string-from-regex
22:40andyfddima: What example were you referring to, out of morbid curiosity?
22:41ddimalett me check, pretty sure gfredericks will be quicker, as it was his
22:41gfredericksums
22:41gfredericksI remember a discussion about backtracking but I'm not sure it was related to what I'm doing
22:43ddimasort of like:
22:43ddima##(time (re-find #"(x+x+)+y" (apply str (repeat 100 \x))))
22:43ddima##(time (re-find #"(x+x+)+y" (apply str (repeat 10 \x))))
22:43lazybot⇒ "Elapsed time: 7.616931 msecs" nil
22:43lazybotExecution Timed Out!
22:43ddimaactually exactly the thing, taken from lein-repl history ;)
22:43andyfYou are going for a useful subset for generating matching strings, not for implementing in Clojure code, yes?
22:44gfredericksandyf: I'm not sure what that second half means
22:44gfredericksbut the first half sounds right
22:45andyfI mean, you are not trying to handle the kind of regexes people use when parsing things.
22:46gfrederickswell maybe; not completely at first
22:46gfredericksthat's a valid target but it's labeled Difficult
22:46gfredericksi.e., I assume anybody using a regex to parse something might also want to use it to generate test data
22:48gfredericksI suppose the most glaring missing features are the common character classes and the anchors?
22:48andyfI use a few char classes frequently \s \S \d
22:48andyfYeah
22:49gfredericksas long as I keep disallowing flags I suppose those would be easy enough
22:50gfredericksthe javadocs actually define each of them in terms of [...] so that couldn't be easier
22:55andyfBy disallowing flags I suppose you mean everything the Java docs call "special constructs"? Seems reasonable to leave those out.
22:55ddimagfredericks: regarding above example taken from you, do you have a pointer as to why it is special (meaning, why its complexity explodes like that, even though it could be "trivially" normalized to something sane), or is it actually a bug?
22:56gfredericksandyf: yeah that section
22:57gfredericksddima: I'm not too familiar with those examples
22:58ddimahm, I thought it was actually something you pasted a couple of weeks ago, experimenting ;)
22:58gfredericksno it's from some documentation
22:58gfredericksregularexpressions.info probably
22:59ddimaoh, ok
22:59andyfddima: I would guess the implementation doesn't try to transform regexes into simpler forms, expecting hand written regexes not to be written like that
23:01ddimaone could assume, I haven't spent time figuring out what the the variants of automatas could look like for this kind of expression, so uneducated surprise - but still a surprise ;)
23:01kenrestivothis damn library gives me an enumeration. how do i turn it into a seq? (seq foo) doesn't.
23:01kenrestivohot damn
23:01kenrestivo,(doc enumeration-seq)
23:01clojurebot"([e]); Returns a seq on a java.util.Enumeration"
23:02kenrestivorich thought of everything
23:13gfredericksokay I take it back can't use any even number of ampersands to do a character class intersection
23:20amalloybbloom: i don't have my log. what did i say that works for you?
23:21kenrestivoi think someone should create a twitter feed called RegExpTorture and compile all these weird edge cases in one place
23:23ddimathat would certainly be educational
23:23gfredericksI thought you could because:
23:23gfredericks&(re-seq #"[a-f&&&&c-h]" "abcdefghijklm")
23:24lazybot⇒ ("c" "d" "e" "f")
23:24gfredericksbut...
23:24gfredericks&(re-seq #"[^a-f&&&&c-h]" "abcdefghijklm")
23:24lazybot⇒ nil
23:24gfrederickswhereas
23:24gfredericks&(re-seq #"[^a-f&&c-h]" "abcdefghijklm")
23:24lazybot⇒ ("g" "h")
23:24gfredericksso they're not equivalent
23:26gfredericksthe openjdk code that parses that stuff is pretty imperative and gnarly
23:32ddimaan idea why? from the first negated case with ^a-f&&&& it feels like he would do an intersection of ^a-f && () && c-h, but obviously not in the first case. an idea?
23:32ddima(never tried to torture poor regexes ;))
23:33gfredericksI think it's undefined behavior
23:33gfredericksGIGO
23:33ddimaheh
23:33ddimafine ;)
23:33ddimafun though
23:33rhg135Poor regexes?
23:34ddimamore like rich regexes
23:34gfredericksI refer you to https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/java/util/regex/Pattern.java#L2426-2525 for more details :P
23:34maxigasunregular regexes?
23:34clojurebotexcusez-moi
23:34ddimathanks gfredericks, thats exactly what I was planning to do at fucking 5:30 in the morning ;)
23:35ddima<bookmark>
23:35gfredericksclojurebot: fucking 5:30 in the morning is https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/java/util/regex/Pattern.java#L2426-2525
23:35clojurebotYou don't have to tell me twice.
23:38rhg135That's not too bad