lua-users home
lua-l archive

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


Am 12.02.2016 um 17:09 schröbte Peter Aronoff:
On Friday, February 12, 2016 at 01:52PM, Roberto Ierusalimschy wrote:
The manual says "names", not "variables".

I'm sorry to be dense, but I don't see what you mean. Is a "name" simply
a toplevel variable? Does it mean something more specific here?

name == identifier. It can be a global variable name, a field name,
a parameter name, a local variable name, etc. All names are names :-)

Ok. Unfortunately both of your responses are too cryptic for me. I don't
know if you're answering my original question. And if you are answering,
I don't know what your answer is.

My thinking is that even though my module exports a table with an
identifier, a name, __VERSION, it's ok because that identifier is
namespaced within any program that imports (requires) it. (It's a field in
a table that no Lua-Rio code touches directly.)

Thus, even though the manual appears to say this is bad, there can't be any
actual conflict in practice.

I'm sure we all agree that a general table should be able to hold any string key including ones starting with _ + uppercase letter. However, a module table is not a general table, and there already has been Lua-Rio code in Lua 5.1 that used the `_M`, `_NAME`, and `_PACKAGE` fields in module tables, so the reservation of those names probably does not apply to global variables (and the registry) only.

For personal use I'd say it doesn't matter much -- if a new Lua version gets released that starts to use `_VERSION`, you just fix your module. Chances are that you have to fix *some*thing anyway. But it's probably a bad name to make a community standard.


Am I wrong? Or were you just commenting on my imprecise use of variable
instead of name?

Thanks, Peter


Philipp