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: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Smart Pointers and Tagged Type Hierarchies Date: Tue, 1 Aug 2017 17:41:00 -0500 Organization: JSA Research & Innovation Message-ID: References: <2017072417413775878-contact@flyx.org> Injection-Date: Tue, 1 Aug 2017 22:41:01 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="14503"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: news.eternal-september.org comp.lang.ada:47550 Date: 2017-08-01T17:41:00-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:olpb12$1o3$1@gioia.aioe.org... > On 2017-08-01 05:43, Randy Brukardt wrote: ... >> One would have to have some form of multiple dispatch to get around that, >> but that's a bridge too far for a language that's mainly used in >> embedded, >> safety-critical systems. > > But Ada already has this form of multiple-dispatch. The issue does not > requires two types. Two controlling parameters of the same type is just > enough: > > type T is tagged ... > procedure Foo (X, Y : T); > > type S is new T with ... > overriding procedure Foo (X, Y : S); > > X : T'Class := T'(...); > Y : T'Class := S'(...); > begin > Foo (X, Y); > > So I would not be much concerned about that. This is described (and implemented) as a single dispatch with a tag equality check. Nothing multiple about it outside of the initial appearance. To use that mechanism implies that you have only one type (and a shared tag) as opposed to two different but related types. I'm not sure how that could work, given the very different properties of a reference vs. an object type. It also would require some relaxation of the "one controlling type per primitive subprogram" rule. I suspect both of those would run into trouble with the generic contract model (specifically with generic derived types), but someone would have to try to work out all of the details in order to be sure. Randy.