lua-users home
lua-l archive

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


On Wed, Oct 9, 2019 at 5:58 PM Ahmed Charles <acharles@outlook.com> wrote:
>
> On Oct 8, 2019, at 6:04 AM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>
> >>> Any function where you have to distinguish between nil and false in the
> >>> return value seems a very bad idea. The standard library always avoided
> >>> that, and will continue to do so.
> >>>
> >>> -- Roberto
> >>>
> >> next({[false]=true})?
> >
> > You are right. This function is in Lua since version 1.0. It probably
> > would have a different API today. (It also spoiled the generic for.)
> >
> > -- Roberto
>
> What api would you prefer for next? And how did its current api spoil generic for? Thanks.

My best guess would be the inability to iterate through and past nil.
The obvious solution is signaling the end with an exception like in
Python instead of a potentially valid and useful object like nil, but
of course proper exceptions are not so easy to implement.