Fully agree with this statement.
The most important lesson I learned from this is that user-defined assignment(=) and automatic reallocation of the LHS don’t work well together:
- the
assignment(=)is a subroutine and therefore requires explicit declaration of the the LHS - adding the
allocatableattribute for the LHS limits theassignment(=)to LHS variables withallocatableattribute - leaving out the
allocatableattribute allows only non-allocatableor already allocated LHS variables in theassignment(=) - this scenario is most relevant for deferred-length characters and deferred-length parametrized derived types
I wonder what would be the required change to allow users to define an assignment(=) operator that works seamlessly together with automatic LHS reallocation.
There are a couple of other things that bring interesting complications with implementing a fundamental data type like a string in Fortran. For example the user defined derived type input and output (UDDTIO) really made a lot of trouble and is still in a half-finished state for string_type.