[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Regarding the name 'pairs'
- From: TNHarris <telliamed@...>
- Date: Thu, 10 Sep 2009 16:24:12 -0400
On Wed, 9 Sep 2009 10:05:08 +0100
"John Hind" <firstname.lastname@example.org> wrote:
> I could not agree more - I think this proposal is a very bad one and I
> am dismayed it is going forward. Pairs and ipairs only makes sense for
> the generalised tables of base Lua. If you are specialising tables (or
> userdata) with metamethods, it is very unlikely these will still be
> relevant: you might want one or many iterators and "pairs" or "ipairs"
> might, but probably will not, be relevant names.
Well, I'm only concerned about the names, not the form of the
metamethods. And I concur with the reasoning for doing away with the
implicit iterator. It's better to be explicit than to have hidden magic.
I don't consider it bloat.
I just anticipate someone expecting that "pairs" can only be used when
the data is arranged as keys and values. With that confusion the
metamethods are likely to be misused or ignored when they shouldn't be.
Whatever it's called, though, I think the protocol is fine.
Also, it occurs to me, could "pairs" take extra arguments that are
passed to the metamethod? Although I can't think of a concrete example
where it would be needed, so maybe that's a misfeature after all.