Hi, I want to ask about local functions. Is there any penalty to calling a function which defines a local function inside it? Does it get "redefined" every call or is there something clever in the compiler?
t
tseisel
11/14/2019, 7:22 AM
AFAIK on the JVM, local functions are compiled just like lambdas expressions : it is compiled as a class implementing
Function
. If that function captures variables from its closure, then an instance of the class is created at call site ; otherwise the same instance is reused.