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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC 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: Mats Weber Subject: Re: Equality operator overloading in ADA 83 Date: 1997/04/22 Message-ID: <335D2B6F.2AA9@elca-matrix.ch>#1/1 X-Deja-AN: 236773784 References: <01bc4e9b$ac0e7fa0$72041dc2@lightning> <335CAEFE.35DC@elca-matrix.ch> Organization: ELCA Matrix SA Reply-To: Mats.Weber@elca-matrix.ch Newsgroups: comp.lang.ada Date: 1997-04-22T00:00:00+00:00 List-Id: > - Ada.Strings.Bounded.Generic_Bounded_Length.Bounded_String: Two > reasonable implementations are: (1) Nul-out the unused > characters, and use bit-wise equality, and (2) use a tagged type > with a user-defined equality. Either way, equality will compose. > This is, admittedly, a slight implementation burden, because it > rules out an untagged record with user-defined equality. I think there is a third possibility that solves the "=" problem (predefined equality works just fine so that it does not need redeclaration): subtype Index is Natural range 0 .. Max_Length; type Bounded_String_Aux (Length : Index := 0) is record Value : String(1 .. Length); end record; type Bounded_String is record Value : Bounded_String_Aux; end record; (I don't know if two types are still necessary in Ada 95, i.e. can a full type declaration have discriminants with defaults if the visible type has none). We're lucky that all these operators have (Left, Right) as their parameter names, or we would have had another funny problem.