lua-users home
lua-l archive

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


On Fri, Mar 30, 2012 at 1:27 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> -- Searches a method in a list of tables. This will be the core
> -- of multiple inheritance featur-- Searches an item in a table.
> -- Returns true on success, plus the key, otherwise false.

That's not going to be very fast at all - a faster solution is to make
and keep a reverse lookup.  Iterating over tables is slow,
particularly for LuaJIT relative to the speed of hashed lookup.

And multiple inheritance .. I've never felt a need for this in Lua.
OOP people have moved away from it, and embraced the restricted form
provided by interfaces (and their C++ equivalent, pure virtual
classes).  And us duck typers do interfaces without even knowing how
to spell them...[1]

steve d.

[1] a paranoid check-errors-early kind of person might want to ask the
question 'does this object satisfy these interfaces?' but this does
not need MI machinery; they just need to rephrase the question as 'is
this set of methods a subset of the object's methods?'