lua-users home
lua-l archive

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




On Wednesday, July 9, 2014, Sean Conner <sean@conman.org> wrote:
It was thus said that the Great Coroutines once stated:
>
> Another thing that seemed pretty arbitrary is that __index can be a
> table.  That table can have a metatable.  But the __index of that
> table that is the first __index cannot have a metatable.  I just
> expect things like that to recurse, instead of being a
> first-level-only trigger.  The same for __newindex.

  Roberto & Co. probably did that to avoid this:

        waiting  = {}
        longtime = {}

        setmetatable(waiting  , { __index = longtime} )
        setmetatable(longtime , { __index = waiting } )

        waiting['for'] = 'Godot'
 
It's technically unavoidable but it does have a check to avoid infinite loop in __index

 

  -spc (But infinite loops are great for producing vast amounts of nothing
        real quick ... )