3 ms·
Heap-allocated was a bad choice of words. I mean strings that allow you to do "a+b" or similar simple concatenation built in almost any other language has (not
by dagss 10y ago
Heap-allocated was a bad choice of words. I mean strings that allow you to do "a+b" or similar simple concatenation built in almost any other language has (not C though, although there null-termination and stdlib helps a lot more than Fortran character arrays does). Though I guess one could roll one own here too, same as with lists and dicts and so on.
- sampo 10y agoIn Fortran you can overload the "+" operator for string concatenation, if you like.
- 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.