def create() -> socket.socket:
    return sock

def create_(func: callable)-> None:

What are the names of those two interfaces between* a socket creator and code using that socket?

Perhaps touch on situations in which one is considerably more appropriate.

* - sockets are just an example application

2 Answers 2


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.

  • Cool, you named both: continuation-passing style; returning a result directly. That's an answer.
    – Vorac
    Dec 15, 2020 at 0:02
  • In object oriented programming this is called message passing to an output port. Dec 15, 2020 at 6:59

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.

  • +1 return an object vs accept a callback is a valid answer. I am accepting the other one because it taught me the term continuation-passing.
    – Vorac
    Dec 15, 2020 at 0:05
  • This only names the structure used. Just because you have a callback function doesn't mean you have to pass it a result. Dec 15, 2020 at 7:01
  • One difference in a callback function is that they typically take two arguments, one of which is null: the result, and an error. This make them more applicable in older procedural or OO style languages.
    – user949300
    Feb 8 at 7:53
  • @user949300: It's significantly more common to have two callbacks (success and error), not a single callback where you have to nullcheck to see which parameter is not null.
    – Flater
    Feb 8 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.