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,5d0ce0dbca0a2038 X-Google-Attributes: gid103376,public From: Mats Weber Subject: Re: Q: Primitive operation of a type Date: 1997/07/02 Message-ID: <33BA43CC.E27C69CC@elca-matrix.ch>#1/1 X-Deja-AN: 254047108 References: <5oq51h$t7u@netline.jpl.nasa.gov> X-Priority: 3 (Normal) Organization: ELCA Matrix SA Reply-To: Mats.Weber@elca-matrix.ch Newsgroups: comp.lang.ada Date: 1997-07-02T00:00:00+00:00 List-Id: Matthew Heaney wrote: > This will dispatch on the tag of the O1 and O2, but only if O1 and O2 > have > the same tag, which can't be determined until run-time. If the > tag-check > fails, then an exception is raised (I forget which, either > Constraint_Error > or Program_Error). It's Constraint_Error. > procedure P (O1, O2 : T1'Class) is > begin > if O1 = O2 then > > This will dispatch on the equality operator, if the tags are the same. > If > the tags are different, then obviously the objects can't be the same, > so no > exception is raised (thankfully) and the function just returns False. I'm not so sure we should be thankful for this one. In the following situation, for instance, you may want "=" to return True even it the tags are different: type Root_Set is abstract tagged private; type AVL_Tree_Set is new Root_Set with private; type Boolean_Array_Set is new Root_Set with private; A : AVL_Tree_Set; B : Boolean_Array_Set; procedure P (X, Y : Root_Set'Class) is begin if X = Y then ... end P; P(A, B); now X => A and Y => B have different tags, but I would like "=" to return True iff A and B have the same elements, not the same elements and implementation.