Gathatoulie

And of these shall I speak to those eager, That quality of wisdom that all the wise wish And call creative qualities And good creation of the mind The all-powerful truth Truly and that more & better ways are discovered Towards perfection --Zarathustra.

Sunday, January 16, 2011

anatomy of a callback

"The 'Call back' is usually the first time everybody making the
commercial has been in the same room together, thus it's no surprise
that lines and action get changed or re-worked. So you may walk in to
see you have been rehearsing the wrong sides, or you might get asked
to read for a different part on the spot. This is all business as
usual, so be ready for it." --
http://commercialsuccessresource.blogspot.com/2009/03/anatomy-of-callback.html

D'oh - not that kind of callback!

At http://tanks4code.blogspot.com/2008/07/c-style-callbacks-in-c-code.html
there a kind of complicated object-oriented scenario is described,
indicating that a "callback" is quite similar to a "hook" but also a
bit like a "closure".

So then... from
http://stackoverflow.com/questions/615907/how-is-a-closure-different-from-a-callback:

"The bit that makes it a closure, is when that function accesses
anything on the context where it lives, like variables outside it."

And from here: http://stackoverflow.com/questions/2070275/javascript-closures-and-callbacks,

"Callbacks are a simpler concept. A callback is basically where a
function accepts another function as a parameter. At some point during
execution the called function will execute the function passed as a
parameter, this is a callback."

They further remark:

"Quite often the reason that closures get created (either
incidentally, accidentally or deliberately) is the need to create a
callback. [... some code defining a function ...] A closure is
created containing in part the 'message' parameter; 'fn' is executed
[on delay] quite some time after the call to 'AlertThisLater' has
returned, yet 'fn' still has access to the original content of
'message'."

So, that's the scoop on that: a "callback" is when a function executes
another function that is one of its arguments, and a "closure" is when
a function executes another function (whether it was initially passed
in as an argument or not) that continues to have access to the scope
of the original function.

OK, not so bad, but still it seems so much more *comprehensible* in
LISP, where one wouldn't geverally bother thinking about whether the
thing was a "closure" or not - one would just put some local variables
to a lambda, then pass that lambda as an argument to another function,
and be done with it.

0 comments:

Post a Comment

Post a Comment

Blog Archive

words cut, pasted, and otherwise munged by joe corneli otherwise known as arided.