From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c3a7c1845ec5caf9 X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Equality operator overloading in ADA 83 Date: 1997/04/29 Message-ID: #1/1 X-Deja-AN: 238324479 References: <01bc4e9b$ac0e7fa0$72041dc2@lightning> <335E0B1F.12C9@elca-matrix.ch> <335F5971.6375@elca-matrix.ch> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-04-29T00:00:00+00:00 List-Id: In article , dewar@merv.cs.nyu.edu (Robert Dewar) wrote: >What frequently happens is that in the body, where a private type is >visible, you don't really want the redefined equality at all, but you >get it some of the time, and you have to convert etc to get rid of it, >which of course is necessary in both Ada 83 and Ada 95 code. But if >you extend the reach of this equality operator, then it will extend >into these bodies -- and that easily cause incomaptibilities of the >worst possible kind (i.e. Ada 83 code would compile fine, but give >subtly different results). > I don't accept this argument about "incompatibilities" in Ada 83 code, because the BEHAVIOR of equality never changes, only the implementation. If a programmer overrides equality to have different behavior from predefined equality, then of course that's an error, no different than overriding addition to mean subtraction. >I must say that I here a lot of sturm und drang with respect to this issue >(equality not composing), but I must say I have never found this a >limitation in real code. Array and record equality is rare in any case, >and is even rarer in cases where component equality has been redefined. Perhaps our experience is different, as I see record comparisons ALL the time. One of the reasons one uses a type like Bounded_String is because he needs a constrained string for a record component: package String_80 is new Ada.String.Bounded.Generic_Bounded_Length (80); type R is record S : String_80; ...; end record; A programmer isn't thinking as he compares objects of type R, "Gee, I can't assume equality composes." He just compares them, and just assumes equality always works as expected. Direct array comparisons are admittedly less popular, but array comparisons DO manifest themselves when an array is used to implement a bounded data structure. I see bounded buffers all the time, to implement I/O across an external interface, for example. -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271