[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Type Metatables for Table and Userdata - Powerpatch
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 7 Dec 2012 09:25:20 +0200
2012/12/6 Andrew Starks <andrew.starks@trms.com>:
> I'm struggling with the problem that this is solving. What thing does it do
> that lua does not already do?
I'm hooking onto this remark, but I'm taking into account later posts that
say in effect "first take a look at what `for k,v, in next,t` can do before
demanding semantic changes in `for k,v in t do`".
A table is the only data structure in Lua. It has to do everything for
everybody. But needs differ.
The availability of both pairs and ipairs is a symptom of the fact
that one man's iterator is another man's shmiterator. There are
many other conceivable iterators for one and the same table,
e.g. all pairs _except_ those hit by ipairs, keys only, values only.
Rooting for the reinstatement of `for k,v in t do` in effect says
"the situation in which there is only one right way to traverse
a table is common enough to justify syntax sugar for it".