comp.lang.ada
 help / color / mirror / Atom feed
From: rick H <rik_nntp@dsl.pipex.com>
Subject: Re: Instantiating private types with discriminants?
Date: Tue, 09 May 2006 14:48:44 GMT
Date: 2006-05-09T14:48:44+00:00	[thread overview]
Message-ID: <gZ18g.28779$Nb2.521756@news1.nokia.com> (raw)
In-Reply-To: QD08g.28768$Nb2.521930@news1.nokia.com

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;



  parent reply	other threads:[~2006-05-09 14:48 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-09 13:17 Instantiating private types with discriminants? rick H
2006-05-09 13:45 ` Georg Bauhaus
2006-05-09 14:06   ` rick H
2006-05-09 13:56 ` Ludovic Brenta
2006-05-09 14:24   ` rick H
2006-05-09 19:48     ` Ludovic Brenta
2006-05-09 14:05 ` Dmitry A. Kazakov
2006-05-09 14:48 ` rick H [this message]
2006-05-09 15:20   ` Jerry Petrey
2006-05-09 15:42     ` rick H
2006-05-09 15:53   ` Avoiding use Ada.Tags (was Re: Instantiating private types with discriminants?) Alex R. Mosteo
2006-05-09 16:01   ` Instantiating private types with discriminants? Dmitry A. Kazakov
2006-05-10  7:42     ` rick H
2006-05-10  9:09       ` Ludovic Brenta
2006-05-10 11:49         ` Georg Bauhaus
2006-05-10 13:44         ` rick H
2006-05-10 14:21           ` Ludovic Brenta
2006-05-10 15:10             ` rick H
2006-05-10 15:45               ` Ludovic Brenta
2006-05-10 14:41           ` Dmitry A. Kazakov
2006-05-10 15:34             ` rick H
2006-05-10 19:01               ` Georg Bauhaus
2006-05-10 19:05                 ` Ludovic Brenta
2006-05-10 21:52                   ` Rick H
2006-05-11  1:17                     ` Jeffrey R. Carter
2006-05-11  7:44                     ` Dmitry A. Kazakov
2006-05-11  8:27                       ` rick H
2006-05-11 10:28                         ` Dmitry A. Kazakov
2006-05-11 15:59                           ` Robert A Duff
2006-05-12  7:37                             ` Dmitry A. Kazakov
2006-05-12  9:24                               ` Georg Bauhaus
2006-05-12 12:40                                 ` Dmitry A. Kazakov
2006-05-12 18:25                                   ` Randy Brukardt
2006-05-09 19:57   ` "Use" and "=" for Tags (was: Re: Instantiating private types with discriminants?) Jeffrey R. Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox