lua-users home
lua-l archive

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

On 31 Oct 2018, at 21:40, Sean Conner <> wrote:

It was thus said that the Great Dirk Laurie once stated:
Op Wo., 31 Okt. 2018 om 16:38 het Hisham <> 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

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`.


> luarocks install binaryheap

$ local binaryheap = require “binaryheap”

So far it has been very clean (unfortunately my older stuff doesn’t follow this convention)