Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8616777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:42:11+00:00 2026-06-12T05:42:11+00:00

I have a strange behaviour with the hook mechanism which i don’t understand and

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:42:12+00:00Added an answer on June 12, 2026 at 5:42 am

    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 by print.

    function foo () print ("i'm in foo") end
    function data () print ("This is the data : ",debug.traceback()) end
    debug.sethook(data , "c")
    foo()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am experiencing some strange behaviour and I really don't have test date/ environments,
I have noticed some strange precision behaviour that I cannot understand, I have some
I know it's a simple question, but I have strange behaviour in here. <pre>
I'm hacking my way through learning Flex and have found some strange behaviour. When
I have come across some strange behaviour, and I'm assuming a bug in Firefox,
I'm trying to learn python and have encountered some strange behaviour. I am experimenting
I'm witnessing some strange behaviour from Fluent nHibernate. I have two objects involved in
I have noticed a strange behaviour when intercepting the preUpdate row hook in Propel
after adding adMob ads to my application, I have noticed some strange memory behaviour.
We have some strange behaviour with the deployment of our message queues and factories

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.