[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: How to use module()
- From: "Dolan, Ryanne Thomas (UMR-Student)" <rtdmr6@...>
- Date: Sun, 15 Jan 2006 14:56:48 -0600
It took me a while to figure this out also, but to create a module I do this:
module "mod";
method = function ()
end;
Then in another script:
require "mod";
mod.method ();
>From what I understand, after a call to module the current environment gets replaced with a new table. This table is what is returned by require. To keep the old environment visible after a call to module, you use the seeall function:
module ("mod", module.seeall);
method = function ()
print ("hello world"); --print would otherwise not be in this environment!
end;
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br on behalf of Jeff Sheets
Sent: Sun 1/15/2006 1:25 PM
To: lua@bazar2.conectiva.com.br
Subject: How to use module()
Though I see in the manual what the module function does, I'm wondering
how one uses it properly.
I am assuming it is intended to be used at the beginning of a module lua
file, which is intended to be required into another lua file. Am I
correct?
Also, when are the functions given as extra parameters to module()
executed, and what environment do they have before execution?
<<winmail.dat>>