You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Both Java and Javascript support the idiom of using the concatenation operator to build a string using
Strings = "" + 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.
The text was updated successfully, but these errors were encountered:
awvwgk
added
topic: utilities
containers, strings, files, OS/environment integration, unit testing, assertions, logging, ...
idea
Proposition of an idea and opening an issue to discuss it
labels
Mar 13, 2021
Additionally to the basic character manipulation in
stdlib_ascii
and thestdlib_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):
Originally posted by @ivan-pi in #336 (comment):
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.
The text was updated successfully, but these errors were encountered: