Does acceptinga a handler instead of returning a result have a name?
https://softwareengineering.stackexchange.com/questions/419992
-
19-03-2021 - |
Question
def create() -> sock.sock:
...
return sock
def create_(func: callable)-> None:
...
func(sock)
return
What are the names of those two interfaces between* a socket creator and code using that socket?
Perhaps touch on situations in which one considerably more appropriate.
* - sockets are just an example application
Solution
With respect to functional programming, I think the term you may be looking for is continuation-passing style. This is contrasted with returning a result directly like in your first example.
OTHER TIPS
In your code example, func
is commonly called a callback function.
As far as I'm aware, there's no real name for the method itself, other than describing it as using a callback function. Continuation methods fill the same functional requirement but their implementation is conceptually different.