lua-users home
lua-l archive

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


On Tue, Jul 17, 2018 at 11:56 PM, Viacheslav Usov <via.usov@gmail.com> wrote:
That can certainly be rewritten with a scoped declaration, but the point, like in the simpler example above, is that this goes against Lua's entire written corpus and oral tradition. People still find 10-15 year old snippets of code online and argue that "your system is broken" when they do not work, and that is AFTER they are given the latest edition of PiL and pointed to the latest docs. A new obscure way to declare variables isn't likely to fare much better.

I think it's a fair argument.  Users will forget to put the proper qualifier on the variable, which will result in subtly wrong runtime behavior.  It reminds me of the async/await implementation in Python.  Apparently if you forget to qualify your async function call with the await keyword, Python will just happily do nothing (since async functions simply return a coroutine).

In my old post, I actually argue for "with .. as" over a new type of local.  That control structure seems well-proven at this point, there are so many use cases.  I don't know if there's some collective ego here about "doing something like Python", but it would be a shame to not consider it seriously.

If Roberto wants to go with a scope-qualified local, at least it's a slippery slope to laying a new control structure on top of it :)
Though it will be important that exit is called on the locals in the reverse order of declaration.