Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!hao!umigw!steve From: steve@umigw.MIAMI.EDU (steve emmerson) Newsgroups: comp.lang.c Subject: Re: swaps with arrays Message-ID: <111@umigw.MIAMI.EDU> Date: Wed, 9-Sep-87 09:51:52 EDT Article-I.D.: umigw.111 Posted: Wed Sep 9 09:51:52 1987 Date-Received: Fri, 11-Sep-87 01:19:12 EDT References: <2376@zeus.TEK.COM> <110@umigw.MIAMI.EDU> <1955@sol.ARPA> Reply-To: steve@umigw.UUCP (steve emmerson) Organization: University of Miami Lines: 30 In article <1955@sol.ARPA> quiroz@ROCHESTER.UUCP (Cesar Quiroz) writes: +-------- |what would you like | swap(1, 2); |to mean? +-------- I think I'm begining to see what you mean: in C, an array is not *completely* equivalent to a pointer to its first element because its value may not be altered. It is therefore meaningless (i.e. semantic nonsense) to even *consider* using arrays as arguments to a generic swap routine since they're constants. One should pass to a swap routine only "swappable" objects. Is this correct? Although I can see the validity of this argument (and I hope I've restated it correctly) I would argue that the swapping of arrays does have valid meaning -- namely an element-by-element exchange of values. This causes each array to become the other and, to me at least, is a straightforward consequence of swap semantics. As such, this functionality should be included in any generic swap routine. It appears we may differ in our judgement of swap semantics. What says the rest of the net? -- Steve Emmerson DDN: emmerson@miami.miami.edu SPAN: miami::emmerson (host 3.2) emmerson%miami.span@star.stanford.edu UUCP: ...!hao!umigw!miami!emmerson emmerson%miami.span@vlsi.jpl.nasa.gov