[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: as so often before require()
- From: "Wim Couwenberg" <w.couwenberg@...>
- Date: Tue, 25 Feb 2003 10:48:45 +0100
Hi,
> Wim:
> > Instead of directly returning a table, a "LTN11" package returns a
> > _function_, that installs the package in a given public table (as its
> > first argument.)
>
> I'm still not sure here why you return a function and not just a module
> table? Eg:
> Complex = import("complex.lua")
The import function _does_ return the package table, but a package itself
(i.e. the package script) returns an install function. This way the import
function can pass arguments into the loaded package script. (This also came
up more recently as a general trick to pass arguments into a "loadfile" or
"loadstring" chunk.) The arguments that import provides to a package are:
1) the public table to use (the former package stub.)
2) the name of the package.
3) the full path where the package was located.
Bye,
Wim