[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Read only tables.
- From: "Imagine Programming" <contact@...>
- Date: Thu, 18 Jun 2009 00:23:46 +0200
Because I prefer this way of inserting stuff in a nummerical indexed table,
it has always worked for me.
That was not the issue in the beginning, neither was overwriting certain
lua functions. My issue was overwriting a specific table used by the script.
the users do this, they will lose all the data stored in it. I was trying to
Now, i use the advice to give them a duplicate table to play with.
From: "Sam Roberts" <firstname.lastname@example.org>
Sent: Wednesday, June 17, 2009 10:33 PM
To: "Lua list" <email@example.com>
Subject: Re: Read only tables.
On Wed, Jun 17, 2009 at 12:16 PM, Imagine
I don't use table insert, i use the next local function plus the line
Same problem, different library function. Your users can redefine
pairs() by mistake, causing your lua code to fail.
local function c(t)
for i, v in pairs(t) do
tValues[c(tValues)+1]="bla"; -- I use lua 5.0
Why are you doing this? Even in 5.0?
pairs() isn't guaranteed to iterate a table in any particular order,
you need ipairs() for that, and table.getn() returns the same
information without iterating the whole table.
And the whole thing does the same as table.insert(), which existed in 5.0.
"The order in which the indices are enumerated is not specified, even
for numeric indices. (To traverse a table in numeric order, use a
numerical for or the ipairs function.)"