lua-users home
lua-l archive

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


On Wed, Aug 24, 2016 at 9:07 PM, Daurnimator <quae@daurnimator.com> wrote:
> Neither of those styles take into account __pairs. If we want to
> spread new idioms, I suggest we pick one that will respect __pairs.

Sure, but it's still good to talk about iteration with plain lua_next :)

> That said, lua_pop is really just lua_gettop + lua_settop. To reduce
> the need for stack discipline we can just use settop instead, perhaps
> something like:
>
> for (int base_idx = (lua_pushnil(L), lua_gettop(L)); lua_next(L, idx);
> lua_settop(L, baseidx))

Eh... that's not ANSI C and I still don't like that it encourages
sloppy stack discipline.

-- 
Patrick Donnelly