lua-users home
lua-l archive

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


> Regarding the global variable the fix is simple of course: just prefix the
> first line of the module with "local". The reason I didn't do this is that I
> don't use the "local" keyword in my shell scripts unless I actually need it

Sorry, but I can't say that I consider "not using locals" to be a good
programming practice in Lua. Regardless of the code you write.

> and then the following seems out of place:

>        local shell = require 'shell'

> Actually I've never liked the "local m = require 'm'" idiom because I almost
> never need the flexibility of using different names for the local variable
> and the module name.

Flexibility for different names is not the main reason to use this
idiom. Sandboxability of the code is.

If you don't alias your globals then you would not be able to run your
code inside a sandbox with changed environment.

That may be not very useful for the throwaway shell scripts of course,
but for the more reusable code I consider it a good style.

Alexander.