lua-users home
lua-l archive

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


On 25 January 2015 at 16:10, SilverWingedSeraph <swingedseraph@gmail.com> wrote:
> Note: resending because I think it didn't send, last time. If it did, feel
> free to yell at me :)
>
> I'm working on a vector math library called Vectorial, I put a link to it up
> on the wiki yesterday. It currently does 2D and 3D vectors and basic vector
> operations, in normal precision. I'm going to eventually extend it with
> n-dimensionality and arbitrary precision. I'd appreciate comments! It's at
> https://github.com/SilverWingedSeraph/Vectorial

Namespacing suggestion: if you already have a suggested table name for
loading the module (`v2d` and `v3d`), use that as the module name. You
can exploit namespaces to your favor, like this:

local v2d = require "vectorial.v2d"

and store the file as vectorial/v2d.lua.

This is not a rule set in stone of course, but last time we discussed
this everyone seemed to agree it's a good idea unless you have a good
reason not to:

"always require a module into a local named after the last component
of the module’s full name" -- me in
http://hisham.hm/2014/01/02/how-to-write-lua-modules-in-a-post-module-world/

"I tend to do that, but not always." -- Pierre Chapuis in
http://blog.separateconcerns.com/2014-01-03-lua-module-policy.html
(check out his exceptions list)

"it is not required that the table variable is called the same as the
file - although it helps" -- Enrique 'Kikito' García in
http://kiki.to/blog/2014/03/31/rule-2-return-a-local-table/

-- Hisham