MIDRANGE dot COM Mailing List Archive

Home » MIDRANGE-L » October 2012

Re: Callback


On Thu, Oct 18, 2012 at 12:58 AM, Vernon Hamberg
<vhamberg@xxxxxxxxxxxxxxx> wrote:
There is an API that walks through IFS files and directories -


Now here's where things get murky - When you call this, you specify a
path and some inclusion criteria - and either the name of a program or
address of a procedure - and the documentation calls this an exit
program - it smells to me like what I think of as a callback - sheesh!!

Yes, this is a classic callback scenario, completely analogous to
qsort(). It would seem IBM likes to call callbacks "exit programs",
and that would be another reason why it is common for folks in the IBM
i community to not have heard the term "callback".

I think I see a callback as connected to a repetitive process, while an
exit program is a one-time thing - but THIS API doc uses the term "exit"
for the repetitive event kind of thing.

There is no repetitiveness intrinsic to the concept of callback. Any
time function A calls function B, and A passes function C to function
B, so that C can be called from B, that function C is a callback.

Now another API is readdir() - this one returns a structure for the NEXT
item it finds in the directory - so YOU have to run this in a loop until
no more objects are found. The first API itself contains the processing
loop - that first API seems to fit the idea, again, of the use of
callback functions or programs. Pretty neat!

Neat, yes. Callback? I don't see it. I think you have conflated the
repetitiveness with the callback concept. If what you are describing
is (pseudocode)

function A() {
x = readdir(mydir);
while (x is not NULL) {
x = readdir(mydir);

there is no callback there. There is just a return value that is used
within the loop, including determining whether to end the loop.
Function A isn't telling readdir() what to call. In higher-level
languages, the readdir() API would likely be presented as an iterator.
For example, if such a thing were in Python, it would be used like

def A():
for x in readdir(mydir):

The Python for-loop doesn't increment a counter, it iterates through
objects (what would be called foreach in many languages).


Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact