3 ms·
Mark S. Miller wrote his dissertation http://www.erights.org/talks/thesis/ http://www.erights.org/talks/thesis/ in large part on expanding the "deferred callbac
by kragen 12y ago
Mark S. Miller wrote his dissertation http://www.erights.org/talks/thesis/ http://www.erights.org/talks/thesis/ in large part on expanding the "deferred callback" pattern this article recommends, including explaining how to make it applicable when it doesn't seem to be applicable. His solution is based on a sort of ultra-fundamentalist object-orientation approach, even though (as I pointed out in another thread) normal object-orientation makes these problems worse rather than better.
I don't think the "Pure Solution" mentioned in the article works. The only effect of a pure function is to compute its return value, so not only is it safe to invoke pure functions as callbacks, it's also perfectly useless — you can't tell whether it even got invoked or not. (Rian in another thread argues that qsort's comparison function is a "callback", but I don't think that's what people usually mean by "callbacks".)
- abecedarius 12y agoIndeed, Miller's thesis is titled "Robust Composition", while this post says of itself it "isn't really about callbacks... [it's] about building robust systems." (And I was reminded of the thesis early on in reading this.)
- rian 12y agoJust 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.