Frank Heckenbach wrote:
... massive snippage ...
There are other functions which really return unimportant results -- e.g., some of the CString routines return a pointer passed as an argument back. This is to facilitate chaining them, but ignoring the result is perfectly safe as well. GPC now allows declaring such functions with the `ignorable' attribute, and many such functions in the RTS and included units are declared so now. So there's no problem either -- GPC will simply accept both procedure and function style use.
This can lead to unexpected and baffling errors, especially in C. My classic example is:
char * revstring(char *s) { /* whatever, to reverse string in place, and return s */ }
....
char thestring[] = "whatever";
printf(""%s" "%s"\n", thestring, revstring(thestring));
which should print out:
"revetahw" "revetahw"
contrary to expectations. The cure is to make revstring a void function, or a procedure in Pascal. Moral: discarding function results should be awkward.