comp.lang.ada
 help / color / mirror / Atom feed
From: Stephane.Barbey@di.epfl.ch (Stephane Barbey)
Subject: Re: Ada95 and Dynamic Type Identification
Date: 18 Jan 1995 08:48:24 GMT
Date: 1995-01-18T08:48:24+00:00	[thread overview]
Message-ID: <1995Jan18.093916@di.epfl.ch> (raw)
In-Reply-To: milodD2Ko8z.98w@netcom.com

In article <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?

yes.

: 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?
: 
: e.g.:
: 
:       foo: FooAlert;         -- special alert
:    begin
:       foo ?= A;              -- is A a FooAlert?
:       if (foo'Valid) then    -- A IS a FooAlert!
:          FooHandler( foo );  -- do something that only
:                              -- applies to FooAlerts
: 

        type FooAlert is tagged ...
        type BarAlert is new FooAlert with ...  
        procedure BarHandler (Bar: BarAlert) 
          -- BarHandler only applies to Bars.
  
  
        A: FooAlert'Class := ...; -- could be a Foo- or a BarAlert
        if A in BarAlert then    -- the membership test
           Primitive (BarAlert(A))

: Anyway, if dynamic typing was left out of Ada95, would 
: that be considered a mistake.  Every other statically
: typed OOPL I know of has eventually provided some form
: of dynamic typing.  Why not Ada?  Is there some subtlety
: about Ada's type system that makes dynamic typing un-
: necessary or irrelevant?

No. There is same kind of dynamic typing in Ada, see "class-wide" in the
index of Barnes book.

-Stephane

--
Stephane Barbey				"It's not easy getting real wings"	
INJ-335, barbey@di.epfl.ch



       reply	other threads:[~1995-01-18  8:48 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 ` Stephane Barbey [this message]
1995-01-18 12:39 ` Ada95 and Dynamic Type Identification Robert A Duff
1995-01-18 17:33 ` David Moore
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