2015-03-07
| 00:00 | justin_smith | then clearly Bender's dating service is not for you |
| 00:21 | AeroNotix | I 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:22 | justin_smith | AeroNotix: do you import the needed gen-class generated class in the ns that creates the interface? |
| 00:23 | AeroNotix | justin_smith: yaeh |
| 00:23 | AeroNotix | yeah* |
| 00:26 | AeroNotix | justin_smith: was there a follow-up to that or were you just making sure? |
| 00:27 | justin_smith | AeroNotix: just ruling out something simple |
| 00:27 | AeroNotix | cool ok |
| 00:27 | justin_smith | I have little experience with gen-class or gen-interface, so I can't be much help on this count |
| 00:28 | amalloy | does your interface-ns require the class-ns? |
| 00:28 | amalloy | if it doesn't, the order they're compiled in will be arbitrary |
| 00:28 | AeroNotix | amalloy: imports it |
| 00:28 | amalloy | do both |
| 00:28 | AeroNotix | ok |
| 00:29 | justin_smith | ahh, yeah, good call. If not for the vodka I might of remembered that. |
| 00:29 | justin_smith | (inc amalloy) |
| 00:29 | lazybot | ⇒ 232 |
| 00:29 | AeroNotix | amalloy: magic |
| 00:29 | AeroNotix | (inc amalloy) |
| 00:29 | lazybot | ⇒ 233 |
| 00:29 | amalloy | good to hear it |
| 00:29 | AeroNotix | Why did that fix it? |
| 00:29 | justin_smith | AeroNotix: loading the clojure code creates the class |
| 00:30 | AeroNotix | ohhh ok, the AOT, it does nothing? |
| 00:30 | justin_smith | AeroNotix: I dunno, depends on how you set lein up. It probably got the ordering wrong or something. |
| 00:31 | AeroNotix | interesting ok, thanks all |
| 00:31 | AeroNotix | the really cool thing is, I can create a jar that just all magically looks like Java and pass it to co-workers. |
| 00:31 | AeroNotix | amazing |
| 00:32 | justin_smith | haha |
| 00:32 | amalloy | AeroNotix: 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:32 | justin_smith | until they try to run a static analysis tool or something :) |
| 00:32 | AeroNotix | amalloy: right that makes sense |
| 00:32 | amalloy | so, if you don't tell clojure what order to compile the files in, it can't AOT |
| 00:32 | AeroNotix | justin_smith: they know it is clojure. I just don't want them to deal with any idiosyncrasies |
| 00:33 | AeroNotix | all in all, Clojure helped me bridge a gap between two teams that were marred with politics |
| 00:33 | AeroNotix | just by being able to drop them some easily consumed code |
| 00:33 | justin_smith | nice |
| 00:33 | AeroNotix | yeah I'm really happy with that |
| 00:33 | amalloy | AeroNotix: 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:34 | AeroNotix | amalloy: 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:34 | justin_smith | AeroNotix: 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:34 | AeroNotix | justin_smith: how does it manifest? |
| 00:34 | AeroNotix | just "oh wait this is clojure wtf' |
| 00:35 | AeroNotix | or some other aspect? |
| 00:35 | justin_smith | that plus "sorry, you can't deploy this code because we can't statically analyze it" |
| 00:36 | AeroNotix | ah, I don't *think* I'll have that issue. We'll see. |
| 00:36 | AeroNotix | I've made it very clear what I am doing to all involved |
| 01:30 | lvh | Hi :-) 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:30 | lvh | Does that mean I have to write my own transducer that mults in the nullary case? |
| 02:45 | SagiCZ | is clojure using new java 8 features like lambdas and Iterable/forEach()? or is that just syntactic sugar? |
| 02:59 | amalloy | clojure supports java 6 |
| 03:59 | expez | when 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:33 | justin_smith | expez: what's the specific error message? |
| 04:34 | expez | justin_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:35 | justin_smith | expez: alembic uses pomegranate doesn't it? |
| 04:35 | expez | justin_smith: yes, but in an isolated classloader |
| 04:46 | justin_smith | SagiCZ: 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:48 | SagiCZ | justin_smith: i see.. thanks and do you have any idea if it would have any performance impact on clojure? |
| 04:48 | justin_smith | I really don't know. |
| 04:48 | SagiCZ | alright |
| 05:36 | wizzo | in this https://github.com/bbatsov/clojure-style-guide it says to prefer nil punning over empty? |
| 05:36 | wizzo | is that true? why? |
| 05:37 | justin_smith | I dunno, I never really liked that rule myself. |
| 05:41 | amalloy | the rule that clojure/corepromulgated is to prefer using seq over (not (empty? ...)) |
| 05:42 | amalloy | choose 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:42 | wizzo | ahh ok i didn't notice the not |
| 05:42 | wizzo | but why? performance? |
| 05:43 | amalloy | because it's dumb to write (not (empty? x)), when empty? is (not (seq x)) |
| 05:43 | wizzo | oooooh |
| 05:43 | justin_smith | (seq x) reads better than (not (empty? x)) |
| 05:43 | amalloy | (if (not (not (seq x))) (srsly what am i (doing (pls help)))) |
| 05:43 | justin_smith | (not (not (not (not (seq x))))) |
| 05:44 | wizzo | eh i think not empty? reads better but that's just me |
| 05:44 | justin_smith | I'm a fan of not-empty |
| 05:44 | wizzo | but it makes sense knowing what empty? actually is |
| 05:44 | justin_smith | ,(not-empty "") |
| 05:44 | clojurebot | nil |
| 05:44 | justin_smith | ,(not-empty "hi") |
| 05:44 | clojurebot | "hi" |
| 05:44 | justin_smith | ,(seq "hi") |
| 05:44 | clojurebot | (\h \i) |
| 05:45 | amalloy | justin_smith: gross |
| 05:45 | amalloy | not-empty shouldn't be used as a predicate |
| 05:45 | wizzo | why |
| 05:46 | justin_smith | amalloy: not-empty + if-let = chocolate + peanut butter |
| 05:46 | amalloy | because it's just a longer way of writing seq |
| 05:46 | amalloy | justin_smith: for sure. but that's not using it as a predicate |
| 05:46 | justin_smith | it's using it as a binding and a predicate, that's what if-let is for |
| 05:47 | amalloy | that's fine. but it sounded like you were saying to use not-empty instead of (not (empty?)) |
| 05:47 | amalloy | since in the middle of that discussion you said "i'm a fan of not-empty" |
| 05:49 | justin_smith | yeah, 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:49 | justin_smith | but we have had this conversation before, and I understand that we disagree. |
| 06:03 | mbac | is there a way to take a sub-array from an array without copying? |
| 06:04 | justin_smith | mbac: subvec for vectors |
| 06:04 | mbac | i'm specifically using arrays tho : / |
| 06:04 | tomjack | you basically have to carry your endpoints around with you, I think |
| 06:05 | justin_smith | yeah, I think that's pretty much the deal |
| 06:05 | doritostains | exit |
| 06:05 | mbac | k |
| 06:23 | justin_smith | the most common street name in the US is second, second place is third, and third most common is first |
| 06:34 | AimHere | justin_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:35 | AimHere | It's only if you have enough forethought to plan two or more streets in advance that 'first' would be in the running |
| 06:35 | justin_smith | right, I just like that the first three popular names are a perfect jumble |
| 06:35 | AimHere | It's not a complete jumble. I imagine that other than 'first', the other 'numbered' streets are more or less in numerical order |
| 06:35 | justin_smith | often instead of "first" you have "name of town" or "main" |
| 06:35 | justin_smith | AimHere: the first three are though |
| 06:36 | justin_smith | http://www.usd116.org/profdev/ahtc/lessons/PlautFel09/scans/2009_07_09/StreetNamesCensus.pdf |
| 06:36 | justin_smith | fourth is fourth |
| 06:36 | AimHere | Nah, 'first' is the only one out of sequence |
| 06:36 | godd2 | The explanation that "first street gets renamed" makes most sense to me |
| 06:37 | AimHere | Why would first be renamed more often than second? |
| 06:37 | justin_smith | AimHere: there is no ordered permutation of 1,2,3 where no item has itself as its position, and no pair are in order |
| 06:37 | justin_smith | I was referring to the former property |
| 06:38 | justin_smith | I would hardly call 3,2,1 a jumble |
| 06:38 | godd2 | AimHere it gets renamed to Main st! |
| 06:38 | AimHere | godd2, wouldn't it be called main to begin with? |
| 06:38 | godd2 | That would require forsight |
| 06:38 | AimHere | Since the next few streets wouldn't be '2nd' or '3rd' but all the ones perpendicular |
| 06:38 | justin_smith | look at history: the road comes first, then the town, for a majority of towns |
| 06:39 | justin_smith | except the largest cities, there the port comes first |
| 06:39 | AimHere | The 1st, 2nd, 3rd tend to be parallel |
| 06:39 | justin_smith | then the roads |
| 06:40 | godd2 | sometimes the river comes first |
| 06:40 | AimHere | godd2, 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:40 | justin_smith | godd2: I should have generalized "port" |
| 06:40 | justin_smith | dock? |
| 06:41 | AimHere | I wonder how many towns had the airport first |
| 06:41 | godd2 | AimHere that's true, but I still like the explanation :P |
| 06:41 | justin_smith | anyway, 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:41 | justin_smith | AimHere: maybe some places like Alaska? |
| 06:42 | justin_smith | some day we may have cities where the launching pad back to earth comes first |
| 06:43 | justin_smith | AimHere: does anything in antarctica count as a city? if so, things are definitely built around the airfields there |
| 06:44 | AimHere | Largest settlement is that McMurdo sound |
| 06:44 | justin_smith | or town even |
| 06:44 | AimHere | And it's beside a body of water |
| 06:44 | justin_smith | yeah |
| 06:44 | AimHere | Also, 1200 residents, so a hefty village, if not a town |
| 06:45 | justin_smith | but nobody permanent |
| 06:45 | justin_smith | I bet 0 children |
| 06:53 | mbac | how is there really no fast Object[] getSubArray(Object[] array,int off,int len) function? |
| 06:53 | justin_smith | it could be done as a wrapper pretty easily by closing over the array |
| 06:54 | mbac | it'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:54 | mbac | yeah, i'm just kind of baffled by the java ecosystem |
| 06:55 | justin_smith | I bet 0 children |
| 06:55 | justin_smith | oops |
| 07:26 | profil | Is there a way to get an overview of threads running in the REPL? |
| 07:26 | justin_smith | (Thread/getAllStackTraces) will show you what they are doing |
| 07:28 | justin_smith | well, it returns a Map from Thread to StackTraceElement[] for all running threads, that can be used to find out what they are doing |
| 07:30 | profil | oh, alright |
| 07:31 | justin_smith | each StackTraceElement can then be queried for the method name, file name, etc. |
| 07:33 | profil | I am unsure if I am doing async tcp correctly.. |
| 07:35 | profil | justin_smith: have you got any experience with aleph? |
| 07:36 | justin_smith | no, I haven't used it actually. I've read a bunch of the code though |
| 07:39 | profil | okay, I am trying to figure out the periodically function from manifold.stream but I cant get my head around it |
| 07:39 | profil | it keeps running even though I have closed the stream |
| 07:46 | justin_smith | profil: just realized that "status of all threads" function would be really useful https://www.refheap.com/98179 |
| 07:48 | profil | nice |
| 07:48 | profil | thats a lot of stuff :D |
| 07:48 | justin_smith | yeah, especially if nrepl is running |
| 07:48 | justin_smith | notice how many of the threads are executing nrepl stuff |
| 07:50 | justin_smith | profil: well, if no-one else can help, ztellman is often here, and hopefully he at least understands what it is doing :) |
| 07:50 | profil | yeah, I have looked for him the last couple of days, but missed him :) |
| 07:53 | justin_smith | profil: reading the source, I would expect it to continue even if the stream was closed |
| 07:53 | justin_smith | https://github.com/ztellman/manifold/blob/master/src/manifold/stream.clj#L497 |
| 07:53 | justin_smith | it catches Throwable |
| 07:54 | justin_smith | so even an Error won't break out |
| 07:54 | profil | yeah, but if L506 is true it will break out? or am I wrong? |
| 07:54 | justin_smith | unless I am misreading |
| 07:55 | profil | (@cancel) means that the every function will be canceled? |
| 07:56 | justin_smith | hmm... |
| 07:56 | justin_smith | it depends on what time/every does I guess |
| 07:56 | profil | From time/every, "Returns a zero-argument function which, when invoked, cancels the repeated invocation." |
| 07:56 | justin_smith | https://github.com/ztellman/manifold/blob/master/src/manifold/time.clj#L159 every will keep calling the function |
| 07:57 | justin_smith | ahh |
| 07:57 | profil | that means that if the stream that put! tries to access is closed it will return nil, which would cancel the repeat? |
| 07:57 | profil | but my function keeps on running 3 times after the stream is closed |
| 07:57 | profil | just 3 times |
| 07:57 | profil | very weird |
| 07:58 | justin_smith | that is weird |
| 07:58 | justin_smith | I see what it's doing with cancel now |
| 07:59 | justin_smith | profil: could this be a race, where there are puts that have not been consumed? |
| 07:59 | justin_smith | (at the time of cancellation, that is) |
| 08:00 | profil | justin_smith: yeah probably, I am connecting this stream to another where map is running |
| 08:01 | profil | justin_smith: this is what my handler is doing, https://www.refheap.com/98180 |
| 08:01 | profil | justin_smith: if I remove line 11, the last "Ping timeout" will be printed 3 times |
| 08:03 | justin_smith | profil: at 5 second intervals? |
| 08:03 | profil | justin_smith: yes |
| 08:04 | justin_smith | but it looked like periodically was checking for the channel being closed |
| 08:05 | justin_smith | profil: maybe something to do with the buffering on the stream? |
| 08:05 | profil | if the stream is closed put! will return nil |
| 08:05 | justin_smith | nil, or something that derefs to nil? |
| 08:05 | justin_smith | because the code is dereffing |
| 08:06 | justin_smith | ,@nil |
| 08:06 | clojurebot | #<NullPointerException java.lang.NullPointerException> |
| 08:07 | profil | defers to nil I guess |
| 08:07 | profil | s/fer/ref/ |
| 08:07 | justin_smith | I guess that's moot beacause either way you get a cancel / close |
| 08:08 | profil | ,(let [d (future nil)] (if @d "true" "false")) |
| 08:08 | clojurebot | #<SecurityException java.lang.SecurityException: no threads please> |
| 08:09 | justin_smith | ,(let [d (delay nil)] (if @d true false)) |
| 08:09 | clojurebot | false |
| 08:14 | profil | I am not fiddling with buffering on the stream myself |
| 08:14 | profil | I have no idea why it does that |
| 08:36 | nicferrier | hey all ... still arsing around with zippers and hiccup. |
| 08:37 | nicferrier | I 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:37 | nicferrier | should 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:38 | irctc__ | 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:41 | irctc__ | I've tried (class AnotherClass) but it returns java.lang.Class instead of com.package.AnotherClass.class or something. |
| 08:43 | nicferrier | have you imported AnotherClass? |
| 08:44 | irctc__ | Yes... like (:import (com.package AnotherClass) |
| 08:44 | irctc__ | Yes... like (:import (com.package AnotherClass)) |
| 08:44 | nicferrier | can't you just (somefunc 'AnotherClass) ? |
| 08:44 | irctc__ | The exception is: java.lang.IllegalArgumentException: No matching method found |
| 08:45 | nicferrier | is it a static method? |
| 08:45 | irctc__ | No, I need an instance of the class to invoke it.... |
| 08:46 | nicferrier | so it's an instance method? |
| 08:46 | nicferrier | and you've got the instance? |
| 08:46 | irctc__ | I'm trying to wrapper this: https://github.com/EsmerilProgramming/graesh/blob/master/src/main/groovy/org/esmerilprogramming/graesh/Graesh.groovy |
| 08:47 | irctc__ | The equivalent of Line 47 not working here. |
| 08:47 | irctc__ | Hey @nicterrier, thanks a lot for your attention by the way :-) |
| 08:48 | nicferrier | so you have something like this (let [a (AeshCommandRegistryBuilder.) b (.commands a AnotherClass)] ...) |
| 08:49 | TimMc | irctc__: Does commands take varargs? |
| 08:49 | irctc__ | (defn init-aesh-command-registry-builder [] (doto (AeshCommandRegistryBuilder.) (.commands (class Cat) (class Cd)))) |
| 08:50 | nicferrier | irctc__: but you need to pass in the instance to .commands |
| 08:50 | TimMc | (.commands builder (into-array Class [Cd Ls Mkdir])) |
| 08:50 | TimMc | irctc__: (class Cat) will give you Class. |
| 08:50 | elsen | hola |
| 08:50 | irctc__ | Hum. But (doto) does that, no ? |
| 08:50 | elsen | anyone using clojure on android? |
| 08:51 | irctc__ | (doto (AeshCommandRegistryBuilder.) (.commands (class Cat) (class Cd))) |
| 08:52 | irctc__ | The Java method has this interface: public AeshCommandRegistryBuilder commands(Class<? extends Command>... commands) |
| 08:54 | martinklepsch | probably 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:57 | irctc__ | It's a combination @martinklepsch |
| 08:59 | irctc__ | Try (:require [clojure.math.combinatorics :as combo]) |
| 08:59 | TimMc | irctc__: Right, so like I said above, that's varargs. |
| 09:00 | TimMc | irctc__: Try the thing I showed you above. |
| 09:00 | irctc__ | (combo/combinations seq 2) |
| 09:00 | borkdude | I saw someone type this on twitter: |
| 09:00 | borkdude | ,(identical? 'a 'a) |
| 09:01 | clojurebot | false |
| 09:01 | borkdude | why is it false again? |
| 09:01 | irctc__ | (class Cat) gave me java.lang.Class :-( |
| 09:01 | martinklepsch | ,(prn 'a) |
| 09:01 | clojurebot | a\n |
| 09:02 | martinklepsch | ,(println 'a) |
| 09:02 | clojurebot | a\n |
| 09:02 | borkdude | symbols are not interned like string literals? |
| 09:03 | martinklepsch | dont know, was just guessing that it could be because of some gensym stuff |
| 09:03 | irctc__ | I have found this: http://tech.puredanger.com/2010/08/08/learning-clojure-class-reference/ |
| 09:03 | TimMc | irctc__: You should the above IRC messages more carefully. |
| 09:03 | irctc__ | Trying to understand. |
| 09:04 | martinklepsch | irctc__: thanks, I somehow assumed that a "combination" would include dupes as in [a b] [b a] |
| 09:04 | TimMc | ,(class "foo") |
| 09:04 | clojurebot | java.lang.String |
| 09:04 | TimMc | ,(class java.lang.String) |
| 09:04 | clojurebot | java.lang.Class |
| 09:04 | irctc__ | Do you mean (.commands builder (into-array Class [Cd Ls Mkdir])) ? |
| 09:05 | TimMc | yes |
| 09:05 | irctc__ | trying... |
| 09:06 | irctc__ | Not yet... :( more tries |
| 09:09 | irctc__ | It compiles! |
| 09:10 | irctc__ | Thanks TimMc !! |
| 09:16 | TimMc | sure thing |
| 09:16 | TimMc | Go read up on varargs, they're weird. :-P |
| 09:17 | TimMc | ,(String/format "%s %s" (to-array [5 :cats])) |
| 09:17 | clojurebot | "5 :cats" |
| 09:18 | gfredericks | TimMc "5 :cats" is an acceptable baby name I think |
| 09:19 | TimMc | I think so too, will mention it to Alex. |
| 09:19 | gfredericks | does the jvm have different endianness details from Normal Honest To Goodness C Code? |
| 09:20 | gfredericks | in particular I'm writing ints to a DataOutputStream which is going to standard out and into a Normal Honest To Goodness C Program |
| 09:21 | gfredericks | oh wait nevermind |
| 09:21 | gfredericks | the bytes are probably different but the bits within the bytes are not (is that even plausible?) |
| 09:40 | dysfun | is there any way to abort a System/exit ? i would like to ensure my function tries to exit during a test |
| 09:44 | gfredericks | dysfun: you could switch to using https://github.com/gfredericks/system-slash-exit ;-) |
| 09:47 | dysfun | gfredericks: <3 |
| 09:48 | dysfun | i was going to write something similar heh |
| 09:48 | dysfun | gosh, no tests though. i mean there's a whole line of code there actually doing something. can't be sure it'll work. |
| 09:52 | dysfun | gfredericks: you need to create a shorter name though.(require '[com.gfredericks.system-slash-exit :refer [exit]]) isn't exactly concise |