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,dad94612ff745427 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!opentransit.net!news.tele.dk!news.tele.dk!small.news.tele.dk!fi.sn.net!newsfeed2.fi.sn.net!newsfeed.kolumbus.fi!newsfeed1.funet.fi!newsfeeds.funet.fi!feeder1.news.jippii.net!nntp.inet.fi!inet.fi!newsfeed1.nokia.com!news1.nokia.com!not-for-mail From: rick H Subject: Re: Instantiating private types with discriminants? Newsgroups: comp.lang.ada References: Organization: home User-Agent: tin/1.8.1-20060215 ("Mealasta") (UNIX) (CYGWIN_NT-5.1/1.5.19(0.150/4/2) (i686)) Message-ID: Date: Tue, 09 May 2006 14:48:44 GMT NNTP-Posting-Host: 172.26.210.110 X-Complaints-To: newsmaster@nokia.com X-Trace: news1.nokia.com 1147186124 172.26.210.110 (Tue, 09 May 2006 17:48:44 EET DST) NNTP-Posting-Date: Tue, 09 May 2006 17:48:44 EET DST Xref: g2news2.google.com comp.lang.ada:4157 Date: 2006-05-09T14:48:44+00:00 List-Id: Thank you, Georg, Ludovic and Dmitri for your replies. Now I know I won't get shouted at for asking novice questions, I have another query for you experts, if you've got the time to have a look: I'm trying to query the tag of a record, which I can do quite nicely, provided I both "with Ada.Tags" and "use Ada.Tags". Just for the sake of it, I tried to remove the "use Ada.Tags" statement, but I can't work out how I would then specify the XXX'Tag attribute of a variable. Here's an example that illustrates my problem ("if Var_A'Tag..." is the problem line): with Ada.Integer_Text_IO; with Ada.Float_Text_IO; with Ada.Tags; -- use Ada.Tags; procedure Simple_Case is type General_T is tagged null record; type Access_T is access General_T'Class; type Type_A is new General_T with record Data : Integer; end record; type Type_B is new General_T with record Data : Float; end record; Var_A : Access_T; -- could be "new Type_A" or a "new Type_B" begin -- Var_A := new Type_A' (Data => 100); Var_A := new Type_B' (Data => 100.0); -- problem line: if Var_A'Tag = Type_A'Tag then Ada.Integer_Text_IO.Put ( Type_A (Var_A.all).Data); elsif Var_A'Tag = Type_B'Tag then Ada.Float_Text_IO.Put ( Type_B (Var_A.all).Data); end if; end Simple_Case;