Fork me on GitHub
Lone Ranger00:09:37

So Rich gave a talk on core.async and this slide was in there:

💯 6
Lone Ranger00:09:40

I'm not disputing the last bullet point but I gotta tell ya most places I work have some funny ideas about what "reasonable" is and since I've never actually seen a "reasonable" architecture, I was wondering if anyone had any more resources about what he's talking about?


Given that it's Rich, my thought would be that "reasonable program" means a program that you can understand by reasoning about it, as contrasted with a program whose output cannot be determined from its inputs unless you know what state it's currently in.

👍 3

Queues are everywhere, they just don't always come labeled that way


Often you can tell a queue is there because people start talking about 'async'

👍 3

Or 'batch processing'


Hi, quick question regarding Java interop. If I have a class like:

public final class Foo {
    private final String str;

    public Bar(String a, String b) {
        str = String.format("%s:%s", a, b);

    String Baz() {
        return str;
In Clojure, how can I get access to str OR call Baz once I've constructed an instance (`(Foo. "hi" "there")`)?


(let [foo (Foo. "hi" "there")]
   (.Baz foo))


@smith.adriane Thanks for the response. Unfortunately I'm getting the following error calling .Baz:

No matching field found: Baz for class Foo


can you modify Foo? what if you change Baz to be public?


otherwise, you might have to use something like in this gist:


(defn invoke-private-method [obj fn-name-string & args]
  (let [m (first (filter (fn [x] (.. x getName (equals fn-name-string)))
                   (.. obj getClass getDeclaredMethods)))]
    (. m (setAccessible true))
    (. m (invoke obj (into-array Object args)))))


This is exactly what I needed. Thank you for the help!


I'm trying to use aphyr's tesser library. Unfortunately its throwing an error on jdk 13 in the multiset dependency. That library is trying to implement toArray on java.util.Collection as

Collection ;----------
(toArray [this a]
  (.toArray ^Collection (or (seq this) ()) a))
and getting the error > Must hint overloaded method: toArray the javadocs are anyone see a quick way to fix this? I'm assuming i need to typehint the a but i'm not positive.


I am not certain, but this might be the same type hint requirement because of more recent JDKs adding an overloaded-by-name method call that required similar changes in Clojure itself and a few libraries. Let me see if I can find an example of a fix made for them to see if they are applicable in your situation....


awesome! thanks andy


looking at javadocs for 7, 13, 14, it seems the collection api hasn't changed in this time (not surprising). so i'm interested to read what you're talking about. i'm not familiar


I think it might be JDK 11 where the new method, or perhaps a default method implementation on a JVM interface, was introduced. Details are a bit fuzzy in my memory at the moment.


thanks for the pointers. hopefully can look around based on that


(^objects toArray [^objects this ^object a]
    (.toArray ^Collection (or (seq this) ()) ^object a))
this doesn't seem to resolve it. not sure where to go


Look for 2018-Jul-9 comment by me on this issue for core.rrb-vector, which may have relevant details:


The patch on that ticket shows uglier type hints to fix the problem there, involving Java-native-array-of-Object type


This patch for data.avl lib shows that perhaps also ^objects hint is useful


Sorry, that was same commit as I linked earlier.


Maybe try ^objects hint on second arg of toArray method, rather than ^object ?


i think that's a single element there. two overloads () and (a) where a is an element to add


oh, no i'm reading it wrong


Can a clojure filter/map be used on a transient , i get an error Don't know how to create ISeq from: clojure.lang.PersistentVector$TransientVector Is there a work around? I had a list of maps, i converted it into transient for speed, i then tried passing it into a threading macro consisting on filters and maps only for the above error to occur

Alex Miller (Clojure team)14:09:17

transients don't support the seq api

Alex Miller (Clojure team)14:09:04

the use case for transients is fast batch filling of a coll

Alex Miller (Clojure team)14:09:26

once you want to do stuff on the transient, you really should persistent! to get back to that world

Alex Miller (Clojure team)14:09:00

you will probably find transducers to be a better solution for faster performance on the use case you describe


I see, thanks for the feedback!


Cat on keyboard? 🙂


How do I bring in a function or variable from one namespace to another. Such that it is publicly available from the namespace it is not actually located in? Wanting to do this to prevent API breakage.


@grounded_sage It depends on whether you want all the metadata/arglists preserved... (def foo quux/foo) is simple, but loses metadata. There are libraries (like Potemkin) that bring in all the metadata but that's kind of overkill for just a few simple uses (and it's kind of a weird library IMO).


I do it directly in expectations/clojure-test -- it's complicated by having both cljs and clj support.


@seancorfield hmm. It is actually cross platform macros and a dynamic var which I am wishing to pull in. Perhaps it needs a bit more thinking.


@grounded_sage It's fairly common for libraries to require users that need to tinker with stuff like dyn vars to have to require a second ns to get at that sort of stuff. Also to have macros in a separate ns that users can require directly.


I would be fairly wary of a desire to import stuff from other ns's "just" to present a single-ns API... part of this suggests to me that the API isn't as cleanly separated from its implementation as perhaps it could be? Or that maybe there needs to explicitly be two or more API namespaces for different levels of usage?


Cool. I was kind of heading in the direction already but wasn’t sure if it was the right way to do it. Though it sounds like it is fairly common after all.


Is it possible when using partition-all as part of a transducer to have a partition (which is not the last partition) which has fewer than the specified n elements? I thought I ran into this issue when I was using partition-all when processing a core.async channel with async/pipeline but now I can’t seem to reproduce the issue and I can’t seem to find any documentation confirming my suspicion.


Oh, I think I found it. Looks like I can use partition-all just fine in transducers, but if I execute the transducer with pipeline then I might run into problems?:


Yes. partition-all is stateful. pipeline is parallel.

👍 3