Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!cmcl2!rna!cubsvax!peters From: peters@cubsvax.UUCP (Peter S. Shenkin) Newsgroups: net.lang.c Subject: Re: Address of array; really structure & [array] passing Message-ID: <456@cubsvax.UUCP> Date: Fri, 4-Apr-86 14:12:48 EST Article-I.D.: cubsvax.456 Posted: Fri Apr 4 14:12:48 1986 Date-Received: Sun, 6-Apr-86 01:17:24 EST References: <750@abic.UUCP> Reply-To: peters@cubsvax.UUCP (Peter S. Shenkin) Organization: Columbia Univ. Bio. CG Fac., NY Lines: 26 A naive question. When a structure containing many objects, some of which may be arrays, is passed, doesn't everything in it have to be copied at execution time, so that manipulations of the contents of the passed parameter within the called function don't affect the copy in the calling function? Wouldn't this also have to occur if arrays could be passed by value? If the structures/arrays are large, doesn't this incur a large overhead? That is, it seems to be a tradeoff between programming ease and syntactical elegance, on the one hand, versus time as well as space, on the other. I'm not trying to make a general argument against pass-by-value for structures [or arrays], but isn't the practice best avoided when large structures may be expected? I'm thinking not only of cases when the arrays contained within a structure are known to be large, but when space for them is dynamically allocated; then you might end up building larger objects than you had anticipated when you wrote the program. On rereading this, perhaps I'm wrong; if I declare struct { float array[MANY]; } sarray; and call result = func(sarray); are all the elements of sarray.array passed to func(), or is just the address of the array copied when the structure is passed? Enlighten me! Peter S. Shenkin Columbia Univ. Biology Dept., NY, NY 10027 {philabs,rna}!cubsvax!peters cubsvax!peters@columbia.ARPA