lua-users home
lua-l archive

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

Is this way to protect a global table a problem? garbage collector/waste
of memory... if function dummy is called very often?

a) it must be a global table
b) it must be filled with new data inside of a function
c) after the function the original data must be available

   data = {day='Sunday'}
   print(  --> Sunday

   function dummy()
      data,memorize = {day='Monday'},data
      print(  --> Monday

   print(  --> Sunday

I don't like to use this stupid way:

   function dummy()
      local memorizeday ='Monday'
      print( --> Monday

And also I don't like to copy the whole table in a for end loop.

Another way? Thanks for your help. Lua is wonderfull!