Description
Additionally to the basic character manipulation in stdlib_ascii
and the stdlib_string_type
we might want to allow for a somewhat looser and less strict string handling.
The idea would be to overload common string operators like //
to allow concatenating with implicit conversion to character values.
Originally posted by @urbanjost in #336 (comment):
I find overloading helps make things much more compact, so assuming you have a function like STR, overloading // with that allows you to do things like "MESSAGE='the value is '//10//' and the limit is '//300.4//'.'". Some would probably like to overload + to do that, but I prefer to overload + - / * to convert strings to numbers, and to overload INT(), REAL(), and DBLE() to take character values and assume they are numeric. So that makes for a symmetric set for converting to and from strings and numeric values.
Originally posted by @ivan-pi in #336 (comment):
Both Java and Javascript support the idiom of using the concatenation operator to build a string using
String s = "" + i;If
operator(//)
were overload then one could do the same thing in Fortran:character(len=:), allocatable :: s s = ''//42 ! or 42//''
Similarly, one could think about overloading the assignment operator for such purposes, at the risk of running into the usual fixed length vs. deferred length character issues.