Timer Class is not correctly returning a variable in the callback function

The Timer Class executes a call back function at the end of the time event. Providing as an argument “id” value.
Which is received in the handler (handlerTimer(id) as a nil value.

Is there a way to handle this?

-- Main.lus

-- Use this function to perform your initial setup
function setup()
    print("Hello World!")

    myTimer1 = Timer(1, function() handlerTimer(id) end)
    myTimer2 = Timer(2, function() handlerTimer(id) end)
    myTimer1:start(1.2)
    myTimer2:start(1.0)
end

-- This function gets called once every frame
function draw()
    myTimer1:update()
    myTimer2:update()
end

-- This handler is called at the end of a timer event
function handlerTimer(id)           --> id is a nil
    print("Timer " .. id .. " time out")
end



-- Timer.lus
Timer = class()

function Timer:init(id, callBackFun)
    -- you can accept and set parameters here
    self.id = id
    self.action = callBackFun
    self.startTime = 0
    self.timeDelay = 0
    self.enable = false
end


function Timer:start(time)
    self.startTime = ElapsedTime
    self.timeDelay = time
    self.enable = true
end


function Timer:update()
    if (self.enable == true) then
        local currentTime = ElapsedTime
        if currentTime - self.startTime >= self.timeDelay then
            self.enable = false
            if type(self.action) == "function" then
                self.action(self.id)  --> return local copy of id
            end
        end
    end
end

Replace the Timer instantiations with:

    myTimer1 = Timer(1, function(id) handlerTimer(id) end)
    myTimer2 = Timer(2, function(id) handlerTimer(id) end)

At the moment, the id in the callback functions is assumed to be a global variable because there is no local declaration of it. The argument to the callback function is discarded because there is no prototype for it. Putting the id in the declaration makes the id in the callback a local variable and it is what lua sets the argument to.

Thank you.

Placing a variable in the declaration makes the identical variable in the callback local. Where did you find this information. My references are "Programming in Lua by Roberto and google.