lua-users home
lua-l archive

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


> Anyway, I think the main problem is not what is the default, but
> any default: if you want good check, you need a way to prevent implicit
> (default) declarations, no matter whether they are global or local.

Well unintended global assignments are worse because they are, well, global
and can potentially create bug anywhere in your code (where globals are
used) that even depend on the order in which execution proceeds.

I thought we went through all this to the nth degree a while back.  Robert
as I recall you ended the discussion with this (from Monday, June 4, 2001):

> That is similar to what we are thinking. A global keyword to declare global
> variables, and a mode that demand explicit declaration of all variables
> that get *assigned* (not used; otherwise we would have to declare every
> global function that we call... Or should we?). (Maybe the "global"
> declaration itself may work also as a switch for strict declaration mode.)
> 
> For modules/libraries, such global declaration at the beginning of the
> file would list all "things" created by that module.
> 
> This solution is simple to explain (both formally and informally), is
> simple to implement (we don't need to go until the end of a function to
> know whether a variable is local), is compatible with previous versions
> (apart from the new keyword), and solves the problem of avoiding nasty
> bugs. 

What is the current thinking of the Lua authors?

Russ