lua-users home
lua-l archive

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

> Is there any chance that the table entry used to store the number of
> ie. n, can be renamed to something less likely to cause a name clash with
> code?
> eg. _n or __n__

Why not go all the way?

n_entry = {}  -- new tables are never ==, right?

l = {1,2,3,nil,5}
l[n_entry] = 5


l = {1,2,3,nil,5; [n_entry]=5}

BTW, I think I figured out why there's resistance to adding the "fori"
syntax.  Base Lua has no concept of lists/vectors at all; everything that
treats tables this way is in liblualib.a, not liblua.a.

This still leaves Lua without syntax for ordered table iteration, and IMO
makes things that are simple and pretty in other scripting languages ugly
and annoying in Lua.

If there was a way to set a tag method for iteration, I would be happy with
that, or perhaps a for syntax that allowed a user-specified iterator
function in some non-ugly way.  (for i,v in t in numeric_order, where
numeric_order is a global function that gives me 1,2,3,4..getn behavior.)