mixing pointers and arrays
mark at cbosgd.UUCP
mark at cbosgd.UUCP
Mon Aug 15 06:51:21 AEST 1983
Having arrays passed by value instead of by reference would
indeed clean up the language. However, let's take a look at
some of the consequences of this move:
(1) Almost all existing programs would have to be rewritten,
since the change would not be upward compatible.
(2) If all arrays are passed by value, then character strings
must be passed by value as well (after all, they are arrays
of characters). This means
(a) programs will be slower, so that the copy can be made,
(b) programs will be bigger, for a place to copy to,
(c) subroutines that modify a character string in place
(like strcpy) will stop working.
(3) The above comments also apply to big arrays of things. In a
language such as Pascal, arrays being passed by value are one
of the worst causes of very slow programs (especially when the
author just didn't realize the array was going to be copied).
(4) The whole paradigm that arrays and pointers are interchangable
would have to be redone, no doubt losing upward compatibility.
Remember that C is not a general purpose high level applications
programming language, it's a systems implementation language. This
means it's closer to the machine, and you are supposed to be aware
of what's going on in the underlying machine. The fact that so many
people are using C for applications shows not that C is well suited
for applications, but that it's usable for applications and nothing
else is supported as well on UNIX.
Mark Horton
More information about the Comp.lang.c
mailing list