[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why are people so afraid of globals?
- From: steve donovan <steve.j.donovan@...>
- Date: Fri, 9 Jul 2010 15:18:21 +0200
On Fri, Jul 9, 2010 at 1:49 PM, Antonio Vieiro <antonio@antonioshome.net> wrote:
> Excuse my ignorance, but C has no namespaces and there's no problem in
> building large applications on top of it, right?
Very true, but C requires everything to be declared up-front. Lua
will automatically declare an unknown variable to be global
(global-as-default), so any misspelling will cause a runtime problem
since the new variable will have the value 'nil'. (Perhaps it
wouldn't be so bad if the initial value was something like
'undefined').
It's a question of scale. A 100-line script does not have to worry
too much about locals and globals, but a 100Kloc program has to be
more careful, especially with global-as-default.
steve d.