lua-users home
lua-l archive

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


On Wed, Oct 31, 2018, at 15:37, Hisham wrote:

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

For what it's worth, I like the "M" part. It's even part of the internal style
guide at my company. It makes modules easier to rename for one thing.
Also works when you overload existing libraries (e.g. you define
`mycompany.json` that depends on luajson...).

The file being named "mymodule" is a bit weird outside of an example
but like Dirk said we frequently do require something called "xxx.foo"
as "foo". That's not unique to Lua either, for instance Python has the
`import xxx as yyy` syntax to do the same thing.

I also agree with Dirk that the main issue is the name of the LuaRocks
package, not the name of the file. Often with large modules the file
name will be `init.lua` anyway.

-- 
Pierre Chapuis