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 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-01-18 09:33:22 PST Path: nntp.gmd.de!Germany.EU.net!wizard.pn.com!sundog.tiac.net!news.sprintlink.net!howland.reston.ans.net!spool.mu.edu!olivea!wetware!barrnet.net!rational.com!davidm From: davidm@rational.com (David Moore) Newsgroups: comp.lang.ada Subject: Re: Ada95 and Dynamic Type Identification Date: 18 Jan 1995 17:33:22 GMT Organization: Rational Software Corporation Message-ID: <3fjjd2$e87@rational.rational.com> References: NNTP-Posting-Host: twain.rational.com X-Newsreader: NN version 6.5.0 #4 (NOV) Date: 1995-01-18T17:33:22+00:00 List-Id: 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.