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,ef86287aa487b07a X-Google-Attributes: gid103376,public From: Mats Weber Subject: Re: Pb with use of redefined "=" operator Date: 1998/11/04 Message-ID: <3640B520.D7BEEE72@elca-matrix.ch>#1/1 X-Deja-AN: 408411315 Content-Transfer-Encoding: 7bit References: <363F62F3.3FF7@club-internet.fr> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: ELCA Matrix SA Mime-Version: 1.0 Reply-To: Mats.Weber@elca-matrix.ch Newsgroups: comp.lang.ada Date: 1998-11-04T00:00:00+00:00 List-Id: Matthew Heaney wrote: > ALWAYS import equality for any non-tagged formal type. In the data > structure library I'm building, every private type is imported as > > generic > > type Item_Type is private; > > with function "=" > (L, R : Item_Type) > return Boolean is <>; > ... > package ACL.Stacks.Adapters is ... I would advise against this, because predefined equality will reemerge in other situations, such as this: type Pair is record X, Y : Item_Type; end record; "=" (Pair, Pair) will use the predefined equality on Item_Type, so that you have to write a new "=" function for Pair. This makes it very hard to check that the code is correct (i.e. every record/array declaration that contains a generic formal type must have its own redefined "="). My advice is that you must know about the reemergence problem and never instantiate a generic with a type whose predefined "=" does not work. You can often do this it using tagged types.