Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!ut-sally!im4u!rutgers!sunybcs!boulder!hao!umigw!steve From: steve@umigw.MIAMI.EDU (steve emmerson) Newsgroups: comp.lang.c Subject: Re: swaps with arrays Message-ID: <110@umigw.MIAMI.EDU> Date: Tue, 8-Sep-87 09:46:03 EDT Article-I.D.: umigw.110 Posted: Tue Sep 8 09:46:03 1987 Date-Received: Wed, 9-Sep-87 03:54:53 EDT References: <2376@zeus.TEK.COM> Reply-To: steve@umigw.UUCP (steve emmerson) Organization: University of Miami Lines: 41 Summary: the key concept is "generic" In article <1354@dataio.Data-IO.COM> bright@dataio.Data-IO.COM (Walter Bright) wrote: +-------- | Having a typeof would make creation of 'generic' routines possible: | #define swap(a,b) { typeof(a) tmp; tmp = a; a = b; b = tmp; } +-------- To which I responded in article "<109@umigw.MIAMI.EDU> steve@umigw.UUCP" saying: +-------- |[swap macro] also won't work with pure array objects (i.e. swapping one |array with another). A generic routine should be able to work with |*anything*. +-------- Causing Dan Tilque to wonder [bear with me ;-)] (in article <2376@zeus.TEK.COM> dant@tekla.UUCP): +-------- |Can someone tell me why every one expects (or requires) a swap macro to |work with arrays? The reason that they don't is that an array name is |a constant and not an object. ... +-------- Well, I can't speak for everyone ;-), but if I was given a generic swap routine that only worked on a subset of all possible data types ... well, I might consider it very useful, but I wouldn't consider it generic. Someone please correct me if I'm wrong, but I believe a "generic" routine is one that will work for any type of input (with a caveat for the above example that the two arguments have the same type). Now, in the original article, Walter Bright had the word "generic" in quotes. Perhaps he was thinking along these lines and ment to imply a "pseudo" or "quasi" generic routine (Walter?). It might be best to chock the whole thing up to "zealous semantic defense". If the meaning of the word "generic" gets degraded, then what word will we use? -- ----------------------------------------------------------------------------- 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