function exiter(param) -- ... end
Is simple syntactic sugar for creating a closure and assigning it to exite, which is
- either a local variable defined earlier in the same or a containing scope,
- or a global variable (aka element of the environment-table
__ENV:
exiter = function(param) -- ... end
Before you execute the assignment, that variable has its previous value, nil if not yet assigned.
Similar for local function:
local function exiter(param) -- ... end
is equivalent to first defining a local variable and then doing the same as without local:
local exiter exiter = function(param) -- ... end
That means any use of exiter before that function statement would not refer to the new local. Defining the local before the assignment is neccessary in order to allow recursive calls, this is not equivalent and does not work:
local exiter = function(param) -- ... cannot recursively call exiter here end