lua-users home
lua-l archive

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


Am 12.12.2012 18:27, schrieb Rena:
On 2012-12-12 8:27 AM, "Philipp Janda" <siffiejoe@gmx.net> wrote:

Am 12.12.2012 11:55, schrieb Dirk Laurie:

[...]

Anyway, the point of Thijs's question is not so much about global
versus local.  It is about conventions for certain names.  For example,
if I start up some script that preloads some stuff, and I see a Lua
prompt, would it not be nice if there is a good chance that typing
`help()`
or `=help` does something helpful, and even better if we could agree
which?  I don't really care whether names like `lfs` and `lpeg` have
been declared local or global by the time I get in. But I would strongly
object if `lpeg` is defined but actually means "linear programming
example
generator".


I wouldn't if "lpeg" was an established acronym or name in the program's
domain and the LPeg library wasn't used in the same program. I'm pretty
confident that I can recognize LPeg code when I see it, so no harm is done.

What if you later want to use LPeg in this program?


If "lpeg" was an established name in the program's domain and the LPeg library was or was going to be used in the same program, I would object to any use of the variable name "lpeg" no matter for which of the two purposes. Btw., I prefer 'local L = require( "lpeg" )' -- it's shorter and typically a lot of LPeg function calls end up in the same expression ... (And one-letter-acronyms are less likely to be reserved exclusively by some library or domain.)

Philipp