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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3d313337c39c5dd5 X-Google-Attributes: gid103376,public From: Samuel Tardieu Subject: Re: run-time type identification Date: 1998/09/03 Message-ID: #1/1 X-Deja-AN: 387465132 References: <01bdd72e$49ee66b0$f330ea9e@ukp03332> Mail-Copies-To: sam@ada.eu.org To: "Bob Fletcher" Content-Type: text/plain; charset=US-ASCII Organization: TELECOM Paris Mime-Version: 1.0 (generated by tm-edit 7.108) Newsgroups: comp.lang.ada Date: 1998-09-03T00:00:00+00:00 List-Id: >>>>> "Bob" == Bob Fletcher writes: Bob> It seems to me that this is something that would make a lot of Bob> sense when dealing with class-wide access types, which can easily Bob> be used to go up the object heirarchy, but not, as far as I know, Bob> to go back down, (without messing about with Bob> unchecked_conversion). You can do it in Ada: (pseudo-code that compiles but is obviously incorrect) package T is type A is tagged null record; type A2 is new A with null record; type A_Ptr is access all A'Class; Z : A_Ptr; Y : constant A2 := A2 (Z.all); end T; Of course, Constraint_Error will be raised if Z.all does not belong to A2'Class. Sam -- Samuel Tardieu -- sam@ada.eu.org