lua-users home
lua-l archive

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


2012/8/25 Rob Hoelz <rob@hoelz.ro>:

> For interesting parties, I have started development:
>
> https://github.com/hoelzro/lua-require

You ask for a name.  What about "from"?

local from = require"from" -- we don't want to zap the standard "require"
-- module "from" returns a function that constructs and memoizes
-- module objects, so another "from" with the same name returns
-- the same object

source = from "mymodule"
-- at least the following
--    source.module = require "mymodule"
--    source.dest = _G
source: import "myfunc" -- source.dest.myfunc = source.module.myfunc
source: into(myenv) -- source.dest = myenv (returns source)

Or if you love Python:

from "mymodule": import "myfunc"
from "mymodule": into(myenv): import "myfunc"