error: implement general state_type
handler
#938
+825
−460
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR was spun off #904 for clarity.
Because the adoption of a
linalg_state_type
was successful and flexible enough, it is proposed to extend the linear algebra error handling type by introducing a newstate_type
base class as part of thestdlib_error
module.This would provide a unified framework for managing error states across all different modules of
stdlib
, not only linear algebra but also I/O, filesystem and other modules.The
state_type
class has the same contents aslinalg_state_type
: integer error flag, fixed-size character storage for messages and error locations, and type-bound procedures for error checking and reporting. The existinglinalg_state_type
now extendsstate_type
, ensuring consistency - and interoperability.The linear algebra modules still require
type(linalg_state_type)
outputs. We could make themclass(state_type), optional, intent(out)
, so they would seamlessly handle both derived types. However, in Fortran, polymorphic arguments cannot appear inpure
procedures, so another alternative would be to template them withfypp
.cc: @jvdp1 @jalvesz @fortran-lang/stdlib