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!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Smart Pointers and Tagged Type Hierarchies Date: Wed, 2 Aug 2017 08:28:40 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <2017072417413775878-contact@flyx.org> NNTP-Posting-Host: MajGvm9MbNtGBKE7r8NgYA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Language: en-US Xref: news.eternal-september.org comp.lang.ada:47555 Date: 2017-08-02T08:28:40+02:00 List-Id: On 2017-08-02 00:41, Randy Brukardt wrote: > "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. Except that the dispatch table that should have been 2-D: T1 T2 T3 T1 * T2 * T2 * You is flatten to 1-D: T1 T2 T3 The check is to ensure that you are indeed on the diagonal. > 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. Same as above. The 2-D table is: A1 A2 A3 B1 * B2 * B3 * You do exactly same thing. You check if you are on the diagonal, then you dispatch using any of two tags once. Just one hop. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de