statics in Lua

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

statics in Lua

Luiz Henrique de Figueiredo
On second thought, here is a better solution:

 local T={x=10,y="lua"}

 function Set(x,y) %T.x=x %T.y=y end
 function Get() return %T.x,%T.y end

The idea is to save all "static" variables as fields in T.
Then, any functions can communicate via T.
And each chunk can have its own pritave tables of statics.
When the chunck ends, the variable is gone but not its value!