lua-users home
lua-l archive

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


On Mon, Dec 17, 2012 at 12:02 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 1. Properties are stored in a proxy table. A special value `none`,
>     unique to each table, is used for properties that have never been
>     set.

That's a useful trick.

> 4. Items stored in the table are passed through a filter. Attempting to
>     store into an item for which no filter has been defined, is an error.
>     The filter itself can also perform checks.

The 'strict structs' I was talking about some time back do that - and
in proxy mode they can additionally do a type check on assignments.

But how about the classic case where a 'property' may or may not be
backed by a method of the object?

The implementation I'm thinking of for Microlight would optionally add
property support (optional because of the extra __index hook needed)
and either map property F to _F (typically for read access) or
get/set_F (useful for non-trivial setters).  One can add a family of
properties that write to _F and additionally call some update method
(an aspect-oriented programming trick)

(The other change would be to make extend/update (aka import) work
with n-tables.)

steve d.