From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d4b510aac9184a29,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-01-18 00:48:24 PST Path: nntp.gmd.de!Germany.EU.net!howland.reston.ans.net!gatech!udel!news.mathworks.com!uunet!fdn.fr!univ-lyon1.fr!swidir.switch.ch!epflnews!dinews.epfl.ch!di.epfl.ch!Stephane.Barbey From: Stephane.Barbey@di.epfl.ch (Stephane Barbey) Newsgroups: comp.lang.ada Subject: Re: Ada95 and Dynamic Type Identification Date: 18 Jan 1995 08:48:24 GMT Organization: Ecole Polytechnique Federale de Lausanne Distribution: world Message-ID: <1995Jan18.093916@di.epfl.ch> References: NNTP-Posting-Host: lglsun1.epfl.ch Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: 1995-01-18T08:48:24+00:00 List-Id: In article , 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