[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: need help: some features of Lua don't fit well together
- From: Dirk Laurie <dirk.laurie@...>
- Date: Tue, 14 Apr 2015 19:10:17 +0200
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