Since Clojure now mandates Java8 as there been prior discussion around making functions implement the java.util.Function
methods to make interop with Java APIs that make heavy use of it a bit more seamless?
If not, is it a discussion worth having 🙂
have been thinking about various approaches @pyr
there is some discussion in this room if you can find the archives
one approach is to make IFn implement some of those things in j.u.f (which ones? why?)
another approach is to enhance host interop calls to be smarter and auto-add interfaces
auto-add interfaces, you mean based on function arities?
do we want to have nice interop with all functional interfaces, including ones that don't live in java.util.function?
ThreadLocal.withInitial(() -> new Whatever()); // creates a Supplier
Thread.currentThread().setUncaughtExceptionHandler((thread, throwable) -> doSomething()); // a Thread$UncaughtExceptionHandler
Java creates lambdas contextually
and they don't have to be in java.util.function -- any interface with one abstract method will do
ok
"It's complicated"
indeed
right now, you can go pretty far with macros to make it nicer
thanks
feel free to vote for https://ask.clojure.org/index.php/767/integration-with-java-util-function-interfaces?show=767#q767
although it is already on the list for 1.11 consideration
there’s also https://github.com/ajoberstar/ike.cljj