Re: __len vs __index
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: __len vs __index
- From: Dirk Laurie <dirk.laurie@...>
- Date: 2016年8月25日 06:56:04 +0200
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?