[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: String indexing again
- From: Greg Falcon <veloso@...>
- Date: Mon, 20 Dec 2010 20:58:47 -0500
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