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.
>

My take on lightweight function syntax is this:

Will lightweight function syntax save, in total over all my
programs, more code characters than its implementation
in Lua core would require?  Will the time saved in reading
my programs compensate for the extra paragraph in the
Lua user's manual?

My profile is this:

1. I'm only ever going to use it for anonymous functions.
2. Any function that I use more than once in all the Lua
    programs I ever write, should have a name, the same
    name, every time I use it.
3. So I'm only ever going to use lightweight function
    syntax for one-off anonymous functions.

I think there is a place for lambda-style syntax.

I don't think that place is Lua.

Dirk