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: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.glorb.com!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Making sense of predicates Date: Mon, 21 Oct 2013 21:51:58 +0200 Organization: cbb software GmbH Message-ID: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: GYYt8Fzv3ax+aWVyAAu7jw.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 X-Original-Bytes: 1900 Xref: number.nntp.dca.giganews.com comp.lang.ada:183688 Date: 2013-10-21T21:51:58+02:00 List-Id: Considering this: type T is tagged null record; procedure P (X : T); type S is new T with null record; procedure Q (X : T); subtype Subclass is T'Class with Dynamic_Predicate => Subclass in S'Class; -- Should have been Static_Predicate, but illegal Now: X : Subclass := S'(null record); begin X.P; X.Q; -- Illegal Well, predicates were not supposed to work in an intelligent way, so why not to add a kind that will? There are number of cases where this would be very useful. E.g. smart pointers: type T1 is tagged ...; type T1_Ptr is access all T1'Class; type H1 is new Ada.Finalization.Controlled with record -- Handle type Ptr : T1_Ptr; end record; type T2 is new T1 with ...; Presently it is impossible to derive H2 from H1 constrained to point to T2'Class. (Neither it were possible with implicit dereferencing) With the above, one would create a subtype of H1 constrained to T2'Class and then derive from it (better in one step, of course). -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de