[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: local pre-declarations
- From: Asko Kauppi <asko.kauppi@...>
- Date: Wed, 1 Sep 2004 03:17:06 +0300
Is there a simple "better way" to this?
When I have local functions that rely on each other, and the one used
cannot be defined before the usage place (it's used at runtime, anyhow)
I do this:
local func2
local function func1()
...
func2()
...
end
...
--local
function func2()
...
This is the "right" way to do it, right?
I don't like it too much, since 'func2' mustn't have "local" before it.
If it does (which happens easily) the value within 'func1' will be
'nil', and things fall apart. Of course, this is not noted until
runtime, so bugs easily lurk in.
Also, the latter definition of 'func2' looks too much of a global.
Good ideas, anyone?
-ak