lua-users home
lua-l archive

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

2013/8/27 Sven Olsen <>:

> Enforcing naming discipline on locals is a mostly unrelated topic -- and
> most examples of local shadowing will happen inside nested blocks, a
> situation where they're not, actually, likely to be a source of memory
> inefficiencies.

Enforcing discipline of whatever kind is the category  of often-suggested
Lua "enhancements" that I hate most.

The only good discipline is self-discipline.

Anybody who does enough programming acquires certain habits willy-nilly,
and it's not a bad idea to acquire some good ones consciously.

For example, currently I put my entire file in one huge do-block. The
locals I declare at the top of that block feel like globals, but actually
are upvalues. In general, I declare locals only directly after 'do', 'then' and
'function', except when there is a cogent reason to transgress: then
I comment that exception.

I'm not saying you should do exactly these too, merely that they represent
a conscious attempt at forming some good habits.