lua-users home
lua-l archive

Re: local by default?

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


--- Russ Webb <Russell.Webb@corp.palm.com> wrote:
> Personally, I like declaring all locals since it prevents typos from
> creating side-effects,
How so?
function foo()
 local bat -- oops, typo
 bar = 10
 return bar
end
function foo()
 local bar
 bat = 10 -- oops, typo
 return bar
end
In either case you've just created a new global, or worse, you've just changed the value of an
existing global. Right?
__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

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