#clojure logs

2015-07-20

00:35crocketDoes anyone know how to step into java instance methods in a clojure debug session?
01:26crocketDoes anyone use :fill-rolling appender inb unilog?
01:26crocketDoes anyone use :fill-rolling appender in unilog?
01:26crocketDoes it ever work for you?
04:27divya`(for [x# ["one" "two"]] ~(symbol (str "(calculate-" x# ")"))) .. I'm trying to evaluate dynamic functions based on values passed, but the auto-gensym causes trouble. Can anyone please help to solve ?
06:20tgoossensi'm unable to create a table (H2 database) using clojure.jdbc
06:20tgoossensI can select tables from information_schema
06:20tgoossensso the connection is there
06:20tgoossens(j/execute! db ["CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))"])
06:20tgoossens=> [0]
06:24kwladykatgoossens, are you sure it didn't create this table?
06:24kwladykaif not exception error it should success
06:24kwladykai guess
06:24kwladykaand be sure to not have this table before run this command
06:25kwladykaand... use migrations, don't create database structure in that way
06:31tgoossenskwladyka, the table does not appear in information_schema.tables
06:32kwladykatgoossens, did you refresh GUI? did you try paste this SQL directly and check errors?
06:33tgoossenskwladyka, {:subprotocol "h2", :classname "org.h2.Driver", :subname "mem:test", :user "", :password ""}
06:33tgoossensi'm using H2 in memory btw
06:35kwladykacant be sure how it looks with H2 in memory but for postgresql (def db {:subprotocol "postgresql" :subname "//localhost/clojure" :user "clojure" :password "secret"})
06:36kwladykatgoossens, maybe user cant be empty?
06:36kwladykabut still you should get some exception i think
06:38kwladykaif not try use this SQL directly in H2, i don't have better idea :)
06:52crocketIs there a better way to write https://www.refheap.com/106730 ?
06:53crocketI want it to be more concise.
07:01crocket(reduce-kv #(assoc %1 %2 (name %3)) overrides)
07:16lodin_crocket: You can do (map #(update 1 name) a-map) instead of using for.
07:16lodin_err, #(update % 1 name)
07:17lodin_crocket: But I'd just write a map-vals (or use any utility library that defines it already), and do (map-vals name a-map).
07:20crocketI used (reduce-kv #(assoc %1 %2 (name %3)) {} overrides)
07:21lodin_crocket: Personally I have a utility function map* that is a multimethod that essentially is (into (empty xs) (map f xs)), but it doesn't reverse the order for seqs and lists.
07:21crocketlodin_, (map #(update % 1 name) a-map) emits a sequence.
07:21lodin_crocket: for does too.
07:22crocketlodin_, (reduce-kv) is the most concise.
07:22lodin_crocket: I think map-vals is if ever do it more than once. :-)
07:24lodin_(map-vals name a-map). Hard to beat.
07:25crocketWrite a macro
07:27crocket(defmacro map-vals [fn & maps] `(into {} (map ~fn ~@maps)))
07:27crocketHa
07:28crocketoops
07:28lodin_Why macro?
07:29wasamasadrunk with power
07:29lodin_haha
07:30wasamasalooks like apply could solve that one
07:34lodin_crocket: I would guess that using into would be more efficient since it uses transients, but I don't have anything to support that.
08:30lodin_Ah. kv-reduce uses Java methods for built-in data types.
09:49kwladykaHow to write this code more beauty? https://www.refheap.com/52cb9e4cae3109242f39b4731
09:50kwladykai don't like the way how i use concat 3 times
09:53Lollypop_hey does anyone know if you can make spigot plugins with clojure?
10:41tgoossensI have no idea where the nullpointer comes from. https://gist.github.com/tgoossens/1c4506e7c36b4409fbe4 . When I manually execute thsis function step by step in reple no problem.
10:41tgoossensBUt when I run it
10:41tgoossens (.getTuple t key)
10:41tgoossensgives nil
10:41tgoossensis there a problem with using let in doseq or something,
10:52crockethi
10:54crocketCan I justok
10:54crocketIt seems I can load new clojure modules during runtime.
10:55crocketIf the current directory is in classpath, I put some .clj files in the classpath and let my program dynamically require them.
10:55crocketOr, I could use an integrated REPL to (require them)
10:56crocketBrilliant
11:05noncomwhat's the clojure way to get a base64 of a string?
11:12dstocktonnoncom: data.codec has an encode function https://github.com/clojure/data.codec/blob/master/src/main/clojure/clojure/data/codec/base64.clj#L230
11:12noncomyeah, well, ended up with this: https://github.com/xsc/base64-clj it is simpler...
11:12dstocktonor that, yes
11:13noncomi just thought it'd be present out-of-the-box, but no
11:13dstocktonyou could use some java interop
11:13noncomyeah, java :)
11:46Empperiit's not bad after java 8
11:46Empperiit has built in base64 encoding
11:47Empperisome javaisms though like you need to get an encoder first before you can encode
11:47Empperibut nothing terrible
11:56noncomEmpperi: yeah, but i thought, you know, like (one-word-fn-does-all-magic ...) like they wrap the java.io ...
11:57noncomi have a basic cli utility architecture question
11:57noncomsay, i am building a jar, and from the cli i want to be able to launch different fns from different nses
11:57noncomwhat is the best way to organize this?
11:57noncomcurrently i am passing something like "(my-ns/my-fn {args})" as the string arg and eval it
11:57noncommaybe there are better alternatives?
12:02justin_smithnoncom: use java -cp your.uber.jar clojure.main your.ns/your-fn
12:12noncomjustin_smith: alright, waht about apssing params? them just go next?
12:12noncomdo i write them in quotes like " ?
12:12justin_smithnoncom: hmm - I'm gonna have to experiment
12:12noncomwell, i think, i will experiment, since it's my task to realize this :D
12:13justin_smithnoncom: I'm also interested in knowing the answer
12:13noncomcool, then someone of us will do it faster.. i'll get to this today, when i finish the script
12:13noncomand upload it to the CI
12:13noncombtw, are you using any CI?
12:15justin_smithnoncom: java -cp your.uber.jar clojure.main "(require 'my.ns) (my.ns/foo \"some arg that is a string\" 1 :a)"
12:15noncomi've managed to push it to use clojure on our CI :D
12:15noncomoh, that
12:15justin_smithnoncom: CI? no, I should be
12:16justin_smithnoncom: yeah, I think unless your function is called -main, that's the one way to do it
12:16justin_smithif it is called -main, you can just pass the namespace name, followed by args (all will be passed as strings)
12:17justin_smithnoncom: I definitely do the "more than one ns has a -main" thing, to support different launch profiles
12:17noncomwell, my current way is java -jar myjar.jar "(my.ns/foo {argzz})" and i require the my.ns into the main ns beforehand ...
12:17noncomour approaches are similar
12:17justin_smithyes
12:18justin_smiththe -jar thing works? it doesn't just hand that string to your -main in your main ns?
12:33egogiraffequick question: was reading ch.6 in Joy of Clojure and punching in these lines of code for comparing rest vs. next into my repl, and i get, well, not what the book expects me to get. http://i.imgur.com/bpGJA6h.png book/repl side by side in the image.
12:35elvis4526Is it possible to use extend-protocol on a class, and all its derived classes ?
12:36elvis4526I used extended-protocol on the JSONWriter protocol with the java.lang.Exception class - is there a way that all derived class from Exception get the same implementation too ? (like PSQLException grr...)
12:38egogiraffethis is the second edition of the joy of clojure, as well, so perhaps, although i would find it a bit of a leap, that the mechanics of laziness behind rest & next changed at some point between publication and the current version of clojure? but i'm just spitballing, because it is still v. odd to me that there is that discrepency.
12:42danielpcoxegogiraffe: that's interesting. i just did it with clojure 1.6.0 and I get what the book expects
12:44egogiraffehm. i shall try it with 1.6.0 as well, and see what it returns for me.
12:44danielpcoxegogiraffe: and i get what you get when i retry it with 1.7.0
12:44noncomjustin_smith: yes, it does pass it into -main
12:44egogiraffemore interesting yet!
12:45noncomjustin_smith: there i just (-> args first read-string eval)
12:48egogiraffedanielpcox: yes, i get the expected results in 1.6.0 as well. given how recent 1.7.0 was, i thought it would be within the realm of possibility that it could have to do with versions.
12:49egogiraffei suppose i should send a mention of this to the authors, so that they can take a look at it and adjust/update accordingly.
12:50danielpcoxegogiraffe: good plan. I notice there's no difference in next's implementation: https://github.com/clojure/clojure/blob/clojure-1.6.0/src/jvm/clojure/lang/RT.java#L596 https://github.com/clojure/clojure/blob/clojure-1.7.0/src/jvm/clojure/lang/RT.java#L672
12:51puredangeriterate changed in 1.7
12:56danielpcoxpuredanger: that's interesting
12:57danielpcoxthanks
13:27divyaHey guys.
13:27divyawhy isnt this valid ?
13:27divya~(symbol (str "(function-name)"))
13:27clojurebotHuh?
13:31amalloydivya: why isn't ~5 valid?
13:32justin_smithnoncom: OK, so the difference is with the -cp version, you don't need a -main that calls eval
13:32noncomjustin_smith: turns out to be so!
13:33noncomdivya: what are you trying to do, anyway?
13:33noncomdivya: maybe you give us the full code and state your intent?
13:33divyai get your point. Do you see what i'm trying to do ? To construct fn names from a string and evaluate it in a macro. What's the best way to do that?
13:35noncomummm.. something like `(eval (list fn (symbol ~your-string) ~@body)) ?
13:35noncom(did not test)
13:35noncombut all in all that does not look like a good idea...
13:35noncomconsing fn names is almost never a good idea...
13:35justin_smithnoncom: you really shouldn't need eval in a macro
13:36noncomah, probably. there should be a better way
13:36justin_smith,(defmacro dontdothis [] (list (symbol (str "print" "ln")) "foo"))
13:36clojurebot#'sandbox/dontdothis
13:36justin_smith,(dontdothis)
13:36clojurebotfoo\n
13:37divyaYeah, I realise it's not a good idea. But I'm just trying to find a way around that.
13:38noncomyes, and justing right, macros always have an implicit eval
13:38noncom*justin, sorry :)
13:39justin_smith,(defmacro dont [s] (list (symbol s)))
13:39clojurebot#'sandbox/dont
13:39justin_smith,(dont "newline")
13:39clojurebot\n
13:40justin_smiththis is a terrible way to do things, it throws away nearly everything that is nice about clojure macros, and puts you back in the world of C macros.
13:41justin_smithwhat changed with newer ring versions such that endpoints returning a string cause the error "java.lang.String cannot be cast to java.util.Map" - older ring versions implicitly built a response map with the string under the :body key
13:41justin_smithwas this functionality moved into compojure or something?
13:42justin_smithI mean I can make my own middleware that does that based on the type of the thing returned, of course, but I wonder if the middleware still exists and was moved or what.
13:44amalloyjustin_smith: forget about terribleness, it just doesn't work because macros run at compile time and you don't have the avlue of this string until runtime
13:44divyaJustin: Thanks, just curious.
13:44justin_smithamalloy: ahh, that too - yeah it will totally break if the arg is not a string literal
13:44amalloyjustin_smith: do you perhaps have a middleware that expects a map before the point at which ring would have converted a string to a map?
13:45amalloy(and if the arg *is* a string literal then this entire exercise is pointless)
13:45justin_smithamalloy: stack trace is in http-kit, with the caller being a future
13:45justin_smithamalloy: true
13:46justin_smithamalloy: at org.httpkit.server.HttpHandler.run(RingHandler.java:91) - older ring versions turn a string into a map before we get this far
13:46amalloythe moral of the story is to never upgrade anything
13:46justin_smithit's an implicit conversion that isn't happening any more, changing ring versions changes the behavior (1.3.0 -> 1.3.2+)
13:47justin_smiththe version where the change happened makes me think it might not have been intentional...
13:48justin_smithamalloy: co-worker upgraded lib version (I assume he had a good reason...) he's on vacation now and things are broken on staging. Such is the life of a developer.
13:59gfrederickscan cljc be used in libraries without requiring users of the library to be on clojure 1.7?
13:59justin_smithgfredericks: checking my all-cljc uberjar to see inside right now...
14:00gfredericksI'm betting not
14:00justin_smithgfredericks: the jar task does not create any clj/cljs tasks here, only cljc source files end up in the jar
14:00justin_smithso yeah
14:00gfredericksso there's either a several year period where high-profile libs can't use cljc or we need another tool
14:01amalloywhat is this cljc thing
14:02gfredericksamalloy: https://github.com/clojure/clojure/blob/master/changes.md#22-reader-conditionals
14:03amalloyoh. it's cljx, blessed?
14:03justin_smithand simplified, yeah
14:04gfrederickswell cljx doesn't have the problem I'm bringing up though
14:04justin_smithgfredericks: why several year, because it will take that long before the rest of the world is using 1.7?
14:04gfredericksyeah
14:04justin_smithgfredericks: I bet we could make a lein-cljc plugin for generating backward compatible jars...
14:04gfredericksmaybe not, depends on your tolerance for forcing other people to upgrade
14:05gfredericksjustin_smith: by reading the cljc file in the appropriate way and then prning it back out?
14:05gfredericksI'm not sure if a lein plugin would work in my case since it's a contrib project
14:06justin_smithgfredericks: yeah, generating clj and cljs which would be after the cljc on the classpath
14:06justin_smithahh
14:09gfrederickshmm
14:09gfrederickswell actually
14:09gfredericksif the lein plugin or whatever spit things onto the filesystem instead of just into the jar
14:10gfredericksthat would probably be useable
14:10gfredericksI think you can have cljc/clj/cljs files all in the same jar
14:10gfredericksand 1.7 would load the cljc file and 1.6 would load the other files
14:11justin_smithgfredericks: right, that's kind of what I was thinking
14:11puredangerclj and cljs are loaded before cljc if both exist
14:11gfrederickswait
14:11gfredericksyes
14:11puredangerRegardless of classpath order
14:11gfredericksI just went to my gmail and typed "Alex Miller" into the search box in order to answer that question
14:11gfredericksbecause I knew it had come up recently
14:12gfrederickspuredanger: am I correct that there is a bit more tooling necessary to use cljc from a contrib library w/o requiring users to upgrade to 1.7?
14:12puredangerYeah, can't say that I thought about that enough
14:13puredangerAlthough I expected it to be adopted much more slowly
14:13gfredericksI'm thinking just something that reads each .cljc and spits out a .cljs and a .clj
14:13gfredericksand ship all three in the jar
14:13puredangerWhich is basically cljx
14:13gfredericksyep
14:13gfrederickswell
14:13puredangerIronic
14:13gfrederickspuredanger: I'm wondering for test.check
14:13gfrederickswhere I suspect cljx doesn't work?
14:14gfredericksI'm assuming hudson is only looking at the pom.xml
14:14puredangerYes
14:14gfredericksso the most practical thing would be to commit all the files
14:15puredangerAlthough I've been playing with a boot build for contrib (purely experimental right now)
14:16puredangerMixed platform builds in contrib are a mess, so that's gotta be fixed
14:17gfredericksright now we just have two copypasta'd source trees
14:18gfredericksso checking in generated files doesn't seem any worse than that
14:22gfredericksman just running tests with 1.6 is going to be difficult o_O
14:22gfrederickswas trying to decide if I should update the generated files on each commit or just before a release :/
14:37TimMcIt's 2015 and we still don't have a good way of handling generated code.
14:54wasamasasweep it under the rug?
15:00noncomwe still don't have many things
15:12justin_smithgfredericks: what about generating files as a pre-action for making the jar, not checking them into git, and making a test runner that operates on the jar rather than the source for 1.6? I guess that's kind of weird.
15:13gfredericksjustin_smith: the building-the-jar part still needs to be compatible with lein-free-hudson
15:13justin_smithahh - but it could require 1.7 right?
15:13gfredericksI guess...?
15:14justin_smithI'm thinking if the build task was abstracted so it could run without lein. But that's probably a pointless rabbithole.
15:15gfredericksand then call out to something from maven?
15:15justin_smithYeah. But that's probably more trouble than all this is worth, the more I think about it.
15:16gfredericksI dunno, could be less hacky than anything else I was thinking of
15:17justin_smithlike, if all it took was a read+spit using 1.7 for each cljc file to a new clj file - that could as easily be invoked by a maven task by loading your clojure dep as it could be by lein I guess?
15:17gfredericksright
15:43gfrederickswhat is the goodest way to run tests for a cljs lib that has nothing to do with browsers/dom?
15:43gfredericksin terms of js runtimes
15:59justin_smithoh my god logging library dep collisions are terrible
15:59justin_smithyuck
16:00gfredericksyay logging libraries!
16:00gfredericksor more accurately, yay, logging from libraries!
16:01justin_smithgfredericks: if libraries that aren't for logging stopped depending on concrete logger implementations, this could be avoided
16:01justin_smithmaybe?? I hope.
16:03gfredericksI'd like to think that but I like structured logging
16:03gfredericksand none of the abstract libraries seem to support that
16:03justin_smithgfredericks: ugh.
16:03gfredericksmaybe we need yet another proxy library
16:04gfredericksso your library logs to log-cabin which at runtime proxies to clojure.tools.logging which at runtime proxies to slf4j which proxies to logback
16:04justin_smithgfredericks: could call it yalp - yet another logging proxy
16:04gfredericksI was thinking log-cabin because it's structured
16:04gfredericksmaybe just cabin?
16:05justin_smithwhelp - well heres _ logging proxy
16:05justin_smithwhere _ starts with e and makes sense
16:05TimMce is for underscorE
16:05gfrederickswhy not just whalp
16:05justin_smithgfredericks: that works too
16:06oddcullygwargl -- the sound you make the last time you had to deal with loggin stuff
16:06TimMcwelp - we excrete logging proxies
16:07TimMc(Please don't use that.)
16:07justin_smith¯\_(ツ)_/¯ - ¯oggers \ucking _uck (ut ツe )ade _nother /hat ¯ver
16:10gfredericksI wonder if tools.logging would ever support structured logs
16:10gfredericksthere's probably a lot of gross design questions
16:12gfredericksmostly related to how it interacts with the impl libs -- i.e., does it serialize before or after?
16:12gfredericksit's all terrible
16:12justin_smithgfredericks: the hard part is we want features that the old API can't provide, and the old API is made worse by the long list of half-assed improvements that didn't fix things (partially due to their attempts to be compatible with the original)
16:12justin_smithwhich makes me think "burn it all down"
16:13gfredericksyou'll still have to deal with other people's libraries using slf4j or something
16:13justin_smithright, yeah
16:13gfredericksthough we could implement the slf4j api I guess?
16:13xemdetiaclojure 1.8.0 now with 4j based logging in core
16:13justin_smithxemdetia: at least that way we could just pick something I guess
16:16redcoatOkay, so something Rich Hickey said in a talk finally clicked with me
16:18redcoatI was discussing STM with someone and how one would implement that for quite sizable data structures in a language without it. They mentioned that compare and swap wasn't the only necessary component; you would also need a write logging mechanism for the retries, and that makes sense to me.
16:18redcoatSo that's quite a lot of machinery. But then I remembered what Rich Hickey said about functional data structures: if you use them, then STM only needs to do a single compare and swap on the pointer.
16:20redcoatAnd if the operations in your atomic block are pure functions, then you're guaranteed to have operationally valid retries. Am I correct in what I'm saying?
16:22amalloythat is certainly true for atoms. for multi-object transactions on refs or something, i think you need a bit more but i'm not sure what
16:23gfrederickspeople so rarely use the stm with multiple refs though
16:23gfredericksis cljs broken with clojure 1.7?
16:24gfredericksI'm getting "Wrong number of args (2) passed to: reader/read" from the cljs.analyzer namespace
16:24gfredericksit's probably something else
16:25justin_smithhmm, I thought atoms weren't STM? could be I'm misinformed and I am forgetting my source
16:26amalloythey're not
16:26amalloyfolks just usually don't distinguish between them
16:26justin_smithso only refs are STM, atoms and agents are their own things separate from that, right?
16:27amalloyno, refs and agents
16:27gfrederickswith agents you can send things from a transaction and only have it really sent if the transaction completes
16:27justin_smiththanks for clarifying. I was going by the fact that clojure.org/refs did not mention agents at all
16:27justin_smithaha
16:29Bronsagfredericks: that usually means you're pulling an older version of tools.reader than the one cljs needs
16:29gfredericksBronsa: yeah that was it
16:29gfredericksmy good ole user profile
16:34gfredericksI'm re-pondering rich numeric literals in cljs
16:35gfredericksmy guess is there's still not a good way to do that
16:36gfrederickseven with data readers
17:10ed-gHello, does anyone have experience with sending vector data to a database, either as a set or a Postgres array object? I'm using clj-postgresql and attempting to use PGobject with type "anyarray", the postgres driver doesn't like it.
17:10gfredericksed-g: I've done the postgres array thing with integer vectors
17:11gfredericksI don't know anything about clj-postgresql though, I was just using java.jdbc
17:11ed-ggfredericks, is any of your code open source? I'm trying to pose an intelligent question but I don't know enough context with java databases so it feels like I'm going in circles.
17:12gfredericksI think I did it by extending the SQLValue protocol in java.jdbc
17:12gfredericksand maybe manually creating the sql syntax for an array
17:12gfredericksit's not open source
17:13ed-ggfredericks, thanks :-) I'll look into the SQLValue protocol
17:13ed-g(inc gfredericks)
17:13lazybot⇒ 140
17:27sobeled-g: i did this in a sandbox project, and it was pretty easy given a quick google search. it takes like 1-2 lines of code to add the protocol for arrays.
17:27sobeli'd share but it's at home. it was easy though.
17:32ed-gsobel, that's encouraging
17:33gfredericksed-g: reading the clojure.java.jdbc source is pretty instructive
17:36sobeli know jdbc from experience but have never had a book on it. the web got me through easily.
17:36ed-gyeah wish I could say the same, I've been working on this for two days now
17:37ed-ggfredericks, thanks I'll check that out
17:37ed-g(inc sobel)
17:37lazybot⇒ 2
17:37sobelhttp://stackoverflow.com/questions/22959804/inserting-postgresql-arrays-with-clojure
17:37gfredericksdnolen: the clojure.test vs. cljs.test naming convention would somewhat preclude eventually using cljc in test.check, wouldn't it?
17:37sobelwas the page that helped me, actually
17:38dnolengfredericks: I don't how
17:38dnolener
17:38dnolen"I don't see how"
17:38dnolengfredericks: conditional reading can happen anywhere including ns forms.
17:39gfredericksdnolen: but the filenames can't vary
17:40dnolengfredericks: you're not saying anything that makes any sense to me yet.
17:40gfredericksdnolen: I'm talking about the test.check codebase, not a user's codebase
17:40dnolengfredericks: still not making any sense
17:40gfredericksso currently it has two code trees
17:40gfrederickswith mostly pasted code
17:41gfredericksand I figured merging those into .cljc files would eventually eliminate the copypasta
17:41gfredericksbut doing (ns #?(:clj clojure.test.check :cljs cljs.test.check)) seems problematic
17:41dnolengfredericks: just pick the same alias ... done
17:42gfredericksbecause the file can't be at .../clojure/test/check.cljc AND .../cljs/test/check.cljc
17:42dnolengfredericks: for imports
17:42dnolengfredericks: for the main namespace itself you have to be OK with a breaking change.
17:42dnolenbut this is a search replace
17:42gfredericksyou mean renaming cljs.test.check => clojure.test.check?
17:42dnolenso IMO not a big deal
17:42dnolenyeah, why not?
17:43gfredericksit's fine with me, I wasn't sure how opinionated of a convention "cljs.test[....]" was
17:43gfrederickswhich is why I'm asking you since I figured you came up with it :)
17:43gfredericksbut it sounds like you don't think it is a big deal from an ecosystem cohesiveness standpoint
17:44gfredericksso I will plan on namespace-changing being an option
17:44dnolengfredericks: could have been same since the file extension is the differentiator
17:44gfredericksright
17:44dnolenbut there wasn't a deep reason
17:45gfredericksdnolen: cool, thanks
17:46dnolengfredericks: the only thing to be careful of is that test.check was written in a bit of a clean Haskell-ish style, lots of partial and comp instead of #(foo ...)
17:46dnolenin ClojureScript I made a bunch of smaller minor changes to remove that to get 10X perf bump.
17:46gfredericksoooh gotcha
17:46dnolenso you will regress perf (which currently is in the Clojure ballpark) if you're not careful.
17:47ed-gsobel, thanks! that stack overflow pointed me in the right direction.
17:47gfredericksdnolen: time to write some macros for partial and comp maybe :)
17:48wits_endI'm trying to get lwjgl3 working but am stuck with UnsatisfiedLinkError and could use a nudge. Has anyone gotten it to work since being released to Maven? Or able to give me a clue on what I'm doing wrong with the path?
17:48gfredericksdnolen: how did you do your perf testing?
17:49dnolengfredericks: test.check is slow
17:49gfredericksI'm hoping to port the RNG soon so that will be relevant
17:49dnoleneverything serious is measured in seconds already
17:49dnolenso just ran it's own tests
17:49dnolenand timed that
17:49gfredericksoh right I need to figure out how to run its own test suite first :)
17:50dnolengfredericks: there's really nothing to do. lein cljsbuild once test-build-id
17:50dnolenas long as you have Node.js installed, that's it
17:51gfredericksdnolen: okay thanks
17:51dnolengfredericks: np!
18:04ed-gOk one more dumb question. How do I create a java array of boxed integers? (make-array Integer/type [1 2 3]) is type [I when what I want is array of java.lang.Integer's
18:06ed-gnever mind. object-array is what I need. Thanks everyone for all the help today!
18:06gfredericks,(type (make-array Integer [1 2 3]))
18:06clojurebot#error {\n :cause "clojure.lang.PersistentVector cannot be cast to java.lang.Character"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentVector cannot be cast to java.lang.Character"\n :at [clojure.lang.RT intCast "RT.java" 1163]}]\n :trace\n [[clojure.lang.RT intCast "RT.java" 1163]\n [clojure.core$make_array invoke "core.clj" 3839]\n [sandbox$eval25 invoke "...
18:07gfrederickswhat
18:07amalloygfredericks: it's not into-array
18:07gfredericks,(type (into-array Integer [1 2 3]))
18:07clojurebot#error {\n :cause "array element type mismatch"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "array element type mismatch"\n :at [java.lang.reflect.Array set "Array.java" -2]}]\n :trace\n [[java.lang.reflect.Array set "Array.java" -2]\n [clojure.lang.RT seqToTypedArray "RT.java" 1719]\n [clojure.core$into_array invoke "core.clj" 3319]\n [sandbox$eval49 invoke "NO_SOURCE_FI...
18:07amalloyand of course 1 is a Long
18:07gfrederickswhatever
18:07ed-ggfredericks, I ended up with #(object-array (map int %))
18:08gfredericks,(type (into-array Integer (map int [1 2 3])))
18:08clojurebot[Ljava.lang.Integer;
18:08amalloyed-g: that's an Object[] though
18:08amalloyjust replace object-array with into-array
18:09ed-gamalloy, ok my grasp of JVM is tenuous. I thought I wanted boxed integer but what I actually wanted was array of objects each of which is integer. This fits the protocol for jdbc .createArrayOf
18:11ed-g(inc amalloy)
18:11lazybot⇒ 288
18:11ed-g(inc gfredericks)
18:11lazybot⇒ 141
18:11gfredericksis `lein test` broken for cljc test files?
18:17gfrederickshow do you refer macros in cljs?
18:18amalloygfredericks: require-macros with :refer, i'd guess?
18:18gfredericksthat's what I thought too :/
18:18gfrederickswait
18:18gfredericksI Mean
18:18gfredericksI used
18:19gfredericks(:require [thing] :refer [what] :include-macros true)
18:19gfredericksI didn't actually try (:require-macros ...)
18:25dnolengfredericks: :include-macros just loads a macro ns with the same name, it interacts in no other way with :require
18:26dnolengfredericks: you want :require-macros + :refer
18:27dnolengfredericks: well "interacts in no other way with :require" beyond :as support.
18:31gfredericksdnolen: cool, thanks
18:45justin_smithoh wow, how did it take me this long to discover this: ##(let [{:keys {a b c d}} {:a 0 :b 1 :c 2 :d 3}] (print a b c d))
18:45lazybot⇒ nil nil nil nilnil
18:45justin_smithLOL
18:46justin_smiththe awesome thing is that it somehow makes sure a,b,c,d are all valid for access, but also they are all just nil
18:47TimMcjustin_smith: That was a short walk and I'm not sure what you're talking about.
18:47justin_smithTimMc: ##(let [{:keys {a b c d}} {:a 0 :b 1 :c 2 :d 3}] (print a b c d))
18:47lazybot⇒ nil nil nil nilnil
18:48TimMcjustin_smith: Do you mean [a b c d]?
18:54justin_smithTimMc: I destructured, I used the wrong kind of brackets, instead of getting any sort of sensible error it just bound all my keys to nil
18:54justin_smithTimMc: leading to a lot of head scratching and shotgun debugging
18:55justin_smithTimMc: if I had seen the code and read it carefully, I would not have expected b and d to be bound to anything, and I would have been dubious about it running at all
18:55justin_smith*compiling
19:14TimMcjustin_smith: Ah! I see, you're marvelling that it didn't error out.
19:14justin_smithright
19:15justin_smiththe fact that it happily gives me nil so my usage of all those bindings fails...
19:15justin_smithit must tree-walk to find all the bindings in the destructure or something?
19:16TimMcnothing so fancy
19:16TimMc&(destructure '[{:keys {AAAAA BBBBB}} _])
19:16lazybot⇒ [map__13793 _ map__13793 (if (clojure.core/seq? map__13793) (clojure.lang.PersistentHashMap/create (clojure.core/seq map__13793)) map__13793) vec__13794 (clojure.core/get map__13793 :[AAAAA BBBBB]) AAAAA (clojure.core/nth vec__13794 0 nil) BBBBB (clojure.core/nth vec__13794 1 nil)]
19:17TimMc&:[AAAAA BBBBB]
19:17lazybotjava.lang.RuntimeException: Invalid token: :
19:17TimMc&':[AAAAA BBBBB]
19:17lazybotjava.lang.RuntimeException: Invalid token: :
19:17TimMcOooh, ##(keyword '[AAAAA BBBBB])
19:17lazybot⇒ nil
19:18TimMcwhat is it even
19:19justin_smith,(let [{:keys {a b}}] {(keyword (str '[a b])) 42}] #_#_ now what)
19:19clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>
19:19TimMcSome part of that macro knows that [AAAAA BBBBB] is a vector, and some part fails to understand that. :-)
19:20justin_smithan oddity
19:20justin_smithwould be a fun trick for an obfuscated clojure contest
19:20TimMc&(let [{:keys {AAAAA BBBBB}} {(keyword "[AAAAA BBBBB]") [5 6]}] AAAAA)
19:20lazybot⇒ 5
19:20justin_smithhahaha, of course
19:24TimMcIt's that (if (keyword? %) % (keyword (str %)))
19:28TimMcSo it *extracts* the value by keywordizing the LHS, but it then looks at the LHS and sees that it needs to do further destructuring.
19:30justin_smithhow babby wat is formd
20:53rpauloclojure on my iOS device!
21:06mfikesrpaulo: Yeah, you can't really tell it is ClojureScript for most stuff.
21:11rpauloI also dislike Rich's commit messages, but what can I do...
21:19lvhHuh. Does unquote-splice inside syntax-quote qualify all syms with clojure.core?
21:20lvhI have a test fixture macro, and it's complaining that it can't find shrieker.fixtures/is
21:20lvherr, sorry, qualify all syms with *the macro's ns*
21:21justin_smithlvh: that's what syntax-quote is for
21:21lvhjustin_smith: But the `is` is being spliced in; not part of the macro
21:22justin_smithyou can pull dirty tricks if you don't want that like ~'foo, or you can just not use syntax-quote
21:22lvh`is` is a thing in the calling namespace
21:22justin_smithlvh: then you should be properly interning is (I assume test/is)
21:23lvhEh, okay; I'll do without the syntax quote then
21:23justin_smithlvh: you can use syntax quote, if you :use clojure.test, or :require clojure.test :refer [is]
21:23lvhjustin_smith: In the calling namespace?
21:24lvhI'm already doing :refer :all there
21:24justin_smithlvh: in the namespace defining the macro, if you want to call is in the macro
21:24lvhjustin_smith: `is` is inside the body I'm unquote-splicing into the macro
21:25justin_smithlvh: in that case you need to require / refer it in the namespace using the macro, yes
21:25lvhjustin_smith: hm, adding it to the *defining* ns fixed the error
21:26lvhoh, *derp*
21:26justin_smith?
21:26lvhOK, so I do remember how syntax quote works
21:26lvhI just forgot that I am actually using is in the macro...
21:26lvhand, it previously worked because I moved the macro around
21:26lvhyay global state
21:27lvhjustin_smith: Sorry & thanks :)
21:27lvh(inc justin_smith)
21:27lazybot⇒ 278
21:30creeseI'm trying to create a leiningen template and hitting a snag.
23:09crocketAre there traps in dynamically requiring a clojure namespace?
23:09justin_smithcrocket: you can call require at runtime
23:11crocketjustin_smith, Does a standalone uberjar include the current directory in the classpath?
23:11crocketAh, that depends on how I invoke java.
23:12crocketIf I include a specific directory in the classpath, I'll be able to load clojure plugins dynamically on runtime.
23:12crocketCan I remove a namespace after loading?
23:14crocketAh, there is remove-ns function.
23:14crocketBe careful
23:14crocketTo emulate a plugin system, is it sane to include a directory in the classpath and require a namespace from that directory and remove the namespace later?
23:20crocketDoes require compile .clj files during runtime?
23:23justin_smithcrocket: yes, clojure always compiles files if you load them.
23:24justin_smithif you want to load a specific file, you might want load-file rather than require
23:24justin_smithfor require to work, the file has to be on a relative path matching the ns
23:24crocketjustin_smith, I created a .clj file after cider REPL launched and required it to see an e rror.
23:25crocketDoes the namespace in a .cljfile have to match 'path.to.file.filename'?
23:26justin_smithyes
23:26justin_smiththat's what I just said
23:26justin_smiththat's why you probably want load-file
23:30crocketjustin_smith, The file is on a relative path matching the ns.
23:30crocketOuch
23:30crocketrequire failed because there was a typo in my .clj file.
23:30justin_smith:reload is your friend here, of course
23:31justin_smithbut if what you explicitly want is to load a specific file at runtime, load-file might match that better anyway
23:31justin_smithif you used something like ScriptEngine with cljs you'd also get sandboxing etc., dunno if any of that matters. Clojure code can do wonky things to the vm / clojure itself.
23:32crocketIt's weird
23:32crocket(require 'clojure-test.oho) returns nil without an error, but there is no actual clojure-test.oho namespace.
23:33justin_smithcrocket: if you don't specify :reload, and it has already tried to load the ns, it will keep returning nil if you require it
23:34justin_smithwhether it worked the first time, or not
23:34crocketga
23:34justin_smithtry (require 'clojure-test.oho :reload)
23:34justin_smithor you could just use load-file
23:34crocketok
23:35crocket:reload
23:35crocket:reload is ok
23:38crocketIt seems require and load-file evaluates .clj files without actually changing the current namespace.
23:38justin_smithyes, that's true
23:38justin_smiththe namespace is changed while code from that file is loaded, and should remain the same in your repl
23:38justin_smiththe namespace isn't changed if the file doesn't do anything to change the ns though
23:40crocketjustin_smith, Each file calls (ns) at the top.
23:40crocketCalling (ns) in REPL changes the current namespace.
23:40justin_smithyes, it's different when evaluating files
23:41crocketI thought load-file would act as if everything in a file was invoked in REPL.
23:41crocket,(doc load-file)
23:41clojurebot"([name]); Sequentially read and evaluate the set of forms contained in the file."
23:41crocketThe explanation was misleading.
23:42crocketProbably, load-file and require remember *ns* and restore it after they finish.
23:43crocketThis is great
23:43crocketjustin_smith, Have you ever implemented a clojure script module system in any clojure program?
23:50justin_smithcrocket: no, but I don't do the kind of code where I would ever trust a user to load source files
23:50justin_smithwell except for some hacking I did on lazybot that is
23:51crocketok
23:51crocketjustin_smith, So, you need a sand-boxed plugin environment.
23:51justin_smithI don't think I need one, though lazybot does have one (had one before I worked on it)
23:51justin_smithI don't need users to load code at all ideally
23:52crocketjustin_smith, hexchat has a plugin system.
23:52crocketIt would be fascinating to add clojure scripting capability to hexchat.
23:52crocketAlthough hexchat is written in C or C++.
23:54justin_smithso you also need to load a jvm...
23:54crocketI'll probably try to embed pixie.
23:55crocketPixie is clojure on native platforms.
23:55crocketIt is close to clojure.