willett wrote:
Just to add confirmation to what Frank and Gale have said. In the following "foo" example, yes, the string length is undefined. Yes it is supposed to be an error, and is defined as an error in ISO and Extended Pascal standards. No, it's probably not desirable to start automatically initializing everything; it would be costly in time and space and generally an error-free program will do it's own initialization when needed. And sure, GPC does not detect undefined values, in fact, very very few "compilers" (actually runtimes) do detect undefined values. (Our "Dr. Pascal" interpreter is one of the few systems that does, and it costs a lot of runtime overhead and complexity.) It's very reasonable for GPC to not try to do this.
Please don't toppost.
I look on the string facility as similar to the file facility in some respects. For files, some sort of automatic initialization is needed so that reset/rewrite can function, and so that the error of reading/writing to unopened files can be detected. For strings the 'capacity' has to be initialized, and I doubt it would be much trouble to zero the length field at the same time. Note that this is much different from initializing the entire string storage.