lua-users home
lua-l archive

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

On Tue, Feb 19, 2013 at 4:38 AM, Gavin Kistner <> wrote:
> If, on the other hand, you are just making a joke, that is also fine. :)

PA likes making jokes, but they usually have a point ;)

One consequence of setfenv magic is that everything becomes slower,
because you now have indirect lookup for everything (that's another
criticisim of module(...,package.seeall) apart from allowing all your
laundry to be exposed).

The pattern that Tomas gives puts everything explicitly into the
master table. Generally the idea is to keep as much in locals as
possible - which is BTW the reason I'm not so keen on the _ENV 5.2

I've found myself doing things like this to split a module over
several files (useful if there's extra functionality you might want to

local foo = {}

function foo.answer() ... end
return foo

local foo = require 'foo'

function foo.more() ... end


return foo

I keep to the 'no magic' style because it discriminates equally
against 5.1 and 5.2 ;)

steve d.