Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What would be the strict definition of "callback" ?


A function that will be called... a continuation. eg. "call me back when you are ready". or "call me when you are outside", "call me when you have arrived", "call me later".


The term "callback" is usually used to refer to a function that you want called after the completion of an async operation (like a database read, a file read, a network call, etc).

This article uses the term callback but then uses functions passed to "map" as its examples; "map" is synchronous and so this usage of the term "callback" is atypical, probably atypical to the point that we can just say it's incorrect :).


FWIW, Wikipedia's defines "callback" as "any executable code that is passed as an argument to other code; that other code is expected to call back (execute) the argument at a given time" and synchronous callbacks are mentioned explicitly [0]. I don't think Jake's usage of the word is atypical.

0 - https://en.wikipedia.org/wiki/Callback_(computer_programming...


The term "callback" is usually used to refer to a function that you want called after the completion of an async operation

I’m not aware of any authoritative definition, but the term “callback” has been used for functions passed in as parameters to higher-order functions since long before the modern idioms for asynchronous code were around. The first use of the term I can remember personally was for the comparator function passed to qsort in C. That was probably sometime in the 1980s. Another common usage that goes way back is for event handlers in event-driven systems.


Exactly, the term typically used for the specific type of callback being discussed here is a "continuation callback", and the specific style is "continuation passing style"

The term is actually used correctly; callback's definition is broad. Of course, noone can resist the temptation to berate members of the JS community.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: