#clojure logs

2015-07-26

01:35elvis4526Are atoms more expensive than vars ?
01:35SeyleriusHrm. I've got a formula that turns an integer representing the index of a new moon (first in 2000 is 0, increment from there) into the date of that new moon. Is it more sensible to have it generate a lazyseq of new moon dates (starting at an arbitrary point), or something else? I'm just not sure.
01:44ebzzryis there a way to convert a string to an InputStream?
02:04arrdemebzzry: StringReader is what you want
02:04arrdemhttp://docs.oracle.com/javase/7/docs/api/java/io/StringReader.html
02:04ebzzryarrdem: thanks
03:04arrdemebzzry: sure
03:05justin_smitharrdem: sometimes I have found I want string -> .getBytes -> ByteArrayInputStream.
03:05justin_smithwhen you really need InputStream, not Reader
03:10arrdemIt would be an interesting thought experiment to look at all the Java base classes and go "Ok, so what went wrong and what would Java2 look like".
03:10arrdem'course like Clojure2 it's an exercise in futility...
03:22jefelanteWould anyone be so kind as to help me figure this out? I'm pulling my hair out trying to extract this data https://gist.github.com/anonymous/b840211c8ce0088d79da
03:24justin_smithjefelante: your outer call should be a mapcat, not a map
03:24justin_smithjefelante: that would give you the result you expect
03:24justin_smith(the outer call being the one you don't show in the gist (mapcat (that anon fn) input)
03:24justin_smith)
03:25domokatothere must be a better way to write this clamp function? http://pastebin.com/Bn3Rxj69
03:25jefelantejustin_smith: awesome, thanks
03:25justin_smithjefelante: the principle to remember is if you want an arbitrary number of output elements for each input, use mapcat instead of map, and make sure your function returns a sequence inside
03:26mmeix,(defn clamp [min-x max-x x] (min (max min-x x) max-x))
03:26clojurebot#'sandbox/clamp
03:27jefelanteokay cool
03:27mmeix(clamp 2 5 7)
03:27domokatommeix: I want min-x and max-x to be optional (omitted by passing nil)
03:27mmeix,(clamp 2 5 7)
03:27jefelanteoddly enough i'd been wondering what mapcat did and why i'd use it
03:27clojurebot5
03:27mmeixhow would your clamp function know between what to clamp?
03:28domokatommeix: if min or max is omitted, clamp only the other
03:28domokato,(min 1 nil)
03:28clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.NullPointerException\n :message nil\n :at [clojure.lang.Numbers ops "Numbers.java" 1013]}]\n :trace\n [[clojure.lang.Numbers ops "Numbers.java" 1013]\n [clojure.lang.Numbers lt "Numbers.java" 221]\n [clojure.lang.Numbers lt "Numbers.java" 3812]\n [clojure.lang.Numbers min "Numbers.java" 4087]\n [sandbox$eval72 invoke "NO_SOURCE_FILE" 0]\n [...
03:29justin_smith,(defn clamp [min-x max-x x] (min (max (or min-x x) x) (or max-x x)))
03:29clojurebot#'sandbox/clamp
03:29justin_smith,(clamp nil -1 10)
03:29clojurebot-1
03:29justin_smith,(clamp 5 -1 nil)
03:29clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.NullPointerException\n :message nil\n :at [clojure.lang.Numbers ops "Numbers.java" 1013]}]\n :trace\n [[clojure.lang.Numbers ops "Numbers.java" 1013]\n [clojure.lang.Numbers gt "Numbers.java" 229]\n [clojure.lang.Numbers max "Numbers.java" 4027]\n [sandbox$clamp invoke "NO_SOURCE_FILE" 0]\n [sandbox$eval145 invoke "NO_SOURCE_FILE" 0]\n [clo...
03:29justin_smithoops
03:29justin_smith,(clamp 5 nil -1)
03:29clojurebot-1
03:29justin_smith,(clamp nil 5 -1)
03:29clojurebot-1
03:30justin_smith,(clamp 1 5 -1)
03:30clojurebot1
03:30justin_smithlooks good to me (shamelessly derived from mmeix 's version of course)
03:30mmeix:-)
03:30domokatoor!
03:30mmeixI'm honored!
03:30domokato<- Java programmer
03:31mmeix<- aspiring clojure beginner
03:31domokatothanks :)
03:31justin_smith,(or nil false 1)
03:31clojurebot1
03:31mmeixanother way would be to use :keys
03:31mmeixI think
03:32justin_smithmmeix: you mean :or defaults in destructuring?
03:32mmeixyes
03:32mmeixhttps://clojurefun.wordpress.com/2012/08/13/keyword-arguments-in-clojure/
03:32justin_smithyeah, but the spec has no datastructures...
03:33mmeixok
03:33domokatoi would have to pass a map in?
03:33justin_smithto do it the way mmeix is suggesting, yeah
03:33domokatoyeah, not worth it. no better way other than passing nils, huh?
03:33mmeixbut positional arguments in this case is readable enough I guess
03:34justin_smith,(defn clamp [min-x max-x x] (let [min-x (or min-x x) max-x (or max-x x)] (min (max min-x x) max-x)))
03:34clojurebot#'sandbox/clamp
03:34justin_smithwhen you spread that out properly I think it's mor readable
03:35mmeixor multi-arity would be another possibility
03:36domokatobut clamping max only and clamping mix only have the same arity, that's the problem
03:36mmeixif the use case lends to it (if this is acorrect english sentence, not sure)
03:37mmeixI find justin's last version rather neat
03:39domokatoit would be nice to write it objective-c style: (clamp x :min 0 :max 12)
03:39mmeix:keys
03:39mmeixno?
03:39clojurebotno is tufflax: there was a question somewhere in there, the answer
03:40domokatooh, so i don't have to pass a map
03:40domokatonice!
03:40justin_smith,(defn clamp ([{:keys [min-x max-x x] :or {min-x x max-x x}}] (min (max min-x x) max-x)) ([min-x max-x x] (clamp {:min-x min-x :max-x max-x :x x}))
03:40mmeixyou would have to
03:40clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
03:40justin_smithoops
03:41justin_smith,(defn clamp ([{:keys [min-x max-x x] :or {min-x x max-x x}}] (min (max min-x x) max-x)) ([min-x max-x x] (clamp {:min-x min-x :max-x max-x :x x})))
03:41clojurebot#error {\n :cause "Unable to resolve symbol: x in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: x in this context"\n ...
03:42justin_smithmmeix: yeah, :or defaults cannot refer to other bindings inside the same map I don't think
03:45mmeixanother possibility (depending on use case): two functions: clamp-above and clamp-below
03:45mmeixand clamp for both
03:45mmeixwould depend on context, I guess
03:47mmeix,(defn clamp-below [min-x x] (max min-x x))
03:47clojurebot#'sandbox/clamp-below
03:47mmeix,(defn clamp-above [max-x] (min max-x x))
03:47clojurebot#error {\n :cause "Unable to resolve symbol: x in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: x in this context"\n ...
03:48mmeixoops
03:48mmeix,(defn clamp-above [max-x x] (min max-x x))
03:48clojurebot#'sandbox/clamp-above
03:49justin_smithmmeix: (def clamp-above min) (def clamp-blow max) :P
03:49mmeix,(map (partial clamp-below 3) [2 7 4 78])
03:49clojurebot(3 7 4 78)
03:49mmeixLOL
03:50mmeixI shoulg get me some coffee, I guess
03:51mmeix,(map (partial min 3) [2 7 1 42])
03:51clojurebot(2 3 1 3)
03:51mmeixright you are
03:52mmeixdidn't think of that
03:52mmeixthanks
03:53mmeixso: lot of options here
03:54mmeixalthough (partial min ...) doesn't read intuitively, I find
03:57domokatohm...i must be doing something wrong
03:57mmeixjust playing around with Day8/re-com, they do everything with named parameters
03:57domokato,(defn clamp [x & {:keys [min max] :or [min nil max nil]}] (clojure.core/min (or max x) (clojure.core/max (or min x) x)))
03:57clojurebot#'sandbox/clamp
03:57domokato,(clamp -1 :min 0 :max 19)
03:57clojurebot0
03:58domokato,(clamp -1 :min 0)
03:58clojurebot-1
03:58domokato?
03:58mmeixmin or :min?
03:58mmeixah, sorry
03:58justin_smithdomokato: that :or clause doesn't do anything
03:58domokatodoh!
03:58domokato,(defn clamp [x & {:keys [min max] :or {min nil max nil}}] (clojure.core/min (or max x) (clojure.core/max (or min x) x)))
03:58clojurebot#'sandbox/clamp
03:58domokato,(clamp -1 :min 0)
03:58clojurebot-1
03:59justin_smithdomokato: it still does nothing
03:59justin_smithdomokato: the default is already nil
03:59domokatoo
03:59domokato,(defn clamp [x & {:keys [min max]}] (clojure.core/min (or max x) (clojure.core/max (or min x) x)))
03:59clojurebot#'sandbox/clamp
03:59domokato,(clamp -1 :min 0)
03:59clojurebot-1
04:00mmeix(also min and max as parameter names are not so good, i think, because these are function names in clojure)
04:00justin_smiththat style of keyword arg is very unpopular
04:02domokatobut why doesn't it work?
04:04mmeix,(clamp -1 {:min 0})
04:04clojurebot#error {\n :cause "Unable to resolve symbol: clamp in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: clamp in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: clamp in this...
04:04mmeixoops
04:05domokatoperhaps cleaner: ,(defn clamp [x & {minimum :min maximum :max}] (min (or maximum x) (max (or minimum x) x)))
04:05domokato,(defn clamp [x & {minimum :min maximum :max}] (min (or maximum x) (max (or minimum x) x)))
04:05clojurebot#'sandbox/clamp
04:05domokatobut still doesn't work
04:05domokato,(clamp -1 :min 0)
04:05clojurebot-1
04:06mmeix,(clamp -1 {:minimum 0})
04:06clojurebot#error {\n :cause "No value supplied for key: {:minimum 0}"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No value supplied for key: {:minimum 0}"\n :at [clojure.lang.PersistentHashMap create "PersistentHashMap.java" 77]}]\n :trace\n [[clojure.lang.PersistentHashMap create "PersistentHashMap.java" 77]\n [sandbox$clamp doInvoke "NO_SOURCE_FILE" 0]\n [clojure.lang.RestFn invo...
04:06mmeixhrmm
04:06mmeixsorry
04:06mmeix... gets coffee
04:07domokatothat won't work because of the &
04:07justin_smith,(clamp -1 :max 1 :min 0)
04:07clojurebot0
04:08TEttingerI'd recommend having a separate fn for clamping down, up, and both... clamp usually means clamp both to me
04:08justin_smithsince you didn't supply max, max was -1, which meant your min was not applied
04:08justin_smithTEttinger: the down and up ones are just max and min
04:08TEttingerhaha
04:08TEttingerright
04:08mmeixhere we go again :-)
04:09mmeixso all that variadic stuff is kind of pointless then
04:09TEttingeryep!
04:09domokatohow did max become -1?
04:09justin_smithdomokato: because if not supplied it is x
04:09domokatoi thought if not supplied it is nil
04:10justin_smithwell that would give you a nullpointerexception
04:10domokatoi used ors though
04:10justin_smithdomokato: (or maximum x)
04:10justin_smithwhich means you get maximum, if provided, or -1
04:10justin_smithso when you don't supply :max, the -1 slips through
04:10justin_smithbut if you do, as shown above, things work as expected
04:11mmeixso I guess we come back to using: min, max and (defn clamp [min-x max-x x] (min (max min-x x) max-x))
04:11mmeixright?
04:11TEttingerjustin_smith: I imagine this is why keyword args are unpopular :)
04:11justin_smithright, I think that makes the most sense
04:11justin_smithTEttinger: not even the main reason!
04:11mmeixwhat would be the main reason?
04:11justin_smith(they compose poorly)
04:12mmeixah, I see
04:12justin_smithmmeix: a common thing in clojure is to take a function, and write another function that takes the same args, and calls that function
04:12mmeixunderstood
04:12justin_smithmmeix: it's hard to capture the args in a usable form when using keyword args
04:12mmeixyes, Isee
04:13justin_smithwhich is why it's more popular to just use a map as one of your args - same functionality, much more powerful
04:14TEttingerand to destructure it, right?
04:14justin_smithright
04:14mmeixyes, and in this simple clamp case it's overkill anyway
04:16mmeixI wondered the other day, which principles led Rich Hickey in designing the argument positions in clojure/core functions
04:17mmeixcolls last, I understand, for thread macro and map
04:17justin_smithif you use a sequence, it should come last, if you use an associative lookup, it should come first
04:18justin_smith(generally)
04:19mmeixthanks
04:20domokatoso this doesn't work...
04:20domokato,(defn clamp [min-x max-x x] (let [min-x (or min-x x) max-x (or max-x x)] (min (max min-x x) max-x)))
04:20clojurebot#'sandbox/clamp
04:20domokato,(clamp -1 0 nil)
04:20clojurebot#error {\n :cause nil\n :via\n [{:type java.lang.NullPointerException\n :message nil\n :at [clojure.lang.Numbers ops "Numbers.java" 1013]}]\n :trace\n [[clojure.lang.Numbers ops "Numbers.java" 1013]\n [clojure.lang.Numbers gt "Numbers.java" 229]\n [clojure.lang.Numbers max "Numbers.java" 4027]\n [sandbox$clamp invoke "NO_SOURCE_FILE" 0]\n [sandbox$eval50 invoke "NO_SOURCE_FILE" 0]\n [cloj...
04:20domokato,(clamp 0 nil -1)
04:20justin_smithremember the last arg is your x
04:20clojurebot-1
04:21justin_smithyeah, so my or thing is wrong, sorry
04:21domokato(is that idiomatic?)
04:23justin_smith,(defn clamp [min-x max-x x] (let [min-x (or min-x x) max-x (or max-x x)] (min (max min-x x) max-x))) ; fixed
04:23clojurebot#'sandbox/clamp
04:23justin_smith,(clamp 0 nil -1)
04:23clojurebot-1
04:23justin_smithor, wait
04:23justin_smithhaha
04:23justin_smithnot fixed
04:29domokatothe best i could come up with
04:29domokato,(defn clamp [minimum maximum x] (let [clamp-bottom (max x (or minimum x))] (min clamp-bottom (or maximum clamp-bottom))))
04:29clojurebot#'sandbox/clamp
04:29domokato(clamp 0 nil -1)
04:29domokato,(clamp 0 nil -1)
04:29clojurebot0
04:30justin_smith,(clamp nil 1 2)
04:30clojurebot1
04:30justin_smithnice
04:31mmeixah! was it the double usage of min-x/max-x in the let assignment?
04:33xtrntrhi, i'm following modern-cljs tutorials right now
04:33mmeixinstructive discussion :-)
04:33xtrntrmight i ask what is a typical workflow environment for people using clojure in web dev?
04:33xtrntrim using sublime + emacs + terminal and it feels a bit strange
04:34xtrntri did all development in an ide only before
04:34justin_smithxtrntr: why both sublime and emacs?
04:34xtrntrfor html and js files
04:34xtrntris there a way to display tree-like directory in emacs?
04:35justin_smithxtrntr: I find M-x dired + i key for opening subdir is good
04:35justin_smithbut it's not quite a tree
04:35justin_smithgood enough for me though
04:35mmeix(if using something like Reagent, html-writing gets to a minimum)
04:35mmeix(I find)
04:35mmeix(js also)
04:35xtrntrah
04:35xtrntri guess im more of asking an emacs question then :blushes:
04:36justin_smithxtrntr: also, you should be able to do your repl stuff inside emacs (though I often prefer not to), and your web server can be running from inside your repl
04:37xtrntrok, i guess thats something to look forward
04:37xtrntrwill follow tutorials at a snail's pace first
04:37mmeixfigwheel or boot-reload are very helpful too, I find
04:38mmeix(but maybe that wasn't the question)
05:12xtrntrhi
05:12xtrntrmy clojure brepl gets stuck
05:12xtrntrdoes anyone know why?
05:31xtrntrit works now
05:31xtrntrbut i don't know why i have to refresh the browser in order for the expression to evaluate
05:31xtrntram i doing it wrong? :(
05:38mmeixare you looking for auto-reloading code?
05:39ddellacostaxtrntr: I missed the beginning of that, did you paste in a code sample?
05:39xtrntrno, i'm just following the modern-cljs tutorials
05:39xtrntryes, looking for auto-reloading code? you mean the default for clojure-brepl is to refresh the webpage to evaluate my expressions?
05:39xtrntralso, i'm very new to web dev
05:40mmeixthere are means to automatically push code to the browser
05:40mmeixfigwheel is one of them
05:41xtrntrok, i'll look at it -later-
05:41xtrntrdon't wanna mess up the tutorials.. i'm treading oh so carefully :)
06:29noncom|2if i store my functions in a [] or {} and then i change and reevalute the defs of them, should the references stored in the {}s and []s point to the new function definition, or will it retain the old one?
06:34shoky_noncom|2: afaik, if you have [f] then it will retain the old one because the function itself is stored. if you have [#'f] then it will point to the new one, as it is storing the actual var. or something like that
06:36noncom|2thank you, a good insight
07:30frudHi! When making a webapp with user accounts, do you all generally prefer Friend or Buddy? Making my first web app in Clojure, and can't find either comparisons or tutorials much :/
08:12xtrntrhey frud
08:12xtrntrare you still there?
08:12xtrntrwanted to link you this
08:12xtrntrhttps://github.com/magomimmo/modern-cljs
08:12xtrntrworking through it myself :)
08:13WaltherHi there! I'm having fun with this one http://iloveponies.github.io/120-hour-epic-sax-marathon/p-p-p-pokerface.html - but ran into a wall. Any ideas on what goes wrong with the "straight" function? http://walther.guru/poker.txt
08:22shoky,(range 10 14)
08:22clojurebot(10 11 12 13)
08:22shokyWalther ^
08:24WaltherAh, range's end is not inclusive
08:26Waltherexcellent, thanks!
09:14expezIf I make a data-reader for #js can I otherwise read cljs file with the clj reader?
10:01sub0What is the useless skin around the vagina called?
10:01sub0WOMAN!
10:26spaceplukhi there, is there any alive project to host clojure on c/c++?
10:32arrubinspacepluk: You could embed a JS engine and use ClojureScript.
10:33spaceplukarrubin: yeah, but I was thinking about things like deftype for c++ classes, calling/generating native code and that kind of stuff
10:42justin_smithspacepluk: there's no active project. I think the big issue is that clojure really needs gc.
10:44spaceplukjustin_smith: that's what it looked like :( I wouldn't mind having a runtime in exchange of that kind of power.
10:45justin_smithspacepluk: in a way, pixie gets close to that - the runtime interop is with C (or really the host OS, but C is pretty approachable from host level), the vm is made using rpythong
10:45justin_smith*python
10:46justin_smithit doesn't aim to be a fully compatible clojure though
10:47spaceplukcljs-terra is very interesting
10:49spaceplukI guess there's not enough public for something like this
10:49justin_smithspacepluk: there's people who would use it, but not many people available who want to spend the decades of man hours to make a good vm from scratch.
10:50justin_smithre-using a vm is so much easier
10:50justin_smithand clojure inherently needs a vm
10:50spaceplukabsolutely
10:51spaceplukI just found this, but I'm not sure what it is -> https://github.com/halgari/mjolnir
10:51justin_smithspacepluk: it's similar to jni - it's for generating native code from within the vm
10:51spaceplukah, ok I saw LLVM and got all excited
10:51justin_smithspacepluk: it's from the same author that went on to do pixie, one of his older projects
10:52spaceplukI'll check it out
10:53justin_smithnote that pixie isn't hosted by python - it uses rpython to compose a native level vm (there is no runtime python)
10:53spaceplukjustin_smith: thanks, I was just thinking about that
10:54spaceplukit sounds very cool
13:00gganleyim trying to import a html table as a map is there any way i can automate that or am I going to have to do it all by hand?
13:05spaceplukgganley: any xml library should work
13:09gganleyspacepluk: which is the most popular one?
13:40spaceplukggherdov: ah sorry, it was just an idea I'm just getting started with clojure
13:40spaceplukand that wasn't for you, I'm sorry again
13:41vasHey everyone, how do I get a repl running from a jar in the namespace that I want?
13:43vasor alternatively, is there a straightforward way to SSH emacs/cider-jack-in ?
14:05rhg135java -cp <JAR>:<clojure jar> clojure.main
14:06rhg135That loads a repl
14:08spaceplukI'm trying to add a maven dependency and I'm getting this (http://sprunge.us/QfUa), any idea what I'm doing wrong?
14:09rhg135does that artifact actually exist?
14:09rhg135The version mostly
14:10spaceplukrhg135: I think it does: http://search.maven.org/#artifactdetails%7Corg.apache.storm%7Cstorm%7C0.9.5%7Cpom
14:12spaceplukI also tried the last version but I get the same error
14:12rhg135Network?
14:12spaceplukit's slightly slow now, but everything else seems to be working just fine
14:13spaceplukno proxies or firewalls
14:14rhg135I'm out of ideas, the only time I see that is when I make a typo
14:15spaceplukrhg135: thanks, I'll keep digging
14:17rhg135There may be a way to debug dependency resolution but I've never tried
14:18spaceplukhmm, other modules download just fine
14:34eric1/set irc.server.freenode.nicks ""
14:44SeyleriusNormally (range x) produces [0 1 2 ... x-1]. What produces [x x+1 x+2 ...]?
14:44mmeix,(range 4 9)
14:45clojurebot(4 5 6 7 8)
14:45SeyleriusNah, what I want is an infinite lazyseq starting at x
14:45mmeix,(doc range)
14:45clojurebot"([] [end] [start end] [start end step]); Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step, where start defaults to 0, step to 1, and end to infinity. When step is equal to 0, returns an infinite sequence of start. When start is equal to end, returns empty list."
14:45mmeixah
14:45mmeix,(iterate inc 5)
14:45clojurebot(5 6 7 8 9 ...)
14:46SeyleriusThere we go.
14:46Seylerius(inc mmeix)
14:46lazybot⇒ 3
14:46mmeix,(doc iterate)
14:46clojurebot"([f x]); Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects"
14:49mmeix,(drop 5 (range))
14:49clojurebot(5 6 7 8 9 ...)
14:49mmeixanother possibility
14:49SeyleriusEven better.
14:50SeyleriusAnd what about if I want a function to behave differently depending on whether the arg is a clj-time datetime or an int? Would I multi-arity it and hint [^int n] as opposed to hinting [^DateTime date]? I'm not sure about that last one...
14:50SeyleriusActually, I'll just make two functions.
14:51mmeixyou could write a multimethod
14:51mmeixhttp://clojure.org/multimethods
14:53mmeixand dispatch on your desired type
14:54mmeixmulti-arity will not work, because you have ONE argument in both cases
14:54mmeixworks only for different numbers of arguments
14:54SeyleriusYeah. I'm just making a couple different functions.
14:54mmeixAFAIK
14:54SeyleriusSimplest.
14:54SeyleriusAlthough thank you for the info.
14:54mmeix:-)
15:02SeyleriusGah. Y'know what sucks? I'm using Gorilla REPL in Conkeror, and my emacs-style keys only work /intermittently/.
15:03SeyleriusI /like/ Gorilla REPL, but this interference with conkeror's keybinds is /annoying/.
15:04reutermjSo I'm using cursive and it cannot resolve a reference to an abstract method
15:04reutermjis this a limitation of clojure's type hints?
15:13vasHey when you guys update a web app running from a jar... do you load balance? Like have version 0 running, have some of it round-robin to version 1 when you upload it, and then finally remove version 0?
15:17amalloyreutermj: no
15:18reutermjamalloy: Hmmmm when I compile it with *warn-on-reflection* I get a reflection warning
15:18amalloyyes, you are doing something wrong evidently
15:18amalloybut so far all you have said is "a thing doesn't work, is something wrong with clojure". nobody can tell how to fix your problem from that
15:19reutermj(defn compute [^RecursiveTask task] (.compute task))
15:20reutermj.compute is an abstract method in RecursiveTask
15:21amalloyit's protected. you can't call it from non-subclasses
15:21amalloyhttp://docs.oracle.com/javase/7/docs/api/java/util/concurrent/RecursiveTask.html#compute()
15:22amalloyso not only is there a reflection warning, the code won't run. the warning has done its job
15:22amalloy(unless you pass in a subclass which has overridden the method to be public)
15:22reutermjok I didn't even notice it was protected
15:26mmeixwhich one would be preferable: (defn f [x] (drop x (range)) or (defn f [x] (iterate inc x))? (I guess the second ...)
15:29pepijndevosI thought (GET "/team" {params :params} in compojure would put the query parameters in parama? It's empty. Do I need some wrapper?
15:29Seyleriusmmeix: iterate looks like it'd have a lower constant cost at the start (grabbing and dropping the first x entries from range), so it depends on the difference in calling cost between inc and each step of range. If repeating inc overtakes that constant from the start, then range wins.
15:36mmeix,(defn f1 [x] (drop x (range))
15:36clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
15:37mmeix,,(def f1 [x] (drop x (range)))
15:37clojurebot#error {\n :cause "Too many arguments to def"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Too many arguments to def, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.RuntimeException\n :message "Too many arguments to def"\n :at [clojure.lang.Util runtimeException "Util.jav...
15:37mmeixhrrm
15:37mmeix,(def f1 [x] (drop x (range)))
15:37clojurebot#error {\n :cause "Too many arguments to def"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Too many arguments to def, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6740]}\n {:type java.lang.RuntimeException\n :message "Too many arguments to def"\n :at [clojure.lang.Util runtimeException "Util.jav...
15:37mmeix,(defn f1 [x] (drop x (range)))
15:37clojurebot#'sandbox/f1
15:38mmeix,(time (take 10 (f1 100000)))
15:38clojurebot"Elapsed time: 0.543007 msecs"\n(100000 100001 100002 100003 100004 ...)
15:39mmeix,(defn f2 [x] (iterate inc x))
15:39clojurebot#'sandbox/f2
15:39mmeix,(time (take 10 (f2 100000)))
15:39clojurebot"Elapsed time: 0.166414 msecs"\n(100000 100001 100002 100003 100004 ...)
18:06justin_smith,(time (f2 100000))
18:06clojurebot#error {\n :cause "Unable to resolve symbol: f2 in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: f2 in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6543]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: f2 in this context"...
18:23justin_smith,(defn f2 [x] (iterate inc x))
18:23clojurebot#'sandbox/f2
18:23justin_smith,(time (f2 100000))
18:23clojurebot"Elapsed time: 0.486575 msecs"\n(100000 100001 100002 100003 100004 ...)
21:03gfredericksI like < better than >
21:03gfredericksyou might say I think that < > >
21:04justin_smithhey, I know, we could rename comp to <-
21:05gfrederickshaha
22:14vasSo say I have an updated version of my jar to upload to my webserver, how to make zero-downtime a reality?
22:25akkadwell if you have more than one server, and say, nginx on the front end, you can start more than one, and have a rolling restart with multiple backends
22:34vasakkad: That is a good idea. I just have one server, with apache on the front. The rolling restart sounds like the proper way to do that. Thank you will look into it.
22:39vasI'm thinking of changing the default port on my .jar and then having apache forward to the new port.. I think that works as a simple zero-downtime for my needs
22:39vaslike have 2 jars running while i turn one off
22:55brandon123i'm trying to pass an array of an enum value into an annotation on a gen-class method and i can't seem to find any information on the right way to do that
22:56brandon123at the risk of being questioned why i would be trying to do what i'm doing, here's a code link https://github.com/brinman2002/springboot-clj/blob/master/src/main/clojure/org/brinman2002/app/service/SimpleService.clj#L7
22:56brandon123when compiling, this gives me a "Exception in thread "main" java.lang.ClassCastException: clojure.lang.Var cannot be cast to java.lang.Class"
23:07brandon123and of course ten minutes later i figure it out... works if you use vectors instead of into-array
23:08brandon123i'll go ahead and take off so you guys can laugh about the person trying to do clojure and spring together
23:31justin_smithlol
23:49TimMcclojure.core/abstract-singleton-proxy-factory-bean
23:55TimMchttp://grepcode.com/file/repository.springsource.com/org.aspectj/com.springsource.org.aspectj.weaver/1.6.3/org/aspectj/weaver/patterns/HasThisTypePatternTriedToSneakInSomeGenericOrParameterizedTypePatternMatchingStuffAnywhereVisitor.java