comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Generic private type declaration
Date: Tue, 29 Nov 2016 17:48:06 -0600
Date: 2016-11-29T17:48:06-06:00	[thread overview]
Message-ID: <o1l41t$2ja$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: o1jpiq$13df$1@gioia.aioe.org

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:o1jpiq$13df$1@gioia.aioe.org...
> On 28/11/2016 22:32, Randy Brukardt wrote:
>> So, yes, Dmitry, the language could strengthen contracts this
>> way -- if one didn't care about usability [or compatibility]).
>
> Rather one should make contracts more complete. If the formal type "X is 
> private" may or may not allow type cloning by "Y is new X" of the actual 
> type, that must be a part of the contract. E.g. tagged types should not 
> match or, better cloning hierarchies tagged types must be allowed.

That would be hard to do, though. It would make generics rather hard to make 
general. One sees that with formal arrays, where it is necessary to make two 
versions of each generic, one for constrained array types and one for 
unconstrained array types.

I tend to agree with your usual analysis that generics are never going to 
really work in an O-O environment. If you make the contracts complete, 
you'll end up with generics that hardly are generic at all (they'd only work 
in very limited circumstances). And if you make them really loose (as in 
C++), you can't really write a body that is certain to work, because too 
much leaks through from the actuals.

Ada's approach tries to tread a middle ground, and as such it isn't 
satisfying to anyone (but it also allows a lot of things that otherwise 
would have to be banned unconditionally). Of course, when trying to have 
ones cake and eat it too, its not unusual to get the rules wrong (either too 
tight or too loose). I doubt that there really is a solution.

                                           Randy.



  reply	other threads:[~2016-11-29 23:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-25 17:36 Generic private type declaration Alejandro R. Mosteo
2016-11-25 19:17 ` Dmitry A. Kazakov
2016-11-28 14:54   ` Alejandro R. Mosteo
2016-11-25 19:18 ` AdaMagica
2016-11-28 14:57   ` Alejandro R. Mosteo
2016-11-25 19:38 ` G.B.
2016-11-26  8:45 ` Jacob Sparre Andersen
2016-11-26 19:18   ` Tero Koskinen
2016-11-28 15:05     ` Alejandro R. Mosteo
2016-11-28 21:32       ` Randy Brukardt
2016-11-29 11:12         ` Alejandro R. Mosteo
2016-11-29 11:42         ` Dmitry A. Kazakov
2016-11-29 23:48           ` Randy Brukardt [this message]
2016-11-28 23:25 ` Robert Eachus
replies disabled

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