3 ms·
No, I was simply responding to your statement that "Modula-2 was already available in 1978". This phrasing might give the wrong impression; Modula-2's practical
by drfuchs 4y ago
No, I was simply responding to your statement that "Modula-2 was already available in 1978". This phrasing might give the wrong impression; Modula-2's practical availability was extremely limited. No doubt it was a fine language, but it never caught on to anywhere near the extent Pascal had, before C proceeded to take over the world. If you wanted to write run-everywhere software, Modula-2 was never a tenable choice.
But we digress. The topic at hand was "How does Pascal store strings?" I stand by the pedantic statement that ISO Standard Pascal does not require string lengths to be stored with the string (nor anywhere else); there's no way for the programmer to obtain the length of a string at compile-time, never mind run-time, without resorting to some sort of compiler-specific language extension (most (all?) of which did indeed put the string length in front). Conversely, the Extended Pascal standard pretty much requires strings to instead be implemented as "fat pointers," consisting of a length and a pointer to the actual characters. I say this because substring operations return references to pieces of the original string, thus you can't stuff a length in front of the actual characters of the substring, as this would over-write characters in the original string.