comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Simple example on interfaces
Date: Tue, 26 Jan 2021 11:25:37 +0100	[thread overview]
Message-ID: <ruoqn0$1cio$1@gioia.aioe.org> (raw)
In-Reply-To: ruons9$ugr$1@dont-email.me

On 2021-01-26 10:37, J-P. Rosen wrote:
> Le 25/01/2021 à 23:06, Dmitry A. Kazakov a écrit :
>> Ada interface is a type that has interface and no implementation. [It 
>> is a silly idea inherited from Java.]
>>
> To make it look a little less silly, think of it as a promise: a type 
> that implements an interface promises to provide a certain number of 
> operations.

I agree. I meant that Ada 95 had that already:

    type Interface is abstract tagged null record;

There was no need to introduce it as a separate concept. I think the 
real reason was laziness. Vendors did not want to implement full 
multiple inheritance. Adding a simple constraint on the base types 
looked bad and also breached privacy:

    type Is_It_Interface is abstract tagged private;
private
    type Is_It_Interface is abstract tagged null record;

> Then you can define algorithms that work on any type that fulfills the 
> promises.
> 
> To me, the big benefit of interfaces is that it is NOT inheritance; you 
> say that your type provides some operations, without needing to classify 
> it with an is-a relationship.

But you do. When you say that T provides F that in other words means T 
*is-a* member of a class that provides F. Interface is merely a 
formalization of that.

> (I can hear screamings of pure-OO people who will not agree with me ;-) )

OO muddied a lot of water. To me things are quite pragmatic. How do I 
spell in the language the fact that Long_Integer is an integer? If 
Integer is an integer and Long_Integer is an integer can I write a 
program that works on integers? Can it be the *same* program for each 
instance of? Simple, natural questions.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2021-01-26 10:25 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-25 16:08 Simple example on interfaces Mario Blunk
2021-01-25 16:41 ` Dmitry A. Kazakov
2021-01-25 17:51   ` Mario Blunk
2021-01-25 22:06     ` Dmitry A. Kazakov
2021-01-26  7:33       ` G.B.
2021-01-26  8:07         ` Dmitry A. Kazakov
2021-01-26  8:17           ` Mario Blunk
2021-01-26  8:55             ` Dmitry A. Kazakov
2021-01-26  9:37       ` J-P. Rosen
2021-01-26 10:25         ` Dmitry A. Kazakov [this message]
2021-01-26 11:15           ` AdaMagica
2021-01-26 11:53             ` Dmitry A. Kazakov
2021-01-26 16:46               ` AdaMagica
2021-01-26 19:44                 ` Dmitry A. Kazakov
2021-01-26 20:04                   ` Shark8
2021-01-26 21:34                     ` Dmitry A. Kazakov
2021-01-27  3:11                     ` Randy Brukardt
2021-01-27 22:51                       ` Shark8
2021-01-30  8:33                         ` Randy Brukardt
2021-01-27  3:09                   ` Randy Brukardt
2021-01-27  8:05                     ` Dmitry A. Kazakov
2021-01-26 10:02     ` Stephen Leake
2021-01-25 17:00 ` Jeffrey R. Carter
2021-01-27  1:48   ` philip...@gmail.com
2021-01-27  8:06     ` Dmitry A. Kazakov
2021-01-27  3:36   ` Randy Brukardt
2021-01-27 23:04     ` Shark8
2021-01-25 19:05 ` Stephen Leake
replies disabled

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