lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> What if the lightweight syntax didn't support functions with
> upvalues? One could still reference globals, but a reference to
> a lexically bound but non-local variable would be an error in a
> lambda expression, whatever the syntax. This would mean that lambdas
> could be allocated once at load time for the bytecode rather than
> at each instantiation. The distinction from functions would be
> justified/clarified by the fact that these are created using different
> syntax.
> Are these still interesting?

I think we arrive at a very restricitve form of functions: no upvalues
and one simple expression. In particular, for functions with no
upvalues, the idea of giving them a name seems even more appealing,
because you may even have a library of useful small functions.

PS: Lua 5.2 already does that optimization of creating only one closure
instance for functions with no upvalues, despite the heavy syntax.

-- Roberto