[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: require, module, globals and "magic"
- From: steve donovan <steve.j.donovan@...>
- Date: Mon, 16 Aug 2010 10:45:25 +0200
On Mon, Aug 16, 2010 at 9:54 AM, Lorenzo Donati
<lorenzodonatibz@interfree.it> wrote:
> whereas I appreciate Lua minimalism, I think that an endorsed standard for
> modules could make more libraries "play nice" to each other and so help
> establish a community-driven "standard libraries collection" (IIRC there was
> a thread about this some months ago).
Ah, but Lua 5.1 did provide that mechanism! The complaint has been is
that one gets these global module tables as well.
http://lua-users.org/wiki/LuaModuleFunctionCritiqued
A person can always write modules-without-magic:
local M = {}
function M.export() .. .end
return M
but the current require() function still creates the global, as Nevin
observes. However, safe_require() is not such a difficult function to
write.
Personally, I'm not too worried with a few extra globals, _providing_
their name and creation follows the standard.
As for standard, generally useful libraries, there's always the famous
quote of Grace Hopper to the effect that the great thing about
standards is that there's so many to choose from ;)
steve d.