Re:Don't use functions as callbacks unless they're designed ...
by dirkt on Sunday February 07, 2021 @03:06AM
(#26053466)
A proper typesystem for functional types will check at compile-time that in all places where you would assign such a function, the function will always have the right type.
So it's NOT a runtime error, it's a compile-time error, even though you can assign different functions at runtime.
Re:Don't use functions as callbacks unless they're designed ...
by mr_toad on Sunday February 07, 2021 @09:04PM
(#26060045)
You can assign a reference to a function and pass that to a function that expects a callback, and then change that assignment based on incoming data. And if that’s not enough you can create and modify functions at runtime. And you’d have to content with JavaScript’s spread syntax and rest parameters.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Re:Don't use functions as callbacks unless they're designed ...
by magicalhippo on Monday February 08, 2021 @07:02AM
(#26063386)
But it would only have to be a runtime error (your words) for the code which is dynamically loaded.
Static code will get checked at compile-time, even though the exact function passed as callback depends on the incoming data via a series of if/case statements say, from a dictionary or whatever.
Functions can be assigned at runtime. It would have to be a runtime error.