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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e408bb0b4469b67c,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!16g2000cwy.googlegroups.com!not-for-mail From: msimonides@power.com.pl Newsgroups: comp.lang.ada Subject: Default comparison of tagged variant records Date: 8 Dec 2006 05:49:28 -0800 Organization: http://groups.google.com Message-ID: <1165585768.342140.201110@16g2000cwy.googlegroups.com> NNTP-Posting-Host: 62.111.211.178 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" X-Trace: posting.google.com 1165585774 27342 127.0.0.1 (8 Dec 2006 13:49:34 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 8 Dec 2006 13:49:34 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.02 (X11; Linux i686; U; en),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: 16g2000cwy.googlegroups.com; posting-host=62.111.211.178; posting-account=YHdqRw0AAAAIPYzcJprg4QGlRlBwcPu_ Xref: g2news2.google.com comp.lang.ada:7864 Date: 2006-12-08T05:49:28-08:00 List-Id: I'm having problem with default comparison of tagged, variant records not calling user-defined "=" operators for record components. At least that's, what I think. Here is an example: with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; procedure Test is type Thing is tagged record null; end record; type Bigger_Thing (Discriminant : Boolean) is new Thing with record case Discriminant is when True => Text : Unbounded_String; when False => Number : Natural; end case; end record; Big_Something : constant Bigger_Thing := Bigger_Thing'( Discriminant => True, Text => Null_Unbounded_String); Big_Something_Copy : constant Bigger_Thing := Big_Something; begin Put_Line ("Are they equal?"); Put_Line (Boolean'Image (Big_Something = Big_Something_Copy)); end Test; It prints "FALSE" and does it for both values of Discriminant, so even when Text component isn't used. However, comparison works properly when either there is no Unbounded_String, the record isn't tagged or the record doesn't have a discriminant. I have read a few threads on predefined operator reemergance on this list and have looked at relevant parts of RM (ie. on generic formal parameters, predefined operations and equality operator inheritance) but it seems that my case isn't covered there. Could you please shed some light on it? For now I have defined an equality operator for the type in question. I'm using GNAT GPL 2006. -- Marcin Simonides