[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Forward declarations in modules
- From: Nick Gammon <nick@...>
- Date: Thu, 7 Sep 2006 13:21:40 +1000
I seemed to have worked out the problem after even more carefully
reading the Programming in Lua book. :)
This version works:
-------
function m_installer ()
module ("m", package.seeall)
local g -- forward declare g
function f ()
print "inside f"
g () -- call g
end -- f
function g ()
print "inside g"
end -- g
end -- module m_installer
m_installer ()
m.f ()
-------
Thanks to Vyacheslav Egorov who replied along these lines while I was
researching it. :)
I was thinking along the C programming lines, that if you forward
declare something (eg. with static) then when you actually define the
function the declaration should look the same, which is why I had
local again.
- Nick Gammon