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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Why does `Unchecked_Deallocation` need the access type? Date: Tue, 28 Jul 2015 09:40:55 +0200 Organization: cbb software GmbH Message-ID: <170ajsv4tazu3.mgrs0or8en9w$.dlg@40tude.net> References: <5d6faxxdsssv.15g7kj5hv86mk$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: 5CNUwuQ0q1vZOSDFkeKrYQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:27072 Date: 2015-07-28T09:40:55+02:00 List-Id: On Mon, 27 Jul 2015 15:20:37 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:5d6faxxdsssv.15g7kj5hv86mk$.dlg@40tude.net... >> On Sun, 26 Jul 2015 00:11:22 -0700 (PDT), EGarrulo wrote: > ... >> What is indeed redundant here is the Object_Type. It is necessary because >> Ada does not have access type introspection. That is, you cannot get the >> object type from an access type, though the compiler knows it anyway. >> Surely there should have been an attribute to get that type, e.g. >> >> Pointer_Type'Target >> >> But there is none. > > (1) The term is "designated type", so the attribute would be > Pointer_Type'Designated. > > (2) Ada 83 did not have any type-valued attributes; it was considered a > problem. ('Base was not an attribute in Ada 83; it could only be used as the > prefix of another attribute.) Ada 95 changed that (for 'Base and 'Class), > but there wasn't any consideration (that I know of) whether there would be > any others that could make sense. >From the top of my head: 1. Arrays type A is array (Positive range <>) of T; A'Index = Positive A'Element = T 2. Records type R is record I : Integer; F : Float; end R; R'Index = type ... is (I, F) -- Enumeration of members R'Member (R'Index'Val (0)) = Integer R'Aggregator = type ... is access function (I : Integer; F : Float) return R 3. Tagged hierarchies type S is new T with private; S'Parent (T'Class) = T (in a public context) The argument indicates the hierarchy where to search for the ancestor (due to MI). 4. Subroutines function Foo (I : Integer; F : Float) return T; Foo'Index = type ... is (I, F) Foo'Argument (Foo'Index'Val (0)) = Integer Foo'Result = T 5. Discriminants type T (I : Integer; B : Boolean) is ...; T'Discriminant_Index = type ... is (I, B); T'Discriminant (T'Discriminant_Index'Val (0)) = Integer T'Constraints = type ... (I : Integer; B : Boolean) is null record; 6. Generics Actuals of generics. The visibility of is a real mess now. E.g. presently I must "rename" actuals of generics like this: generic type T is ...; package Bar is subtype My_T is T; to be able to access T in some generic contexts. + Some comparison of anonymous types A'Index'Subtype_Conformant (B'Index) -- yields Boolean A'Index'Type_Conformant (Integer) -------------------------- The use cases are clear. Generics, universal stream I/O, persistency layers, constructing/destructing will hugely profit from introspection. #3 is essential for robust code, when calling parent operations, e.g. in Finalize. > (3) We recently had a proposal for 'Subtype that applies to an object. That is different I suppose, because it involves subtypes and because it acts on an object, things which are not so static as plain types. Allowing the attributes above for objects will possibly have similar problems. But they are worth each attempt to resolve, IMO. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de