Murga-Projects Forums
possible callback inconsistency? - Printable Version

+- Murga-Projects Forums (http://www.murga-projects.com/forum)
+-- Forum: Project Forums (/forumdisplay.php?fid=1)
+--- Forum: MurgaLua - General (/forumdisplay.php?fid=2)
+--- Thread: possible callback inconsistency? (/showthread.php?tid=20)


possible callback inconsistency? - mikshaw - 05-17-2007 09:13 AM

I'm not sure if I'm just misunderstanding the logic in using callbacks, if there's something I'm overlooking, or if there is an inconsistency.

Let's assume you have the following pseudo function:

Code:
function funk(a,b,c)
do a command
maybe do something else
end

Now assume a button named "button", which is used to call funk. If you don't use any parameters, you can set it up like this:

Code:
button:callback(funk)

If you need to use funk's parameters, you apparently must create a second function to use as the callback, like this for example:

Code:
button:callback(
function(button) funk("hay","bee","sea") end
)

If this seemingly redundant function is not created, the callback is done immediately when the application runs. This occurs if the callback is create like this:

Code:
button:callback(funk("hay","bee","sea"))

It doesn't seem logical or consistent to have to change the way a callback is defined just because you want to pass a parameter to the function. It also seems unnecessary to create a function in order to call a function.
Am I missing something? Maybe I've been defining callbacks incorrectly?


RE: possible callback inconsistency? - dvw86 - 05-19-2007 03:34 PM

I've noticed the same thing. I don't believe that "pure" Lua acts that way though.