This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-05
Channels
- # announcements (3)
- # babashka (64)
- # bangalore-clj (1)
- # beginners (12)
- # calva (21)
- # cider (7)
- # clj-kondo (16)
- # cljdoc (1)
- # clojure (49)
- # clojure-dev (2)
- # clojure-europe (10)
- # clojure-germany (3)
- # clojure-italy (1)
- # clojure-uk (13)
- # clojuredesign-podcast (6)
- # clojurescript (2)
- # code-reviews (21)
- # data-science (2)
- # datomic (3)
- # emacs (20)
- # events (1)
- # fulcro (2)
- # graphql (4)
- # java (3)
- # malli (14)
- # off-topic (45)
- # re-frame (2)
- # shadow-cljs (7)
- # tools-deps (167)
- # vrac (14)
- # xtdb (4)
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.
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: https://gist.github.com/sunng87/13700d3356d5514d35ad
(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)))))
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 https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/util/Collection.html#toArray(java.lang.Object%5B%5D). 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....
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
Maybe this change a while back in the data.avl library? https://github.com/clojure/data.avl/commit/03f32144951ab7b50b8a74ea5e8c22629e7fbde0
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.
(^objects toArray [^objects this ^object a]
(.toArray ^Collection (or (seq this) ()) ^object a))
this doesn't seem to resolve it. not sure where to goLook for 2018-Jul-9 comment by me on this issue for core.rrb-vector, which may have relevant details: https://clojure.atlassian.net/browse/CRRBV-18
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
https://github.com/clojure/data.avl/commit/03f32144951ab7b50b8a74ea5e8c22629e7fbde0
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
awesome! thanks @U0CMVHBL2
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
transients don't support the seq api
the use case for transients is fast batch filling of a coll
once you want to do stuff on the transient, you really should persistent! to get back to that world
you will probably find transducers to be a better solution for faster performance on the use case you describe
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
https://github.com/clojure-expectations/clojure-test/blob/develop/src/expectations/clojure/test.cljc#L527 -- 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?: https://clojure.atlassian.net/browse/ASYNC-164