News for hackers. Stuff that matters.
Re:Don't use functions as callbacks unless they're designed ... by username90 on Saturday February 06, 2021 @07:24AM (#26046083)
Yeah, I see the point, in for example C# if you have overloaded methods it tries it best to map it to the accepted type. However you'd have to work really hard to invent a case where a library updates a signature to accept another type, and then you in your code have 2 overloads of a method that you pass and it now choses the wrong version, all while the library change doesn't break any other code.

Scenario: Library changes signature so you always pass functions with more parameters.

Result: This will break almost every codebase, they probably wouldn't do this in a minor patch.

Scenario: Library adds a new signature where you can pass functions with more parameters and keep them overloaded between each other.

Result: Compiler can't identify which of the two signatures to pass your overloaded function and throws a compilation error.

There are no comments on this comment yet.