#clojure logs

2015-08-10

05:32WickedShellI'm trying to chase down a large and ever growing number of java.lang.reflect.Method's that I'm building up till they are GC'd (well up in the millions) but when I turn on *warn-on-reflection* I now get a nullpointer in one of my source files that has been compiling without any problem until now. Anyidea why this might happen?
05:34TEttingerWickedShell: clone an earlier version that didn't have the bug from version control, turn on warn-on-reflection, check if bug is present then?
05:34WickedShellI... yeah I guess. Gotta go back really far. Will try
05:43WickedShellIs there any reason why passing nil into a java library function could cause warn-on-reflection to break? That seems to be the only thing of significane on the line
05:44WickedShellThe offending line (g2 is already type hinted as java.awt.Graphics2D ): (.drawImage g2 planeIcon 0 0 nil)))
05:55WickedShellApparently it can't resolve the inherited method .drawImage I had to instead cast it to a graphics object and draw with that :/ which is werid but I guess it works
06:12WickedShellhm... I've solved all the reflection cases that occur within my code (that is running, theres some that has some left but isn't active) and did a lein clean, and am still seeing about 10k more instances of reflect occur every second...
07:05CookedGryphonIs there a reason partition-all doesn't have a transducing version with a step?
07:05CookedGryphonthe arities are n, n coll, or n step coll, and I want n step with no coll
07:41hyPiRionCookedGryphon: backwards compat. [n coll] is already there
07:41hyPiRionThat's my guess at least
08:43justin_smithdevn: my preference is to not use lein on production boxes, and not to use aot either. I make a very small shim namespace that loads up the rest of my code in an uberjar.
08:57cenzheHi all, I got this problem and hope some one can point me in the right direction
08:57snowellcenzhe: Just ask it, and somebody should answer :)
08:57cenzheWe are currently combining Spring with Clojure
08:58cenzheBut the classpath that is received by the clojure part of the code seems wrong
08:58cenzheWhen I print (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader)))
08:59cenzheI got only $TOMCAT_HOME/bin/bootstrap.jar and $TOMCAT_HOME/bin/tomcat-juli.jar
09:01cenzheDo I need to add some bootstrap code or anything to make this work?
09:01cenzheThe question I asked is obviously incomplete, but I'm not sure what to add here
09:01cenzheplease ask if you think anything relevant
09:03cenzheThe logic I understand here is: I took AOT on some of the ns, generating some annotated classes for spring MVC component scan.
09:04cenzheWhen I triggered a URL request, this request was received by spring framework, past the filters and reached the mapping I declared in clojure.
09:07cenzheAnyone can point me to further readings on how clojure was bootstrapped, with all the classloader details explained?
09:12kastermaI am trying to load the example data as used in the datomic turorial. This generates a “two datoms in the same transaction conflict”. My code is at https://gist.github.com/kasterma/9e6087f9c0e93239fadc
09:12kastermaI have queried a datomic db enough, but never added data to it. Hoping I am just doing something silly.
09:13kastermaAny obvious mistakes?
09:14kastermaI don’t understand the format in seattle-data0.edn yet, so hard for me to see if there is an issue there. LIkely the issue is between chair and keyboard though.
09:37bornthirdHi - does anyone know how I can select all text content from elements - including empty content - with enlive? When I try (html/select some-resource [:table :tr :td html/text]), I'll only get back non-empty content. I'm guessing that is because :content nil for empty nodes, but I still want to get back that nil or ""
09:48cenzhehave you tried putting html/text outside?
10:01bornthirdcenzhe: ahh yah, if i map that to the results that works, duh. Thanks!
10:04justin_smithcenzhe: are you making an uberjar?
10:05justin_smithcenzhe: what clojure will need is to find either a clj file or the generated aot artifacts on the classpath for every namespace you use
10:05justin_smiththe part I don't know is how you would tell spring to make those available
10:10cenzhejustin_smith: No, i'm not making an uberjar. I'm building it using maven, generating a WAR archive
10:10justin_smithcenzhe: OK, then an uberwar, or are you providing the deps in some other manner?
10:11cenzheI'm not sure what you mean here..
10:11justin_smithcenzhe: I don't really know the maven options, but "lein ring uberwar" can create a war containing all the deps your clojure code needs at runtime
10:11justin_smithas opposed to only containing your own code and relying on some other mechanism to supply your deps at runtime
10:13cenzheem.. I kinda got your point but the framework is not easily changed in production, and I'm trying to minimize the amount of change to push things forward
10:14justin_smithcenzhe: all I'm trying to do is figure out how you are providing the deps the clojure code expects. I'm suggesting the methods I have historically used. I am sure there are other alternatives.
10:14justin_smithcenzhe: when your code needs clojure.jar, where exactly is that provided from? who supplies it?
10:14justin_smithbecause your code will not run without clojure.jar
10:15cenzheyes, you're absolutely right. I guess the tomcat servlet is able to load the AOT file, as well as other deps that clojure requires.
10:16cenzheI can make invocations to other clj methods in the controller I defined
10:16justin_smithOK
10:16cenzheit's just the classpath seems not right
10:16justin_smithperhaps your deps are on that new classpath?
10:16justin_smithit shouldn't be too hard to look, right?
10:17cenzheyah, I'll try track it further
10:18justin_smithcenzhe: my experience with tomcat (but not using spring) is that I wrap up my code and all its deps into a war file (an "uberwar"), and then tomcat adds those deps to the classpath after extracting the war in its custom place
10:18cenzhe:D correct, I extracted the WAR file, and all those deps are lying right at the WEB-INF/classes folder
10:19justin_smithyes, that's exactly how I remember it
10:19cenzhewhoops, WEB-INFO/lib folder
10:19justin_smithheh, close to what I remember still...
10:32cenzhewow, problem solved! the classpath I got is correct
10:32cenzhethe reason I thought it's wrong, is because I failed to distinguish a context class loader from system class loader
10:32justin_smithI guess that would do it
10:33justin_smithtbh some stuff about classloaders still baffles me - eg. anything about OSGI
10:33cenzhe:D thanks! justin!
10:34justin_smithheh, I don't think I did much, but you're welcome anyway
10:34oddcully(inc rubberduck)
10:34lazybot⇒ 4
10:37cenzhehaha, how to do that? I'm new to IRC
10:38justin_smithcenzhe: /me
10:39ericbmerrittis there a convention around using deftest vs with-test and where tests should be (ie in the same file as the tested thing or in the tests directory)?
10:39justin_smithericbmerritt: most common is deftest and giving tests their own files / directories
10:40ericbmerrittThats the impression I have been getting. I dislike that it separates tests from the thing tested, but it does seem to make things a bit cleaner
10:40justin_smithericbmerritt: the convention is for the test namespaces to follow the same heirarchy as the regular namespaces
10:41justin_smithericbmerritt: editors have commands to automatically jump to the test ns based on that convention
10:41ericbmerrittso the namespace is exactly hte same? no '-test' at the end?
10:42justin_smiththat's the one difference - each ns has -test added, but is otherwise in the same place under a separate test/ root
10:43justin_smithI actually like the idea of defining a test with the code it is testing, but have experienced so much friction against it that I have accepted the convention
10:44ericbmerrittfriction in that you ran into problems with executing, or friction people are idiots and don't like to change?
10:44justin_smithhehe now I wouldn't call them idiots...
10:44justin_smithno, the execution was no problem at all, it was a culture / convention issue
10:45ericbmerritthmmm, I am not sure how much I care about a convention that is 'bad' for some value of bad
10:52oddcullyif you need an argument for the separation: you could end up with deps into test libs in regular code
11:09axsk,(/ 39.4 100)
11:09clojurebot0.39399999999999996
11:09axskwhat can i do against that strange division "error"
11:10axski want it to be 39.4, which is representable in double afaik
11:10axskeh 0.394
11:12akabanderI'm trying to build a CLI utility using lein-bin, but when I run "lein bin", I get a "No implementation of method: :as-file of protocol: #'clojure.java.io/Coercions found for class: clojure.lang.Symbol" error. I'm sure I'm missing something, can anyone point me in the right direction?
11:13oddcully,(/ 39.4M 100.0M)
11:13clojurebot0.394M
11:19akabanderI'll note that it works when I do "lein run"
11:20akabanderAnd I can build and execute an uberjar.
11:56kungiI am trying to transact a large transaction in datomic and get this error: http://pastebin.com/tVHTkz9s any idea what I can do?
12:01oddcullykungi: after it's the same entity, attribute and tx, right?
12:02oddcullys/after/&all/
12:02kungioddcully: Somehow It becomes the same entity yes
12:02oddcullysome error while reading?
12:04kungiI create a vector of maps with [{:db/id #db/id[:db.part/user] :some :data ...}] with about 1200 entries
12:04kungiWhen I transact this the entity ids clash
12:05oddcullydid the business in question move? have you duplicate data?
12:05kungioddcully: The database is initially empty
12:05oddcullythe error seems legit
12:06oddcullyif the entity in question has more than one street, could the schema be wrong?
12:07oddcully(i doubt it, since an address would not only consist of the street0
12:07kungino it only has one street :-)
12:07kungiI have an idea ...
12:08oddcullythen my guess is, that your import data have the entity there two times (or at least you detect it as the same)
12:08kungiOk each entity has the same id in my import ...
12:11kungi\o/
12:33csd_does anyone here run spacemacs? if so, i'd love help setting up paredit/similar
12:36BinaryResult_Hey everyone, in case you hadn't heard Disco Melee is currently searching for remote full-stack clojure devs https://docs.google.com/document/d/1AZNGw7QaoN7jY8MjwpxcKcTTwqjUM7q--2W3aRM36yI/edit?usp=sharing
12:37BinaryResult_if you have any questions let us know at work@discomelee.com. you can also check us out at http://beta.discomelee.com/#landing
12:48kungiSuppose a datomic schema with a cardinality/many attribute of type string (lets say NAMES). I would like to find all the entity where an entry in NAMES starts with "foo". How can I get the individual NAMES entries in a subsequent where clause?
12:50chouserIs there any value gained in using an immutable map (over a mutable one) when some of the "values" in the map are themselves mutable (eg. an atom)?
12:56kungi(take 20 (d/q '[:find ?zip :where [_ :account/zips ?zip] [(.startsWith (.toString ?zip) 0)]] (d/db CONN)))
12:56kungiCompilerException java.lang.RuntimeException: Unable to resolve symbol: ?zip in this context
12:57kungiWhy does this yeild an exception when :account/zips is a cardinality many attribute?
12:58kungi=> Because you cannot nest function calls in a where cluse
12:58kungiclause m(
13:00justin_smithchouser: if the map was used as a key in another map, the hash-code would not be changed by updating the contents of the atom
13:00justin_smithchouser: and of course you lose the nice guarantees that tend to come with defaults in clojure
13:01chouserI guess one example to use to think about the problems is (atom {:foo 1 :bar 2}) vs {:foo 1 :bar (atom 2)}, though I mean my question to be broader than that.
13:02justin_smithoh, I thought you meant like a java.util.HashMap or something
13:02chouserBut in that example, what are the benefits of the latter that outweigh its costs.
13:03kwladykais a better way to write this?
13:03kwladyka(-> (partial (fn [boards-pool board] (conj boards-pool (rotate-90-board [cols rows] board))))
13:03kwladyka (reduce boards boards))
13:03kwladykathis function takes boards and add to this boards 90 degree boards
13:03justin_smithkwladyka: I'd use let to name that partial
13:04justin_smithinstead of passing it forward with ->
13:04kwladykajustin_smith, but what with (reduce boards boards)?
13:04justin_smithkwladyka: (reduce <name you gave the function> boards boards)
13:05kwladykajustin_smith, i know but i am repeating boards twice
13:05justin_smithkwladyka: also, how is (partial f) different from (f) in your example?
13:05justin_smithkwladyka: if you need to repeat it twice, repeat it twice, what's wrong with that?
13:06kwladykalook at full defn, do you think "let" has sense?
13:06kwladyka(defn rotate-90-boards [[cols rows] boards]
13:06kwladyka (if (= cols rows)
13:06kwladyka (-> (partial (fn [boards-pool board] (conj boards-pool (rotate-90-board [cols rows] board))))
13:06kwladyka (reduce boards boards))
13:06kwladyka boards))
13:06justin_smithdon't do that
13:06mistaBIZcurious why you repeat it twice? (for educational purposes)
13:06kwladykajustin_smith, i dont know what's wrong, maybe is better function for that
13:07kwladykamistaBIZ, because i am increasing pool of boards about boards rotated by 90 degree
13:07justin_smithkwladyka: don't paste multi line functions, use a gist or refheap or something
13:07kwladykaso i am starting with the same pool, but only add something new there
13:07kwladykajustin_smith, sorry
13:07justin_smithkwladyka: what I am saying is that for any f (partial f) should behave the same as f because you are not providing any args to the partial
13:08justin_smithonly use partial for (partial f x) if you have some x to provide there
13:09kwladykajustin_smith, mmm ?
13:11amalloy,((comp partial partial partial partial) 5)
13:11clojurebot5
13:11justin_smithkwladyka: (defn rotate-90-boards [[cols rows] boards] (let [f (fn [boards-pool board] (conj boards-pool (rotate-90-board [cols rows] board)))] (if (= cols rows) (reduce f boards boards) boards)))
13:11mistaBIZwhere x is the evaluated (f) of f?
13:11justin_smithmistaBIZ: where x is some arg partially applied to f
13:11justin_smithmistaBIZ: my point is that (partial f) for any f is silly
13:11justin_smithit's just noise
13:12justin_smith(partial f x) (or more args) is actually useful
13:12kwladykajustin_smith, so what do you recommend? loop and recur?
13:13justin_smithkwladyka: no, just remove partial, it isn't doing anything
13:13kwladykajustin_smith, oh.... so true....
13:13justin_smithkwladyka: look at what I suggested above - it uses let instead of -> and gets rid of the pointless partial
13:14kwladykajustin_smith, now i understand
13:14justin_smithkwladyka: you can probably come up with a better name than f
13:16justin_smithmistaBIZ: the thing with reduce and repeating boards is that he wants to take boards as the base state for his accumulator, and for each item in boards, also derive a new item to add to that accumulator
13:17justin_smithmistaBIZ: at least that would be the normal reason to do that
13:17justin_smithyou could do the same thing but interleaved rather than appended via mapcat
13:18akabanderOkay, this is probably a common noob question... I have some code that works in the REPL, but fails to process the sequence when run on the command line (lein run, or from jar)
13:19justin_smithakabander: are you using a lazy operation like map or for?
13:19akabanderThis seems to be the offending function:
13:19akabanderUm, yes, map
13:19akabanderhttp://gitlab.bandersnatch.org/snippets/1
13:19justin_smithakabander: if so the repl can force lazy results by printing
13:19justin_smithand that will not happen in your jar
13:19akabanderAh, but the compiled version can't?
13:19justin_smithso use dorun or doall to force the lazy sequence
13:19justin_smithakabander: not that it can't, but if you don't do something that forces it, it won't
13:20justin_smithakabander: the printing is a side effect of the repl, you need to use something else (dorun or doall) to simulate what it does
13:20akabanderAha... I suspected something like that, too green to know all the ins-and-outs.
13:20justin_smithor you could just print, I guess
13:20justin_smithyeah, that map of println, you could change to (dorun (map ...)) and it would work
13:21akabanderI do print eventually, but clearly too far along the call chain.
13:21justin_smithakabander: it's inside a lazy operation, and the lazy-operation doesn't get forced, and dorun would fix that
13:21justin_smithif you needed to use the list later, you could use doall instead of dorun
13:23akabanderAnd there we go... Thanks, I'm off to study The Joy Of Closure. Ironically I just started the first chapter that goes into detail on laziness.
13:23akabanderI really appreciate the quality of help around this joint. :^)
13:24mistaBIZagreed
13:24kwladykayes, justin_smith do good job helping all around :)
13:25birdspiderhello, I'm looking for an easy way to stop play-clj/lwjglapplication killing my REPL when I close the OpenGL window - what should I be googling for ? :)
13:31justin_smithbirdspider: maybe something like "on-close"
13:41dumptruckmananyone familiar with running lazybot in background mode?
13:42dumptruckmani've got it running with a log file but when i add --background to launch args it doesn't start up properly and logs nothing
13:42justin_smithdumptruckman: I've done it before if you have a specific question, but it was a while ago and don't have my bot install handy right now
13:46justin_smithdumptruckman: are you doing this via lein, or via an uberjar?
13:46dumptruckmanuberjar
13:46dumptruckmani'm not sure how to run it via lein
13:47justin_smithso it just does nothing if you start it with the --background arg, it doesn't exit or start up, just hangs there?
13:47dumptruckmanwell, i can see a java process start and then quickly close
13:47justin_smithand it's not printing out any error?
13:49dumptruckmancorrect
13:49justin_smithreturn code?
13:50dumptruckmannone
13:50dumptruckmanor at least, i'm not at a place where i could see one
13:50justin_smithyou can use "echo $?" to get the value returned by the last command in the terminal
13:51dumptruckmaneh?
13:51dumptruckmanit returns $?
13:51dumptruckman(Windows CLI)
13:51justin_smithoh, never mind then!
13:52justin_smithI'd hazard a guess that lazybot simply cannot run in background mode on windows, I'm somewhat surprised it runs on windows at all
13:52dumptruckmani see
13:52justin_smithon a *nix machine, you can get the return value of the last command with $?, I have no idea if there is even a concept of a "return value" from a program in windows
13:57xemdetiajustin_smith, echo Exit Code is %errorlevel%
13:57xemdetiayou have to use windows vars
13:58justin_smithxemdetia: oh, interesting
13:59jmbroxsfor Clojure web development, is Chestnut a good start for beginners ?
13:59dumptruckmanexit code is 0
14:00DifferentLambdaNo, jmbroxs
14:00wasamasajmbroxs: hmm, as a beginner I'd start out with piecing the components manually together
14:01wasamasajmbroxs: so, start with ring and boot up a http server
14:01wasamasajmbroxs: add compojure for routing, hiccup for templates, garden for css, etc.
14:02jmbroxsThanks wasamasa. Besides books, are there some really good online tutorials for learning Compojure+Ring+Hiccup+etc. ?
14:03wasamasajmbroxs: the docs, duh :P
14:03wasamasamost of these are so simple that you can read the sources for figuring out what's going wrong
14:03wasamasaso far the only exception I've run into is this liberator
14:06jmbroxswasamasa, what I meant by online tutorials are videos of people actually writing code and showing the results on a web page
14:06wasamasajmbroxs: hmm, no idea, I don't use video tutorials
14:06jmbroxsOh ok. Thanks anyway wasamasa
14:11dumptruckmanwell
14:12dumptruckmani guess i'll just use some windows hackery to backgroundify this batch file
15:00OlajydI want an exponential function (it takes a base and an exponent) raises the base to the exponent and limits the answer to 12 characters?
15:04Olajydsorry the question is I want to be able to restrict the exponent to 12 characters
15:05Olajydand not restrict the answer to 12 characters as earlier stated
15:06amalloycharacters? like you want to allow 2^999999999999 but not 2^1000000000000?
15:13Chaunceyamalloy: Looks like Olayd just tried to compute that :D
15:45hehnopehey everyone, i'm trying to use slurp to read a file (slurp "/proc/cmdline") and its returning with "IOException Invalid argument java.io.FileInputStream.available (FileInputStream.java:-2)" any idea why?
15:46awwaiidhmm
15:47hehnopethis works though (slurp (java.io.FileReader. "/proc/cmdline"))
15:49awwaiidlooks like proc is special maybe -- https://bugs.openjdk.java.net/browse/JDK-7132461
15:50awwaiidif you want a hack, you could maybe read the results of `cat /proc/cmdline`
15:52awwaiidhehnope: (use '[clojure.java.shell :only [sh]]) (:out (sh "cat" "/proc/cmdline"))
15:54hehnopeye ait looks like its not going to be fixed either
15:54hehnope"This function is not used in jdk8 or 9, we're not going to backport a fix. Closing as not an issue "
15:55awwaiidtell me if the sh hack works :)
15:56hehnopeawaaiid: yea it works
16:31awwaiidsuweet
16:31kwladykaHow to Clojure show data instead clojure.lang.LazySeq@cf55badd https://www.refheap.com/84e2274119b25dab46745dcd6
16:32gfredericksso let's say you like multimethods generally but you like how protocols group "methods" together
16:32gfredericksis there any reason you wouldn't want to use a library with a couple helper macros, defmultis & defmethods?
16:32gfrederickspresumably the group would share a dispatch function
16:34justin_smithI wouldn't use it if you named it uber
16:37gfredericksno worries there
16:37gfredericksI wonder if there's any way to implement reify for such a thing
16:38justin_smithNDXOXCHWDRGHDXORVI is a good name for something if not that lib http://www.dailymail.co.uk/sciencetech/article-3187667/Can-solve-riddle-NDXOXCHWDRGHDXORVI-British-Library-appeals-help-cracking-code-carved-medieval-double-edged-sword.html
16:39justin_smithgfredericks: reify for the dispatch, or for grouping the multimethods?
16:39gfredericksI'm not entirely opposed to using that name
16:39gfredericksjustin_smith: I was thinking for creating an anonymous type that implements the multimethod, but now that I say it outloud that only makes sense for type-based dispatch
16:40gfrederickskwladyka: prn?
16:42kwladykagfredericks, thx
16:44gfrederickskwladyka: also pr-str if you wanted a string
16:45kwladykagfredericks, "even square board " 4 "x" 4 " pieces: " (:queen :rook :rook :bishop :bishop :king :king :knight) <- how to do that without "?
16:45kwladyka(pr-str "even square board " size "x" size " pieces: " pieces)
16:46justin_smithkwladyka: (println "even square board " 4 "x" 4 " pieces: " (pr-str coll))
16:46justin_smithwhere coll is the thing with the keywords in it, of course
16:47kwladykajustin_smith, no one function for that? (str "even square board " size "x" size " pieces: " (pr-str pieces)) <- is it the best one?
16:47justin_smithwait, did you want the string or to print something?
16:47justin_smiththere's also format I guess
16:47kwladykajustin_smith, string
16:48justin_smithyeah, then use str / pr-str, or maybe format / pr-str
17:01kwladykai have special functions only for tests and i am using this test only in one test file. Where should i have this functions? In the same file? In another? Where?
17:03awwaiidSeems like a helper for a test should be fine to live alongside the test (same file)
17:03kwladykathis functions check some heuristic properties of data
17:04kwladykaeven if functions take more lines then tests ? :)
17:04kwladykajust not sure about best practice
17:05awwaiidI don't really know about best practice for clojure, but my heuristic probably still applies. If there is a spot where you put lots of these test helpers, esp if more than one test uses them, then it is ok to be separate. otherwise drop that sucker in the test and realize that it IS the test, even if it is split up into helper and assertion
17:05sdegutisCan someone make Clojular please.
17:08sdegutisOkay has anyone made it yet.
17:17sdegutis,(.parseInt "5")
17:17clojurebot#error {\n :cause "No matching field found: parseInt for class java.lang.String"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "No matching field found: parseInt for class java.lang.String"\n :at [clojure.lang.Reflector getInstanceField "Reflector.java" 271]}]\n :trace\n [[clojure.lang.Reflector getInstanceField "Reflector.java" 271]\n [clojure.lang.Reflector invokeNoArgInsta...
17:17sdegutisWhat am I missing?
17:17sdegutisOh.
17:26sdegutis,(Integer/parseInt "5")
17:26clojurebot5
17:27awwaiidexactly
17:27sdegutisWould make more sense if there was an Interface like ParsableAsInt with .parseInt which String conformed to and then you could just do (.parseInt "5").
17:39kwladykaawwaiid, for now i am thinking the same, but file is going to have too many lines i am a little confuse about that
17:54sdegutis,(conj #{} :foo)
17:54clojurebot#{:foo}
17:54sdegutis,(assoc #{} :foo nil)
17:54clojurebot#error {\n :cause "clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Associative"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.PersistentHashSet cannot be cast to clojure.lang.Associative"\n :at [clojure.lang.RT assoc "RT.java" 785]}]\n :trace\n [[clojure.lang.RT assoc "RT.java" 785]\n [clojure.core$assoc__4130 invokeStatic "core.clj" 191]\n [clojure.cor...
17:58puredangeryou should really use (Integer/valueOf "5") - that gives you the boxed (cached) value and Clojure is going to box the primitive return from parseInt anyways.
18:01sdegutispuredanger: Cool good to know.
18:02sdegutispuredanger: top Google result says to use (Integer. s) instead... you might wanna post your answer there
18:03puredangeroh, I wrote my piece on this years ago http://tech.puredanger.com/2007/02/01/valueof/
18:03celwellHi, how can I use java interop in a (comp)? (comp .getTime :timestamp) is "unable to resolve symbol"
18:03puredanger(comp #(.getTime %) :timestamp)
18:03puredangerJava methods aren't functions, but you can wrap them into one
18:04celwellthanks, that's not very pretty, oh well
18:06sdegutispuredanger: nobody reads anything except what's on stackoverflow
18:07sdegutispuredanger: so that's the place to post it
18:13amalloypuredanger: that article doesn't seem relevant to the difference between parseInt and valueOf
18:14amalloyyou get the same cached value either way
18:14amalloyif you were arguing against (Integer. "5"), as your article does, i would agree
19:18sdegutisO snap, amalloy just outClojure'd puredanger
19:46simoin1234Hi there! I want to use the clojure.doc function from inside my program. The thing is, if I give it a Var it does not work, I guess this is because doc is macro. But how can I use doc then?
19:50devnCould someone help me out with understanding a docstring:
19:50devn,(doc iterator-seq)
19:50clojurebot"([iter]); Returns a seq on a java.util.Iterator. Note that most collections providing iterators implement Iterable and thus support seq directly. Seqs cache values, thus iterator-seq should not be used on any iterator that repeatedly returns the same mutable object."
19:51devnThat last bit: "*repeatedly* returns the "same" _mutable_ object"
19:53simoin1234Ho don't worry for my question I use the private function in clojure.repl passing meta to it. That's working.
19:53devnI have a KafkaStream that I am doing: (doseq [message (iterator-seq (.iterator stream))] ...) on
19:55simoin1234By the way I have another minor question, is there any way to write a multiline string indented for readability purpose but whose value gets rid of the indent (trimmed)? I guess you have to do this by hand right, there is no special reader macro?
19:55devnA) What does 'same' mean, when talking about a mutable object? Like, the identical object?
19:57devnB) RE: Caching values. I'm not sure this is what I want. Once I've read a value from the iterator, I'd like to discard it, not cache it.
19:58devnbut, I am not sure how to go about investigating whether or not KafkaStream fits the criteria of A. Any help would be welcome.
20:02amalloydevn: it is talking about some really badly-behaved classes whose iterator just constructs a single entry, and then every time you call .next it mutates that entry and gives it back to you
20:02devnLike, if you were to read that docstring above for iterator-seq, would you say (iterator-seq (.iterator (.keySet (System/getProperties)))) fits the bill?
20:02amalloyi can't remember off the top of my head an example in the jdk that does that. some kind of map type in its entrySet as i recall
20:03devnamalloy: how's your scala? wanna look at a kafka.consumer.KafkaStream? ;)
20:03amalloykafka's stream implementation is reasonably well-behaved
20:04amalloyyou shouldn't have any trouble treating it as an iterable
20:04amalloybut iterator-seq of .iterator is bonkers: just seq over the .keySet itself
20:04devnThat's sort of what I expected. Really appreciate you adding some color on that docstring.
20:04devnamalloy: yeah, that's a bad example
20:05devn(seq a-kafka-stream) doesn't work
20:05devnwithout that chain
20:05devnby which i mean: (iterator-seq (.iterator a-kafka-stream))
20:07devnamalloy: one more for you: https://github.com/pingles/clj-kafka/blob/master/src/clj_kafka/consumer/zk.clj#L71
20:07amalloyi don't think that's true
20:07amalloydevn: http://stackoverflow.com/a/5455903/625403 is an example of the kind of evil iterator it is warning about
20:08devnI've managed to give myself an OOME using that that messages function, and I think there's something about the way that lazy-seq is being constructed that I'm missing
20:09devn(loop [msgs (zk/messages consumer "foo-topic")] (do something with (first msgs)) (recur (rest msgs)))
20:11devnwhich is really why i'm here in the first place -- some tests i've been writing are a lot easier if I can treat the messages as a lazy-seq instead of running kafka, zookeeper, constructing a message steam, etc.
20:12amalloyoh, wow. puredanger: what is the deal with c47e1bbc? chunking everything that gets seq'd sounds like a serious change that would break any programs that want to work with another language's lazy stuff
20:12devnso, after an OOME happened, and i found the culprit to be related to the use of that messages function, i switched over to just calling (.iterator stream), recuring with the iterator after doing what I needed to do on (.next thing)
20:12amalloyer, link at https://github.com/clojure/clojure/commit/c47e1bbc
20:13devnamalloy: i was wondering the very same thing about that chunkIteratorSeq
20:13amalloydevn: it looks like iterator-seq was changed to be automatically chunked as of this march, which means you can't really use it to walk over a collection that isn't yet all realized
20:15devnamalloy: hmm, im not sure i follow
20:15devnwhy must it be all realized?
20:15devnsince it will be chunked, you mean?
20:16amalloydevn: so, the .hasNext function on a kafka iterator blocks until it either gets a new item from the server, or gets shut down (so there will be no new items)
20:16devnyes, i have this running in a go-loop
20:16devn(just FWIW)
20:16amalloywhich means that the chunked iterator's attempt to bundle the first 32 items into a chunkedcons will return nothing at all until 32 items are available
20:18devn!!!
20:19devnmy god am I glad I came in here and asked
20:19devnamalloy: just tested that, and you're absolutely right
20:19devni've been hammering this thing with input, and didn't notice the 32 element threshold
20:21devnamalloy: so, you mentioned that you think i'm blowing smoke on (doseq [msg (iterator-seq (.iterator stream))] ...)
20:22devni think i may just be misunderstanding what you're suggesting
20:22devnin the case that i dont call iterator-seq, are you expecting me to call .hasNext and .next myself?
20:22amalloyno. you just call seq
20:23amalloyor let doseq do it for you: (doseq [msg stream] ...)
20:24devnhm, i could swear i tried that, but let me give it a go
20:27devnamalloy: now im not sure if it's kafka that's batching
20:27devn:D
20:28devnit wasn't responding to a message at a time, granted those were tiny messages
20:28justin_smithdevn: you can set it's buffering size, I cut the default by 1000x and got good latency
20:29justin_smithlike the config file had a default buffer of 4410000 and I changed it to 44100
20:29justin_smithwhich is obviously the right choice because duh
20:30devn32 is the magic number again
20:30devnwhich makes me a little nervous, since the messages i was sending were like 100k
20:30devnscratch that, 72k
20:31justin_smiththat's still small enough that the default buffering is going to cause weird behaviors if you expect any kind of reasonable response time
20:31devnkafka is a strange beast, i must say
20:32justin_smithvery powerful though
20:32devnagreed, just wish there was a training wheels version, because there are /so many/ options
20:33devnjustin_smith: i suppose this conversation is now bleeding into #apache-kafka
20:33devngot a second?
20:33justin_smithdevn: sure, 'sup?
20:33devncheck #apache-kafka
21:12SeyleriusAre there any systems LISPs that can compare favorably with Clojure? Racket seems to try, but doesn't seem to get the data structures nearly as right as Clojure does, from what I'm reading.
21:37justin_smith,(apply str (mapcat (partial map (comp char (partial + 77))) (interpose [11] [[1 -9] [2] [-10 -5 10 -9 5 -6 -5 -9] [2 5 9 -4]])))
21:37clojurebot"NDXOXCHWDRGHDXORVI"
21:37justin_smiththat's today's magic word, btw
21:37devnSeylerius: in what sense?
21:38devnSeylerius: I mean, compare how? You mentioned data structures, but there's a lot more to it than just that.
21:40SeyleriusYou're right, there are more things. Clojure's just a lot more... fluid to program in. The layout, the standard library, the syntax, it all just feels cleaner to me than other lisps. The nature of the data structures leaves the language feeling more sensible to me. The JVM's a mixed blessing, though, and the language can't really be used for systems programming, since you can't compile all the way down to machine-code.
22:04namragreetings, i have a set with keywords, and a keyword looks something like this: :Android/d8:50:e6:7f:52:ae/APAasdfasgd
22:04namrabut now i want to turn that into a string, thus i use the name procedure
22:04justin_smithI don't think that's a valid keyword - not a valid keyword literal at least
22:05namrabut this returns a string where "Android/" is missing
22:05justin_smith,(namespace :Android/d8:50:e6:7f:52:ae/APAasdfasgd)
22:05clojurebot"Android"
22:05namraah i see
22:05justin_smith,(name :Android/d8:50:e6:7f:52:ae/APAasdfasgd)
22:05clojurebot"d8:50:e6:7f:52:ae/APAasdfasgd"
22:06justin_smithit's a weird keyword, I did not expect the reader to accept it
22:06namrawas kinda ignorant, didn't ask how those ids will look like
22:06namraand to avoid duplicates and to make removing of them easier i went for a set with keywords
22:07amalloyjustin_smith: little known fact: the reader accepts just about any old junk
22:07justin_smithI guess it works
22:07justin_smithamalloy: haha
22:07justin_smith,(keyword "this should not be news to me")
22:07clojurebot:this should not be news to me
22:07amalloynamra: why do you have this keyword at all?
22:08amalloyit clearly is not something you typed into your source code, so i presume you read a string from some external source at runtime. just leave it as a string; it's clearly not good keyword material
22:08namraamalloy: because as i said above, prio to implementing it that way i didn't know how the possible ids would look like that go into the set
22:08amalloyyou don't really need to know that. strings that come from outside your application are bad candidates for keywords
22:09namrabecause (disj (:devices user) (keyword device-id)) is so short ^^
22:09amalloyeven if it were just a nice easy string like "Android-5" you'd want to leave it as a string
22:09amalloynot as short as (disj (:devices user) device-id)!
22:09namrathat'll work with string?
22:09justin_smithyes
22:09namra:/
22:09amalloyyes, that is what i am trying to tell you
22:09justin_smithstrings are equal by value
22:09namrathanks alot guys
22:09amalloyclojure's data structures contain objects of any sort
22:09justin_smith:)
22:15justin_smithamalloy: but coming from some other languages you might not expect strings to have value equality
22:19puredangeramalloy: re your earlier question - you are already at risk of this when you use potentially it in combination with any lazy sequence transformation (like map, filter, etc). Programs that rely on the number of elements computed "ahead" for any lazy seq operation are inherently fragile. If you want more control, it's easy to do so with your own lazy-seq,
22:19puredangerloop-recur, or any transducing function (which defers processing till the point where it's needed).
22:49reutermjHow do you type hint a string array?
22:50justin_smith,(type (into-array ["a"]))
22:50clojurebot[Ljava.lang.String;
22:50justin_smith"[Ljava.lang.String;"
22:51justin_smithyou can use the string instead of the usual symbol
22:52justin_smithof course you can't use it outside a string because the reader would hate it
22:58SeyleriusInteresting... Anyone seen clojure-scheme (https://github.com/takeoutweight/clojure-scheme)? It seems to be a decent way of making one's way down to bare metal from Clojure, which might be a way around my irritation with existing systems-lisps.
22:58reutermjAlright, I'm still a little confused on how to use that in java interop code
22:59justin_smith(defn foo [^"[Ljava.lang.String;" bar] ...)
22:59justin_smithfoo now expects an array of string called bar as its arg
23:00reutermjok thanks
23:07binjuredwhen writing a macro that takes a class or function as an argument, how can i ensure the resulting code is ns-qualified?
23:13gfredericksum
23:13gfredericksbinjured: it doesn't normally need to be
23:13gfredericksbinjured: do you have a specific example where you think that's necessary?
23:15binjuredgfredericks: yeah, i know. what i'm trying to do specifically is write a macro that takes a class as an argument, then imports something in the same namespace as that class. however, if i call the macro like (some-macro Foo) instead of (some-macro bar.baz.Foo), i haven't figured out how to get the FQNS from within the macro.
23:17gfredericks,(resolve 'Long)
23:17clojurebotjava.lang.Long
23:17gfredericks,(type (resolve 'Long))
23:17clojurebotjava.lang.Class
23:17gfredericks,(type (resolve 'first))
23:17clojurebotclojure.lang.Var
23:18justin_smith,(nth (iterate resolve resolve) 1000)
23:18clojurebot#error {\n :cause "clojure.core$resolve cannot be cast to clojure.lang.Symbol"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.core$resolve cannot be cast to clojure.lang.Symbol"\n :at [clojure.core$ns_resolve invokeStatic "core.clj" 4218]}]\n :trace\n [[clojure.core$ns_resolve invokeStatic "core.clj" 4218]\n [clojure.core$ns_resolve invokeStatic "core.clj" 4208]\n [clojure...
23:18gfredericks^ I think that'll do what you want
23:18justin_smith:(
23:18binjuredah, cool. thanks!
23:21justin_smith,(nth (iterate (comp resolve :name meta) #'resolve) 1000000)
23:21clojurebot#'clojure.core/resolve
23:23DeltaLambdaThat's one way to implement identity on vars
23:24justin_smithDeltaLambda: there's a bunch of amazing ones in clojure
23:24justin_smith,(def id (partial get get get))
23:24clojurebot#'sandbox/id
23:24justin_smith,(id 42)
23:24clojurebot42
23:24justin_smith,(id id)
23:24clojurebot#object[clojure.core$partial$fn__4517 0x6dcdad6b "clojure.core$partial$fn__4517@6dcdad6b"]
23:24justin_smith,(id 'YOLO)
23:24clojurebotYOLO
23:25DeltaLambdaInteresting
23:25binjuredis there a less janky way of turning the result of (resolve 'Thing) into a string than (str) and removing the "class" prefix?
23:25DeltaLambda. getName
23:26justin_smithDeltaLambda: any instance of of the function get can be replaced by (get get get get) without changing the meaning of the program
23:26binjuredexcellent
23:26justin_smiththe rule can even be applied recursively
23:26DeltaLambdaI'll begin doing so
23:27binjuredhahah
23:28justin_smithgfredericks: free slide for you if you plan on doing a transducers talk some time https://i.imgur.com/uKoNV3G.jpg
23:28justin_smithwell I mean anyone could use it
23:28DeltaLambda,(get get get (get get get get))
23:28clojurebot#object[clojure.core$get 0x3da99244 "clojure.core$get@3da99244"]
23:30justin_smith,((get get get (get get get get)) {:a 42} :a)
23:30clojurebot42
23:31DeltaLambdaAll the gets
23:42TEttinger,((get get get (get get get get)) {get 42} get)
23:42clojurebot42
23:42justin_smitheven better
23:44rhg135,((get get get (get get get get)) {get get} get)
23:44clojurebot#object[clojure.core$get 0x2f5ba1ff "clojure.core$get@2f5ba1ff"]
23:44justin_smithit's like that movie, being john malkovitch
23:44justin_smithbut with clojure.core/get
23:44TEttinger,((get get get (get get get get)) {"get" get} get "get")
23:44clojurebot"get"
23:45justin_smith(the phenomenon is called "semantic saturation")
23:45justin_smithgetjure - new dialect of clojure, where the only function allowed is get?
23:46rhg135,((get get get get) (get get get get) (get get get get) (get get get get))
23:46clojurebot#object[clojure.core$get 0x2f5ba1ff "clojure.core$get@2f5ba1ff"]
23:47rhg135Good way to break some brains, justin_smith
23:47rhg135That and swearjure
23:50amalloyall this ((get get get get) (get get get get) (get get get get) (get get get get)) stuff feels like it ought to be sung, to the tune of https://youtu.be/drVYvZ2cqHQ?t=33
23:53rhg135Get get get, get get get, get your get