Seems to me this'll be tricky to pull off. The GWT compiler has no
notion of captured scope. If you want to create a class type that
represents a lambda, but which doesn't actually get output as a class,
you'd have to change many many parts of the compiler.

I think perhaps the best thing you could do would be a kind of
'peephole' optimization pass. After all Java optimization passes have
run, and after JS has been generated, go through using pattern
matching to find "new generatedlambda(captured variables)" and replace
it with "makeLambda(classtype, castMap, classLiteral, function(...) {
body of single abstract method })". Then hope the JS dead code pruning
removes the unused inner class.

I think if you try to model this in the Java AST it would impact too much stuff.


On Mon, Apr 18, 2016 at 9:04 AM, 'Roberto Lublinerman' via GWT
Contributors <google-web-toolkit-contributors@googlegroups.com> wrote:
> We accept patches :)
>
> On Sun, Apr 17, 2016 at 8:40 PM, Paul Stockley <pstockl...@gmail.com> wrote:
>>
>> Given that it will be realistically a couple of years before most large
>> projects could migrate to J2CL, it would be really nice to have a more
>> optimal code generation for lambda's, especially for JsFunction. When 2.8
>> gets released, I think people will really start taking advantage of existing
>> JS libraries that really heavily use functions.
>>
>>
>> On Friday, April 15, 2016 at 12:03:12 PM UTC-4, Roberto Lublinerman wrote:
>>>
>>> It should not be hard to make JsFunction lambdas more terse, but there
>>> are no plans for GWT 2.x.
>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "GWT Contributors" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/google-web-toolkit-contributors/d75d8079-463a-4334-8c3c-75f11cc9ab20%40googlegroups.com.
>>
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "GWT Contributors" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAC7T7g%3DkH9YQjA_P02ibv-Fg4u-gRW6s4Ojm6S2KgTK0KDOYmQ%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAPVRV7csJ3vykGQ1rt%2BSTZtYL0cwjMH8zzY0zgiHszfETPg4Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to