lua-users home
lua-l archive

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


I feel very confortable with the syntax << t[] = 'newvalue' >>. PHP does it and it is extremely easy - at least for me.

Other thing I really would love to do, is Lua keep the items in the right order.

I mean:

// ---
lua_newtable(L);

lua_pushstring(L, "key1");
lua_pushstring(L, "val1");
lua_rawset(L, -3);

lua_pushstring(L, "key2");
lua_pushstring(L, "val2");
lua_rawset(L, -3);

lua_pushstring(L, "keyn");
lua_pushstring(L, "valn");
lua_rawset(L, -3);

// --- Could be a for loop to :)

And an iteration in that table won't always give you in the order they were pushed: key1 = "val1", key2 = "val2", key3 = "val3", ...

Probably, it has been discussed earlier, but I couldn't find any mail about it. (maybe if I do a more 'hard' search later... )

ps: I know I could make an integer-indexed table and use others tables as values to store any data I need to be available in the 'creation order'.

--rb