lua-users home
lua-l archive

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


Miles Bader <miles@gnu.org> wrote:

>> It could be more concise than how it is normally done now.
>
> That particular boilerplate, though, is so minimal, that I'm not sure
> it's worth much effort to eliminate.
>
> Moreover, I think explicitly using the module name in exported function
> declarations increases program clarity, so not doing so might even be a
> considered a _bad_ thing...
>
> e.g.
>
>    local blarg = {}
>
>    function blarg.foo () ... end
>
>    function blarg.oink () ... end
>
>    return blargh
>
> Is _more clear_ than a version which leaves out the "blarg." bits.

I personally don't like the extra 'blarg's, I don't find much value to them.

With the proposed style using a import function, the only functions
in the module's code which don't have a module name in front are
either built-ins like print(), type(), etc., or they are functions which
are in the same module (which for now means the same file).  I am
not expecting that someone reading the module after I have written
it in this style ought to get confused.  Only the most primitive of
development environments will require more that a couple keystrokes
to locate the definition of that function if it is in the same file.

I really don't like all the 'local foo = require "foo"' lines that are
needed for the current style either.  I think it adds too much cruft
and helps obscure the important information, such as which modules
are being used.

James