[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Metamethods: fallbacks or overrides?
- From: Coroutines <coroutines@...>
- Date: Sun, 17 Aug 2014 19:59:33 -0700
On Sun, Aug 17, 2014 at 7:55 PM, Tim Hill <drtimhill@gmail.com> wrote:
> But notice this is all about pairs(), not ipairs(). It’s pairs() and __pairs() that provide this generic model to my mind. ipairs() is really just a convenience function, created as an obvious companion to pairs(). After thinking it through I think Roberto and co are right; ipairs() is just a convenience for iterating over the numeric range [1,#t], and nothing else, and has no business having __ipairs() at all; the low-level __len/__index can do all the necessary abstraction.
I think it's just a bit frustrating to me because I've always viewed
pairs() as iterating over the implementation order of the structure,
and ipairs() as ordered (not simply 1 to #t). In my mind they had
very defined roles -- whether I cared about a "natural order" or not.
I've never liked the names but they were better than anything I could
come up with because they were always shorter :3