[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Concept of static variables in Lua (like C)
- From: TNHarris <telliamed@...>
- Date: Sat, 7 Jul 2012 15:18:31 -0400
On Saturday, July 07, 2012 03:12:35 PM meino.cramer@gmx.de wrote:
> Hi,
>
> is there a concept of static local variable in function
> as it exist in C?
>
Lexical scoping and upvalues provide it.
in C:
int increment(){
static int N = 0;
N = N + 1;
return N;
}
in Lua:
local N = 0
function increment()
N = N + 1
return N
end
--
tom <telliamed@whoopdedo.org>