lua-users home
lua-l archive

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


On Tue, May 18, 2010 at 10:35 PM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> On Tue, May 18, 2010 at 8:12 PM, Petite Abeille
>> <petite.abeille@gmail.com> wrote:
>> > Hmmm... ipairs? deprecated? ouch.
>>
>> Wow, yeah. Pretty bold. I notice that the readme still refers to it:
>> "ipairs now goes until #t" (i.e. respecting __len metamethods) - and
>> that change (as far as I understand it) must have meant either
>> changing what ipairs returns into a closure, or else calculating #t
>> every iteration - both of which would have been a bit costlier than
>> what the old one did.
>
> Not really. It only needs to calculate #t when the value is nil.
>

Well, my thought was that it's possible you might have (something
like) a table used as a stack that just alters its "length" field
(that the __len metamethod refers to) when elements are popped,
leaving garbage values past the end. But it's probably not very likely
people would do that in practice.

-Duncan