4 ms·
Just curious, how would you describe what most people usually mean by "callbacks"? I've always considered function arguments to functions like qsort() as callb
by rian 12y ago
Just curious, how would you describe what most people usually mean by "callbacks"?
I've always considered function arguments to functions like qsort() as callbacks, and from my interpretation of Wikipedia it seems to agree. Now I wonder if my interpretation has been overly general or if a more specific interpretation has become more commonplace.
- dllthomas 12y agoWhile my impulse was to agree with you, I think there might be a worthwhile distinction to be made here. If so, we all need to be a bit clearer on it. If qsort's comparison function is a callback, is that true of any function argument to any higher-order function? If so, why the additional term? If not, what makes a function passed as argument a "callback"?
- kragen 12y agoWhen I read "callback", I interpret it as "function argument to be invoked to deliver a notification to a user-specified place". For example, to tell you that your transaction has completed, that your network connection was broken, that your write failed, that a log message is available, etc. Typically a callback returns no useful result and takes one argument, but sometimes takes no arguments, and in systems that don't have closures (like C) it typically takes an additional argument supplied along with the function pointer.
- dllthomas 12y agoI think that's pretty reasonable.