|
On 25/08/16 01:56 AM, Dirk Laurie wrote:
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?
Never. That is, it should never return. -- Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.