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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!news.stack.nl!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Making sense of predicates Date: Mon, 21 Oct 2013 23:35:59 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1382416559 6976 69.95.181.76 (22 Oct 2013 04:35:59 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 22 Oct 2013 04:35:59 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Original-Bytes: 3063 Xref: number.nntp.dca.giganews.com comp.lang.ada:183690 Date: 2013-10-21T23:35:59-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:myuy19txq4vq.6xym4vrt6irl.dlg@40tude.net... > 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? They're plenty intellegent: they're purely a runtime check, just like a constraint. If you don't want a runtime check, don't use 'em. You want a new kind of type, which is something very different. > 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). It should be one step (only). We'd need something like co-derivation for that, which might make sense to pursue someday (the main reason would be to get rid of access types altogether, but to do that you need some sort of handle, like the container cursor -- and clearly you need to be able to derive the container and its handle together). But that would be a big job to define properly, it would take the existing inheritance rules and make them much more complex. (There are already 3 pages of rules associated with inheritance for derived types.) Randy.