`stdlib` `string_type` `parameter` array currently possible?

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 allocatable attribute for the LHS limits the assignment(=) to LHS variables with allocatable attribute
  • leaving out the allocatable attribute allows only non-allocatable or already allocated LHS variables in the assignment(=)
  • 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.

3 Likes