comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Preventing private procedure visibility being made public through extension
Date: Tue, 23 May 2017 09:38:29 +0200
Date: 2017-05-23T09:38:29+02:00	[thread overview]
Message-ID: <og0otl$187b$1@gioia.aioe.org> (raw)
In-Reply-To: ofvk7b$2uh$1@franka.jacob-sparre.dk

On 22/05/2017 23:12, Randy Brukardt wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> 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

  reply	other threads:[~2017-05-23  7:38 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-20 17:33 Preventing private procedure visibility being made public through extension Jere
2017-05-20 20:13 ` AdaMagica
2017-05-20 21:55   ` Jere
2017-05-20 20:32 ` Dmitry A. Kazakov
2017-05-20 22:51   ` Jere
2017-05-21  0:51     ` Jere
2017-05-21  9:16       ` Chris Moore
2017-05-21 22:55         ` Jere
2017-05-21  8:44     ` Dmitry A. Kazakov
2017-05-21 12:19       ` J-P. Rosen
2017-05-21 12:53         ` Dmitry A. Kazakov
2017-05-21 20:06       ` Jere
2017-05-21 21:07         ` Dmitry A. Kazakov
2017-05-21 22:28           ` Jere
2017-05-22  8:52             ` Dmitry A. Kazakov
2017-05-22 13:33               ` AdaMagica
2017-05-22 13:43           ` AdaMagica
2017-05-22 21:17         ` Randy Brukardt
2017-05-25  4:06           ` Jere
2017-05-25 19:39             ` Randy Brukardt
2017-05-25 22:53               ` Jere
2017-05-25 22:57                 ` Jere
2017-05-26 20:46                 ` Randy Brukardt
2017-05-26 22:35                   ` Simon Wright
2018-05-20 11:22                     ` Simon Wright
2018-05-20 12:03                       ` Jere
2017-05-26 22:58                   ` Jeffrey R. Carter
2017-05-30 21:15                     ` Randy Brukardt
2017-06-02  1:07                       ` Jere
2017-06-02  7:31                         ` Dmitry A. Kazakov
2017-06-02  8:09                         ` Mark Lorenzen
2017-06-02 11:31                         ` Simon Wright
2017-05-22 21:12   ` Randy Brukardt
2017-05-23  7:38     ` Dmitry A. Kazakov [this message]
2017-05-21 18:14 ` Robert Eachus
2017-05-21 20:21   ` Jere
2017-05-21 21:09     ` Jeffrey R. Carter
2017-05-21 22:46       ` Jere
2017-05-22 21:24         ` Jeffrey R. Carter
2017-05-25  3:45           ` Jere
2017-05-21 21:20     ` Dmitry A. Kazakov
2017-05-21 21:45       ` Jere
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox