comp.lang.ada
 help / color / mirror / Atom feed
* package Ada.Tags
@ 2012-06-07 20:36 RasikaSrinivasan
  2012-06-07 21:35 ` Simon Wright
  2012-06-07 21:49 ` Adam Beneschan
  0 siblings, 2 replies; 8+ messages in thread
From: RasikaSrinivasan @ 2012-06-07 20:36 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-06-08 16:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-07 20:36 package Ada.Tags RasikaSrinivasan
2012-06-07 21:35 ` 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

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