comp.lang.ada
 help / color / mirror / Atom feed
From: davidm@rational.com (David Moore)
Subject: Re: Ada95 and Dynamic Type Identification
Date: 18 Jan 1995 17:33:22 GMT
Date: 1995-01-18T17:33:22+00:00	[thread overview]
Message-ID: <3fjjd2$e87@rational.rational.com> (raw)
In-Reply-To: milodD2Ko8z.98w@netcom.com

milod@netcom.com (John DiCamillo) writes:


>Does Ada95 have some sort of dynamic type identification
>equivalent to C++ RTTI or Eiffel's assignment-attempt?
>That is, given a procedure

>   procedure Process_Alerts(A: Alert'Class) ...

>Is there any way to find out precisely what type of
>object A is?  Or are we limited to dynamic dispatch?

There is an attribute "tag". So if we want to determine if
A is of a particular type (Dozing, say) we can either write:

if a'tag=dozing'tag then

or we can write:

if a in dozing then

There is also a predefined package that will return textual names
of types. 

package ada.tags is
   type tag is private;
   function expanded_name(t:tag) return string;
   function external_tag(t:tag) return string;
   function internal_tag(external:string) return tag;
private 
...
end ada.tags;

Note we can also say

if a in dozing'class

which will be true if a is in any class derived from the tagged type.




  parent reply	other threads:[~1995-01-18 17:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <milodD2Ko8z.98w@netcom.com>
1995-01-18  8:48 ` Ada95 and Dynamic Type Identification Stephane Barbey
1995-01-18 12:39 ` Robert A Duff
1995-01-18 17:33 ` David Moore [this message]
1995-01-18 19:12 ` R. William Beckwith
replies disabled

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