By "available documentation", are we taking about https://www.lua.org/pil/14.2.html?
-- Robert
global X global<const> * print(math.pi) -- Ok, 'print' and 'math' are read-only X = 1 -- Ok, declared as read-write Y = 1 -- Error, Y is read-only
FWIW, I really appreciate the addition of global. While there are certainly examples of code that might cause head scratching, things seem clear and predictable when global is used as intended.
That said, the most subtle part for me was understanding that global affects what you’re allowed to access, not what is actually global. For example:
```--
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lua-l/d7df8e62-b333-482c-bedb-5fecc2ecaf44n%40googlegroups.com.
If I have this right, I really don't like it. It's tantalisingly similar to the rules for _ENV, but the interplay is far from intuitive, and that one exception sticks in my craw. Now a declaration of an unrelated name can affect the legality of a free name, and there's more context to keep track of.
> 3. The new global keyword is meant to enable the author of the script to
> avoid accidentally creating or modifying globals because he forgot the
> local keyword
I would change "is meant to enable" to "enables"
-- Roberto
Maybe I missed it somewhere in this thread or another thread, though I tried to do my due diligence and read quite a lot, including the whole manual section about global, several times.But I'm utterly confused as to the rationale behind introducing the new global keyword instead of just making good use of _ENV (or _G) to accomplish apparently all the same things.
--
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lua-l/CAGj8priS2Ou-DBs5XyTFHb51utj_CWmdde36k2BZBn8reBDbfA%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lua-l+un...@googlegroups.com.