[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Cons of 5.1 Style Modules (Was: Is "scripting" truly Lua's future?)
- From: Veli-Pekka Tätilä <vtatila@...>
- Date: Sat, 13 Sep 2008 01:51:40 +0300
David Given <dg@cowlark.com> wrote:
<heavy snippage>
- the module structure is a pain when writing single applications ---
because once you've done module(), the standard library is no longer
available. You have to import everything with 'local print = print'
statements. And if you forget one you get no warnings or error messages
until it crashes at run time, either. Again, #include would have helped
with this. Eventually I gave up on modules.
Errm, maybe I'm missing something here, but couldn't you just say:
module( ..., package.seeall )
The way I've understood it this will:
* name and create your global module table (aka. class) after the physical
file basename
* make sure that "global" assignments incl. function definitions go in your
module table
* fetch stuff from _G if it is not found in your module, when looking for
"globals"
The only disadvantage I've found is that I can no longer use the colon
syntax. I would say:
function class:setX(x)
But now, it becomes:
function setX(self, x)
The self does feel quite cozy as a Perler, but would be even neater to omit
that in the param list. The new module syntax makes the old syntactic sugar
less sweet. But that's just cosmetic quibbling, <grin>.
Hth.
--
With kind regards Veli-Pekka Tätilä
Accessibility, Apps and Coding plus Synths and Music:
http://vtatila.kapsi.fi