comp.lang.ada
 help / color / mirror / Atom feed
From: DrPi <314@drpi.fr>
Subject: How to check class type ?
Date: Wed, 21 Apr 2021 19:08:24 +0200	[thread overview]
Message-ID: <60805c0e$0$12690$426a74cc@news.free.fr> (raw)

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

             reply	other threads:[~2021-04-21 17:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-21 17:08 DrPi [this message]
2021-04-21 17:26 ` How to check class type ? AdaMagica
2021-04-21 17:33   ` DrPi
2021-04-21 17:48   ` DrPi
2021-04-23 16:13     ` John McCabe
2021-04-21 17:40 ` Dmitry A. Kazakov
2021-04-22  8:50   ` DrPi
replies disabled

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