lua-users home
lua-l archive

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


> I would prefer to write large table literals than to populate tables
> by individual assignment, since I don't want to pay the costs for growth.

One thing that I wish I had a nice solution for is that the bytecode for
table literals actually does not care that the table is a new table: it
only requires a table at the correct register. So, in principle, you could
"merge" a table literal into an existing table very efficiently, if only we
could say it in the program. (If you're generating bytecode, then like I said
you don't need to do anything special.)

One possible syntax would be
	t<<{ ... }
but that requires a new token.

Other possibilities that do not require a new token are
	t#{ ... }
	t:{ ... }

One not so nice point is that this would be a *statement*, not an expression.
Also, this needs to be a syntactical construct, not a run-time metamethod.

Oh well, I don't think there's a nice solution, which is a pity because
no change would be needed in the VM.
--lhf