From mboxrd@z Thu Jan 1 00:00:00 1970 From: usotsuki@buric.co (Steve Nickolas) Date: Sun, 14 May 2017 10:58:18 -0400 (EDT) Subject: [TUHS] C declarations. In-Reply-To: <201705141411.v4EEBYjv021607@coolidge.cs.Dartmouth.EDU> References: <201705141411.v4EEBYjv021607@coolidge.cs.Dartmouth.EDU> Message-ID: On Sun, 14 May 2017, Doug McIlroy wrote: >> 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. QuickBasic uses the ( ) trick too. >> 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.] > > Doug > Three! O_O That's a lot, if you're used to the 6502 and its mere *two* index registers. -uso.