From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!news.szaf.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!cleanfeed3-a.proxad.net!nnrp1-2.free.fr!not-for-mail Newsgroups: comp.lang.ada X-Mozilla-News-Host: news://news.free.fr:119 From: DrPi <314@drpi.fr> Subject: How to check class type ? Date: Wed, 21 Apr 2021 19:08:24 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Message-ID: <60805c0e$0$12690$426a74cc@news.free.fr> Organization: Guest of ProXad - France NNTP-Posting-Date: 21 Apr 2021 19:08:30 CEST NNTP-Posting-Host: 82.65.30.55 X-Trace: 1619024910 news-2.free.fr 12690 82.65.30.55:52445 X-Complaints-To: abuse@proxad.net Xref: reader02.eternal-september.org comp.lang.ada:61887 List-Id: Hi, I have the following declarations (just for the example) : type Root is tagged null record; type Root_Ptr is access all Root'Class; type Leaf1 is new Root with null record; type Leaf1_Ptr is access all Leaf1'Class; type Leaf2 is new Root with null record; type Leaf2_Ptr is access all Leaf2'Class; To check if a variable is of type Leaf1_Ptr or Leaf2_Ptr, I do : if var'Tag = Leaf1'Tag then ... elsif var'Tag = Leaf2'Tag then ... end if; It works. But is this correct ? Should the test be done differently to suit Ada coding style ? Nicolas