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: <335CAEFE.35DC@elca-matrix.ch>#1/1 X-Deja-AN: 236666161 References: <01bc4e9b$ac0e7fa0$72041dc2@lightning> 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: > It took me a while to realize that, yes, even for types (without access > objects) that have a physical length greater than the logical length, you > can make the predefined equality work. This is true even for Ada 83, so > you may be able to apply this technique to your problem. Yes, but the performance penalty is pretty big and it's hard to find the bug if you forget the padding just once. > I would like to take this opportunity - while I'm on my soapbox :-) - to > politely remind compiler vendors that they should make sure that equality > for Ada.Strings.Bounded.Bounded_String always works. Either use some > compiler magic to make sure the overridden equality operator gets called, > privately tag Bounded_String, or implement the type using the technique > I've shown above. The same holds for Ada.Strings.Unbounded, and there was some discussion on this a year ago or so here in c.l.a. Is anything being done so that an AI is issued to ensure this (if AIs still exist) ? > You the purchaser of a compiler should test to make sure Bounded_String > works. If the predefined equality is ever getting called, let your vendor > know his product is broken. Perhaps this should be an ACVC test, too > (maybe it is already). GNAT 3.09 would fail, I just chacked: there is no padding of strings shorter than the max length. Making Max_Length a discriminant of a subcomponent of Bounded_String would solve the problem, probably better (at least cleaner) than padding with nulls.