Should I be worried about writing to global variables like time/table?

I find using time or table to reference objects or events/account is easier to remember than clock or array/dictionary.

So if I made something like this

local function foo(table)
   local time = 0
   for i,v in pairs(table) do
   end
end

It wouldn’t have any impact on performance or garbage collection of the global variables?

Both time and table are global variables since they are Lua Globals function. I recommend you to not use these as the names of variables or anything. You can just use like Time and Table something like that.

1 Like

Variables aren’t garbage collected, only GCObjects get garbage collected. There is also no performance implications for doing this. You’ll definitely want to avoid using table as an identifier, since it is a standard library and you won’t be able to use the functions in it due to variable shadowing. time isn’t frequently used as far as I am aware, so it shouldn’t really matter.

1 Like