lua-users home
lua-l archive

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


The chief argument I can see for providing an alternative to the proxy
approach is that if you have to put items in a separate table to trap
writes, then you get in the way of reads and more significantly iterations.
If I'd like to build a data structure that looks from a consumption
standpoint just like a Lua table but provides notification when changed,
that's actually a bit difficult without overriding various other functions
like pairs and next.

As for simply providing "better" support for proxies, I have to agree that
there needs to be a demonstrable need. The benefits of a userdata proxy as
opposed to a table proxy are probably mostly speed -- you avoid the effort
to look things up in the empty table though if the table really is empty
that probably doesn't cost too much. I suspect that an empty userdata and an
empty table have roughly the same space cost but I haven't pulled up the
headers to check.

If sticking with the existing proxy system, the most useful extension I
could see to Lua would be to add table.swap which would exchange the
contents of two tables so that you could convert an existing table into a
proxied table. This would not be compatible with userdata-based proxies.

As a longer term design process, it might be worth examining what one would
expect from a Lua proxy data type but I would agree that expanding the set
of basic data types is something best done with care.

Mark