[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How Lua code can be updated at runtime without breaking global state?
- From: Dirk Laurie <dirk.laurie@...>
- Date: Tue, 26 Mar 2013 06:58:35 +0200
2013/3/26 Vadim Peretokin <vperetokin@gmail.com>:
> You can do value = value or default as a pattern to prevent that
> problem.
>
> Otherwise, the only real problem are upvalues, as those can't be
> updated (or easily?).
do
local x=10
function diff(y) return y-x end;
function sum(y) x=20; return y+x end
end
print(diff(100)) --> 90
print(sum(100)) --> 120
print(diff(100)) --> 80