|
|
|
|
|
by kazinator
3667 days ago
|
|
Users of languages that have excellent support for first-class functions and exception handling will probably not agree with you, sorry. Lower-level code often doesn't "know" how to handle a situation when it is not able to complete its job. The executive decision about how to proceed is somewhere higher up. Returning an error code that has to be propagated through several levels to the appropriate place is blub programming that belongs to the 1960's. Higher order functions are useful for error handling, but only when coupled with a dynamic control transfer. The low-level routine invokes a callback, which is some closure belonging to a higher level. For this architecture to be useful to its full potential, that closure must be able to make a jump (for example, a jump to the surrounding code in the function where that closure was created, to effectively abort all the frames between that function and the low level where the error occurred). |
|