lua-users home
lua-l archive

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


Hi list :-)

the Lua 5.2 will release soon, In these time I use metalua a lot, and
really miss the feature that you can embed a statement into a
expression, In Lua you can do this:

local a = (function(a, b) print "a statement" return a + b end)(10, 20) + 30

that use a anonymous function to contain a statement in expression context.

My question is:

- In Lua5.2, is this idiom has some extra overhead (e.g. allocate
memory when *every time* this line executed)?
- Is we need some promise with this idiom, or need we add a new syntax
to implement this useful features? like this:
local a = let a + b in local a, b = 10, 20 end + 30

it's just like anonymous function but needn't allocate a new function
every time.

- Has anyone else need this feature? except moonscript implement and metalua.

Thank you all :-)

regards.