lua-users home
lua-l archive

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


Mark Hamburg escribió:

> Note that the problems iterating proxy tables are also an issue for the
> lazy-copy approach to copying tables.

Absolutely. If you need to iterate a table, lazy copy is probably not the 
answer. The main reason to use lazy copy is when you do not think that 
most members of the copy will ever be referenced; if you are planning to 
iterate, that is obviously not the case.

If, on the other hand, you are not going to iterate, then lazy copy avoids 
many issues having to do with recursion or depth of copy.

So I don't think there is a one-size-fits-all approach. If the application 
were a spell-checker and the original table were a dictionary, and the 
point of copying it were to add a few local overrides, then lazy copy 
would almost certainly be correct. A common case -- inheriting methods 
from a prototype -- is also suitable for lazy copy unless introspection is 
required.

It is probably not necessary for every object interface to support 
iteration, just like it is not necessary for every object interface which 
supports iteration to support stable iteration.

R.