groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Sun <>
Subject About the callable native lambda
Date Tue, 30 Jan 2018 00:14:25 GMT
Hi all,

      I'm trying to implement the callable native lambda(e.g.
`Function<Integer, Integer> f = e -> e + 1; assert 3 == f(2);`), and there
are 2 ideas come to my mind:

1) Generate a proxy implementing the FunctionInterface(e.g. `Function`,
`Consumer`, etc.) and a `Callable` interface(maybe we should create a new
one), the proxy will delegate invocations of `call(Object... args)` method
of `Callable` to the method of the FunctionInterface. As you know, `f(2)` is
actually ``, so we need the method `call`.
2) Transform `f(2)` to `f.apply(2)`, we can get the target method name by
the type of FunctionInterface. To make it clear, let's have a look at two
example: `Function`'s method is `apply`, `Consumer`'s method is `accept`.

       I prefer the first way, but I want to get advice from you :-)

       In addition, have you any idea about the issue[1]? If you do not know
off the top of your head, I'll have to investigate when I have some spare
time. Any help is appreciated!



Sent from:

View raw message