#clojure logs

2015-01-29

00:33DraggorAm I missing something? How do I make the lein script not download clojure every time.
00:35amalloyit will only download clojure if the project you're building requires a version of clojure that you don't already have downloaded
00:40DraggorHow do I install clojure so that lein sees it? I've got the zip downloaded and extracted.
00:40Draggorlinux platform
00:41rhg135It downloads it from maven central
00:43DraggorI get that, but it seems to do it every time I issue a lein command.
00:44rhg135Is ~/.m2 there?
00:44DraggorYep
00:44Draggorhow long should it take to get into lein repl?
00:45rhg135~1s for me
00:45clojurebotI don't understand.
00:46DraggorAbout 6s here.
01:16amalloyDraggor: are you inside a lein project when `lein repl` appears to download clojure? if so, can you gist its project.clj?
01:19Draggoramalloy: So it seems to not be downloading it, but still has a very slow startup time of 6 seconds when I'm inside of a lein project.
01:21Draggoror apparently longer, that one was 15s
01:21amalloylein's startup time is legit pretty terrible. there are some things you can do to speed it up, but also you don't have to start lein very often; you can leave a repl or an nrepl session up for a long time
01:23amalloylike i start up lein repl ~never (i use an emacs interaction plugin instead). the emacs plugin takes a silly amount of time to start too, but i only start it once or twice a day and then live in it for the rest of the day, so that awfulness is not such a big deal
01:26mgaareyou can also use this https://github.com/ninjudd/drip
01:26DraggorI'm poking at getting vim + fireplace going
01:27DraggorThe documentation for it all is not the best I suppose.
01:32amalloyvim is fine
01:33amalloyif you prefer vim to emacs, you don't need to switch just to use clojure
01:39Draggoramalloy: well, in terms of getting a slime like thing going, one of this is clearly way more effort than the other, heh.
01:39amalloywhich one?
01:40Draggorvim + fireplace and the rest
01:41wgwgzsdfwe,(.shiftLeft 2 (biginteger 8))
01:41clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: shiftLeft for class java.lang.Long>
01:41wgwgzsdfweThis once worked.
01:48wgwgzsdfwe,(.shiftLeft (biginteger 8) 2)
01:48clojurebot32
01:48wgwgzsdfweOopsies.
01:54DraggorWhere did I put all my old clojure projects... How hard is upgrading from around 1.0.0 to current?
02:02sm0kenever heard someone using 1.0.0
02:03sm0kewow must be very old
02:14devnDraggor: It's not the end of the world.
02:14devnDraggor: why do you need to upgrade?
02:14devnI realize you want to, just asking why you *need* to.
02:15devnA particular library, new development on the project, just making it work?
02:19clj123What is the best way to concat more than 2 lists for eg. ['a' 'b' 'c'] + ['d' 'e' 'f'] + ['g' 'h' 'i'] => ['a' 'b' 'c' 'd' 'e' 'f' 'g' 'h' 'i']
02:30bucketh3adclj123: concat takes more than one argument, so that should work just fine
02:31ianhedoesit,(into [] (concat [\a \b \c] [\d \e \f] [\g \h \i]))
02:31clojurebot[\a \b \c \d \e ...]
02:32ianhedoesit,(into [] (concat ['a' 'b' 'c'] ['d' 'e' 'f'] ['g' 'h' 'i']))
02:32clojurebot[a' b' c' d' e' ...]
02:33ianhedoesitclj123: note that the quote is not used as a character literal
02:33clj123ok thanks
02:34clj123should have been double quote. clojure treats single quote differently
02:35ianhedoesitwhen trying to run my tests (`lein test` or `lein midje`), I'm getting a 'FileNotFoundException: Could not locate <project>/handler__init.class or <project>/handler.clj on classpath: , compiling:(<project>/core/handler_test.clj:1:1)'
02:36ianhedoesitI can't figure out what is different about this project vs the last project I had which works fine and runs tests fine. the structure is the same as far as I can see.
02:38Draggordevn: no real reason, I just haven't tried running the old code with the latest version.
02:47ianhedoesitnever mind me. I made a silly mistake.
03:39Emppericfleming: debugging works again, at least mostly. let values are not shown and evaluate expression is broken
03:41cflemingEmpperi: When you say let values are not shown, what do you mean?
03:41cflemingEmpperi: Which version of IntelliJ are you using?
03:42Empperi14, latest
03:42Empperijust updated today
03:43Empperiand I mean that they are not shown in the debugger as values
03:43Empperionly function parameter values are
03:43Empperisame problem with custom macro parameters
03:43Empperithat I kinda understand though
03:43Empperibut the thing I'm missing most is the evaluate expression
03:44EmpperiI want to stop the execution to specific point, then evaluate some expressions when the application is in certain state
03:44Empperieg. right now I have a bug in my code which integration tests showed
03:44Empperibut for it to happen my database has to be in certain state
03:44Empperiwhich my tests do initialize
03:45Empperinow, when evaluate expression worked all I had to do was to place a breakpoint to certain part of my code, then when the execution stops I could query the state of the database via evaluate expression
03:45Empperisince the tests use in-memory H2 there would be all kinds of hassle to make it persistent
03:46Empperican be done, but would be so much easier :)
03:46cflemingEmpperi: So evaluate expression should work in 0.1.44. Do you get any exceptions in the log when you try it?
03:47Emppericfleming: no, I can evaluate a single value but not a clojure expression
03:47Empperiit doesn't show the clojure logo in the evaluate expression window which I think it did before
03:47Empperiit seems to be an ordinary java expression evaluation
03:48cflemingEmpperi: I use it myself, it works fine for me. Let values should be shown, but there's one issue - if the value you want is closed over (i.e. you're in an anonymous fn of some kind) they will be shown as fields on 'this'
03:48Empperiwell, not showing here :(
03:48cflemingEmpperi: If that's not the case, can you send a screenshot of the locals view?
03:48EmpperiI'm kinda used to checking the value of this by now
03:48Empperisure
03:48cflemingActually, of the locals view and the code around the stopped line.
03:49cflemingWhen you try to evaluate a Clojure expression, what happens? Do you get an error?
03:49Empperiyes
03:50Empperieg it breaks on foo-bar at -
03:50Empperiwhich would indicate it's using java evaluation
03:50cflemingEmpperi: Yeah, it might be getting confused about the context somehow.
03:51cflemingEmpperi: I'm trying to fix some bugs in expr eval in 13.1, but 14 has always worked well so far. Interestingly, the 13.1 bug is that it seems to be using a Java context - might be the same bug
03:51cflemingEmpperi: I do see the Clojure icon by the eval text field though
03:53Empperinot here :/
03:54Emppericfleming: sent mail
03:55Empperiidea says plugin version is 0.1.44
03:55cflemingEmpperi: Thanks - you're stopped at the line marked in red there?
03:55Empperiyes
03:56cflemingEmpperi: That is very strange. Is this a work project? Can you send it to me so I can try to reproduce?
03:57Empperiunfortunately yes, this is a work project
03:57cflemingEmpperi: If not, I'll try to fix the 13.1 bug, since that might actually be the same cause.
03:57cflemingOk
03:57Empperiso can't send the source code
03:57cflemingWhen I have this other bug fixed I'll send you a build to try to see if it fixes your problem.
03:57Empperinice
03:58cflemingEmpperi: If you keep stepping in from that line, do you ever see the locals appear?
03:59Empperisometimes
03:59Empperibut only in function parameters
03:59Empperinever with let locals
03:59cflemingEmpperi: See, there's a problem - JDI debugging is line based. So there's at least three points that you might be stopped on at that line - update-in, map, or fn
03:59Empperibut I can access all of them from evaluate expression just by typing the name
03:59Empperibut can't type clojure code there
04:00cflemingEmpperi: That is really weird, I have no idea how that's working
04:00Empperiand yeah, I've already got used to having to keep stepping several steps forward before I get my locals in view
04:00Empperithis used to work just fine
04:00cflemingEmpperi: You get all the weird ones :/
04:00Empperihehe, sorry for being such a pain in the ass :)
04:01cflemingEmpperi: Hehe, no worries - hopefully this other bug will turn out to be the same
04:01Empperiwould be nice :)
04:01cflemingIf I'm lucky I'll get that fixed tonight - will let you know
04:01Empperibut anyway, I have this problem both on windows and mac
04:01cflemingOk, thanks
04:01Empperiso this time it's not operating system related
04:01cflemingI've been working on the other one this afternoon, I might have to consult JetBrains on this one
04:02Empperino worries, you're doing a great job
04:02Empperiand even more awesome I have this direct feedback link to you :D
04:03Emppericfleming: oh, btw the exact Idea version number is 14.0.3
04:04cflemingEmpperi: Ok, thanks. It mostly matters whether it's 13.1 or 14, since in 14 they changed a bunch of stuff in the debugger
04:04Empperiyeah, the debugger worked fine in 13.1
04:05Empperiat least as far as I remember
04:05Empperibeen using 14 since it came out
04:06cflemingEmpperi: Well, the debugger got broken in Cursive, in 0.1.43, then I fixed it up for 0.1.44. For almost everyone it's now way better than it was :)
04:07Emppericfleming: :)
04:07cflemingEmpperi: Looking at your screenshot, it's executing update-in since your top thread frame is still mark-double-xmls, not some anonymous fn
04:09cflemingEmpperi: You're not doing anything that would change bytecode, right? A JVM agent or anything like that?
04:09Empperino
04:09Empperithis is just plain ol' clojure
04:09cflemingEmpperi: Because the locals display is all IntelliJ, I actually want to change that but I can't
04:09Empperirunning on top of http-kit normally, but in this case through clojure.test
04:10Empperiopened a repl via leiningen
04:10cflemingSo if it's not showing the locals, it's because IntelliJ isn't finding them in the stack frame context
04:10Empperidirectly from idea
04:10cflemingI don't get to do anything till long after that
04:10Empperiso no remote connections or such things from terminal launced lein
04:11Empperithen I just execute the tests from the active namespace to repl
04:11Empperiand debugger gets caught but doesn't show anything
04:15m00nlight_What's the right way for an require library to access its own resource file? I can do it in the library's repl, but when I use the library in another project, it report an "Not a file" error of the resource file
04:15m00nlight_I use the io/resource to access the file under "resources/" directory
04:20tomjackm00nlight_: you're trying something like: file at project-a/resources/foo/bar.txt, then in project-b, (io/resource "foo/bar.txt") ?
04:21m00nlight_tomjack: No, in fact, I only require the library, the library itself will need the "resources/file.dict" of its own
04:22m00nlight_tomjack: but when I require the file in another project, it report an error like "Not a file: jar:file:/home/m00nlight/.m2/repository/clj-cn-mmseg/clj-cn-mmseg/0.1.2/clj-cn-mmseg-0.1.2.jar!/CNCharacter.freq, compiling:"
04:23m00nlight_I use (io/file (io/resource "file.freq")) in the library code, I want to know is it the right way?
04:25tomjackwhat do you want to do with the file?
04:25tomjackyou're not going to be able to call io/file on that
04:26m00nlight_It's just an dictionary for language processing
04:26m00nlight_so only (io/resource "file.dict"), you mean?
04:27tomjackright
04:28clgvm00nlight_: you can open inputstreams from URLs returned by io/resource
04:28tomjackyou can e.g. (slurp (io/resource path))
04:28tomjackor, yeah, (io/input-stream (io/resource path))
04:28tomjack(io/reader (io/resource path))
04:29m00nlight_So maybe the doc here https://clojuredocs.org/clojure.java.io/resource need update?
04:29m00nlight_What's the difference? Why use io/file will cause not a file error on another project?
04:29tomjackyes, that's a bad example
04:29clgvm00nlight_: more use cases could be added, but it is not wrong
04:29tomjackwell, sure
04:30tomjackbut say you uberjar and run in production
04:30tomjackboom?
04:30clgvthe use of a global var for the file is horrible anyway
04:32tomjackm00nlight_: the difference is that, in the example, it is assumed that "hello.txt" is on the classpath because you're inside the project, and the project's files on the filesystem are directly on your classpath
04:32tomjackso io/resource will return a file:/ URL, from which the path can be extracted to get a File
04:33tomjackbut e.g. (io/resource "clojure/core.clj") will return a jar:file:/ URL, which a File can't represent
04:34eglitomjack: so how do I pack schema files that I need for schema validation. Can't I put them in resources?
04:35tomjackyou can
04:35eglitomjack: you are saying that (StreamSource. (io/file (io/resource schema))) is not going to work in an uberjar?
04:35tomjackright
04:36tomjackuse (StreamSource. (io/input-stream (io/resource schema))) or (StreamSource. (io/reader (io/resource schema))) I guess
04:36m00nlight_tomjack: (slurp (io/resource "file.dict")) also work, right?
04:37eglitomjack: thanks, I'll try that
04:38tomjack,(apply str (take 30 (slurp (clojure.java.io/resource "clojure/core.clj"))))
04:38clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil>
04:38tomjackshucks
04:38tomjackit should work for you :)
04:39m00nlight_tomjack: Thanks a lot, I will try it
04:53m00nlight_tomjack: Solved, Much thanks
04:53clj123what is the purpose of '@' in clojure. While using one http lib I see code like (:status @response) (:body @response). When I try using '@' using a test hash table it doesn't work.
04:54sm0keclj123: ##(doc deref)
04:54lazybot⇒ ------------------------- clojure.core/deref ([ref] [ref timeout-ms timeout-val]) Also reader macro: @ref/@agent/@var/@atom/@delay/@future/@promise. Within a transaction, returns the in-transaction-value of ref, else returns the most-recently-committed value of... https://www.refheap.com/96621
04:54sm0keclj123: it is applicable only on @ref/@agent/@var/@atom/@delay/@future/@promise
04:55sm0keyou cant do ## @{:a 1}
04:55lazybotjava.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.concurrent.Future
04:55sm0kejust a ## (:a {:a 1}) ; should be enough
04:55lazybot⇒ 1
04:56clgvclj123: as long as you getting started and are not learning about atoms/refs/etc... just forget about @ ;)
04:58sm0kehow do i `install` test namespaces?
04:58clj123I see. thanks.
04:58sm0ke#leiningen is out of my timezone it seems
04:58sm0kegrrr time
04:58clgvhuh?
04:59clgvsm0ke: you want to load a test namespace?
04:59sm0keclgv: well i want to be able to use it from a different project
04:59sm0keclgv: mainly some utils namespaces in test
04:59clgvsm0ke: make it separate lib that is in the :dev dependencies
04:59sm0keregular helper functions for test i wrote, not (deftest..) etc
05:00clgvsm0ke: other approaches will be hacks.
05:00sm0kewth
05:01sm0kecant i force lein to do that?
05:01clgvone of these hacks: you could have the "test" directory as additional "source" directory instead of a test directory
05:01clgvor a third source directory "test-utils"
05:02clgvi.e. source dirs "src", "test-utils" and test dir "test"
05:03sm0kehurmm can i add a single file to source? let me check the epic sample lein project.clj
05:03clgvbut the separate lib is probably the best choice since you will be wanting those tools in other projects as well
05:03clgvsm0ke: nope. you need a directory
05:03sm0keouch
05:04sm0kehow bad can packaging a test dir be?
05:04eglitomjack: it works! I owe you a beer!
05:04egli(inc tomjack)
05:04lazybot⇒ 3
05:04clgvsm0ke: well then just add it as source directory
05:05sm0kehurmm is that a trap?
05:05sm0kei wonder if deftest will expand at runtime and start running tests every time the jar is loaded
05:05perplexaare there any alternatives to clj-time?
05:05clgvno. but if you want to include it in the jar, thats an option
05:05sm0keperplexa: joda
05:06Glenjaminperplexa: what problem are you having that makes you seek an alternative?
05:06clgvsm0ke: what? even if it did you would have to load the namespace first
05:06sm0keclgv: hurmm i hate that lein does not allow classifiers
05:06clgvGlenjamin: the optimal solution for sm0ke would be a separate test-utils lib added as :dev dependency in the projects he needs it
05:07Glenjamini agree
05:07sm0kei would other wise just publish the "test" dirs with a classifier "test"
05:07clgvsm0ke: but afaik deftest results in a function definition
05:07perplexaGlenjamin: the periodic time stuff is broken here, i keep getting "No matching method found: multipliedBy for class org.joda.time.Period" and apart from that, its author is an arrogant jerk, who rather choses to rant about being contacted instead of fixing his stuff ;P
05:07clgvsm0ke: midje is not and runs the test when the namespace is evaluated
05:07Glenjaminperplexa: :s
05:08sm0keperplexa: harsh words
05:08Glenjamincan you link to the github issue?
05:09perplexasm0ke: i wrote to him directly and he called me a 'disrespectful dip shit' for not using the mailing list and followed it up with "I will never pay any attention to any issue you report."
05:09perplexaway to go.
05:10clgvinteresting.
05:10sm0kehurmm
05:10clgvperplexa: is the library that good that you will continue using it?
05:10perplexano i will ditch it over this
05:10sm0keclgv: thats not the point
05:11GlenjaminJoda is the best lib on java i know of, and with clj-time wrapping joda i suspect your only alternative is interop to joda directly =/
05:11sm0kei wonder if you should directly write to an unknown person asking to fix stuff
05:11Glenjaminsm0ke: even if not, the sensible response is "please repost this to ML / github issues"
05:11perplexaif he doesn't want to be contacted he shouldn't put his mail in public places
05:11sm0kei agree
05:11clgvsm0ke: from a practical point of view that would be a major descion argument for me
05:12clgvsm0ke: the other one being: can I fix and maintain it myself ;)
05:12Glenjaminfork: friendly-clj-time
05:12sm0kethere are 61 contributors to the lib
05:12sm0kebe one
05:13clgvah it's clj-time? well, I hardly use that one. only formating timestamps so far ;)
05:16clgvI wonder whom he did write. I would guess not one of the top contributors
05:16perplexaGlenjamin: gonna look into https://github.com/dm3/clojure.joda-time ;p
05:16perplexaoh 'build failing'
05:19perplexahttp://perplexa.be/Screen%20Shot%202015-01-29%20at%2011.16.42.png
05:19perplexai wonder what's wrong with that guy :D
05:21clgvperplexa: why dont you use clj-time instead?
05:21sm0keperplexa: no use getting personal, did you file an issue?
05:21sm0keclgv: i think he is talking about it ony
05:22perplexaclgv: yeah using it and it's behaving weird ;p
05:22perplexasm0ke: well since the author told me right away that he's gonna ignore any reported issues, there's probably not a point in it.
05:23sm0kethere are 61 authors someone will respond.
05:23GlenjaminThat's not the point, getting a response like that from a project lead would put me off right away
05:24clgvperplexa: one of the top contributors of clj-time gave you that response?
05:25perplexaclgv: yes, it came from michael klishin.
05:26clgvhard to believe judging from the stuff I read from him. maybe a bad day...
05:28clgvperplexa: just create an issue on the project and describe the problem properly. with that many contributors it'll get a fix provided it is not out of the scope of that library
05:31algernonfwiv: https://twitter.com/michaelklishin/status/560741014525472769
05:32cflemingUmmm... so that's not very cool either.
05:33algernonit's not very cool from either side.
05:33acron^Ouch
05:33cflemingAgreed
05:34sm0kei feel like i am back in highschool
05:34perplexa:P
05:36hellofunkthis is pretty funny: https://github.com/landondyer/kasm/blob/master/LICENSE
05:36cfleminghellofunk: Yeah, I had a little smile at that too
05:37acron^lol
05:37acron^why the hate on RMS ?
05:37cflemingWho knows?
05:37hyPiRionno idea
05:37sm0kehaha thats just sadist
05:40sm0kewell RMS is the father of open source (?) and he make a license for his open source project which is not for RMS
05:40sm0keacron^: get it?
05:41acron^i get it
05:41acron^but why doesn't he want RMS to use it
05:41sm0ke:/
05:41acron^is he trying to be ironic?
05:41sm0keyea
06:06zarkonehello all. Does anybody use clojurescript and cider nrepl? cannot get it work propery..
06:09Jahkeup_zarkone: you'll have to connect to a brepl (browser repl)
06:10Jahkeup_zarkone: take a look at something like https://github.com/cemerick/austin
06:10mavbozozarkone: what library do you use?
06:11hellofunkzarkone: you can use cider and clojurescript together for many tasks, but the REPL is not a part of cider if you need that
06:13hellofunkzarkone: cider includes clojure repl, and also lots of cider features work in both clojure and clojurescript. figwheel and weasel are the popular clojurescript repl choices (though personally i rarely need a cljs repl even when working in cljs all day)
06:23cflemingEmpperi: So this bug I'm fixing is almost certainly not your problem
06:34zarkoneJahkeup_: hellofunk thank for response, sorry that i've missed it >..< I start cider-nrepl middleware with ring server. That i start figwheel. Than I connect to the repl and eval this: (piggieback/cljs-repl :repl-env (weasel/repl-env :ip "0.0.0.0" :port 9001))). It works quite ok, reload the code, etc. But source maps do not work properly -- my CIDER go-to-symbol uses old source location, wich was wirst build with cljs... I see, that
06:34zarkonesource maps are changing in out/ dir. But i cannot understand -- is my browser does not relod maps on fly or is it cider issue? in browser debugger->sources i see old maps =(. cljs options :source-map and :source-map-timestamp are true, :optimization :none
06:34zarkonesorry for the long story >..<
06:36hellofunkzarkone: i don't know. i just use lein cljsbuild auto all day and never open a repl or deal with that stuff. i've always been happy with my workflow but am not using these more advanced features (and thus not dealing with their problems)
06:36zarkoneoh, i get used to source docs, param highlight, jump to source...
06:37zarkonei miss it so much)
06:37hellofunkzarkone: i must be an odd one, but the incredible consistency between clj and cljs allows me to do all my repl experiements in clojure while actually writing cljs code.
06:38zarkonehellofunk: actually, may be it's even better, because e.g. wrong arity is just warning, sometimes i do not see it
06:39zarkonein cljs
06:39justin_smithhellofunk: funkhello
06:40hellofunkzarkone: yeah i've learned to just read the errors if any that get spit at the chrome console, perhaps i've gotten rehearsed at writing error-free cljs most of the time, though early on i had to figure them out. i don't think perfect source maps would save me any time now.
06:40hellofunkjustin_smith: word
06:45justin_smithso, turns out Acid Mothers Tempple are playing during Clojure/West, we should make an outing https://www.youtube.com/watch?v=QSJnhpmuuhc
06:49hellofunkjustin_smith: that band reminds me of Ozric Tentacles
06:50justin_smiththere are some similarities
06:51hellofunkin reading the comments it appears i'm not the only one to make that comparison
06:51zactshuh, I wonder where an actual manual / guide for overtone is
06:51zactsI don't see one on the homepage
06:52hellofunkzacts: there are some demo source files somewhere, let me see if i can find them
06:52justin_smithhellofunk: also much like Gong
06:55zactshey I also found this https://github.com/overtone/overtone/wiki
06:55zactsI guess the wiki is a work in progress documentation for it
06:56zactsalso I found this http://vimeo.com/22798433
06:57zactswhich is the intro to doing overtone live coding
06:58zactshellofunk: hey cool, yeah that could be useful
06:59cflemingjustin_smith: Wow, that's... pretty freaky.
07:01zactsjustin_smith: https://github.com/scheme/scsh
07:02zacts^ it seems someone may be maintaining scsh a bit
07:02justin_smithfascinating
07:02zactsbut theres a bunch of code that could probably be converted into clojure
07:02clojurebotExcuse me?
07:02zactssilly bot!
07:02zacts:-)
07:02justin_smithclojurebot: you're excused
07:02clojurebotNo entiendo
07:04cflemingclojurebot: Porque eres tonto
07:04clojurebotI don't understand.
07:04cflemingObviously
07:05justin_smithhaha
07:06cflemingI shouldn't mock the bot, when the singularity happens I'll be first against the wall
07:07justin_smithcfleming: in that case, midje users are in trouble
07:07cflemingjustin_smith: Ba-doom *tschhhh*
07:08clgvcfleming: when the singularity happens clojurebot will choke on an unbalanced paren resulting in a RuntimeException ;)
07:08clgvso no danger from it
07:08clgv:P
07:08hellofunkah, singularity, the great imaginary doom that will never happen but still scare everyone anyway
07:09cflemingBy the time the singularity happens, I suspect clojurebot will have figured out how to temporarily disable paredit :-)
07:09clgvcfleming: are you saying he is secretly using cursive with paredit? ;)
07:09cflemingclgv: Shhhhh
07:10cflemingHe will be when he gets smart enough, at least ;)
07:13hellofunkzacts: https://github.com/mgandin/lightning-talk-clojure-overtone
07:17zactsoh cool thanks hellofunk
07:48arav93Does persistent hash set have a data type of its own? Or do we mention all as merely set itself?
07:48arav93Sorry about asking the same question in #typed-clojure channel as well!
07:48justin_smith,(class #{})
07:48clojurebotclojure.lang.PersistentHashSet
07:49justin_smitharav93: oh, you mean in the typed clojure sense? I don't know that part
07:53clgvarav93: does your program need to verify that distinction? (better not)
07:53arav93clgv: I was trying annotate clojure.set.
07:54arav93I wasn't quite sure whether to use persistenthashset or just the normal set
07:55justin_smith"normal set"?
07:55justin_smithclojure.set is a namespace with operations on PersistentHashSet
07:55justin_smithor do you mean java.util.Set or something?
07:59clgvjustin_smith: he probably means PersistentTreeSet
08:00clgv,(type (sorted-set))
08:00clojurebotclojure.lang.PersistentTreeSet
08:00clgvok, the distinction of sorted vs unsorted could indeed be valid to some functions
08:09yocapybaraguys this is not a clojure problem really, but say I'm using java 7 watcher stuff and I get a message that a file is created, any way to definitively tell it isn't being written to short of repeatedly checking its bytes and declaring it finished after a certain period of time? I've tried Files.move atomic move to rename, but it seems a file can be renamed while still being copied. I've tried opening it for random access reading and
08:09yocapybara that seems to be permitted also when the file is being copied too.
08:11yocapybarahave been using interop to do the stream reading and Files.move stuff... but can't find a reliable approach. Will likely try to sidestep the problem but would be nice to resolve it!
08:12justin_smithyocapybara: what OS?
08:12yocapybarajustin_smith: hi there - developing on osx, deploying to ubuntu
08:12justin_smithyocapybara: for example, on a Linux system you can move a file while it is being written without interrupting write
08:13justin_smithas long as the move is to the same file system
08:13clgvyocapybara: does the java api support locks on files?
08:13yocapybarajustin_smith: yup, I didn't know what would happen and found that to be true :) shoud have perhaps looked it up!
08:13clgvyocapybara: so if you control both you could coordinate via file locks
08:14yocapybaraclgv: I think Java 7 supports locking files, though I thought that was only inside JVM, do the locks interoperate with the OS somehow for this?
08:14justin_smithyocapybara: in fact, you can delete a file that another program is using, and the file is still usable by that program until they exit or close the file
08:14yocapybarajustin_smith: that got me confused the first time I deleted a tomcat log!
08:14justin_smithyocapybara: this is also how they hide the video files that make video streaming possible, to prevent keeping a local copy of the video
08:15yocapybarajustin_smith: that I had no idea of, clever but annoying
08:15clgvjustin_smith: "security" by obscurity? :P
08:15Glenjamini once zeroed a deleted logfile via /proc because i didn't know how to safely restart an app
08:16Glenjaminthe /proc stuff is crazy magic
08:16yocapybaraclgv: aaah from java.nio.channels.FileLock 'This file-locking API is intended to map directly to the native locking facility of the underlying operating system. Thus the locks held on a file should be visible to all programs that have access to the file, regardless of the language in which those programs are written.'
08:16yocapybaraclgv: this looks worth a try
08:16clgvyocapybara: yeah, but you need to control the writer and the renaming process and force them to aquire the log
08:17justin_smithclgv: the issue is that everything is accessible on Linux (it's an open system), so DRM stuff is always a sloppy hack
08:17clgvjustin_smith: DRM is broken by design ;)
08:17justin_smithclgv: right, but they can fake it better on closed systems
08:18yocapybaraclgv: in my case I'm getting large files ftp'ed in - now I can try to configure the ftp server, but I wanted a reliable fallback to see if I can just find if a file is finished. So my plan was watcher API to give me create events, then run off a go block that establishes if it is finished periodically, and then fire the file off to its destination once done
08:18justin_smith$mail andyf are there known issues with eastwood arity checking and clojure.java.jdbc/insert! or is it an issue with this codebase?
08:18lazybotMessage saved.
08:18justin_smithanyone else is free to offer an answer, of course :)
08:18clgvyocapybara: well, then the file lock might proof useless
08:19yocapybaraclgv: you don't think the ftp server would lock the file when it was being transferred?
08:19yocapybaraGlenjamin: I didn't realise you could do that, that's pretty awesome
08:19clgvjustin_smith: isn't this part of the custom :arglists discussion?
08:20clgvyocapybara: I don't know, hence the "might" in the statement ;)
08:20yocapybaraclgv: no worries :)
08:21justin_smithclgv: oh, that bullshit
08:21justin_smithyeah
08:21justin_smithprobably
08:22justin_smithGlenjamin: yocapybara: this is also why env vars are inherently insecure
08:22justin_smithyou can read any process' env via proc
08:22justin_smith(don't tell 12factor)
08:22yocapybarahahaha
08:23Glenjaminjustin_smith: if you have perms for that, you'd be able to read config files too?
08:23yfenghi all
08:24justin_smithGlenjamin: encrypted properties file, assign the password to nil once you have it decrypted, assign creds to nil once you are authenticated
08:24justin_smithGlenjamin: but as we know, there are no reliable methods to reassign env vars inside the jvm
08:24justin_smithnot portable at least
08:25Glenjaminhow do you pass in the decryption key?
08:25justin_smithugh, I had this worked out once...
08:25justin_smithhaha
08:25clgvGlenjamin: there is a monkey sitting in the server that is trained to type in the password on server reboots ;)
08:26Glenjaminyeah, so i need the same or higher perms than the process owner to read its env var
08:26justin_smithGlenjamin: anyway, at the very least, the env isn't any more secure than other methods of providing the creds (though of course keeping them in git is bad)
08:26Glenjamini don't think env vars are any more insecure than other methods
08:26clgvor a banana to bribe the monkey
08:26Glenjamin^^
08:31justin_smithGlenjamin: in all seriousness though, a higher priveleged (and more locked down / more restricted use) account can provide the credentials for unlocking a properties file, and unlike an env var, the jvm process can assign these things to nil once they are unused. This is probably more vigilance than most apps need though.
08:32justin_smithGlenjamin: what this does is make it harder for a random takeover of the server process itself to get access to credentials.
08:32Glenjaminjustin_smith: i'm still not sure how the privileged process can pass the data safely down before it drops perms
08:32Glenjaminyeah, i can see how that would be preferrable
08:32Glenjaminoh, stdin is safeish?
08:33justin_smithGlenjamin: it wouldn't drop perms, it's a separate service. I think things like PAM are designed for this sort of thing.
08:33justin_smithGlenjamin: yeah, or even a pipe
08:33justin_smithbecause there is no persistence of what passes through the pipe
08:33justin_smithbut this is all james-bond stuff, beyond what most of us need to worry about :)
08:34Glenjaminyeah, to do automated ops stuff it's realistically going to end up in a file somewhere
08:34justin_smithbut minimizing the spread of credentials, minimizing scope of permissions, etc. are good things to keep in mind regardless
08:34Glenjaminmm
08:34justin_smithGlenjamin: right, it's in a file, but the account that has access to that file has very little functionality
08:34justin_smithlittle functionality = small surface of attack
08:34justin_smithfewer things that can break
08:35Glenjaminisn't it the contents of the file that we're trying to protect?
08:35Glenjamini've lost track a bit :D
08:35justin_smithas opposed to my webapp that runs a turing complete compiler at runtime :)
08:35justin_smithGlenjamin: like I said - the account that can access the master file does very little
08:35justin_smithit does not run a compiler
08:35justin_smithit is not turing complete, and we can prove it
08:36Glenjaminoh, interesting
08:36justin_smiththe process running a compiler at runtime only gets those credentials under very specific circumstances, controlled by the other process
08:37justin_smithnone of this is unbreakable I am sure, but you have degrees of breakability
08:37Glenjaminyeah, i like the general idea
08:39justin_smithbut I think we have to be a little more careful, since we have full access to a compiler at runtime
08:54dysfunor we just defer compile time to runtime
08:54dysfundepending on how you look at it
09:05nort_Hi, I have a .nar file that I want to use from Clojure, but leiningen doesn't seem to support it atm. I found someone with the same problem here, explaning how he could work around it https://groups.google.com/forum/#!topic/maven-nar/d9BjwT_u2h8 . But I really don't understand how it's solved, or whether I can also do that. Does anyone have an idea how I can easiest access .nar-file from Clojure?
09:05nort_I don't have much experience with leiningen, so I wanted to ask here before I dig deeper and risk going in a wrong direction..
09:08justin_smithnort_: you may have more luck on #leiningen
09:08clgvnort_: projects like overtone directly include native dependencies in subfolders afaik
09:08justin_smithnort_: it seems like this wouldn't be a hard thing to add to lein though
09:09justin_smithclgv: but do they use the nar file abstraction? I don't know if that is a specific requirement here I guess.
09:10clgvjustin_smith: I think they do not. so my workaround suggestion would be to extract the nar and build a jar working in leiningen
09:11justin_smithclgv: well, a nar is just a renamed jar, but the tooling knows you can't use it without extracting it to disk (since the OS needs to access the contents)
09:11justin_smiththat's my understanding at least
09:11justin_smithnot hard to hack, but it would be nice to do it the normal way
09:11clgvwell the jar setup also extract the native dependencies
09:12justin_smithahh, OK, I did not realize that was automatic
09:12clgvbut I never used it myself...
09:15nort_Ok, I will try in that channel also. But if I understand correctly, it should be possible to extract the .nar, create a .jar from it, and then use that instead?
09:17clgvnort_: I guess so. you just have to find an example how clojure projects with native dependencies set this up
09:19nort_Ok, thanks
09:35justin_smithnort_: actually, it may be as simple as renaming .nar to .jar, I think the naming just indicates it should be handled differently (automatically extracted) and there is no difference in actual structure of the artifact from a jar
09:41R0B_RODMorning
09:41nort_justin_smith: Oh, that would be awesome! I will try it out :-) Thanks
09:41justin_smith~UGT
09:41clojurebotUGT is Universal Greeting Time http://www.total-knowledge.com/~ilya/mips/ugt.html
09:42justin_smithR0B_ROD: UGT to you as well
09:43R0B_RODjustin_smith: :) Hey there
09:46clgvUGT is **** ;)
09:46clgv(don't insert "awesome" for the stars) :P
09:49R0B_RODjustin_smith: I learned something new. UGT to you
09:49R0B_ROD;>
09:49R0B_RODIm doing the koans
09:50R0B_RODLike you advised the first time I logged in here
09:50R0B_RODI am aka as brainacid
09:50maiohow would I write macro which takes function as an argument? simplified example (which doesn't work): (defmacro foo [f arg] (f arg))
09:50R0B_RODbut after learning more about open-source and true programmers I decided to use a shortened version of my name
09:50R0B_RODlol just talking out loud
09:50clgvmaio: what exactly is the overall goal? what should the macro do with the function?
09:51maioclgv: I want to call that function (in compile time)
09:52michaniskin__i once saw a great chart that showed a graph of clojure collections and the protocols they implement
09:52maio(defmacro foo [f arg] ((eval f) arg)) seems to work, but is that OK?
09:52michaniskin__does anyone know how i can find it again?
09:52clgvmaio: ah. macros do not work that way. you do not get the function but the symbol referring to the function when the macro is expanded
09:53clgvmaio: are you sure that you do need a macro. it looks pretty much like you want an higher order function
09:53clgv?
09:53maioclgv: I think I need macro. My real code is here https://github.com/maio/defns/blob/master/src/defns.clj
09:54clgvmaio: what is that code supposed to do?
09:54justin_smithmaio: a macro needs to return at compile time the code for run time
09:55maiojustin_smith: sure but I want/need to do some stuff at compile time (call some function in this case)
09:56clgvmaio: but you do not know the function when defining the macro? that is a pretty rare use case - hence the question whether you are sure that is really a solution to your problem
09:56justin_smithmaio: well, if you want to call the function at compile time, then yeah, there you go
09:56clgvjustin_smith: you can just use (some-> some-fn-symbol resolve deref) to get hold of the function
09:57clgvmaio: ^^
09:57maioclgv: It's up to the user to specify which (custom) function to use. For example in tests I need different function than in production code (https://github.com/maio/defns/blob/master/test/defns_test.clj)
09:58clgvmaio: I sense a weird hack lurking there
09:58maio:)
09:58maioIt's just some experiment :)
10:15meliponehello, I need to save a java random object to a file and read it back (since there is no getSeed() in java for that). How can I do that with Clojure?
10:17justin_smithmelipone: you should be able to use the serialization stuff via interop
10:17justin_smithmelipone: how random of an object?
10:17justin_smithcould it be replaced by eg. an edn map or a properties file?
10:18hyPiRionjustin_smith: the java.lang.util.Random kind
10:18meliponejustin_smith: Just (Random. 143123)
10:18justin_smithmelipone: why not just store the number part?
10:18hyPiRionjustin_smith: because there's no getSeed()
10:18hyPiRionI'd just do reflection on the object, fetch its seed and put it on disk.
10:18justin_smithmelipone: ahh, now I get it, sorry
10:19justin_smithyeah, reflection may be the easier way, compared to the default serialization methods
10:19Glenjaminheh, i read it as "an arbitrary object" too
10:19justin_smithglad I'm not alone
10:22clgvmelipone: do you want to continue the random number sequence from an intermediate state? since seeds are usually preprocessed that wont be possible like that, even with getSeed
10:23tcrayford____justin_smith: here's a cool clojure learning for me from today (:or (:cached-thing foo) (expensive-computation foo)) is an amazing fuckup (it always runs the expensive computation, but because it's just caching, things *seem* fine)
10:23hyPiRionmelipone: You could use serialization if you want some kind of guarantee that reflection doesn't blow up.
10:23tcrayford____(it should be (or (:cached-thing foo) (expensive-computation foo)))
10:23clgvmelipone: you could store the initial seed and count the invocations. a nasty reflection is probably possible as well
10:23justin_smithtcrayford____: haha, so you meant to use or
10:23justin_smithlol
10:23tcrayford____yeah haha
10:23clgvmelipone: why exactly do you want to do that?
10:23tcrayford____but it worked fine!
10:23tcrayford____been in production for a year like that!
10:24tcrayford____haha :(
10:24justin_smithoh shit!
10:24Glenjaminis that because you're not using the value of the expression?
10:24justin_smithcaching for side effects I guess
10:24clgvtcrayford____: sell it as well crafted performance improvement ;)
10:24tcrayford____the caching happens outside that code
10:24justin_smithGlenjamin: ahh, it's because keyword takes a second, default arg
10:24gfredericks~(:or (:cached-thing foo) (expensive-computation foo)) is an amazing fuckup
10:24clojurebotOk.
10:24Glenjaminoh right
10:24justin_smithGlenjamin: since the first thing had no :or key, the second part is run and returned
10:25Glenjaminyeah, i see
10:25Glenjaminouch
10:25gfredericks~an amazing fuckup
10:25clojurebotTitim gan éirí ort.
10:25tcrayford____I mean, I say "expensive", it's like a sha256 call over a relatively small string haha
10:25justin_smith,(:or (:blah {:blah "OK"}) (:expensive {:expensive "OK"})) ; this is what he did
10:25clojurebot"OK"
10:26gfrederickstcrayford____: that one-use-of-keyword linter mightacaughtit
10:26justin_smiththe right return value, but the wrong source
10:26meliponeclgv: I want to continue the computation later with the same random seed to be able to compare results
10:26tcrayford____gfredericks: the one in eastwood?
10:26tcrayford____I literally just started using eastwood yesterday haha
10:26tcrayford____(it didn't catch it)
10:26justin_smithtcrayford____: aye, that is the one linter we have matey
10:26justin_smithbut the keyword linting is not on by default
10:26clgvmelipone: why not just store the initial seed for comparison?
10:27tcrayford____justin_smith: yeah, I turned *all* of the linters on yesterday and went through em, then turned off the ones that were super noisy
10:27clgvmelipone: usually you just specified a concrete seed at the beginning of the computation
10:27tcrayford____the keyword one is *fun* with bootstrap and hiccup: "found :div.span6, did you mean :div.span3" etc
10:27justin_smithhaha
10:28tcrayford____I have https://gist.github.com/tcrayford/0a82713cfb821eeca269 on and my build fails if I create more errors than the current allowed limit
10:29gfrederickstcrayford____: yeah eastwood
10:29tcrayford____(there are 38 linting errors eastwood spits out on my ~10k lines of code that are incorrect/wrong)
10:30gfrederickstcrayford____: if the keyword linter allowed a regex as a whitelist that could fit your html purpose I imagine
10:30tcrayford____yeah, that'd be dope
10:30tcrayford____(related: I *wish* kibit let you customize what linters you had on in project.clj)
10:31meliponeclgv: yeah, I know
10:31tcrayford____I have a whole loada code that explicitly does (if thing bar nil), because I wanna remind myself that `nil` comes out of this conditional, don't want it sneaking around
10:32gfredericksmelipone: this might not help immediately but I've been working on alternative RNGs that would let you do this
10:33tcrayford____gfredericks: perf benchmarks for yeller's api handler after eliminating that stupid :or thingy: https://gist.github.com/tcrayford/90756c22354d9ad19783
10:33tcrayford____easiest perf win I've ever done haha
10:33gfrederickstcrayford____: christmas is saved!
10:34justin_smithvery nice
10:34gfredericksmelipone: it also wouldn't be too hard to copypasta the Random.java file from openjdk and adapt it to be serializable
10:35gfrederickshttps://github.com/openjdk-mirror/jdk/blob/jdk7/jdk7/master/src/share/classes/java/util/Random.java
10:35gfredericksit does implement Serializable but I don't know what that means :/
10:36tcrayford____(lmao if your api's response time isn't measured in hundreds of microseconds)
10:38meliponegfredericks: But java.util.Random IS serialiazable
10:39meliponegfredericks: so how can I write a serializable java object to file in clojure?
10:39hellofunkwhen running lein cljsbuild, how does it know which profile to use in project.clj?
10:39justin_smithhellofunk: dev is the default profile
10:40justin_smithwell, it's a sum of profiles, and you get like user+dev if you specify nothing else
10:40justin_smithyou can provide them as arguments to lein with-profile
10:40justin_smithlein test activates :test, of coruse
10:40justin_smith*course
10:40mmitchellugh, why doesn't this macro eval the (get names :foo) arg so that the resulting def is FOO? ... https://gist.github.com/mwmitchell/2db95d5b2f5264102f3e
10:40hellofunkif i have two different cljsbuild profiles, how do i specifiy to lein cljsbuild which one to use?
10:41daniel__1lein with-profile profile1 cljsbuild auto
10:41daniel__1for example
10:41hellofunkdaniel__: ah cool, thanks
10:42justin_smithactually cljsbuild takes profile args too
10:42justin_smithlein cljsbuild auto profile-name
10:42hellofunkoh cool
10:43justin_smithwhich specify keys under :builds
10:43daniel__1cool justin_smith, didnt know
10:43hellofunkforgive my ignorance but where did you look this up exactly justin_smith?
10:43gfredericksmelipone: googling suggests you want to use ObjectInputStream and ObjectOutputStream
10:43justin_smithit's right above "repl support" in the readme
10:43justin_smithhttps://github.com/emezeske/lein-cljsbuild
10:43gfredericksmelipone: and likely the best clojure way to do it is using interop and doing whatever you would do in java
10:43zactshttp://mitpress.mit.edu/books/structure-and-interpretation-classical-mechanics-2
10:43zacts^ a new edition of SICM next month
10:44justin_smithhellofunk: most of my skill as a dev is a direct outgrowth of my dungeons and dragons hobby as a kid, and learning to be the one that was best at looking up rules :)
10:44justin_smith(if you are the best at looking up rules quickly, you can make sure rules that help you are always looked up, and you can "overlook" the ones that don't)
10:44meliponegfredericks: okay, I have already a function in Java to do that. I thought there would be something like that built-in in Clojure.
10:45hellofunkjustin_smith: interesting what you describe would be a build id, while what daniel__ describes would be a profile. i guess they do similar things?
10:45justin_smithhellofunk: good point - I may have sidetracked us with the profile thing (or maybe they are related in some way I don't quite know) - but build ids are clearly documented to work
10:46justin_smithmost things in lein will be parameterized by profile
10:46hellofunkjustin_smith: most project.clj files i see for cljs development use profiles not build ids, which is why i wondered how they were getting accessed
10:46justin_smithaha
10:46justin_smithso we all learned something today
10:47hellofunkafter i get it working, then i'll be able to say i learned something :)
10:52clgvmelipone: Clojure interop is built-in and you can use it to implement reading/writing with the object streams
10:53hellofunkso if your lein profile is :dev you'd pass dev with no colon to lein with-profile ?
10:57justin_smithhellofunk: :dev is the default, you don't need :with-profile for that
11:01hellofunkjustin_smith: daniel__ there must be more to the story. i have a profile as :prod but running lein with-profile :prod and lein with-profile prod cljsbuild auto both result in Warning: profile not found
11:03clgvhellofunk: don't use the colon on th command line
11:03clgvmultiple profiles are separated via comma
11:04daniel__1hellofunk: think you'll have to gist your project.clj, second command looks ok
11:04daniel__1but unfortunately i have to go
11:05hellofunkdaniel__ clgv : https://www.refheap.com/96634 but i run this it says :prod not found: lein with-profile prod cljsbuild auto
11:07justin_smithhellofunk: the key is :profiles
11:07justin_smithhellofunk: not :profile
11:07clgv:D
11:07justin_smithhellofunk: showing my work https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L155
11:08justin_smithhellofunk: that example project.clj is a good place to look whenever some config you put in lein is not behaving the way you expected
11:08hellofunkah geez profile vs profiles. yikes how ridiculous.
11:09justin_smithhellofunk: easy mistake, lein is very willing to accept invalid keys without complaint
11:09hellofunk...which it has indeed been doing for along time for me
11:10clgvjustin_smith: because they are not necessarily invalid but meaningless to leiningen ;)
11:10justin_smithclgv: indeed
11:10clgvbut some plugin may use them
11:11justin_smithright, it just makes the helpfulness that strictness might provide unattainable
11:11clgvbut a test-mode to list unknown options (for leinigen) would probably help debugging
11:12justin_smithclgv: if it was combined with an API to ask each plugin for the keys it considered interesting...
11:13justin_smiththat actually wouldn't be too hard, though it would require a lot of cooperation to do it retroactively of course
11:14hellofunkleiningen is a big black magical box to me that i've never really looked inside for fear of... well, it's so much a box that i don't even know what my fear of it is
11:15justin_smithreminds me of that old weird movie, "the cube" - it was a good sci fi / horror kind of thing
11:15justin_smithoh no they made "the cube 2, hypercube" - probably fucking terrible
11:26bacon1989Was wondering, what would be the best non-relational database I could use with clojure?
11:27bacon1989Datomic looks interesting, is that one hard to adopt outside of clojure?
11:27tbaldridgebacon1989: Java support for Datomic is pretty solid
11:27justin_smithbacon1989: datomic has extensive docs for usage from other languages at datomic.com
11:28bacon1989Oh neat
11:29bacon1989Wait... Datomic uses Groovy in it's shell?
11:29justin_smithbacon1989: the docs show how to use Groovy
11:29justin_smithand I guess maybe the default shell is Groovy?
11:30bacon1989Is there a C API for Datomic, or is it strictly in the JVM?
11:30bacon1989I see a ruby implementation
11:31justin_smiththat is likely via a server connection
11:31justin_smithso you could likely use a TCP lib to use it from C I guess?
11:31tbaldridgebacon1989: datomic does provide a REST interface, the Ruby version uses that, or JRuby can use the JVM API
11:31{blake}justin_smith: Actually Cube 2 and Cube 0 are both pretty good, but nowhere near the original.
11:32bacon1989tbaldridge: I see, that would make sense
11:32justin_smith{blake}: good to know!
11:32bacon1989Maybe i'll try out Datomic, anyone here familiar with the free nature of Datomic?
11:32bacon1989I don't really understand the restrictions
11:32tbaldridgebacon1989: sure. although #datomic is probably a better place for this conversation
11:32justin_smithbacon1989: I'd ask on #datomic about that
11:32justin_smithheh
11:32bacon1989Ah, good idea
11:33justin_smithalso, since it is a commercial project, I am sure you could email support and expect a helpful response
11:37sveriHi, which middleware do I have to apply to parse query-params in get requests?
11:39justin_smithsveri: ring.middleware.params/wrap-params
11:39nkozasveri: ring.middleware.params
11:39justin_smiththey show up as :query-params on the request map
11:39justin_smithand also in :params (merged with :form-params)
11:41sverijustin_smith: nkoza hm, that was my guess too, but somehow the uri is not parsed, maybe the uri is wrong? /user/login?next=/user/admin
11:41sveriquery-params is just empty
11:41jneenhello! does anyone know of a clojure interface to truffle / graal? or have an opinion on whether making one is worth it?
11:42sverioh, wait, I guess I made a mistake here, obv. I have this uri when rendering the login page, but obv. not when sending the login form to the server
11:42jneenits api is based mainly on annotated classes with overloaded methods, so it'd stretch java interop quite a lot i think
11:42justin_smithjneen: yeah, annotation is possible, but not simple
11:43justin_smith(from clojure that is)
11:43jneenhm yeah that's what i gathered
11:43justin_smithjneen: how many annotated things do you need?
11:43justin_smithyou could make some small java shims that call out to clojure
11:43jneenwell
11:43jneenarbitrarily many
11:43jneenone per node type
11:43jneenso, defined by the language implementer
11:43jneenideally through some sort of macro...
11:44jneenbut i think that means a lot of funky class generator stuff
11:44justin_smitha macro that generates your :gen-class invocation could be doable
11:44jneencan gen-class do class annotations?
11:44sverijustin_smith: nkoza thank you, I just had my brain think in the wrong direction
11:44jneeni've been looking through the docs and haven't found anything
11:45justin_smithjneen: yes, gen-class can do annotations
11:45jneenoh!
11:45jneenum
11:45jneen...how...?
11:46justin_smithoh wait! deftype can do it
11:46justin_smithhttps://gist.github.com/richhickey/377213
11:47justin_smithfrom the man himself ^
11:47justin_smithjneen: actually that looks quite a bit easier than I had imagined
11:47jneenoh nice
11:47jneenhaha i ended up on the same gist
11:47jneencool
11:48justin_smiththat gist deserves the high page-rank it clearly has
11:48llasramjneen: Are the annotations involved runtime annotations?
11:49jneenllasram: compile-time i believe
11:49jneen(disclosure: i am not very well versed with java stuff)
11:49llasramYeah, so using them with deftype won't help you much
11:49jneenyeah but i'd guess gen-class does it?
11:49llasramnope
11:49jneenaww
11:50jneeni thought gen-class was compile-time
11:50justin_smithllasram: what is the distinction here?
11:50stuartsierraAnnotation support isn't really documented anywhere, but you can find examples in the Clojure language tests.
11:50jneenhence the requirement for AOT compilation
11:51justin_smithllasram: is this about annotation preprocessors for java code generation?
11:51justin_smithbecause yeah, doing that in clojure would be a bit pointless
11:51llasramjustin_smith: Yah
11:51jneenhm
11:52jneeni figured gen-class would do that :\
11:52jneenmaybe it's not possible then
11:52justin_smithjneen: well you see, clojure does not generate java code
11:53justin_smithit compiles to jvm bytecode with no java step
11:53jneenso the annotations are syntactic?
11:53justin_smithso if the point of the annotation is to pre-process java source, clojure can't help you do much useful with it
11:53jneeni figured that was what they were doing
11:53justin_smithjneen: not sure, llasram says they are
11:53jneenhrm
11:54llasramI'm not sure the one's of interest here are -- it's something to be aware might be the case though
11:54jneenyeah i figured they generated bytecode for other classes, but if they generate actual java syntax for other classes it could be weird
11:54justin_smithhttp://lampwww.epfl.ch/~magarcia/graal/replacements-tutorial.html would this be the relevant documentation?
11:55justin_smithit's talking about stuff happening during compilation, which would mean no-clojure
11:56jneenwell
11:56jneenit's also compiler infrastructure
11:56justin_smithjneen: you could likely define a transform that uses clojure via interop
11:56justin_smithjneen: so you could use calls to clojure to assist in the compilation
11:56justin_smiththat is feasable
11:56jneenso like, graal is compiling other lang's code
11:56justin_smithright
11:57justin_smithand you want graal to use clojure in the process of generating other lang code
11:57R0B_RODAny resources available focusing on Introductory programming with Clojure??
11:57lazybotR0B_ROD: Uh, no. Why would you even ask?
11:57justin_smithR0B_ROD: yeah, aphyr's clojure info is very introductory
11:57justin_smithhttps://aphyr.com/posts/301-clojure-from-the-ground-up-welcome
11:57R0B_RODI have seen his site, not interesed.
11:57justin_smithhaha
11:57justin_smithit's a good guide though
11:58seangrove$seen bbloom
11:58lazybotbbloom was last seen quittingQuit: Textual IRC Client: www.textualapp.com 5 days and 13 hours ago.
11:58seangroveHe's gone, he's gone.
11:58R0B_RODThats ok I have seen the data but not compatible with his implementation and organizing of info.
11:58R0B_ROD.. but I am not ...
11:58godd2R0B_ROD Clojure for the Brave and True
11:59R0B_RODgodd2: Also aware but my poor a** is too broke to pay for information at the moment.
11:59R0B_RODOK. I will continue my current workflow
11:59{blake}R0B_ROD: I, personally, did not find any of the introductory works to be sufficient.
11:59godd2R0B_ROD you can just read it online: http://www.braveclojure.com/getting-started/
12:00{blake}R0B_ROD: I went to Aphy, B&T, got some videos, listened to youtube lectures, bought everyone's book...
12:00R0B_ROD{blake}: Indeed I am agreeing but I am not a programmer just a computer enthusiast. I dont even have a specific domain of interest. Just trying to develop some kind of skill-set
12:01R0B_RODgodd2: Ah very nice! #Thanks!
12:01{blake}R0B_ROD: And I still had to ping-pong around between all of those, plus clojure koans, plus 4clojure, and develop some simple game logic.
12:02{blake}R0B_ROD: On the plus side, as you get accustomed to the grammar, Clojure is not a world of secrets or assumptions.
12:02justin_smithyeah, clojure lacks magic in many respects, and things are generally explicit though concise
12:02hiredman /win 19
12:02justin_smith(one of my favorite things about it actually)
12:02{blake}R0B_ROD: Also, this chat is indispensible. =P
12:03R0B_ROD{blake}: You are the second to be very chatty with me. #!Thanks. First: justin_smith
12:03{blake}justin_smith: Me, too. So far every big sticking point I've had was easily resolved by digging into the code--and I've never had to dig deep, because there's generally not a lot of "deep".
12:04R0B_ROD{blake}: Thanks for your sequence. I do have the koans but not 4clojure. I will be here so we can share in the future as well.
12:04{blake}R0B_ROD: My pleasure. I'd have been in trouble without this group so if I can pay it forward, I will.
12:04R0B_ROD{blake}: Very nice attitude. I am glad you will pay it forward.
12:05{blake}R0B_ROD: Also, it's fun.
12:06R0B_RODMy experience is a little: Haskell, Racket, Python2, Perl, Linux Shell Scripts, basic C/x86_64 Assembly, Arch Linux config and install.
12:06R0B_RODPlayed with classical FORTRAN just at the surface
12:07{blake}R0B_ROD: If you've got Haskell, Clojure should be easier for you than it was for me. I had studiously avoided functional programming (even in Smalltalk, which has quite a few HOFs).
12:07ToxicFrogYeah, a lot of the clojure concepts should be familiar with that background.
12:08R0B_RODBUT this is all at the syntactic and result level, the art of programming or better-said, the systematic methods of creating software is what I want to learn before learning a language
12:08R0B_RODresults as in building basic calculators or some very basic text manipulations
12:09ToxicFrogFundamementally, that's something you learn by writing a lot of programs.
12:09R0B_RODI enjoy the combination of Clojure so Im going to try and focus on developing my foundations and learn Clojure to solidify my findings.
12:10R0B_RODToxicFrog: Reading and debugging a lot of code is also a missed portion of learning fundamentals
12:11ToxicFrogR0B_ROD: I file that under "writing programs". You're going to be doing a lot of reading and debugging as part of that process.
12:11justin_smithgood luck writing working programs without debugging or reading code!
12:11ToxicFrogAlthough I should probably have been more general: you become a better programmer by programming.
12:11R0B_RODToxicFrog: I dont believe that creation, design and implementation are an all-in-all for everyone. Im not ery creative but very tinkere/disassembler type.
12:11benmossare these warnings something that should be fixed by the libraries maintainer? via (:refer-clojure :exclude [protocol?])?
12:11benmosshttps://gist.github.com/benmoss/19231a7f5d4b53e973e7
12:12R0B_RODToxicFrog: Yes I agree with you in your general statement. No doubt
12:12justin_smithbenmoss: yeah
12:12justin_smithbenmoss: that should be a very easy PR to do if you feel like giving back :)
12:12R0B_RODToxicFrog: I mean: I enjoy someone else telling me how to help instead of me creating something useful from scratch
12:12benmossjustin_smith: cool, i thought so, i just wanted to verify there wasn’t some reason they weren’t before going ahead and making the PR :)
12:13ToxicFrogR0B_ROD: yeah, that's fair. Which is part of why, on reflection, I think that "by programming" is the better formulation.
12:14ToxicFrogSince "programming" is a lot broader than "writing programs"
12:14R0B_RODIndeed ToxicFrog ;) :D xD :P
12:14R0B_RODIm just here guys... I dont have any other outlet to the outer-world
12:14godd2ToxicFrog here's a pretty good list of the things that programming encompasses (plus some more) http://plato.stanford.edu/entries/computer-science/
12:15R0B_RODI dont have friends-in-flesh... Trying to tap into IRC and make bytecode-friends
12:15R0B_ROD;>
12:17benmossjustin_smith: ah, i realize now my instinct was correct, these warnings are coming from installing Ultra yesterday (https://github.com/venantius/ultra) which has some stuff that adds fns to clojure.core, including `protocol?`
12:17ToxicFrogThat sounds familiar. My wife and I are trying to rebuild our social lives after basically losing track of everyone we knew in meatspace.
12:17benmossjustin_smith: mentioned here https://github.com/venantius/ultra/wiki/Java
12:17justin_smithbenmoss: oh, that's weird and kind of evil
12:18benmossjustin_smith: yeah makes me inclined to remove it
12:19ToxicFrogWe still have IRC-friends, but sometimes you just want someone to help bake a cake and then snuggle with.
12:19R0B_RODToxicFrog: I just live in a town where there isnt real:down2earth folk. Its all superficial, 'oh-what-car-u-drive?', 'got $$$' type culture
12:19justin_smithbenmoss: you know something about that project was setting off my spidey senses already, now that I am reminded which one it was
12:19justin_smithbenmoss: "smells like rubby"
12:19R0B_RODToxicFrog: I hear you. I just got seperated from my wife because she just didnt want to snuggle.
12:20R0B_RODToxicFrog: Im trying so hard to build a skill-set so I can find work using computers and linux. :|
12:20R0B_RODI have a feeling Clojure will help too!
12:21devllHow to setup -Xss option for Clojure ?
12:21justin_smithdevll: are you using lein?
12:21devllyes
12:21justin_smith:jvm-opts [ ... ]
12:21devllI am getting stackoverflow exceptions from a previously working code.
12:22justin_smithyou may need the ^:replace metadata to override the defaults
12:22ToxicFrogR0B_ROD: erk. My condolences.
12:22devlljustin_smith: thanks
12:22justin_smithdevll: I know you need ^:replace to specify the -server option for example
12:22ToxicFrogI graduated, and then we moved, and then we had a baby, and that kind of nuked our social life -- we've basically got my family (hers lives hours away), my ex, and an old friend of hers from uni she just reconnected with, and that's it :/
12:25devllOK. thx
12:29R0B_RODToxicFrog: My condolences. Glad you graduated. Im a father too. I feel you on social life for a married young couple. Im 30 y/o
12:31ToxicFrogR0B_ROD: hah! I'm 29.
12:32ToxicFrogShe's starting to make friends at the baby's swimming lessons, but I'm at work all day. And neither of us are really good at meeting new people.
12:33ggherdov,(into {} '(("a" "b") ("c" "d")))
12:33clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map$Entry>
12:33justin_smithggherdov: it needs vectors
12:34ggherdovjustin_smith: ah thanks
12:34justin_smith,(into {} '(["a" "b"] ["c" "d"]))
12:34clojurebot{"a" "b", "c" "d"}
12:34ggherdovI see thanks
12:34justin_smiththough that message mentioning String - that's messed up actually
12:34R0B_RODToxicFrog: Nice;>
12:34justin_smithit should have complained about list not string, right?
12:35ggherdovjustin_smith: it got me very confused. I still am not sure what the error is about.
12:36justin_smith,(into {} '((["a" 1] ["b" 2]] [["c" 3] ["d" 4]]))
12:36clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>
12:36ggherdovI'd have guessed that vectors and lists has interchangeable interfaces
12:36justin_smith,(into {} '((["a" 1] ["b" 2]) (["c" 3] ["d" 4])))
12:36clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry>
12:36justin_smithwat
12:36justin_smiththat's a bug in the error message
12:37justin_smithbecause vectors definitely can be cast to map$entry
12:37ggherdovjustin_smith: what is a map$entry ? The key, the value or the key-value pair?
12:37csd_Can anyone suggest a library for mocking sockets?
12:38justin_smithggherdov: key/value pair
12:38ggherdovok
12:38justin_smith,((juxt type identity) (first {:a 0}))
12:38clojurebot[clojure.lang.MapEntry [:a 0]]
12:38justin_smiththey even print identical to vectors
12:38justin_smith,((juxt type identity vector?) (first {:a 0}))
12:38clojurebot[clojure.lang.MapEntry [:a 0] true]
12:38ggherdovI see.
12:38justin_smiththey even count as a vector
12:39justin_smithanyway, off to add a bug report on the tracker
12:39mahinshaw,(into {} '([:a 1] [:b 2]))
12:39clojurebot{:a 1, :b 2}
12:44R0B_RODgodd2: Hey I check the Clojure Brave and True site but I think thats more for quiche eaters.
12:45godd2R0B_ROD well I don't know what a quiche eater is supposed to be, other than someone who eats quiche, which I can't really see as an insult, so can you clarify?
12:47R0B_RODgodd2: Just a little humor. Quiche-eater is reffered to someone with sensitive programming requirements, Pascal programmers, or other "easy-structured" language. Its folk tradition in Unix culture. The Story of Mel < google
12:48godd2I've read the story of Mel. He was pretty hardcore though
12:48R0B_RODgodd2: Yup
12:49R0B_RODgodd2: I commented on the site of 'brave' and true, he remmoved it, lol. Constructive critisism
12:50R0B_RODOh well... in this age of free and bloated functionality there is nothing less I expect. The future is doomed
12:50{blake}R0B_ROD: Huh. By that def, I'm a quiche eater, but I didn't find Brave & True that helpful.
12:51godd2R0B_ROD you can feel free to be pessimistic. In the future, I'll remember not to offer you any recommendations to try and help :)
12:51R0B_ROD{blake}: LOL
12:51{blake}Actually, I've been fretting over it for a while. I'd like to produce some really great beginner's stuff.
12:51R0B_RODgodd2: Nah man, I didnt mean it that way, chill
12:51R0B_ROD{blake}: Can I help?
12:51godd2THE SMILEY PROVES THAT IM CHILL UGH
12:52{blake}godd2: lol
12:52noonian_from the story of mel: “If a program can't rewrite its own code”, he asked, “what good is it?”
12:52R0B_RODgodd2: ugh, Im a bad parser
12:52{blake}R0B_ROD: Maybe some day. Writing good beginner's stuff is an odd balance of having mastery over the material with the memory of what it's like to not know anything.
12:53godd2R0B_ROD its okay, that's something computers are good at. I hear if you learn a LISPy language, you can make a parser easily. I wonder which one you could choose...
12:53R0B_RODlol {blake}
12:53{blake}I'm usually pretty good at it, but it can be especially difficult when the thing you're doing changes your brain. =P
12:53csd_Can anyone suggest a library for mocking sockets or suggest how to test without one?
12:54R0B_RODgodd2: Not sure, too soon to tell. So much for me to learn
12:54godd2R0B_ROD ah then may I suggest that you hold your criticisms until you learn more
12:54Glenjamincsd_: midje has some stuff built-in, with-redefs is in core, there are libs on clojars called "bond" and "q" which do some stuff
12:54Glenjaminoh
12:54Glenjaminsockets
12:54godd2in that it would be in your best interest
12:55Glenjamini didn't see that bit
12:55cddrIs there a name for the concept of tree which is a copy of another tree but with some nodes transformed or removed
12:55csd_yeah :-/
12:55Glenjaminignore everything i just said
12:55csd_haha
12:55csd_ Any alternatives?
12:57R0B_RODgodd2: To my memory I havent critizied anything. I suggested a web site an improvement.
12:57godd2That is an example of a criticism
12:57godd2I mean, do what you want, it was just a suggestion
12:58godd2word to the wise, if you will
12:58R0B_RODOk :)
12:58godd2when in clojureland do as the clojurans do
12:58godd2clojans?
12:58R0B_RODOh I dont do as anyone
12:58noonian_i think its Clojurians or Clojurists
12:58R0B_RODSorry this might be the wrong plce for me
12:59godd2but definitely not Clojuristas
12:59csd_ is there maybe someway to shadow ServerSocket so that particular method calls return exactly what I want?
12:59csd_@Glenjamin
12:59godd2Clojurinianists
12:59uptownclojet cases
13:00justin_smithcsd_: sounds like a good case for making a proxy or reify
13:00justin_smithcsd_: implementing the same interfaces ServerSocket does, with dummy method impls
13:01csd_i'll give that a shot
13:02justin_smithcsd_: another option is to rewrite your code to use a protocol (which you extend ServerSocket for) and pass in the impl
13:02justin_smithso for the test you pass in the test impl
13:02noonian_thats my recomendation
13:03csd_sorry i don't understand that justin, can you explain a bit further
13:04justin_smithcsd_: you would define a protocol that does all the things you need your ServerSocket to do, and then extend ServerSocket to that protocol
13:04csd_what's the advantage of that? seems like it would be easier to use reify?
13:04justin_smiththen you define a record that extends that same protocol, with testing impls of all the protocol methods
13:04justin_smithcsd_: if it is easier to use reify, that is your answer
13:04justin_smithprotocols are helpful when you abstract a bit more from the concrete jvm class
13:05csd_i'm guessing. i don't have experience doing any of these things before
13:05justin_smithcsd_: if your functionality that you want to wrap is just the core functionality of ServerSocket, I would just proxy ServerSocket and override the applicable methods, or reify the interfaces ServerSocket uses
13:06csd_ok
13:06csd_thanks
13:06justin_smithand then you have a small refactoring to pass in the impl rather than creating a ServerSocket every time
13:06justin_smithbut that part should be straightforward
13:18{blake}So, if I'm using ring in my ns, but it isn't in my dependencies list, that means I'm using whatever version some other lib (compojure, say) is pulling in, yes?
13:18justin_smith{blake}: yeah, if you run "lein deps :tree" it will show you where ring is coming from
13:19{blake}justin_smith: Thanks! I had forgotten that!
13:19{blake}(inc justin_smith)
13:19lazybot⇒ 177
13:20{blake}And this is bad, because we end up with hidden, unspecified dependencies. Or could it be good in some cases?
13:22justin_smith{blake}: it's good form to explicitly depend on it if you use it directly
13:22{blake}justin_smith: I guess the "good" is if you don't rely on it directly you're not required to care.
13:24pandeirois there anywhere that clojure's roadmap WRT to java version compatability is outined?
13:26justin_smithpandeiro: anything 1.5+ will work, there has been talk about raising that limit though
13:26justin_smithpandeiro: but I don't know that there is any concrete plan to upgrade the required version
13:26pandeirojustin_smith: is that documented anywhere, eg for clojure 1.7?
13:26justin_smithpandeiro: it should be somewhere on clojure.org or maybe even the main clojure project README
13:27pandeirojustin_smith: yep, http://clojure.org/getting_started
13:27pandeirosays 1.6
13:27justin_smithho ho!
13:29clgvpandeiro: it probably stays with Java 6 for Clojure 1.7
13:30clgvJava 6 is required since Clojure 1.6
13:30{blake}I've been using Java 8.
13:30clgvthat's ok ;)
13:31{blake}Appears to be!
13:33hyPiRiondoc <
13:33hyPiRion(doc <)
13:33clojurebot"([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically increasing order, otherwise false."
13:33hyPiRion^ what's up with `non-nil`? I thought it always would return true.
13:34Glenjamin,(<)
13:34clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/<>
13:34justin_smithggherdov: I created a bug report on the Clojure jira for that issue http://dev.clojure.org/jira/browse/CLJ-1651
13:34Glenjamin,(< 1)
13:34clojurebottrue
13:34BronsahyPiRion: yeah doesn't look like it will return anything else
13:34GlenjaminBut I guess it's allowed to in future.
13:34justin_smithBronsa: did you see that? I found it a bit amusing.
13:35GlenjaminOr maybe did in the past?
13:36Bronsajustin_smith: I never understood that error message
13:36justin_smithBronsa: "PersistentVector cannot be cast to Entry" ohh reeeealy???
13:36lazybotjustin_smith: How could that be wrong?
13:37hyPiRionGlenjamin: yeah, but that would mean you cannot do (sort < [3 2 1]) for instance
13:37Bronsa(dec lazybot)
13:37lazybot⇒ 36
13:38Bronsa,((ancestors (class [])) java.util.Map$Entry) ;; justin_smith
13:38clojurebotnil
13:38justin_smithaha
13:38{blake}ancestors hould never return nil. Just turtles.
13:38justin_smithso it's technically true, though not helpful
13:39justin_smith🐢
13:39Bronsajustin_smith: I actually thought that PV implemented AMapEntry too
13:39Bronsa,((ancestors (class (first {1 1})) java.util.Map$Entry)
13:39clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
13:39Bronsa,((ancestors (class (first {1 1}))) java.util.Map$Entry)
13:39clojurebotjava.util.Map$Entry
13:40Bronsa,(first {1 1})
13:40clojurebot[1 1]
13:40Bronsa^ I guess this is why it confused us both
13:40Bronsa,(class (first {1 1}))
13:40clojurebotclojure.lang.MapEntry
13:40justin_smithso the issue is that if you pass in a vector, it can be specialized to a map entry
13:40justin_smithand a map entry is a vector
13:41justin_smithso really, it should complain that it can't be coerced to vector
13:41BronsaI just accepted that conj on maps is weird
13:41justin_smithheh
13:41Bronsaan try not to use it
13:41justin_smithbut into is so handy
13:41hyPiRion,(let [f (juxt key val)] (-> {1 2} first f f))
13:41clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry>
13:41Bronsaassoc/merge for maps, conj/into for vectors
13:41hyPiRion,(let [f (juxt key val)] (-> {1 2} first f))
13:41clojurebot[1 2]
13:42Bronsajustin_smith: I believe that if the PV enhancement proposed by ztellman gets into 1.8, we will be able to unify PV with MapEntry
13:43justin_smithcool
13:43Bronsasince we will have a concrete type for a 2-element vector
13:48llasramHuh. Clojure at one point had a FixNum class
13:49llasramhyPiRion: I was hoping software archaeology would reveal that the numeric comparison operators once returned the larger/smaller value on truth, but no -- that docstring is just wacko
13:50gfrederickswhat was FixNum? a wrapper around Long to mess with hash codes?
13:50hyPiRion(< 1 2) → :hi-there
13:52llasramgfredericks: https://github.com/clojure/clojure/blob/b58d5badd4ed397f0f6e9be306ac12311c7049d9/src/jvm/clojure/runtime/FixNum.java
13:52llasramgfredericks: `int` apparently
13:54TimMchyPiRion: (< 1 2) → false ;; false is non-nil
13:54hyPiRionTimMc: hah, that's an even better example
13:54justin_smith(< 1 2) -> false "am I on crazy pills?"
13:55hyPiRion(inc TimMc)
13:55lazybot⇒ 87
14:02csd_ it doesn't look like reify will work after all. reify only works on java interfaces, and ServerSocket only has the interfaces Closeable and AutoCloseable, which don't help me
14:02csd_@ justin_smith
14:02justin_smithcsd_: that's where proxy comes in
14:02justin_smithyou can proxy ServerSocket itself
14:03csd_i see
14:03justin_smithalso, failing that, this is where coding to a clojure protocol wins
14:03csd_whatever the outcome, learning a lot
14:04justin_smithcsd_: the way clojure likes to do things, coding against interfaces and protocols, works out really nicely I think
14:05csd_do any of you use erc? very frequently the nick auto-completion doesn't acually end up in my submitted text, even though i see it before i hit return... very strange
14:05csd_ protocols and interfaces are basically the same thing, just one is for java and the other for clojure, correct?
14:06justin_smithcsd_: weird - I switched to irssi so I could leave irc logged in on my vps, but I never had that issue with erc
14:06justin_smithcsd_: protocols are backed by an impl interface
14:06justin_smithbut they define some extra stuff too
14:07justin_smithkind of like with defrecord defining a class, but giving you some stuff for free
14:14cddrI tried java 8 but ran into problems with the new date package. It may have been me being stupid though and I didn't have time to investigate much
14:18justin_smithcddr: I have had zero issues with java8
14:20TimMcGood, because Java 7 is apparently end of life.
14:20TimMcNo more public security patches (at least on Oracle side.)
14:21hyPiRiononly protected ones.
14:21justin_smithhyPiRion: so you need to be in Larry Ellison's will to have any hope of a patch?
14:22hyPiRionjustin_smith: you must just extend him.
14:22justin_smithhaha
14:23justin_smitham I allowed to use the rack?
14:25svericddr: IIRC the new date package is taken from joda-time which is pretty awesome
14:37cddrYeah it might have been a clojure lib trying to pull in joda-time and getting collisions.
14:37csd_proxy is giving me "method not found in class errors
14:39csd_shouldn't at least one of these work? https://www.refheap.com/96652
14:39justin_smithcsd_: do your arg counts match?
14:39Bronsacsd_: proxy unlike reify/deftype doesn't require an explicit "this" arg
14:40Bronsacsd_: and ServerSocket/accept takes no args
14:41Bronsacsd_: you can't define new methods using proxy, reify or deftype, only override already existing ones
14:45csd_ what should i do if i want to pass a ServerSocket into a function, and have it return an overridden (.getHostName (.getInetAddress socket))
14:46csd_getHostName is part of the InetAddress class, not ServerSocket
14:46justin_smithcsd_: override (.getInetAddress socket) to return a reify / proxy that covers .getHostName
14:47justin_smithor, write a protocol that does (.getHostName (.getInetAddress socket)) for a socket, and returns a string for your test impl
14:47csd_but I'm creating the socket via (ServerSocket. port)-- how would the InetAddress get wrapped in?
14:48csd_oh i think i see what you're suggesting
14:48csd_proxy getInetAddress, and have the proxied version return the overriden function
14:48justin_smith.getInetAddress returns an InetAddress describing a port on localhost
14:48justin_smithright
14:49csd_is this a the point yet where it would be easier to write a protocol
14:49justin_smithyeah, that way you don't need to use reify or proxy, and you don't need to replicate deeper structure of types of methods
14:50justin_smithso I would say yes
14:50csd_ok
14:50justin_smithbut the exercise of doing it with a proxy is worth it :)
14:50justin_smithand will be useful another time I am sure
15:00sdegutisWhat's an impeccable technique for taking a list and getting a map of all duplicated items like {item => times-found} where times-found is more than 1?
15:01justin_smithsdegutis: frequencies
15:01justin_smithwait, more than 1?
15:01justin_smith,(frequencies [1 2 3 2 3 3 4])
15:01clojurebot{1 1, 2 2, 3 3, 4 1}
15:02justin_smithhmm, could be clearer ##(frequencies [:a :b :c :b :c :c :d])
15:02lazybot⇒ {:a 1, :b 2, :c 3, :d 1}
15:02justin_smithI guess you can then filter it to remove 1
15:03justin_smith,(into {} (remove #(= (val %) 1) (frequencies [:a :b :c :b :c :d])))
15:03clojurebot{:b 2, :c 2}
15:04sdegutisWell that is impeccable I suppose. But what about an immaculate method?
15:04csd_so proxy returns a new class. it seems like i can't use it as a constructor though. e.g. (def foo (proxy ... )); (foo. bar) isn't valid
15:05justin_smithcsd_: (.newInstance (class foo))
15:05hiredmanproxy turns an instance of the class
15:05hiredmannot a class
15:06csd_ how do i tell it what the constructor params are?
15:06hiredman,(doc proxy)
15:06clojurebot"([class-and-interfaces args & fs]); class-and-interfaces - a vector of class names args - a (possibly empty) vector of arguments to the superclass constructor. f => (name [params*] body) or (name ([params*] body) ([params+] body) ...) Expands to code which creates a instance of a proxy class that implements the named class/interface(s) by calling the supplied fns. A single class, if provided, mus...
15:06justin_smithcsd_: why do you need to construct it?
15:06justin_smithwhy not just use the result of proxy directly?
15:06csd_i'm going to construct in my tests file the extended socket, and then pass that into my test functions
15:07justin_smithcsd_: why not directly use the result of proxy? or wrap it in a function that returns the proxy if you must
15:07justin_smithI mean newInstance will work, but it seems odd
15:08csd_i misunderstood how to call proxy. it looks like I do (proxy [class & args] ...). Didn't realize the args followed the class name
15:08hiredmanthey don't
15:08csd_oh
15:09gfredericks(proxy [class & interfaces] [args] ...)
15:16csd_https://www.refheap.com/96659
15:17csd_Anything noticeably wrong?
15:18sdegutisThanks for your help, dynamic typers.
15:18sdegutisEspecially justin_smith.
15:19amalloycsd_: that error message is saying that the no-arg constructor for InetAddress is not public
15:20amalloyand indeed there are no public constructors at all
15:20amalloyso you can't subclass it in any way i can think of
15:20csd_it's a method of ServersSocket, which is public http://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html#getInetAddress()
15:21amalloycsd_: the objection is to the proxy of InetAddress, not ServerSocket
15:21amalloyyou simply cannot proxy that class
15:21amalloybecause you cannot subclass it
15:22amalloyyou would get the same error from just: ##(proxy [java.net.InetAddress] [] (getHostName [] (println "foo")))
15:22lazybotjava.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to clojure.lang.DynamicClassLoader
15:22amalloywell, okay, except some lazybot weirdness i guess
15:22amalloyie, reading the docs for serversocket will not help you at all, because your problem is not in serversocket
15:22csd_I want to override InetAdress.getHostName given a ServerSocket. Is my only option left to try extending via a protocol or is that ruled out too now?
15:23csd_reason for this is I'm trying to find a way to mock sockets for testing
15:23amalloycsd_: no, just return something which isn't a proxy
15:23amalloyuse the static methods in InetAddress
15:24csd_ how would you mock sockets personally?
15:25amalloyi don't really understand what you're trying to do. i don't know why i would mock a socket at all. just create a real socket bound to localhost and talk to it
15:27csd_i think that's the route i'll take
15:44{blake}Options for using MS's jdbc interface for MS-SQL? I can set up a repository, do stuff with Maven...but can't I also just put the JAR somewhere on my CLASSPATH? (I mean, I guess I can't 'cause I tried that, but maybe I'm just doing it wrong.)
15:44{blake}lein can't find the JAR when I put it in /targets.
15:45justin_smith{blake}: mvn install
15:45sdegutisDo most of you prefer to use core.typed in most of your code?
15:45sdegutisOr do you prefer the freedom and danger and excitement of dynamic typing?
15:46ToxicFrogsdegutis: I would love to use core.typed in most of my code, but historically I've had issues with it choking on things like command line parsers.
15:46ToxicFrogAt that point I spend more time fighting the type checker than I gain in up-front bug detection, so I shelve it for another half year.
15:47{blake}sdegutis: "I’m not against types, but I don’t know of any type systems that aren’t a complete pain, so I still like dynamic typing."
15:47bodie_this feels like a dumb question, but how would you write a function that does nothing but eval to the same value no matter what?
15:47justin_smithbodie_: constantly
15:47bodie_ok. thanks
15:47{blake}justin_smith: Wow...can I kiss you if that works? Or, send a designated hot female (or male, your choice) to kiss you?
15:47sdegutis{blake}: which ones have you tried?
15:47justin_smith,(map (constantly 42) [:a 2 "hello" nil []])
15:47clojurebot(42 42 42 42 42)
15:48justin_smith{blake}: no need, but it will work
15:48sdegutis{blake}: I'm curious especially if you've tried Haskell and found it to be problemsome, since I'm looking into Haskell myself.
15:48{blake}sdegutis: Clojure is my first functional language.
15:49{blake}sdegutis: But I've coded in Basic, Pascal, PL/I, C, C++, Java...that may be it for statically typed systems. Wait, does Javascript count? I sorta don't think so. Actionscript is statically typed, and I do that.
15:50bosky101does anyone know of a http client that prints that stops just short of sending data over the socket, and instead returns the binary data . eg “GET / HTTP/1.1\r\n..."
15:50justin_smith{blake}: hindely-milner (as ml and haskell use) is a completely different experience compared to most static typing
15:50{blake}sdegutis: Then there's Smalltalk, PHP, Perl, Python and Ruby. I feel a little uneasy in Ruby sometimes, but I actually haven't had any issues with typing.
15:51justin_smith{blake}: hindley-milner type systems don't require type annotations at all, as long as the types are unambigous based on binding or usage
15:51amalloybosky101: just use a real http client, and an http server on your own machine that prints out what it gets, or wahtever
15:51{blake}justin_smith: I'll check it out. The more I don't use typing, the less I miss it. And, again, big Pascal guy here. (And PL/I which would happily convert anything to anything with the gentlest of warnings about it. Then you'd get killed on your CPU-cycles bill.)
15:52{blake}justin_smith: Wait, does that count, then? =P
15:52justin_smith{blake}: no, the typing is quite strict, with few implicit conversions (ml won't even force into to float)
15:52tomjackI think they just don't require type annotations at all, unless the type inferred is not the type you want?
15:53justin_smithyou just don't need to declare the type if the logic engine can prove what type the binding has to be
15:53tbaldridge{blake}: I used to do some work on a Pascal/Delphi system. It's a crime C won mindshare over Pascal. it's really a wonderful language.
15:53{blake}justin_smith: But strict <> static. Smalltalk is strict.
15:53justin_smith{blake}: strict and static
15:53justin_smith{blake}: but does not need explicit declarations
15:53{blake}tbaldridge: It is, though Delphi has become more and more Java-C#-esque.
15:53sdegutis{blake}: wow those are some unpleasant languages you named
15:54tomjackI prefer something which generally requires type annotations because inference is undecidable, but where annotations can be omitted whenever the system happens to be able to infer the type
15:54{blake}justin_smith: Well, so...let's say it's inferred one thing from use, then you do something that makes it infer something else...Well, I guess that's still static, but yeah, that'd be a horse of a different color.
15:54sdegutistomjack: like Haskell?
15:54tomjackno, like Agda
15:54sdegutisOh cool.
15:55justin_smith{blake}: if there is no unification of the inference possible (because it would need to be two different types, or no usage makes the type clear) you get a compilation error
15:55justin_smith{blake}: but in practice, almost always, usage makes the type clear
15:55tomjacke.g. omitting annotations on most defns is a non-goal for me, because the first thing I probably want to do when writing a defn is to specify the type
15:56tomjackotherwise, how will I know that the implementation is correct? :)
15:56{blake}sdegutis: I liked all of them except C and C++. Perl makes me woozy, but for what it is and what it does, it's tough to beat.
15:56{blake}I forgot REXX! No typing at all in REXX. Everything is a string. =P
15:56{blake}OOREXX is ...well, it's just ... a thing to be experienced.
15:57{blake}Also, while I rather enjoy PHP, working in it usually means unravelling some awful framework.
15:57justin_smithOOREXX is the sound I make when a language turns my stomach
15:57{blake}(I consider it a dangerous toy, sorta like Basic.)
15:58{blake}justin_smith: That's what happens on an all-string diet.
15:58justin_smithlol
15:58{blake}REXX's big thing was the principle of least surprise. That was its guiding consideration. It is the most surprising language I've ever worked with.
15:59{blake}Mis-spell "DOG" that you're using as an integer counter as "DOGG" and add one to it...I think you get "DOGG1"?
16:00{blake}Awesome batch language, tho'.
16:04{blake}I guess assembler is the ultimate dynamically typed language.
16:05justin_smith{blake}: untyped, which is different
16:05justin_smithin dynamic typing, eventually, at runtime, you check the type
16:05justin_smithuntyped is like, OK, it's bytes, that checks out, chuck 'em in
16:06justin_smithbecause everything is just some quantity of bytes
16:06{blake}justin_smith: And, really, isn't that always true? (True, but not helpful, as you noted earlier.)
16:07justin_smith{blake}: types are of course the fiction of some language. But it's a fiction that helps us ensure correctness.
16:07justin_smithit's a constraint that isn't intrinsic to the machine, but in practice makes programming so much easier...
16:12{blake}Back to Maven install...is there a maven repository for each lein project? Is that the deal? So if I install a JAR with maven install for project A, it must be done again for Maven B?
16:12{blake}er project B?
16:12justin_smith{blake}: no, there is one repo per user
16:12justin_smithso unless you have a different user for each project, it only needs to be installed once
16:23{blake}justin_smith: So I think I've installed it. mvn reports success. Do I need to specify a repository in project clj or install with lein or...?
16:24justin_smith{blake}: if mvn installed it, you require it like you would any other lib in project.clj
16:24justin_smith[group/dep-name "version"]
16:24justin_smiths/require/depend on it/
16:38{blake}So if it's not working for me, I probably have the name wrong somehow.
16:38justin_smith{blake}: what coords are you trying to use?
16:39{blake}justin_smith: Well, I installed it as "com.microsoft.sqlserver/sqljdbc4".
16:40{blake}(That's the group ID/artifact ID.
16:40justin_smithOK
16:40justin_smithand what does the entry in project.clj look like?
16:40{blake}Version 4.
16:40justin_smith?
16:40{blake}[com.microsoft.sqlserver/sqljdbc4 "4.0"]
16:41{blake}The path is \.m2\repository\com\microsoft\sqlserver\sqljdbc4\4.0\sqljdbc4-4.0.jar
16:41justin_smiththat all looks right
16:42justin_smithand when maven installed it, did it also install a pom?
16:42{blake}Yes. Same path, just .pom
16:43{blake}Wait, I'm describing this wrong.
16:44{blake}I apologize. My lein deps is fine. It's showing up in the tree.
16:44{blake}I just can't seem to actually use it.
16:44justin_smith{blake}: recall that the object package is not always (or even usually?) the same as the package coords
16:45justin_smithhow are you trying to access the classes in the jar?
16:45{blake}justin_smith: I was trying to require it.
16:45justin_smith{blake}: you can only require clojure code
16:45{blake}And I just don't need to do that. It just has to be there for clojure.java.jdbc.
16:45{blake}Right. Dumb.
16:46{blake}It's installed. Thanks.
16:46justin_smithglad you got it sorted out
16:46{blake}I'm allergic to ODBC.
16:49{blake}So...I can only require Clojure code...but I can import whatever?
16:50justin_smith{blake}: right
16:50justin_smithand the jvm autoloads things from the classpath as they are accessed
16:50justin_smithimport is just a syntactic convenience
16:50{blake}justin_smith: For?
16:51{blake}Manually loading stuff?
16:51justin_smithfor not having to type out the full package name
17:02gfredericks,["symbol" 'keyword :string]
17:02clojurebot["symbol" keyword :string]
17:03justin_smithgfredericks: that's like that test where the words for the colors are written in other colors
17:03seangrovejustin_smith: I was thinking the same thing
17:03justin_smithhttps://faculty.washington.edu/chudler/words.html
17:04justin_smith"the stroop effect"
17:06gfredericks,[(atom "ref") (ref "agent") (agent "atom")]
17:06clojurebot[#<Atom@622f497c: "ref"> #<Ref@5fbc8330: "agent"> #<Agent@ce82bd7: "atom">]
17:06gfredericksoh even better
17:06gfredericks,[(atom ref) (ref agent) (agent atom)]
17:06clojurebot[#<Atom@2718561f: #<core$ref clojure.core$ref@9e0e83d>> #<Ref@caf01dc: #<core$agent clojure.core$agent@66bfb2c5>> #<Agent@3371d836: #<core$atom clojure.core$atom@5d111be2>>]
17:06justin_smithand now I am thinking of stroopwafels.... mmmmm stroopwafels
17:06gfredericks,(atom (ref (agent atom)))
17:06clojurebot#<Atom@45ba6928: #<Ref@514de4db: #<Agent@50ec0f90: #<core$atom clojure.core$atom@5d111be2>>>>
17:08gfredericks^ concurrency protip
17:08amalloygfredericks: ##(map #(% %2) (partition 2 1 [atom ref agent atom]))
17:08lazybotjava.lang.SecurityException: You tripped the alarm! agent is bad!
17:09justin_smithgfredericks: I'd like to see a single swap! call that rearranges all those contents (maybe changes their nesting)
17:09justin_smithmaybe throw a delay or a promise in there too
17:10gfredericks,(->> [atom ref agent delay future] (rand-nth) (fn []) (repeatedly 10) (reduce #(%2 %1) 42))
17:10clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/delay, compiling:(NO_SOURCE_PATH:0:0)>
17:10gfredericksaw snapchat
17:10gfredericks,(->> [atom ref agent] (rand-nth) (fn []) (repeatedly 10) (reduce #(%2 %1) 42))
17:10clojurebot#<Ref@4531bbc1: #<Agent@441d9f64: #<Agent@74cb812b: #<Agent@5c8d69f4: #<Agent@482741a4: #<Agent@9469afe: #<Agent@7a699e73: #<Ref@2c21cece: #<Ref@5f904d04: #<Ref@7ab0729f: 42>>>>>>>>>>
17:10justin_smithit's like a rat-king of concurrency containers
17:11gfredericksand then you mutate the bottom one to contain the top one
17:11TimMc&(let [a (atom nil)] (reset! a a) a)
17:11justin_smithgfredericks: or put a promise at the very bottom, and deliver the top one to it
17:11lazybotjava.lang.StackOverflowError
17:11seangrove,(let [b (atom nil) a (atom (ref (agent b)))] (reset! b a) (loop [v a c 10] (recur (deref v) (dec c))) :unprintable)
17:11clojurebotExecution Timed Out
17:12seangrove,(let [b (atom nil) a (atom (ref (agent b)))] (reset! b a) (loop [v a c 10] (when (pos? c) (recur (deref v) (dec c)))) :unprintable)
17:12clojurebot:unprintable
17:12seangroveicanclojurez
17:19slipsetwhat would be the idiomatic way to interupt a go-loop in a repl?
17:20justin_smithslipset: one option is to make a "poison pill" channel that askes the loop to stop
17:21slipsetjustin_smith: thanks, I've used an atom, like this:
17:21slipset (go-loop []
17:21slipset (handle-output cfg (<! messages))
17:21slipset (when @continue
17:21slipset (recur)))
17:22slipsetBut it would be nice to be able to kill the thing without restarting the repl
17:22justin_smithslipset: here's a poison channel example from danneu http://www.reddit.com/r/Clojure/comments/2ka3na/how_do_you_organize_your_coreasync_code/cljqzwb
17:24slipsetjustin_smith: thanks for the link, very nice approach
17:30slipsetjustin_smith: in http://www.reddit.com/r/Clojure/comments/2ka3na/how_do_you_organize_your_coreasync_code/
17:30slipsetit is mentioned that
17:31slipset(go-loop [m (<! messages)]
17:31slipset(handle-output cfg m)
17:31slipset(recur (<! messages)))
17:32slipsetwill terminate once messages closes
17:33slipsetbut I can't read that out of the docs for neither go-loop, loop nor recur
17:33slipset~loop
17:33clojurebotloop is https://www.refheap.com/90332
17:35slipsetcrap, my bad, didn't read the whole code
17:35slipsethe had a when in there.
17:35slipset(go-loop [v (<! in)] (when v (println v) (recur (<! in)))
17:38tomjackjustin_smith: are the natural numbers fictional? :)
17:39xyz_Hello, using clj-time/clj-time, how do I import DateTime ? I have a check like that : (condp = x DateTime (...)) and I (:require [clj-time.core :as t] [clj-time.format :as f])
17:40justin_smithtomjack: of course, they are a mental construction
17:40TimMcxyz_: To refer to DateTime without the full package prefix, you need to :import it.
17:40TimMcThis is just like in Java -- "import" is an unfortunate term.
17:41slipsetxyz_: (:import [java.net URLEncoder])
17:41xyz_TimMc: I see. And it is in core then I guess? so I should use t/DateTime ?
17:41TimMcso this would be like (:import (org.joda.time DateTime))
17:42xyz_TimMc: Oh ok. Thank you!
17:42slipsetTimMc: but with the square breackets, yes?
17:42slipsets/breackets/brackets/
17:42TimMcI use lists instead of vectors there. I think it actually specifies that but will accept either.
17:43TimMcxyz_: The foo.bar/baz syntax is for vars, which are a Clojure thing. DateTime is a class. While it could have been defined by something in clj-time.core, it isn't a var.
17:43justin_smith(doc import)
17:43clojurebot"([& import-symbols-or-lists]); import-list => (package-symbol class-name-symbols*) For each name in class-name-symbols, adds a mapping from name to the class named by package.name to the current namespace. Use :import in the ns macro in preference to calling this directly."
17:44TimMc(In this case it is defined by joda, but to the same effect.)
17:44TimMcjustin_smith: It says list, so I use lists. Also, the first element is distinguished. :-)
17:44justin_smithyes, just checking what the doc actually said
17:45xyz_TimMc: ok this clears the fog a bit now. And to import the joda jar? Is it in leiningen ? (I've only imported clojars)
17:45justin_smithxyz_: you don't import jars
17:46justin_smithand import doesn't open things or make them accessible, it just makes it syntactically simpler to refer to them
17:46justin_smiththe fact that the thing is on the classpath (as lein sets it up) is what makes the class available
17:46TimMcxyz_: Both joda and clj-time are jars. Clojars is a repository of jars. leiningen is a build tool that (among other things) pulls down jars from repositories.
17:47TimMcMore correctly, clj-time is an *artifact* -- a specification of dependencies along with an actual jar. Since it specifies joda as a dependency, when you ask leiningen to get clj-time, it also fetches joda and makes it available to you.
17:48xyz_timMc / justin_smith: not sure I get it yet : how will it find org.joda.time ?
17:48justin_smithxyz_: because it is in the classpath
17:48xyz_timMc / justin_smith: shoudl I look for importing from maven with lainingen ?
17:48sobelhi, i have a question about use of loop/recur. i'll be parsing a quasi-CSV file that has variable record types and some light rules about nesting. i thought i would just pass parse state as the loop variables. is that generally the worst use of memory or what?
17:48justin_smithit is in the classpath because lein set up your classpath, and downloaded it if it was not on your machine yet
17:49justin_smithxyz_: import doesn't make the class accessible, it's just a shortcut for referring to the class. The classpath makes the jar (and its classes) available.
17:49xyz_TimMc: ok that makes sense.
17:50justin_smithsobel: passing the object to the next loop doesn't use any more memory than any other way of leaving it accessible would
17:50xyz_justin_smith: I get it now thank you. And now, if I wanted to re-export DateTime from a namespace so that it becomes available, how would I do that? (:import [org.joda.time DateTime]) (def DateTime DateTime) doesn't work
17:50justin_smithsobel: clojure does very little copying, because most things we use are typically immutable anyway
17:51justin_smithxyz_: that's not how it works. If DateTime is on the classpath, any namespace can use it.
17:51justin_smithxyz_: why would you def?
17:52justin_smithdef creates vars, DateTime is a class.
17:52xyz_justin_smith: yes but the second namespace has to import it also ? Sorry if I'm unclear I can re-explain just say so.
17:52sobeljustin_smith: so i don't have to worry about it behaving like a real stack, which would grow proportionally with the loop count
17:52justin_smithxyz_: namespaces don't contain classes, they contain vars
17:52justin_smithxyz_: packages contain classes
17:52justin_smithsobel: no, there is no stack to loop
17:52TimMcxyz_: You specify [clj-time/clj-time "1.2.3"] or whatever in your project.clj. Leiningen asks Clojars (and other repos) "do you have that"? One says "yes, here is the jar for it and here's what it depends on". Leiningen continues to download dependencies until they're all in your ~/.m2 directory. Then when you start your program, all those jar files are included on the classpath. Any classes in those jars can simply be refe
17:52sobeljustin_smith: thx
17:52tomjackjustin_smith: I think the universe needs _at least_ primitive recursion to function, whether there are minds in the universe or not :P. I don't think I had noticed this ontological perspective on the 'church vs curry types' distinction before... thanks.
17:52amalloysobel: loop/recur uses jump instructions, not call
17:53xyz_TimMc / justin_smith: thank you for your help !
17:53TimMcxyz_: That part is basically identical to how Maven works with Java programs.
17:54justin_smithtomjack: sure, but the natural numbers don't need to exist as a reified thing, and as a description of our reality, they need not obey our mathematical axioms regarding the natural numbers
17:54justin_smithtomjack: we can find the mapping from our mathematics to how things in the world work useful, of course
17:54sobelok, probably going to write an amazingly elegant clojure statement to do some file parsing then recode the whole thing in java for realsies (deployment) because i don't (yet) work in a clojure shop
17:54justin_smithbut it's a model imho
17:54xyz_TimMc: unfortunately I did some java quite some time ago, and never used Maven... but I get the idea (similar to npm in node). Thank you!
17:55justin_smithxyz_: the namespaces with vars vs. packages with classes thing is a tricky one
17:55justin_smithxyz_: but it's better than the situation would be if we just used packages / classes for everything I think
17:58xyz_justin_smith: I trust it is :) I was confused indeed.
18:15TimMcxyz_: Better for now not to think too much about how vars and namespaces interact with classes and packages. The one interaction you need to know of is that namespaces *can* define classes, so you'll occasionally need to :require a namespace before you can use the classes it defines (by any name.)
18:19xyz_TimMc: I'll probably have to take some time to play with it before understanding that, so your simplification is welcome
18:23TimMcxyz_: WHen you :require a namespace you are actually causing it to be loaded, compiled, and made available for use (if it hasn't been already.) That includes side-effects like defining classes. :-)
19:28arohnerI'm getting "Could not find artifact net.mikera:mikera-pom:pom:0.4.0 in clojars.org' when I add [net.mikera/core.matrix "0.32.1"]
19:29arohnerand AFAICT, I haven't modified my :repositories settings
19:29arohnerand it looks like that pom is in mvn central
19:30arohneraha, it says it couldn't find it in clojars
19:30arohnerbut that version isn't in clojars
19:31arohner0.0.4 is the latest in clojars, 0.4.0 is the latest in mvn
19:31amalloywell, does it eventually find it in maven central?
19:31arohneramalloy: no, it errors out with a big stacktrace
19:31amalloyhonestly though i don't understand how pom-only artifacts work, or parent poms
19:39arohnersigh. replacing my :repositories order fixed it
19:40arohnerthis looks like a maven bug, because there are old net-mikera/mikera-pom versions on clojars, but not the version I asked for
20:09andyfjustin_smith: Which version of Eastwood are you using? Version 0.2.1 has some code where I tried to eliminate incorrect arity warnings specifically for clojure.java.jdbc/insert!
20:13justin_smithandyf: oh, my version is 0.1.5, that must be ancient by now
20:13justin_smiththanks
20:13andyfversion 0.2.0 and earlier do have known issues with incorrect warnings there. If you see them with 0.2.1 I would appreciate if you could file an issue with whatever details you can provide
20:13andyfOnly 4 months or so
20:14justin_smithandyf: that fixed it, thanks!
20:14justin_smith(inc andyf)
20:14lazybot⇒ 25
20:14justin_smith(inc eastwood)
20:14lazybot⇒ 8
20:15andyfCool
20:19xyz_Hello, I'd like to get some help on my merge/validate maps code. I made it work for simple nested maps, but it fails in the case of an array as a value inside the map. I'm not sure how I can attack the problem yet. Any ideas? I can post the full code if needed.
20:19justin_smithxyz_: for vectors, get-in / update-in can use a numeric index
20:20justin_smith,(get-in {:a [:b {:c 0} :d]} [:a 1 :c])
20:20clojurebot0
20:20justin_smithxyz_: unless you really mean arrays - not sure if it works with those
20:21xyz_justin_smith: good to know. I'm not sure how I can use that though. I used the flatten-map idea to list all the keys, so I should modify it ?
20:22justin_smithxyz_: you can update your flattened-map to descend to each numeric index of the vector separately
20:22xyz_I mean things like {:a [{:b "b" :c "c"}]}
20:22justin_smithxyz_: ##(get-in {:a [{:b "b" :c "c"}]} [:a 0 :c])
20:22lazybot⇒ "c"
20:23xyz_justin_smith: to be honest I don't quite get the code yet. I took it from amalloy's answer there http://stackoverflow.com/questions/21768802/how-can-i-get-the-nested-keys-of-a-map-in-clojure/21769786#21769786
20:24xyz_justin_smith: I'll experiment with the get-in / update-in and numeric indexes then (does it work for assoc-in too? I'm using that right now), and then try to modiy the fletten function.
20:24justin_smithxyz_: you would change the (if (map? m) ...) to a (cond (vector? m) ... (map? m) ...) and in the vector case you would iterate descending to each numeric index
20:24justin_smithxyz_: yes, assoc-in should also follow the numeric indexes
20:25xyz_justin_smith: thank you for the tip ^^ I'll probably be back again then :)
20:26justin_smithxyz_: another option, if you know the schema statically, is to replace [a b c] with {0 a 1 b 2 c}, which would generate the right keys in the output vec to work with get-in / update-in / assoc-in
20:28TEttinger,(zipmap [:a :b :c] (range))
20:28clojurebot{:c 2, :b 1, :a 0}
20:28justin_smithTEttinger: opposite order, but yeah, great point
20:28TEttinger,(zipmap (range) [:a :b :c])
20:28clojurebot{2 :c, 1 :b, 0 :a}
20:28TEttingeryeah just realized
20:28xyz_justin_smith: the schema is a parameter, so I guess it's not static ?
20:29justin_smithxyz_: in fact, you could just update the code you have now to do what TEttinger just did if you hit a vector, and then treat it the same way you would a map
20:29TEttingeryup
20:29justin_smithhrm
20:29justin_smith,(keys [:a :b :c])
20:29clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry>
20:29justin_smithaww, shucks :)
20:30TEttinger,(sequential? {:a 1})
20:30xyz_TEttinger / justin_smith: I really appreciate the help thank you! I'll try that first
20:30clojurebotfalse
20:30TEttinger,(sequential? [:a :b])
20:31clojurebottrue
20:31TEttinger,(zipmap (range) '(:a :b :c))
20:31clojurebot{2 :c, 1 :b, 0 :a}
20:31TEttinger,(sequential? '(:a :b :c))
20:31clojurebottrue
20:31TEttingergood
20:32TEttingerI'm not sure if there's a better test of "collection that isn't a map" here
20:33justin_smith,(map (every-pred (complement map?) coll?) [[] () #{}])
20:33clojurebot(true true true)
20:33metellusanything wrong with (not (map? ..
20:34justin_smithTEttinger: (every-pred (complement map?) coll?) catches one coll yours does not
20:34justin_smith(of the most common sorts)
21:10tcrayford____is there a way to specify multiple type tags on a local?
21:10tcrayford____e.g. I wanna say "this type is both clojure.lang.Counted and clojure.lang.IMeta", without two locals or involving reflection on either
21:21TEttingertcrayford____: do you mean type hints? you could probably make an interface that implements both? I'm not sure what the way to do this is
21:21TEttingerI'm not sure if Counted is an interface or class, tbh
21:27tcrayford____TEttinger: turns out you can just do (let [^clojure.lang.Counter ^clojure.lang.IMeta a thingy] …)
21:27tcrayford____I think anyway
21:27TEttingerwoah nice
21:27tcrayford____nope
21:27tcrayford____maybe not
21:27tcrayford____haha
21:27tcrayford____it compiles
21:27tcrayford____but it doesn't work ;)
21:28tcrayford____lang.Counted is an interface ;)
21:28TEttinger,(let [^clojure.lang.Counted c [1]] (meta c))
21:28clojurebotnil
21:35turbofail,(meta '^clojure.lang.Counted c)
21:35clojurebot{:tag clojure.lang.Counted}
21:36turbofailanyway the proper thing to do is not have to do that at all
21:36turbofailbut instead define separate functions that call the methods that you care about
21:36turbofaileach with their own relevant type hint
21:38turbofailand then hope those functions get inlined by the JVM
21:39turbofailbut in practice as long as you're not hitting reflection, you're probably in decent shape performance-wise even with the function calls
21:41tcrayford____turbofail: this is for *extremely* performance sensitive code, and I know what I'm doing (mostly)
21:41tcrayford____(in this case: trying to eliminate the conditional inside clojure.core/meta in clj-tuple's calling of it)
21:42tcrayford____though I suspect the JIT's prolly ahead of me here
21:42tcrayford____(on the other hand: http://cl.ly/image/2Z1G2f0e3d2A)
21:53TimMctcrayford____: Yeah, multiple ^foo.Bar will just overwrite each other.
22:26ambrosebs,(= (Boolean. false) false)
22:26clojurebottrue
22:26ambrosebs,(if (Boolean. false) 1 2)
22:26clojurebot1
22:27ambrosebs,(if (first [false]) 1 2)
22:27clojurebot2
22:27justin_smiththat's some weird ass shit
22:27ambrosebs,(if (first [(Boolean. false)]) 1 2)
22:27clojurebot1
22:27ambrosebsSo my question is, does `false` get boxed once it gets inserted into a vector?
22:28justin_smithwait, there is such thing as unboxed false?
22:28ambrosebsI'm highly ignorant here
22:28tomjackBoolean/FALSE
22:28tomjackBoolean. is a nono in clojure
22:29ambrosebsis Boolean/FALSE an object?
22:29tomjackclojure pretends it doesn't exist to make the non-insane case have better perf
22:29tomjackright
22:29justin_smithhttp://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html yeah, looks like boolean can actually be unboxed, TIL
22:29ambrosebsah so the primitive boolean is something different?
22:30justin_smithyeah, the "true false" has only one possible instance
22:30justin_smithand if you make new falses, they are not actually truly false
22:30justin_smithin fact they are instead falsely true!
22:30ambrosebsso I get this right, Boolean/FALSE is a boxed primitive false?
22:31justin_smith,(get {Boolean/FALSE 42} false)
22:31clojurebot42
22:32justin_smiththat either auto-boxed, or established that Boolean/FALSE is boxed
22:32justin_smith,Boolean/FALSE
22:32clojurebotfalse
22:32tomjack`public static Boolean FALSE = new Boolean(false)`
22:32tomjacker, final too
22:32ambrosebsoh I see.
22:33tomjack(with a `private final boolean value;`)
22:33ambrosebsI guess clojure uses pointer equality to test against FALSE
22:33tomjackclojure wants (identical? FALSE x) though
22:33tomjackyeah
22:34ambrosebswhen we type (Boolean. false), is that a nested boxed boolean anyway?
22:34ambrosebs,(= Long/NaN)
22:34clojurebot#<CompilerException java.lang.RuntimeException: Unable to find static field: NaN in class java.lang.Long, compiling:(NO_SOURCE_PATH:0:0)>
22:34justin_smithambrosebs: do you want Double/NaN ?
22:35justin_smith,(= Double/NaN)
22:35clojurebottrue
22:35ambrosebsthx :)
22:35ambrosebsfor a twitter snark
22:35justin_smith,(get {Double/NaN 42} Double/NaN)
22:35clojurebotnil
22:35justin_smithhaha
22:36ambrosebs,(= Double/NaN Double/NaN)
22:36clojurebotfalse
22:36ambrosebsnever gets old
22:44danielszmulewiczIs there an idiom to write a function that does x if its argument is a map, and does the same x for each map when the argument is a sequence of maps?
22:44tomjackno
23:17gfredericksthis bytecode is super weird
23:18gfredericksI just compiled (defn foo [x] (def bar x))
23:18justin_smithif someone had said "someone on #clojure discovered something super weird" I would have put a $100 bet on "gfredericks", no hints needed.
23:18gfredericksand the bytecode creates a map in the static initializer
23:18gfredericksan IPersistentMap
23:18justin_smithwoah
23:19gfredericksand stores it in a static field for good deffings later
23:19gfredericksthis is all normal
23:19justin_smithwhat does the map do?
23:19gfredericksit's got the metadata for the def
23:19gfredericksline number and such
23:19justin_smithahh, of course
23:19gfredericksbut
23:19gfredericksthe type of the static field is........
23:19gfredericksclojure.lang.AFunction
23:20gfredericksthen at runtime it pulls the map out of that static field and checkcasts it back to a persistent map
23:20gfredericksO_O
23:20gfredericksafaik there's nothing that is both an IPersistentMap an an AFunction
23:20gfredericksso I believe this bytecode is impossible
23:20gfredericks(it checkcasts it as AFunction on the way in as well)
23:21justin_smiththis isn't related to creating the var bar?
23:21gfredericksthe var itself is created in the static initializer
23:21gfredericks(not at runtime)
23:22justin_smithoh, right
23:22TEttingerwhat is AFunction? different how from IFn?
23:22gfredericksit's a class, not an interface
23:22gfredericksAFunction is an IFn
23:23justin_smithhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/AFunction.java
23:23justin_smithgfredericks: extends AFn
23:23gfrederickssure
23:23justin_smithimplements Fn
23:23gfredericksAFn implements IFn though so by extension...
23:24justin_smithwell it's an abstract class, so technically does it implement anything? not sure of those distinctions
23:24gfredericksyes
23:24justin_smithOK
23:24gfredericksI mean it's not instantiable
23:24gfredericksbut if you have something that is an AFn then it is definitely those other things as well
23:25gfredericksanyhow we can at least agree that ##(instance? clojure.lang.AFunction (hash-map 3 4))
23:25lazybot⇒ false
23:25TEttingerthat's extremely odd, yeah
23:25gfredericksAFunction is the superclass of any given function literal
23:26gfredericks,(supers (class #()))
23:26clojurebot#{clojure.lang.AFn clojure.lang.Fn java.util.concurrent.Callable java.lang.Runnable clojure.lang.IFn ...}
23:26TEttinger,(clojure.string/join " " (supers (class #())))
23:27clojurebot"class clojure.lang.AFn interface clojure.lang.Fn interface java.util.concurrent.Callable interface java.lang.Runnable interface clojure.lang.IFn interface clojure.lang.IMeta interface java.util.Comparator class java.lang.Object interface java.io.Serializable class clojure.lang.AFunction interface clojure.lang.IObj"
23:27TEttinger,(clojure.string/join " " (supers (class {})))
23:27clojurebot"interface clojure.lang.IEditableCollection interface clojure.lang.ILookup class clojure.lang.APersistentMap class clojure.lang.AFn interface clojure.lang.MapEquivalence interface clojure.lang.IHashEq interface java.lang.Iterable interface java.util.concurrent.Callable interface clojure.lang.IPersistentMap interface clojure.lang.Associative interface java.lang.Runnable interface clojure...
23:28gfredericksAFn is in there, but AFunction shouldn't be
23:29TEttinger,(re-seq #"\w+ (.+?AFunction)" (clojure.string/join " " (supers (class {}))))
23:29clojurebotnil
23:29TEttinger,(re-seq #"\w+ (.+?AFn)" (clojure.string/join " " (supers (class {}))))
23:29clojurebot(["interface clojure.lang.IEditableCollection interface clojure.lang.ILookup class clojure.lang.APersistentMap class clojure.lang.AFn" "clojure.lang.IEditableCollection interface clojure.lang.ILookup class clojure.lang.APersistentMap class clojure.lang.AFn"])
23:29gfredericksoh wait
23:29gfredericksI lied
23:29gfredericksit stores it as an AFn
23:29TEttingerheh
23:29TEttingercrisis averted!
23:30gfredericksindeed
23:30gfredericksclojure is saved
23:30gfredericksalso now I know exactly what happens when you def something in a function
23:31TEttingerwhat's your reason for doing this, gfredericks?
23:31TEttingerare you doing optimizations on clojure's core?
23:31gfredericksoh heck no
23:31gfredericksjust making a talk on vars
23:32justin_smithgfredericks: wait, what is stored as an AFn?
23:32gfredericksjustin_smith: the metadata map
23:32justin_smithfascinating
23:32gfredericksbut a map is an AFn so it's okay
23:32gfredericksweird but okay
23:33gfredericksseems to necessitate extra checkcasts