comp.lang.ada
 help / color / mirror / Atom feed
From: "RasikaSrinivasan@gmail.com" <RasikaSrinivasan@gmail.com>
Subject: package Ada.Tags
Date: Thu, 7 Jun 2012 13:36:32 -0700 (PDT)
Date: 2012-06-07T13:36:32-07:00	[thread overview]
Message-ID: <0067e29b-aceb-4c50-9d62-453c4f549f2e@googlegroups.com> (raw)

Friends

I have two types declared as follows:

with Ada.Calendar ;

package events is
    type events_record_type is abstract tagged 
      record
         time : ada.Calendar.time ;
      end record ;
   procedure show(event : events_record_type) ;
   
   type basal_delivery_event_type is new events_record_Type with
      record
         amount : float ;
      end record ;
   overriding
   procedure show( event : basal_delivery_event_type ) ;
   
   type bolus_delivery_event_type is new events_record_Type with
      record
         amount : float ;
      end record ;
   overriding
   procedure show( event : bolus_delivery_event_type ) ;
   
   type SMBG_event_type is new events_record_type with
      record
         amount : short_integer ;
      end record ;
   overriding
   procedure show( event : SMBG_event_type ) ;
   
end events ;

The following implementation in the body:



   procedure show (event : events_record_type) is
      use GNAT.Calendar.Time_IO;  
   begin      
      put( ada.Tags.Expanded_Name( event'tag ) );      
      put( gnat.Calendar.time_io.Image( event.time , gnat.Calendar.Time_IO.ISO_Date & " %T")) ;      
   end show;

gives me a compilation error:

"tag" attribute can only be applied to objects of class - wide type.

In the above, isnt event an object meeting this criterion?

clearly i am missing something. The question is I want to find out the equivalent of RTTI from C++. ie Which one if the derived types is it.

clues appreciated. srini



             reply	other threads:[~2012-06-07 20:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-07 20:36 RasikaSrinivasan [this message]
2012-06-07 21:35 ` package Ada.Tags Simon Wright
2012-06-07 21:48   ` RasikaSrinivasan
2012-06-08  9:50   ` Yannick Duchêne (Hibou57)
2012-06-08  9:59     ` Dmitry A. Kazakov
2012-06-08 15:26     ` Adam Beneschan
2012-06-08 16:31     ` Simon Wright
2012-06-07 21:49 ` Adam Beneschan
replies disabled

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