[TUHS] C declarations.
doug at cs.dartmouth.edu
Mon May 15 00:11:34 AEST 2017
> Are there languages that copy arrays in function calls defaultly?
> Pascal is an example.
Pascal's var convention, where the distinction between value
and reference is made once and for all for each argument of
each function, is sound. The flexibility of PL/I, where the
distinction is made at every call (parenthesize the name to
pass an array by value) is finicky, though utterly general.
> Where is all that [memory] going to come from if you pass a
> large array on a memory-constrained system of specs common back in the
> days when C was designed
Amusingly, under the customary linkage method in the even earlier
days when Fortran was designed, pass-by-reference entailed a big
overhead that could easily dominate pass-by-value for small arrays.
[In the beginning, when CPUs had only one register, subroutine
preambles plugged the reference into every mention of that variable
throughout the body of the subroutine. This convention persisted
in Fortran, which was designed for a machine with three index
registered. Since reference variables were sometimes necessary
(think of swap(a,b) for example) they were made standard.]
More information about the TUHS