Article View: comp.std.c
Article #363Re: struct comparison
From: Niels J|rgen Kruse
Date: Sat, 15 Jul 1989 15:10
Date: Sat, 15 Jul 1989 15:10
28 lines
1576 bytes
1576 bytes
henry@utzoo.uucp (Henry Spencer) writes:
>In article <2874@solo3.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes:
>>Why does the PROGRAMMER have to go through all that trouble?
>>I just want to say:
>> puts(mork == mindy ? "equal" : "unequal");
>>Is the ANSI committee trying to tell us the compiler cannot transform the
>>equality test into the correct member-by-member comparison code?
>Yes. Think about unions. Or pointers (do you compare the pointers or
>what they point at?). The compiler just doesn't have enough information.
Just like the compiler doesn't have enough information to
initialize a union, right? !
A simple rule like comparing first members of unions and the
pointers themselves would work nicely in a lot of cases and
match the way initialization works.
Or comparison of structs with inconvenient members could just
be outlawed, which wouldn't reduce the usefullness much.
Or perhaps better, inconvenient members could just be ignored,
leaving them for the programmer to handle separately.
--
Niels J|rgen Kruse
Email njk@diku.dk
Mail Tustrupvej 7, 2 tv, 2720 Vanlose, Denmark
Technical Details
Message-ID:
<4644@freja.diku.dk>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!apple!sun-barr!cs.utexas.edu!uunet!mcvax!kth!sunic!dkuug!freja!njkReferences:
<2874@solo3.cs.vu.nl> <1989Jul14.155312.2063@utzoo.uucp>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!apple!sun-barr!cs.utexas.edu!uunet!mcvax!kth!sunic!dkuug!freja!njk From: njk@freja.diku.dk (Niels J|rgen Kruse) Newsgroups: comp.std.c Subject: Re: struct comparison Message-ID: <4644@freja.diku.dk> Date: 15 Jul 89 15:10:30 GMT References: <2874@solo3.cs.vu.nl> <1989Jul14.155312.2063@utzoo.uucp> Organization: DIKU, U of Copenhagen, DK Lines: 28