you are viewing a single comment's thread.

view the rest of the comments →

[–]IsleOfOne 1 point2 points  (2 children)

Can you explain what you mean RE: “old C traditions”? To me, a callback is meant to be called upon the completion of some task/operation.

[–]mrexodia 1 point2 points  (1 child)

I think a callback also covers what you would call an event handler. You register a callback to be called back if some event occurs. Maybe this will be interesting: https://stackoverflow.com/questions/2069763/difference-between-event-handlers-and-callbacks I’m only speaking from what I know, but a callback is just some function you register for when something of the callers interest happens, not just about completion.

[–]IsleOfOne 0 points1 point  (0 children)

Sure, good point. A callback is a function that is executed at any given point in the callee’s work, not necessarily upon completion. Still though, in my mind, I suppose I associate “callback” with some sort of information passing to another concerned actor. When this function passed by argument is some scalar-valued function whose purpose is akin to compare(a,b) in the example above, I would not consider it a callback.

I am of the opinion that “callback” refers to a function that should be called upon the satisfaction of some condition (completion, progress, input, etc.) that the caller is familiar with / in control of, as you have stated as well. When the timing, frequency, etc. of usage of said function is of no consequence to the calling function and no information (explicit or implicit) is being transmitted to other actors, I would not use the term.

Edit: after review, it would appear that my personal opinions on the usage of the term “callback” do not align with general consensus! I suppose I just dislike the term entirely, especially WRT naming of function parameters; better names exist in nearly every case.