|
Lua being a dynamic language doesn't mean that you should monkey-patch (or allow monkey-patching). Lua also is a language that allows you to prevent monkey-patching for certain modules, so it basically comes down to "Allow monkey-patching because I like monkey-patching" which by your own definition isn't a good reason.
In most cases I consider the use of standard library functions in my modules to be an implementation detail, so by caching them in locals I _enable_ you to monkey-patch to your heart's desire without fear of breaking the functions of my modules.
locals are faster than upvalues, so for tight loops it might make sense to cache the upvalues defined at the beginning of the module in locals ... :-p
If you move your modules from `./my-package` to `./lib/my-package`, you should change `package.path` and not your module references!
And your `current_folder` trick is (slightly) broken. When you run `my-package/init.lua` via `require( "my-package" )` `...` will contain "my-package", not "my-package.init"
You just use `local mod1 = require( (...)..".module1" )` to get to your submodules.