lua-users home
lua-l archive

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

On 9/26/06, Rici Lake <> wrote:
Breadth-first may not be what you want, either, but in any event to
implement it you need to bypass the Lua __index mechanism, since you
need an actual tree of inheritances.

However, you might want to look at this paper:

which discusses various algorithms for ordering inheritance orders.
C3 was the algorithm selected for Python, I believe.

Doing this computation dynamically is probably too time-consuming;
either the computation should be done when the class is created, or
when it is first needed.

I am planning to do memoizing, i.e. after first successful search in
the hierarchy the element found (or method or whatever) is added to
the metatable of the calling object so that next time one does not
need to traverse the entire inheritance tree again.