lua-users home
lua-l archive

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


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?
> 
>> No. It is simply wrong.
> 
> Why? It seems to me that, with lexically scoped local variables, the use
> of Globals other than for extending or customising the language or
> publishing libraries is lazy and should always be something the
> programmer has to think about and justify.
[...]

Actually, I think he was talking about local-by-default being wrong, which I
heartily agree with --- local-by-default is horrible and evil.

Global-by-default I also think is wrong, but I can live with it: it's not
actually evil. The preferred option is neither-by-default, where variables
must be explicitly declared. There are a number of hacks to allow this on Lua
with varying degrees of success that don't require any changes to the
underlying language semantics.

-- 
+- David Given --McQ-+ "Wizards get cranky, / Dark days dawn, / Riders
|  dg@cowlark.com    | smell manky, / The road goes on. / Omens are
| (dg@tao-group.com) | lowering, / Elves go West; / The Shire needs
+- www.cowlark.com --+ scouring, / You may as well quest." - John M. Ford

Attachment: signature.asc
Description: OpenPGP digital signature