comp.lang.ada
 help / color / mirror / Atom feed
From: Mario Blunk <marioblunk.alere@gmail.com>
Subject: Re: Simple example on interfaces
Date: Mon, 25 Jan 2021 09:51:37 -0800 (PST)	[thread overview]
Message-ID: <9e1b5d67-be08-4f53-aadc-fbed761a8c24n@googlegroups.com> (raw)
In-Reply-To: <rumsck$nfj$1@gioia.aioe.org>


> You must define "property." What is it? 
With "property" I mean the selectors like p0, p1 or p2.
> In your code these types have p2 
> already. Is this static polymorphism not enough? 
It seems so. Suppose there would be more types like C1, D1, ..., each of which derived from type_base, then
I don't want to define p2 over and over.

> Do you need A2 and B1 
> in a class having p2, with polymorphic objects of the class? Then that 
> would indeed be an interface. 
How would that look like ?

> Now, there is no full multiple inheritance in Ada, if p2 must be a 
> component, you are out of luck. You have only one shot and you have 
> spent it on p0 in the type Base. 
That is forbidden as far as the final application is concerned. The example I posted here is a simplification of a more complex scenario.

> But if p2 could be a function or a getter/setter pair then you can do this: 
> 
> type P2_Interface is interface; 
> function P2 (Object : P2_Interface) return Enum is abstract; 
> 
> type A2 is new A1 and P2_Interface with private; 
> overriding function P2 (Object : A2) return Enum; 
> 
> type B1 is new Base and P2_Interface with private; 
> overriding function P2 (Object : B1) return Enum; 
I need to digest that... I know an interface can not have a selector, just abstract functions.
 
> (I removed annoying "type_" prefix from all types) 
I got used to this notation in order to avoid confusion between a type and a variable. Not important here.

  reply	other threads:[~2021-01-25 17:51 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 [this message]
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
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