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

Haven't you guys written a whole compiler that generates bytecode? :-)

It might be a little tricky given the slick nature of your one-pass
compiler, but it would be fabulous if the next minor version of Lua
could handle arbitrarily large table literals by spawning off
preceding statements as needed.  (This is a place where you could
actually exploit Roberto's famous insistence of having no defined
order of evaluation.)  I did something like this once when I had to
translate a language with structure literals into ANSI C, which has
only statements assigning to structures.  It is a little messy but
really just another form of backpatching.

I wish I had time to take a swing at this and send you a patch.
But maybe somebody else will!  If not, there's always next summer...


Norman