lua-users home
lua-l archive

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


On Tue, 12 Feb 2013 20:57:54 +0100
David Olofson <david@olofson.net> wrote:

> On Tue, Feb 12, 2013 at 7:17 PM, Peter Slížik
> <peter.slizik@gmail.com>wrote:
> 
> > Okay, here's the new thread I announced a while ago...
> >
> > Lua-users wiki cites Roberto's words:
> >
> > "Local by default is wrong. Maybe global by default is also wrong,
> > [but] the solution is not local by default."
> >
> > Could anybody who understands Lua innards elaborate?
> >
> 
> FWIW, I think this is a language design problem, rather than anything
> to do with implementation internals. Can't speak for Lua
> specifically, but having designed and implemented a similar language,
> I've been over this, and my conclusion is that both ways are
> dangerous tricks to avoiding some typing. What I did is require
> explicit keywords for all declarations. That is, you cannot
> accidentally use an existing variable when you intend to declare a
> new one, or vice versa, because you're explicitly telling the
> compiler what you intend to do.
> 
> TL;DR: Implicit behavior is dangerous.

Yeah, I like that a whole lot better than global by default. With
required declaration, one way or the other, within the function, it's
impossible to accidentally do the wrong thing.

SteveT