lua-users home
lua-l archive

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



On 21/06/2014 19:33, David Given wrote:
On 21/06/14 20:34, Duncan Cross wrote:
[...]
My understanding is that the blurred distinction between statement and
expression that you find in C adds a level of complexity to the parser
that (the Lua team have decided) is not justified. As a language that
is usually parsed at run-time, Lua's syntax is designed, from the
bottom up, to be parsed/compiled quickly. A strict separation between
statement and expression is a part of this.
I've tried to implement this sort of thing myself. It's a pig, with
rough edges everywhere. Consider:

a, b, c = function_returning_multiple()

vs.

function_with_arguments(a, b, c = function_returning_multiple())
If only...
func(a,b,c = ..., something) -- calls func with (...[1], ...[2], ...[3], something) func(..., select(2,...), select(3,...), something) -- the slow way Lua currently supports func((function(a,b,c,d) return b,c,d,a end)(something, ...)) -- another way to do it, faster in 5.2 but still slower than handcrafted bytecode

(Altho I am thinking about something different, and either way it's ambiguous...)

Making assignments expressions simplifies things no end.