#clojure logs

2015-03-07

00:00justin_smiththen clearly Bender's dating service is not for you
00:21AeroNotixI have a gen-interface that depends on the output of a gen-class. I have them both in AOT in the dependency order. It won't compile claiming it can't find the gen-class class on the classpath. Do I need to do anything else?
00:22justin_smithAeroNotix: do you import the needed gen-class generated class in the ns that creates the interface?
00:23AeroNotixjustin_smith: yaeh
00:23AeroNotixyeah*
00:26AeroNotixjustin_smith: was there a follow-up to that or were you just making sure?
00:27justin_smithAeroNotix: just ruling out something simple
00:27AeroNotixcool ok
00:27justin_smithI have little experience with gen-class or gen-interface, so I can't be much help on this count
00:28amalloydoes your interface-ns require the class-ns?
00:28amalloyif it doesn't, the order they're compiled in will be arbitrary
00:28AeroNotixamalloy: imports it
00:28amalloydo both
00:28AeroNotixok
00:29justin_smithahh, yeah, good call. If not for the vodka I might of remembered that.
00:29justin_smith(inc amalloy)
00:29lazybot⇒ 232
00:29AeroNotixamalloy: magic
00:29AeroNotix(inc amalloy)
00:29lazybot⇒ 233
00:29amalloygood to hear it
00:29AeroNotixWhy did that fix it?
00:29justin_smithAeroNotix: loading the clojure code creates the class
00:30AeroNotixohhh ok, the AOT, it does nothing?
00:30justin_smithAeroNotix: I dunno, depends on how you set lein up. It probably got the ordering wrong or something.
00:31AeroNotixinteresting ok, thanks all
00:31AeroNotixthe really cool thing is, I can create a jar that just all magically looks like Java and pass it to co-workers.
00:31AeroNotixamazing
00:32justin_smithhaha
00:32amalloyAeroNotix: while AOTing, the namespaces have to be loaded in some order, right? and the classes are created in the same order as the namespaces
00:32justin_smithuntil they try to run a static analysis tool or something :)
00:32AeroNotixamalloy: right that makes sense
00:32amalloyso, if you don't tell clojure what order to compile the files in, it can't AOT
00:32AeroNotixjustin_smith: they know it is clojure. I just don't want them to deal with any idiosyncrasies
00:33AeroNotixall in all, Clojure helped me bridge a gap between two teams that were marred with politics
00:33AeroNotixjust by being able to drop them some easily consumed code
00:33justin_smithnice
00:33AeroNotixyeah I'm really happy with that
00:33amalloyAeroNotix: personally i'd rather write java interfaces and classes in java, vs writing them in clojure with a gen-class, but whatever works for you
00:34AeroNotixamalloy: I was going to do that if it didn't work but I wanted to see how far I could go with just writing clojure. Turns out, all the way nearly!
00:34justin_smithAeroNotix: my experience was having success sneaking some clojure into a backend stack, and then the client had a security issue with another contractor, which led to mandatory static analysis for everyone, which led to much wtf, wailing, and gnashing of teeth
00:34AeroNotixjustin_smith: how does it manifest?
00:34AeroNotixjust "oh wait this is clojure wtf'
00:35AeroNotixor some other aspect?
00:35justin_smiththat plus "sorry, you can't deploy this code because we can't statically analyze it"
00:36AeroNotixah, I don't *think* I'll have that issue. We'll see.
00:36AeroNotixI've made it very clear what I am doing to all involved
01:30lvhHi :-) I'm trying to figure out how to use core.async. I have a bunch of work items (data structures describing what to do). I want to execute them with limited parallelism. pipeline-* seems ideal. However, each of the processes relies on some continuously changing shared state of the world. I figured I'd make that a channel that gets updated whenever a new state-of-the-world is available). However; how do I do that with pipeline? I only get to pass one xform.
01:30lvhDoes that mean I have to write my own transducer that mults in the nullary case?
02:45SagiCZis clojure using new java 8 features like lambdas and Iterable/forEach()? or is that just syntactic sugar?
02:59amalloyclojure supports java 6
03:59expezwhen lein repl says it couldn't locate something on cp and refuses to start, what could be wrong when the jar is present in .m2 as expected?
04:33justin_smithexpez: what's the specific error message?
04:34expezjustin_smith: I was trying to include alembic as a dependency in refactor-nrepl (to get rid of pomegranate) but I don't think that's possible. I think the user has to include it as a dependency in the toplevel project or in profiles.clj
04:35justin_smithexpez: alembic uses pomegranate doesn't it?
04:35expezjustin_smith: yes, but in an isolated classloader
04:46justin_smithSagiCZ: some day, Clojure might directly use that java 8 stuff, but for now Clojure itself targets 1.6 (there's some cool stuff in 1.7 that isn't even used by core yet). But we can use it all via interop.
04:48SagiCZjustin_smith: i see.. thanks and do you have any idea if it would have any performance impact on clojure?
04:48justin_smithI really don't know.
04:48SagiCZalright
05:36wizzoin this https://github.com/bbatsov/clojure-style-guide it says to prefer nil punning over empty?
05:36wizzois that true? why?
05:37justin_smithI dunno, I never really liked that rule myself.
05:41amalloythe rule that clojure/corepromulgated is to prefer using seq over (not (empty? ...))
05:42amalloychoose between nil punning or empty? based on which reads better in context; since seq and empty? are opposites, you can use them to reorder your then/else clauses
05:42wizzoahh ok i didn't notice the not
05:42wizzobut why? performance?
05:43amalloybecause it's dumb to write (not (empty? x)), when empty? is (not (seq x))
05:43wizzooooooh
05:43justin_smith(seq x) reads better than (not (empty? x))
05:43amalloy(if (not (not (seq x))) (srsly what am i (doing (pls help))))
05:43justin_smith(not (not (not (not (seq x)))))
05:44wizzoeh i think not empty? reads better but that's just me
05:44justin_smithI'm a fan of not-empty
05:44wizzobut it makes sense knowing what empty? actually is
05:44justin_smith,(not-empty "")
05:44clojurebotnil
05:44justin_smith,(not-empty "hi")
05:44clojurebot"hi"
05:44justin_smith,(seq "hi")
05:44clojurebot(\h \i)
05:45amalloyjustin_smith: gross
05:45amalloynot-empty shouldn't be used as a predicate
05:45wizzowhy
05:46justin_smithamalloy: not-empty + if-let = chocolate + peanut butter
05:46amalloybecause it's just a longer way of writing seq
05:46amalloyjustin_smith: for sure. but that's not using it as a predicate
05:46justin_smithit's using it as a binding and a predicate, that's what if-let is for
05:47amalloythat's fine. but it sounded like you were saying to use not-empty instead of (not (empty?))
05:47amalloysince in the middle of that discussion you said "i'm a fan of not-empty"
05:49justin_smithyeah, I actually like using it in predicates as well (because seq is more overloaded, and the name not-empty describes what I am checking for)
05:49justin_smithbut we have had this conversation before, and I understand that we disagree.
06:03mbacis there a way to take a sub-array from an array without copying?
06:04justin_smithmbac: subvec for vectors
06:04mbaci'm specifically using arrays tho : /
06:04tomjackyou basically have to carry your endpoints around with you, I think
06:05justin_smithyeah, I think that's pretty much the deal
06:05doritostainsexit
06:05mback
06:23justin_smiththe most common street name in the US is second, second place is third, and third most common is first
06:34AimHerejustin_smith, Makes sense. Some early towns started out as just being a single street. If you only have one thing, you don't call it 'first'
06:35AimHereIt's only if you have enough forethought to plan two or more streets in advance that 'first' would be in the running
06:35justin_smithright, I just like that the first three popular names are a perfect jumble
06:35AimHereIt's not a complete jumble. I imagine that other than 'first', the other 'numbered' streets are more or less in numerical order
06:35justin_smithoften instead of "first" you have "name of town" or "main"
06:35justin_smithAimHere: the first three are though
06:36justin_smithhttp://www.usd116.org/profdev/ahtc/lessons/PlautFel09/scans/2009_07_09/StreetNamesCensus.pdf
06:36justin_smithfourth is fourth
06:36AimHereNah, 'first' is the only one out of sequence
06:36godd2The explanation that "first street gets renamed" makes most sense to me
06:37AimHereWhy would first be renamed more often than second?
06:37justin_smithAimHere: there is no ordered permutation of 1,2,3 where no item has itself as its position, and no pair are in order
06:37justin_smithI was referring to the former property
06:38justin_smithI would hardly call 3,2,1 a jumble
06:38godd2AimHere it gets renamed to Main st!
06:38AimHeregodd2, wouldn't it be called main to begin with?
06:38godd2That would require forsight
06:38AimHereSince the next few streets wouldn't be '2nd' or '3rd' but all the ones perpendicular
06:38justin_smithlook at history: the road comes first, then the town, for a majority of towns
06:39justin_smithexcept the largest cities, there the port comes first
06:39AimHereThe 1st, 2nd, 3rd tend to be parallel
06:39justin_smiththen the roads
06:40godd2sometimes the river comes first
06:40AimHeregodd2, calling it 'first' would require foresight, since then you have to presume the town will get big enough to support at least 2, and more likely 3 more roads
06:40justin_smithgodd2: I should have generalized "port"
06:40justin_smithdock?
06:41AimHereI wonder how many towns had the airport first
06:41godd2AimHere that's true, but I still like the explanation :P
06:41justin_smithanyway, first you have a road, then people live near it, and finally you get parallel streets, this was the pattern through much of the US at least
06:41justin_smithAimHere: maybe some places like Alaska?
06:42justin_smithsome day we may have cities where the launching pad back to earth comes first
06:43justin_smithAimHere: does anything in antarctica count as a city? if so, things are definitely built around the airfields there
06:44AimHereLargest settlement is that McMurdo sound
06:44justin_smithor town even
06:44AimHereAnd it's beside a body of water
06:44justin_smithyeah
06:44AimHereAlso, 1200 residents, so a hefty village, if not a town
06:45justin_smithbut nobody permanent
06:45justin_smithI bet 0 children
06:53mbachow is there really no fast Object[] getSubArray(Object[] array,int off,int len) function?
06:53justin_smithit could be done as a wrapper pretty easily by closing over the array
06:54mbacit's clearly a net loss for everyone who wants to have fast subarrays to carry around endpoints and also hope everyone who implements a library that operates on arrays provides methods that take an off and len parameter
06:54mbacyeah, i'm just kind of baffled by the java ecosystem
06:55justin_smithI bet 0 children
06:55justin_smithoops
07:26profilIs there a way to get an overview of threads running in the REPL?
07:26justin_smith(Thread/getAllStackTraces) will show you what they are doing
07:28justin_smithwell, it returns a Map from Thread to StackTraceElement[] for all running threads, that can be used to find out what they are doing
07:30profiloh, alright
07:31justin_smitheach StackTraceElement can then be queried for the method name, file name, etc.
07:33profilI am unsure if I am doing async tcp correctly..
07:35profiljustin_smith: have you got any experience with aleph?
07:36justin_smithno, I haven't used it actually. I've read a bunch of the code though
07:39profilokay, I am trying to figure out the periodically function from manifold.stream but I cant get my head around it
07:39profilit keeps running even though I have closed the stream
07:46justin_smithprofil: just realized that "status of all threads" function would be really useful https://www.refheap.com/98179
07:48profilnice
07:48profilthats a lot of stuff :D
07:48justin_smithyeah, especially if nrepl is running
07:48justin_smithnotice how many of the threads are executing nrepl stuff
07:50justin_smithprofil: well, if no-one else can help, ztellman is often here, and hopefully he at least understands what it is doing :)
07:50profilyeah, I have looked for him the last couple of days, but missed him :)
07:53justin_smithprofil: reading the source, I would expect it to continue even if the stream was closed
07:53justin_smithhttps://github.com/ztellman/manifold/blob/master/src/manifold/stream.clj#L497
07:53justin_smithit catches Throwable
07:54justin_smithso even an Error won't break out
07:54profilyeah, but if L506 is true it will break out? or am I wrong?
07:54justin_smithunless I am misreading
07:55profil(@cancel) means that the every function will be canceled?
07:56justin_smithhmm...
07:56justin_smithit depends on what time/every does I guess
07:56profilFrom time/every, "Returns a zero-argument function which, when invoked, cancels the repeated invocation."
07:56justin_smithhttps://github.com/ztellman/manifold/blob/master/src/manifold/time.clj#L159 every will keep calling the function
07:57justin_smithahh
07:57profilthat means that if the stream that put! tries to access is closed it will return nil, which would cancel the repeat?
07:57profilbut my function keeps on running 3 times after the stream is closed
07:57profiljust 3 times
07:57profilvery weird
07:58justin_smiththat is weird
07:58justin_smithI see what it's doing with cancel now
07:59justin_smithprofil: could this be a race, where there are puts that have not been consumed?
07:59justin_smith(at the time of cancellation, that is)
08:00profiljustin_smith: yeah probably, I am connecting this stream to another where map is running
08:01profiljustin_smith: this is what my handler is doing, https://www.refheap.com/98180
08:01profiljustin_smith: if I remove line 11, the last "Ping timeout" will be printed 3 times
08:03justin_smithprofil: at 5 second intervals?
08:03profiljustin_smith: yes
08:04justin_smithbut it looked like periodically was checking for the channel being closed
08:05justin_smithprofil: maybe something to do with the buffering on the stream?
08:05profilif the stream is closed put! will return nil
08:05justin_smithnil, or something that derefs to nil?
08:05justin_smithbecause the code is dereffing
08:06justin_smith,@nil
08:06clojurebot#<NullPointerException java.lang.NullPointerException>
08:07profildefers to nil I guess
08:07profils/fer/ref/
08:07justin_smithI guess that's moot beacause either way you get a cancel / close
08:08profil,(let [d (future nil)] (if @d "true" "false"))
08:08clojurebot#<SecurityException java.lang.SecurityException: no threads please>
08:09justin_smith,(let [d (delay nil)] (if @d true false))
08:09clojurebotfalse
08:14profilI am not fiddling with buffering on the stream myself
08:14profilI have no idea why it does that
08:36nicferrierhey all ... still arsing around with zippers and hiccup.
08:37nicferrierI can see it's a powerful technique, but it seems like the xml.zip package has some pretty basic utils that hiccup doesn't have.
08:37nicferriershould I abandon hiccup and try and make my data parsable by the standard xml stuff? is that a more normal way to work with xml data in clojure?
08:38irctc__Hello ... I'm trying to call a Java method from AClass in Clojure that receives as parameter AnotherClass.class. Not a instance, but the class itself. How can I do that?
08:41irctc__I've tried (class AnotherClass) but it returns java.lang.Class instead of com.package.AnotherClass.class or something.
08:43nicferrierhave you imported AnotherClass?
08:44irctc__Yes... like (:import (com.package AnotherClass)
08:44irctc__Yes... like (:import (com.package AnotherClass))
08:44nicferriercan't you just (somefunc 'AnotherClass) ?
08:44irctc__The exception is: java.lang.IllegalArgumentException: No matching method found
08:45nicferrieris it a static method?
08:45irctc__No, I need an instance of the class to invoke it....
08:46nicferrierso it's an instance method?
08:46nicferrierand you've got the instance?
08:46irctc__I'm trying to wrapper this: https://github.com/EsmerilProgramming/graesh/blob/master/src/main/groovy/org/esmerilprogramming/graesh/Graesh.groovy
08:47irctc__The equivalent of Line 47 not working here.
08:47irctc__Hey @nicterrier, thanks a lot for your attention by the way :-)
08:48nicferrierso you have something like this (let [a (AeshCommandRegistryBuilder.) b (.commands a AnotherClass)] ...)
08:49TimMcirctc__: Does commands take varargs?
08:49irctc__(defn init-aesh-command-registry-builder [] (doto (AeshCommandRegistryBuilder.) (.commands (class Cat) (class Cd))))
08:50nicferrierirctc__: but you need to pass in the instance to .commands
08:50TimMc(.commands builder (into-array Class [Cd Ls Mkdir]))
08:50TimMcirctc__: (class Cat) will give you Class.
08:50elsenhola
08:50irctc__Hum. But (doto) does that, no ?
08:50elsenanyone using clojure on android?
08:51irctc__(doto (AeshCommandRegistryBuilder.) (.commands (class Cat) (class Cd)))
08:52irctc__The Java method has this interface: public AeshCommandRegistryBuilder commands(Class<? extends Command>... commands)
08:54martinklepschprobably a dumb q: I have a list [a b c] now I want to apply f to each possible combination of two items ignoring how they're ordered (e.g. apply f only to [a b] but not [b a]) — I'm sure there is a word for that kind of thing?
08:57irctc__It's a combination @martinklepsch
08:59irctc__Try (:require [clojure.math.combinatorics :as combo])
08:59TimMcirctc__: Right, so like I said above, that's varargs.
09:00TimMcirctc__: Try the thing I showed you above.
09:00irctc__(combo/combinations seq 2)
09:00borkdudeI saw someone type this on twitter:
09:00borkdude,(identical? 'a 'a)
09:01clojurebotfalse
09:01borkdudewhy is it false again?
09:01irctc__(class Cat) gave me java.lang.Class :-(
09:01martinklepsch,(prn 'a)
09:01clojurebota\n
09:02martinklepsch,(println 'a)
09:02clojurebota\n
09:02borkdudesymbols are not interned like string literals?
09:03martinklepschdont know, was just guessing that it could be because of some gensym stuff
09:03irctc__I have found this: http://tech.puredanger.com/2010/08/08/learning-clojure-class-reference/
09:03TimMcirctc__: You should the above IRC messages more carefully.
09:03irctc__Trying to understand.
09:04martinklepschirctc__: thanks, I somehow assumed that a "combination" would include dupes as in [a b] [b a]
09:04TimMc,(class "foo")
09:04clojurebotjava.lang.String
09:04TimMc,(class java.lang.String)
09:04clojurebotjava.lang.Class
09:04irctc__Do you mean (.commands builder (into-array Class [Cd Ls Mkdir])) ?
09:05TimMcyes
09:05irctc__trying...
09:06irctc__Not yet... :( more tries
09:09irctc__It compiles!
09:10irctc__Thanks TimMc !!
09:16TimMcsure thing
09:16TimMcGo read up on varargs, they're weird. :-P
09:17TimMc,(String/format "%s %s" (to-array [5 :cats]))
09:17clojurebot"5 :cats"
09:18gfredericksTimMc "5 :cats" is an acceptable baby name I think
09:19TimMcI think so too, will mention it to Alex.
09:19gfredericksdoes the jvm have different endianness details from Normal Honest To Goodness C Code?
09:20gfredericksin particular I'm writing ints to a DataOutputStream which is going to standard out and into a Normal Honest To Goodness C Program
09:21gfredericksoh wait nevermind
09:21gfredericksthe bytes are probably different but the bits within the bytes are not (is that even plausible?)
09:40dysfunis there any way to abort a System/exit ? i would like to ensure my function tries to exit during a test
09:44gfredericksdysfun: you could switch to using https://github.com/gfredericks/system-slash-exit ;-)
09:47dysfungfredericks: <3
09:48dysfuni was going to write something similar heh
09:48dysfungosh, no tests though. i mean there's a whole line of code there actually doing something. can't be sure it'll work.
09:52dysfungfredericks: you need to create a shorter name though.(require '[com.gfredericks.system-slash-exit :refer [exit]]) isn't exactly concise