Re: Java 8 Lambda Interop

2017-04-11 Thread Matan Safriel
Sorry to awaken this old thread. It seems like reifying a valid lambda, for the specific clojure function which you want to pass to Java code, is indeed the most sensible way, given all the surface that java's lambda api entails. To the best of my knowledge no generic interop features or librar

Re: Java 8 Lambda Interop

2015-07-28 Thread Andrew Oberstar
My use case isn't a particularly great one at that minute. It mainly just seemed like an unfortunate extra step to interacting with Java APIs. Essentially, I was trying to leverage APIs that return a Java Stream, but wanted to interact with them with Clojure goodness, like map/reduce/transduce. I

Re: Java 8 Lambda Interop

2015-07-28 Thread Colin Fleming
> > Which seems unlikely given the conservatism of Clojure development. More than that, it would mean that Clojure required Java 8. On 28 July 2015 at 05:23, Mikera wrote: > Ah, I get what you are doing now. > > Don't think that is likely to work unless Clojure starts making IFn > instances im

Re: Java 8 Lambda Interop

2015-07-27 Thread Mikera
Ah, I get what you are doing now. Don't think that is likely to work unless Clojure starts making IFn instances implement the right java.util.function.* interfaces. Which seems unlikely given the conservatism of Clojure development. Having said that, I do think it is possible, have been playing

Re: Java 8 Lambda Interop

2015-07-27 Thread Sean Corfield
I think Mike was suggesting something like this: (-> (IntStream/range 0 100) (.filter ^Predicate odd?) (.limit 5) (.collect Collectors/toList)) and having the Clojure compiler figure out that you’re trying to cast an IFn to a functional interface and therefore "do the magic" for you. I don’t kn

Re: Java 8 Lambda Interop

2015-07-27 Thread Andrew Oberstar
Mikera, I think you're addressing a different interop concern. I'm particularly interested in something like this: (-> (IntStream/range 0 100) (.filter odd?) (.limit 5) (.collect Collectors/toList)) Where "odd?" is a normal Clojure IFn that I want to use when calling a Java API that expects somet

Re: Java 8 Lambda Interop

2015-07-27 Thread Mikera
It could certainly be achieved in the Clojure compiler, by allowing (some-functional-interface .) to compile to the appropriate function call even if it doesn't implement IFn It would be quite a big change though and would probably have some limitations, e.g.: a) It probably wouldn't work w

Re: Java 8 Lambda Interop

2015-07-27 Thread Andrew Oberstar
Thanks for the reply Gary. Sounds like I'm on as good a track as I can be with current Clojure. I am curious though why you say that it is unrealistic for IFn to support arbitrary @FunctionalInterface. It certainly seems like it would require compiler changes, but I would think that either through

Re: Java 8 Lambda Interop

2015-07-27 Thread Gary Verhaegen
On Sunday, 26 July 2015, Andrew Oberstar wrote: > Hi, > > I'm wondering if anyone has a good approach for making calls from Clojure > to Java APIs (e.g. Stream API) that expect a @FunctionalInterface type. > > Ideally, IFn would transparently work, but I'm guessing that requires some > compiler c

Java 8 Lambda Interop

2015-07-26 Thread Andrew Oberstar
Hi, I'm wondering if anyone has a good approach for making calls from Clojure to Java APIs (e.g. Stream API) that expect a @FunctionalInterface type. Ideally, IFn would transparently work, but I'm guessing that requires some compiler changes. Right now, the best I can think of is a function or m