Re: Auto converting Python lambdas to functional interface impl.

Nicolas Falliere <[email protected]> Wed, 27 Jan 2021 14:46:41 -0800
Newsgroups gmane.comp.lang.jython.devel
Message-ID <CAJP=iOUjNJ=MohG2vBSZVwmCaaFpxTixKy8PTRrx0_iJ08tbYA@mail.gmail.com>
Thanks for the info Jeff.

Best regards,
--
Nicolas Falliere ([email protected])
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>


On Wed, Jan 27, 2021 at 11:46 AM Jeff Allen <[email protected]> wrote:

> 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 ([email protected])
> 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>
>
>

_______________________________________________
Jython-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-dev