lua-users home
lua-l archive

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


2016-08-25 0:16 GMT+02:00 Soni L. <fakedme@gmail.com>:

> Why doesn't # respect __index? Is it because the behaviour of # is
> implementation-defined and thus it shouldn't leak through __index?
>
> Would it be a big deal for # to leak through __index?
>
> Can we have both __index-friendly # and __len override?

Consider the following code:

; a = setmetatable({1,2,3},{__index = function() return 0/0 end})
; print(#a)
3

What should an index-friendly # return instead?