lua-users home
lua-l archive

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


On Fri, Aug 15, 2014 at 11:01 AM, Jan Behrens
<jbe-lua-l@public-software-group.org> wrote:
>> Not to mention a lot of drivers know the size of the resultset before
>> they start streaming records to you anyway.
>>
>> /s/ Adam
>>
>
> And some drivers don't. It would be nice to be able to use ipairs(...)
> here as well. What's the sense of ipairs anyway, if it behaves the same
> as the arithmetic "for"?
>
> -- Jan
>

That question is the reason ipairs() was nearly removed. Parallel
construction is the only reason I can see for it -- making iteration
over a sequence visually the same as iteration over any other
well-defined collection.

Now, as for the database example, you really shouldn't want to use
ipairs() or pairs() for that ANYWAY. You should be using something
like "resultset:rows()".

/s/ Adam