CRTMv3 repository for coordinated development and releases. Code history is not carried in this repository prior to v3, to reduce the cloning overhead. For v2.x history leading up to v3, see JCSDA/crtm repository.
Other
6
stars
6
forks
source link
[Feature] Operator Overloading for Assignment (=) between Existing and New/Empty Types in CRTM (Fortran) #81
Within the CRTM, there are multiple custom types (e.g., Options_Type) used for various functionalities. Currently, assigning an object of an existing type to an uninitialized or new object of the same type requires explicit member-wise assignment, which can be cumbersome and error-prone.
Feature Description:
Implement operator overloading for the assignment operator = in Fortran to allow for straightforward assignment between existing and new or uninitialized objects of custom types within CRTM. This will enhance code readability and reduce the risk of errors.
[ ] Identify all custom types within CRTM where this feature could be beneficial.
[ ] Implement the overloaded assignment operator = for these types using Fortran's interface assignment construct.
[ ] Update relevant documentation to reflect this new feature.
[ ] Write unit tests to verify the correct functionality of the overloaded assignment operator.
Expected Benefits:
Simplifies code related to object initialization and assignment.
Reduces the risk of bugs due to member-wise copying. This was noticed with Opt = Options assignment. This becomes particularly problematic when there are allocatable optional components of a given type.
Improves maintainability by reducing the amount of code needed for type assignments.
List of custom types eligible for operator assignment, I think choosing only the operators that have an existing (==) (equal check) operator should have the assignment (=) operator:
Background:
Within the CRTM, there are multiple custom types (e.g., Options_Type) used for various functionalities. Currently, assigning an object of an existing type to an uninitialized or new object of the same type requires explicit member-wise assignment, which can be cumbersome and error-prone.
Feature Description:
Implement operator overloading for the assignment operator
=
in Fortran to allow for straightforward assignment between existing and new or uninitialized objects of custom types within CRTM. This will enhance code readability and reduce the risk of errors.Example:
! Current way of doing assignment
! ... and so on
! Proposed way
Tasks:
[ ] Identify all custom types within CRTM where this feature could be beneficial.
[ ] Implement the overloaded assignment operator = for these types using Fortran's interface assignment construct.
[ ] Update relevant documentation to reflect this new feature.
[ ] Write unit tests to verify the correct functionality of the overloaded assignment operator.
Expected Benefits:
Simplifies code related to object initialization and assignment.
Reduces the risk of bugs due to member-wise copying. This was noticed with Opt = Options assignment. This becomes particularly problematic when there are allocatable optional components of a given type.
Improves maintainability by reducing the amount of code needed for type assignments.