Adriaan van Os wrote:
I dislike "CString" because it obfuscates the difference between a data structure and a pointer to a datastructure -- not to mention the runtime issues involded. Same with Delphi. To me, a "CString" is a sequence of characters, followed by a char( 0). This is not the same as a pointer to those characters, allocated dynamically on the heap. Sidebar -- what happens is the dynamic allocation fails ?
Well, to be fair, `CString' (or `char *') doesn't say anything about the allocation method. It can point to any character sequence. If a C allocation fails, it returns nil (NULL). What programs do with that is left to them (as always in C). Some libc routines/versions accept NULL, others don't. GPC tries to (and treats them as empty strings), e.g. in `CString2String'.
In my perception, a well written algorithm is the reflection of clear thinking, Clear thinking is inextricably bound to clear terminology and utmost attention to detail.
I think we don't need to discuss C's deficiencies here. :-) We have `CString' mostly to interface to C code, not to write Pascal algorithms with it (though, unfortunately, in BP this has become somewhat usual practice, probably influenced by its lack of a longer than 255 char Pascal string type, and Borland's promotion of `CString', in turn probably because of their unwillingness to make a proper Pascal interface for the Windows functions ...). Anyway. Frank -- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: 51FF C1F0 1A77 C6C2 4482 4DDC 117A 9773 7F88 1707