From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_05,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:ae9:dfc4:: with SMTP id t187mr1841915qkf.299.1611597098113; Mon, 25 Jan 2021 09:51:38 -0800 (PST) X-Received: by 2002:a25:9902:: with SMTP id z2mr2145626ybn.339.1611597097902; Mon, 25 Jan 2021 09:51:37 -0800 (PST) Path: eternal-september.org!reader02.eternal-september.org!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 25 Jan 2021 09:51:37 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=87.143.127.6; posting-account=rHjQvgoAAACyPWm5s-bLXdFCueApAPxr NNTP-Posting-Host: 87.143.127.6 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <9e1b5d67-be08-4f53-aadc-fbed761a8c24n@googlegroups.com> Subject: Re: Simple example on interfaces From: Mario Blunk Injection-Date: Mon, 25 Jan 2021 17:51:38 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:61197 List-Id: > 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.