[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: "static <type> <varname>;" like C in lua?
- From: Coda Highland <chighland@...>
- Date: Mon, 17 Mar 2014 21:08:52 -0700
On Mon, Mar 17, 2014 at 9:04 PM, <meino.cramer@gmx.de> wrote:
> Hi Sean,
>
> sorry for being inexact...
>
> I am in search of a way to create a variable in the scope of a
> function which is persistent i.e. does not loose it content over
> several calls of its funtion.
>
> best regards,
> mcc
You want to use an upvalue.
Something like this:
local fn
do
local staticvar = 3
fn = function() staticvar = staticvar + 1 end
end
/s/ Adam