Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site opus.UUCP Path: utzoo!watmath!clyde!floyd!harpo!seismo!hao!cires!nbires!opus!rcd From: rcd@opus.UUCP Newsgroups: net.lang.c Subject: Re: structure and array and string comparisons Message-ID: <280@opus.UUCP> Date: Sun, 1-Apr-84 00:57:09 EST Article-I.D.: opus.280 Posted: Sun Apr 1 00:57:09 1984 Date-Received: Tue, 27-Mar-84 02:58:03 EST References: <253@opus.UUCP> <365@denelcor.UUCP> Organization: NBI, Boulder Lines: 21 <> > Except for > the problem with unions, the compiler has as much information about the > structure as the programmer does--often more. Actually, this isn't true either. If you think about situations in which you want to compare structures, it is probably true a fair amount of the time that the comparisons should be done in a particular order. That is, you will want the effect of if ((a.f1==b.f1) && (a.f2==b.f2) && ...) where the compiler would not necessarily choose to compare f1 before f2. The point is that the programmer may well have more information - he may be able to decide which fields mismatch more often and arrange to compare them first. [An aside: I would conjecture that the efficiency gains from having the compiler use special comparison instructions would probably be less overall than the efficiency gains from having the programmer specify the comparisons in optimal order.] -- {hao,ucbvax,allegra}!nbires!rcd