lua-users home
lua-l archive

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


On 18 August 2010 14:34, Matthew Wild <mwild1@gmail.com> wrote:
> As Luiz points out, using globals is not a performance "hit". Using
> locals is a performance "gain" ;)

Ugh, sorry but this is like saying "smoking is not bad for you, its
just not smoking is better for you". Weasel speak.

The use of globals in code that frequently references them will incur
a performance hit that can be mitigated by using locals.

> I believe the argument against globals is much stronger in terms of
> maintainability than performance - i.e. I'd argue the same even if
> globals and locals had the same cost to reference them.

A lot of anything is hard to manage :(

For me the big problem is that globals and locals can interact (by
forgetting to declare something as local when it already exists as a
global) and cause some nasty bugs.