lua-users home
lua-l archive

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


>From steve@inquisit.com Sat Apr  4 20:49:11 1998
>
>Lua 3.1 doesn't have fallbacks.

fallbacks were replaced by tag methods in 3.0.
if you #define LUA_COMPAT2_5, then you'll get fallbacks as in 2.5.

>How do I get fallback like behavior
>out of tags? I want to get tags to apply to *all* tables, not just ones
>I specifically add them too.

use the tag returned by tag() as in

function f(a,i)
        print("`index' tag method",a,i)
        return rawgettable(a,i)
end

settagmethod(tag({}),"index",f)

>There was an example of implementing prototype-based inheritance via
>fallbacks, anyone implemented the same thing with tags?

the code will be in the FAQ when 3.1 is released.
but the general idea is the same.
--lhf