Will ES6 or post-K2 compiler or both (or anything ...
# javascript
j
Will ES6 or post-K2 compiler or both (or anything else) unlock the ability to implement functional interfaces for JS? I suspect you can't implement two, but one seems possible. Am I missing something about this limitation as to what prevents it from working in JS?
👀 1
a
It's an unrelated issue, unfortunately. The problem with the function interface is next: in the JS target, we are trying to use function expressions everywhere, so on the call site, the compiler translates it to the regular function invocation. Because JavaScript doesn't have any way to call the function as a class - we need to compile every lambda call into something like this:
Copy code
typeof lambda.invoke === "function" ? lambda.invoke(ARG_LIST) : lambda(ARG_LIST)
even if the functional interface was not used (and the
invoke
function should have a stable name). It makes the bundle size and the performance worse. But we definitely need to investigate the problem to find some solution (any proposal is welcome)