lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Dec 20, 2010 at 3:44 AM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> sa = StringAccessor 'hello'
> for c in sa:iter() do  -- (see [2])
...
> [2] With Lua 5.2, ipairs can be overriden as well, making string
> accessors more 'table-like'

I think this highlights an interesting point.  If the Lua core were to
change to make strings be indexable by numbers, then it wouldn't be
long before someone made this argument on the grounds of consistency:
if strings are a sort of collection, then pairs() should work on them.
 (And I think they'd be right, even if ipairs() is more appropriate
here.)

Greg F