lua-users home
lua-l archive

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


On Wed, Apr 9, 2014 at 10:22 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> There is something not too dissimilar in Penlight -- maybe Steve can
> chip in here.

utils.import(tbl,dest) is a wholesale import (dest defaults to
"current environment" which is just _G; we can do better for both 5.1
and 5.2 here)

I also like 'local .... in T' because of no new keywords; perhaps some
bored capable person could update the patch for 5.2?

As for PA's hack, David Manura suggested an elegant use of
debug.getlocal which unfortunately I can't find in the archives.
Unfortunately, debug.getlocal only returns _active locals_ - if
they're just declared, they don't appear in the runtime record)
because otherwise this form is completely doable:

local _,import,printf,_ = import "pl.utils"

Could get away with this in theory:

local import,printf = slots(2)
import "pl.utils"

But this cure is arguably uglier than the disease...