lua-users home
lua-l archive

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


Based on reading the code rather than executing it...

The first issue that leaps out at me is that TrackAll generates proxy tables
for subtables which it then throws away. You probably want to copy the
contents of table to be tracked over into a new table, empty the original
table, and use the original table as the proxy. (It would be nice if there
were a way to force Lua to shrink the original table after doing so.)

A second issue in your code once you've addressed that is that you probably
want to do some of the conversion in pre-order traversal and detect already
tracked tables so that you can handled shared tables and cycles.

On a broader front, proxy tables in Lua can be at best described as sort of
working. In particular, they don't work well with iteration. It would be
nice to have some sort of table protection mechanism that forced all reads
and writes for a table through the metamethods. This could be implemented
via a "protected" flag in the metatable __mode field, but that would be
expensive to look for on every table access and hence would need caching. It
also wouldn't necessarily work cleanly with table iteration. Stepping back a
bit, one could avoid the iteration issues by focusing just on table writes.

Mark