lua-users home
lua-l archive

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


How hard would it be to modify the parser so that the index and
newindex metamethods could have multiple parameters?

Usage would be something like:

   foo[1, 2, 3] = 4

I suppose in the case of newindex it would make sense to pass the
value it's setting in the same position with extra parameters
trailing.  Ideally it would be earilier but for compatibility it would
have to be similar to the old method.

   function foo.__newindex(obj, idx1, value, idx2, idx3 ...)
      ...
   end

I realize it's possible to just pass a table but this has performance
problems for me compared to regular indexing.  Actually I'm not sure
what kind of performance penalty this multiple parameter indexing
might have but I wouldn't think it would be any worse than a function
call (?).

CR