[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Static variables
- From: "Virgil Smith" <Virgil@...>
- Date: Thu, 18 Mar 2004 15:05:42 -0600
Unless I'm mistaken, upvalues in Lua 5 are NOT read only.
If I am mistaken then someone will probably quickly correct me. :-)
Also, anyone with a compiler handy can check the code easily.
This means that you can accomplish the equivalent of static variables by
doing something like the following....
local StaticA = 0 -- Declare/Initialize statics here
local StaticB = 0
StaticA = StaticA + a
StaticB = StaticB + b
Foo = MakeFoo()
[mailto:email@example.com]On Behalf Of Phil Bewig
Sent: Thursday, March 18, 2004 1:53 PM
Subject: Static variables
I'm considering lua for a specific project. One of my needs is for static
variables that retain their value from one invocation of a function to the
next. In a quick reading of the manual section on variable scoping, I saw
no mention of static variables. Does lua provide static variables? Did I
miss something while reading the manual?