2 ms·
> I mean strings that allow you to do "a+b" or similar simple concatenation Meet "//", the character concatenation operator. Part of Fortran at least since the
by jabl 10y ago
> I mean strings that allow you to do "a+b" or similar simple concatenation
Meet "//", the character concatenation operator. Part of Fortran at least since the FORTRAN 77 standard.
With the F2003 additions I mentioned, one can do stuff like
program stringtest
implicit none
character(:), allocatable :: s
s = "hello"
s = s // " world"
print *, s
end program stringtest
where the first executable statement (s = "hello") allocates space for "hello" on the heap, and the second statement reallocates that heap space to now have room for the previous contents + " world".
And since Fortran allocatables are a bit like C++ RAII, they are automatically deallocated when they go out of scope.
Is this as convenient as doing string handling in, say, python? IMHO, no, but better than plain C + stdlib.