!ASIS Issue #094 !topic Default "=" /= Is_Equal? !reference ASIS 95-8,9,10,13,20,21,22 !from Bill Stanley 98-04-03 !keywords "=" operator Is_Equal Is_Identical abstract !discussion It appears that there is a small problem with the Asis specification. The Is_Equal function is required because the default "=" operator might not properly evaluate the test for equality (or inequality). This is fine, but it opens the door for possible programming errors. It is very easy during a moment of inattention to use the "=" operator instead of the Is_Equal function. If the default "=" operator does not always give the correct results, we then have an incorrect program. To make matters worse, there are no compiler errors generated by the improper use of the "=" operator. I ran into this issue when using a generic linked list package and instantiated a linked list of Asis.Elements from this package. The generic package uses the "=" operator to test for equality between the generic items. Since it is a relativly easy matter to implement the "=" and "/=" operators, The logical thing to do is to override the default "=" and "/=" functions. This will eliminate a possible source of errors. !resolution Accept, with Modification. !date 98-04-30 Add the following function to clause 3.5, type Context: function "=" (Left : in Context; Right : in Context) return Boolean is abstract; Add the following function to clause 3.6, type Element: function "=" (Left : in Element; Right : in Element) return Boolean is abstract; Add the following function to clause 3.10, type Compilation_Unit: function "=" (Left : in Compilation_Unit; Right : in Compilation_Unit) return Boolean is abstract; Add the following function to clause 9.1, type Container: function "=" (Left : in Container; Right : in Container) return Boolean is abstract; Add the following function to clause 20.1, type Line: function "=" (Left : in Line; Right : in Line) return Boolean is abstract; Add the following function to clause 21.1, type Id: function "=" (Left : in Id; Right : in Id) return Boolean is abstract; Add the following function to clause 22.1, type Record_Component: function "=" (Left : in Record_Component; Right : in Record_Component) return Boolean is abstract; Add the following function to clause 22.3, type Array_Component: function "=" (Left : in Array_Component; Right : in Array_Component) return Boolean is abstract; Add appropriate rationale to the new section D.4.4, Abstract "=" for private types, in Annex D: D.4.4 Abstract "=" for private types An Is_Equal function has been defined for the private types Context (Clause 3.5), Element (Clause 3.6), Compilation_Unit (Clause 3.10), Container (Clause 9.1), Line (Clause 20.1), Id (Clause 21.1), Record_Component (Clause 22.1), and Array_Component (Clause 22.3). An abstract function "=" has been defined for each private type because the semantics for the Is_Equal function for these types may differ from the semantics of the default "=" operator. This prevents improper use of the "=" operator.