|
From: Jeff A. <ja...@fa...> - 2021-01-27 19:46:43
|
Hi Nicolas,
This has been suggested as a feature ISTR but is way beyond any plan for
2.7, which is bug-fixing at best. I'm giving nearly all my time to a
possible Jython 3.
I agree it seems a natural feature to expect, that Python lambdas (or
functions in general) should match an argument that is a functional
interface (of the right shape).
Jeff Allen
On 27/01/2021 16:51, Nicolas Falliere wrote:
> Hello dev team,
>
> int foo(BiFunction<Integer, Integer, Integer> f) {
> return f.apply(1, 2);
> }
> foo((a, b) -> a + b ); // ok
>
> I was wondering if Jython 2.7 would auto-convert to idiomatic lambdas,
> and tried:
> foo(lambda a, b: a + b)
>
> alas, I got a
> TypeError: can't convert <function <lambda> at 0x3> to
> java.util.function.BiFunction
> (same problem with a single-arg lambda, e.g. foo(lambda (a, b): a + b))
>
> Any plan to support that in a future maintenance release, or maybe for
> Jython 3?
>
> Thanks,
> --
> Nicolas Falliere (ni...@pn... <mailto:ni...@pn...>)
> JEB Decompiler, Founder and Architect
> PNF Software <https://www.pnfsoftware.com/>| Follow us on Twitter
> <https://twitter.com/jebdec> | Join us on Slack
> <https://www.pnfsoftware.com/chat> | Bulletin Board
> <https://www.pnfsoftware.com/forum>
>
|