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: Preventing private procedure visibility being made public through extension Date: Tue, 23 May 2017 09:38:29 +0200 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: vZYCW951TbFitc4GdEwQJg.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 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Language: en-US Xref: news.eternal-september.org comp.lang.ada:46856 Date: 2017-05-23T09:38:29+02:00 List-Id: On 22/05/2017 23:12, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:ofq943$14v4$1@gioia.aioe.org... > ... >> ---------------------------------- >> The actual problem you have is parallel types hierarchies. You want to >> derive tied instances of Base_Type'Class and Base_Param'Class. >> >> Base_Type ----- Base_Param >> | | >> Derived_Type -- Derived_Param >> >> This requires >> >> 1. Full multiple dispatch >> 2. Dispatch constrained to certain combinations (parallel hierarchies) >> >> This is not supported in Ada (or in any other OO language I am aware of) > > Right. Having investigated this, it seems impossible to support in any > language that is intended to support LSP (which is the backbone of OOP). The > basic problem is dispatching. In Ada terms, you have a call: > > Something (Classwide_Obj, Othertype_Obj); > > where Classwide_Obj is of Root'Class. Now, the problem is that the other > (usually untagged) parameter is of the wrong type for the routines that you > dispatch to. A rough idea would be to have classes of tuples. The tag is then assigned to the tuple of types: (Base_Type, Base_Param) rather than to an individual type. The call X : Base_Type'Class := Y : Base_Param := Something (X, Y); would be statically illegal because (X, Y) is not in the class (Base_Type x Base_Param)'Class but in Base_Type'Class x Base_Type Also illegal would be X : Derived_Type := Y : Base_Param := Something (X, Y); Because (Derived_Type, Base_Param) is not in the class either. One should invent something to flatten tuples and means to produce class-wide tuples implicitly and explicitly. This model is fully statically checkable and supports dispatch. > There are various ways you can fix this dynamically (for instance, as you > noted, with multiple dispatch), but there is no way to have any static > typing in these cases. Right, but that is rather uninteresting from Ada's and SPARK POV. > But the entire point of doing a "co-derivation" is to > get static typing, so you're doing a lot of work for very little gain. Exactly. > Co-derivation probably could be made to work for untagged types (as they > don't have dispatching to worry about), but it's unclear that enough benefit > would arise. Right, but that works exactly because there is no class-wide objects of untagged types. > Anyway, this is an agenda item for the ARG, but unless someone has an idea > that hasn't been considered to date it isn't going anywhere. Very good. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de