lua-users home
lua-l archive

Re: How Lua code can be updated at runtime without breaking global state?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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

AltStyle によって変換されたページ (->オリジナル) /