I have a strange behaviour with the hook mechanism which i don’t understand and id love some help.
It’s quite a simple example as i am studying the language :
foo function :
function foo () print ("i'm in foo") end
some data function :
function data () print ("This is the data : ") end
Then i do the hook set up :
debug.sethook(data , "c")
And the wired thing is when i call foo this is the output i get :
This is the data :
This is the data :
This is the data :
This is the data :
i'm in foo
This is the entire program, so no hidden stuff that could cause it.
I was wondering why is the hook being called 4 times and not just once?
In the program below, I see only 3 messages, not 4. The explanation is that the call hook is called for each call after it is set:
foo,print,tostring, which is called byprint.