lua-users home
lua-l archive

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


Hisham <h@hisham.hm> wrote:
> Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> >
> > > I would be more comfortable with _VERSION, with the Lua interpreter
> > > itself, as "master module", already adhering to that convention :-)
> 
> The Lua interpreter does things that modules are not supposed to do,
> such as loading a bunch of globals. It is an example of "main program"
> behavior, not "module behavior".
> 
> > +1.
> 
> But what about what the Lua reference manual says about using names of
> that sort:
> 
> "As a convention, programs should avoid creating names that start with
> an underscore followed by one or more uppercase letters (such as
> _VERSION)."
> 
> It even uses _VERSION as the example of what _not_ to do!

Thanks for asking this question, Hisham! I was too shy, but I had the
exact same thought. A few years ago, I rewrote all my modules *not* to use
_VERSION, _AUTHOR, etc.[1]

Maybe I didn’t need to rewrite them after all?

Best, P

[1] What I do now is export functions version(), author(), etc. It works
    out pretty much the same.

    https://github.com/telemachus/split/blob/master/src/split.lua#L129-L143

-- 
We have not been faced with the need to satisfy someone else's
requirements, and for this freedom we are grateful.
    Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System