[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: A Type Metatable for Tables?
- From: Miles Bader <miles@...>
- Date: Wed, 20 Feb 2008 22:54:41 +0900
"John Hind" <john.hind@zen.co.uk> writes:
> 1. Setting an instance metatable could displace the type metatable
> completely. This would be appropriate if we think of Tables with instance
> metatables as different types from generic Tables.
>
> 2. The instance metatable could be searched first, then the type metatable.
> This would be appropriate if we think of Tables with instance metatables as
> sub-types of Table.
>
> Both alternatives could be offered by having a key in the instance metatable
> specifying if the type metatable should be inherited or not.
It seems like 2 could be implemented using existing Lua mechanisms:
an instance metatable can just have its own metatable, with an __index
entry pointing to the global table metatable.
-Miles
--
Aborigines, n. Persons of little worth found cumbering the soil of a newly
discovered country. They soon cease to cumber; they fertilize.