lua-users home
lua-l archive

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

On Wed, Oct 19, 2011 at 9:41 AM, Geoff Leyland
<> wrote:
> That looks like it's on the right track.

I note that the definition of module() does not actually do anything
except set _NAME, so that you can create modules this way without
actually calling it.

-- fred.lua
--module 'fred'  -- ha, don't really need to call this!

function answer()
    return 42

function go ()
    show 'hello'

function show (s)

It gets away with the ugly package.seeall, but has much the same
behaviour - and sandboxers still need to be aware that globals can be
accessed through the module table.

local fred = require 'fred'
print( -- !!

Although the no-magic style still works, it automatically becomes
burdened by all the indirection, unless you're careful to give local
aliases up front.

steve d.