lua-users home
lua-l archive

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


On Tue, Apr 17, 2012 at 11:08 AM, chris <csrl@gmx.com> wrote:
> Therein is your fallacy. The creator self knowledge was never in question, it is
> the consumer of the table that may not know much about the table (assuming lack
> of contract).

But it would be a poor API that did not give some kind of guarantee.
In fact, most people do just fine with a dodgy #, once they have
realized that Arrays May Not Have Holes. The contract is that if the
API gives you an array, you can assume that they've done their due
diligence and left no holes, _or_ defined __len to enforce the
intended meaning.  (If not, it's a bad API)

> Following my recommendation that the length operator always return nil unless
> __len metamethod exists, the creator of the table who "knows" what the table is
> has the ability to define such a metamethod,

That would seriously break most existing Lua code, and as such, is
never going to happen.

steve d.