[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Is this a bug in LOOP?
- From: "Renato Maia" <maia@...>
- Date: Mon, 31 Dec 2007 20:46:03 -0200
On Dec 30, 2007 2:32 PM, Aladdin Lampé <email@example.com> wrote:
> Peeking at the code, I understand why this happens, but I can't think of a simple patch, which wouldn't break the design goal of dynamicity of Renato's library.
> Does somebody have any idea how to solve this? Renato, maybe? :-)
I think you can change Lua so fields of a metatable can be supplied by
a '__index' field of its own metatable. But my "pure-Lua" solution is
to use the 'cached' class model of LOOP. In this model, class fields
are copied through out the hierarchy thus all inherited fields are
copied to each class (i.e. metatable). The dynamicity problem is
solved by the use of "class proxies" instead of the metatable itself
to represent a class. These proxies intercept any change applied to
the class and update its subclasses properly. The use of these proxies
slow down operations on classes (e.g. introspection operations), but
it shouldn't be a problem if such operations are not frequent.
PhD student at PUC-Rio