lua-users home
lua-l archive

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


2015-04-14 17:37 GMT+02:00 Konstantin Osipov <kostja.osipov@gmail.com>:

> Bottom line, if we had a quick way to tell apart a Lua table from an array,
> or if multiple return object was coercible to a Lua table or array,
> there would be a scheme that worked well and could be easy to understand.

Object-oriented programming. Either array or non-array is default,
the other requires a constructor that provides a metatable with some
distinguishing feature, e.g.

NonArray = function(tbl) return setmetatable(tbl,{
   __len=function() return "non-array" end})
   end