On 31 Oct 2018, at 21:40, Sean Conner <***@conman.org<mailto:***@conman.org>> wrote:
It was thus said that the Great Dirk Laurie once stated:
Op Wo., 31 Okt. 2018 om 16:38 het Hisham <***@hisham.hm<mailto:***@hisham.hm>> geskryf:
I'm slightly annoyed that basic Lua module examples often display
messy naming practices. Here, the module is written named as "M",
stored in a file called "mymodule" and required into a variable "vec".
I understand that this is to didactically showcase that the names are
not _required_ to be the same, but it promotes those practices (which
are sadly common among Lua programmers, probably due to top-down
examples like this) and IMO it makes the module system look even more
jerry-rigged.
I have no problem with what Lua programmers do. In fact local renaming
is to my mind good practice.
The package name is "lua-xml". The file is "LuaXml.lua". The resulting
module name is "xml". Annoying as hell.
local json = require"org.conman.parsers.json"
Nothing wrong with that.
No. But there, the package name is 'org.connman.parsers.json'. The file
is 'org/conman/parsers/json.lua'. And the resulting module is named ...
well, in this case, it would be a local variable named 'json'. There's a
logical progression one can follow.
I do have a problem with what some Lua package writers do. The actual
name to be required is something Unixly cryptic like lfs or lom. but
the package name is longer (luafilesystem) and may even have nothing
to do with the module name (luaexpat). BTW why must the package name
start with or contain the tautological "lua"?
Because otherwise someone might mistake it for JavaScript.
Thatâs why I name modules and packages the same way, yet in the repo I add a `.lua`.
Repo: https://github.com/Tieske/binaryheap.lua
luarocks install binaryheap
$ local binaryheap = require âbinaryheapâ
So far it has been very clean (unfortunately my older stuff doesnât follow this convention)
Thijs