lua-users home
lua-l archive

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


On Tue, Feb 21, 2012 at 10:48 PM, Dimiter 'malkia' Stanev
<malkia@gmail.com> wrote:
>        I think Mike added support for them, if you make compile with

That _is_ interesting pairs/ipairs support:  I wonder what he thinks
of __len for tables?

Axel's code as it is does fine, although it does need __len (which is
trivial enough) since we know that ipairs is not as optimal as a
numerical for-loop.

Another variant is to implement slices, which are views of an
underlying array. They can be made read-only, or do COW if they are
altered.

As for Cynthia's question about default COW for tables, I think that
would lead to confusion in the long run. For one thing, the standard
table functions would have to be made aware of these tables.  You
would find it eventually hard to explain your programs to yourself,
let alone someone else.

It isn't too inconvenient to alias C = makeCOW and explicitly create
your tables with C{...}.

steve d.