Jump to content

dbQuery - why not use local function?


Bonus

Recommended Posts

Probably because callback functions aren't called instantly, rather it waits for result, and after your function finishes that code, everything that was declared local inside of that function will be erased from memory automatically, thus making your local callback function non-existant and so you'll never recieve result from dbQuery

Link to comment

Sry, but I'm absolutely sure that's not the case.
The garbage collector in Lua isn't that stupid.
Also a local table would get erased, too, because it get's passed by reference like a function.
But we can use tables to pass optional parameters in dbQuery, that's why your idea is impossible.

Link to comment
  • Moderators

It should be indeed not a problem. But keep in mind that once the function with a callback has been executed, it leaves the lua environment. If MTA doesn't tell lua to keep that function then the garbage collector loves to clean it. If you want to know this for sure, you can manually collect it and see if an error appears.

It is probably old information if you ask me.

 

 

 

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...