[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Forward declarations in modules
- From: Mark Edgar <medgar@...>
- Date: Wed, 06 Sep 2006 20:19:52 -0700
Nick Gammon wrote:
However, for documentation reasons I wanted to put f (the exported
function) near the top of the file, and have g (the internal function)
further down.
function m_installer ()
module("m", package.seeall)
-- forward declare g
local g
function f()
print"inside f"
g()
end
function g()
print"inside g"
end
end
m_installer()
m.f()
You were very close. Remember that this syntax:
local function g() end
is equivalent to
local g = function() end
and that the local statement creates a new local.
-Mark