lua-users home
lua-l archive

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

On Tuesday 03 October 2006 15:30, John Hind wrote:
> Would Roberto maybe admit that if he was redesigning Lua from
> scratch today variables would be local by default and global by
> declaration? If not, why not?

I don't really understand why anyone would want variables to be 
*anything* by default, as in automatic declarations. All it does is 
save you a few keystrokes every now and then, while opening up for 
endless fun looking for stupid, hard to find typo and name mixup 
bugs. (Assignment instead of declaration and vice versa.)

I wasn't really aware of this issue at first (haven't designed all 
that many languages before), and of course, got it wrong in EEL 
(local by default), did some scripting, realized it was just plain 
stupid, switched to explicit declarations for everything, and never 
looked back.

I'd almost go as far as saying that in general, default behavior, 
pretty much anywhere, is a Bad Thing(TM). It opens up for non-obvious 
bugs, makes the code harder to understand (especially if you have to 
deal with multiple languages), and probably a bunch of other things 
I'm forgetting right now.

Considering that we already spend too much time debugging and too 
little time actually writing new code, I don't see how saving a few 
keystrokes here and there can be a good deal, ever. (And this is 
coming from someone who dislikes verbose programming 
languages...! :-D )

//David Olofson - Programmer, Composer, Open Source Advocate

.------- - Games, SDL examples  -------.
| - 2.5D rendering engine       |
| - Music/audio engine          |
| - Real time scripting         |
'-- - Rheology instrumentation  --'