From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Private extension of a synchronized interface Date: Mon, 18 Feb 2019 08:33:37 +0000 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: reader02.eternal-september.org; posting-host="be5f75c042c6e7a51c0c430d9866770f"; logging-data="3272"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19CWgJxXBp498osuvKj2T2vFBZpdlORVqQ=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (darwin) Cancel-Lock: sha1:Whtlfrw3WVFwabaGi66agGzskMc= sha1:pUmhOh4JJ4lqUHmY+09sq/1gtCY= Xref: reader01.eternal-september.org comp.lang.ada:55561 Date: 2019-02-18T08:33:37+00:00 List-Id: --=-=-= Content-Type: text/plain Jere writes: > In the other part that I commented out I was trying to add a publically > available override to the interface operation, but haven't been successful. > Do you know of any syntax changes I might need to do to: > > -- The following lines give the errors: > -- "p1" conflicts with declaration at line xxx > -- and > -- missing body for "p1" > > --overriding > --procedure p1(Self : in out Instance); > > So I don't need to always dispatch? I'm not 100% sure why this works & the other doesn't - I think because Instantiation.P1 is actually publicly visible. Also not sure whether you could do away with the inner Instantiation. Anyway, --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=jere.adb Content-Description: working example with Ada.Text_IO; use Ada.Text_IO; procedure Hello is package Example is type An_Interface is synchronized interface; procedure P1 (Self : in out An_Interface) is abstract; package Instantiation is type Instance is synchronized new An_Interface with private; overriding procedure P1 (Self : in out Instance); private protected type Instance is new An_Interface with procedure Actual_P1; private end Instance; end Instantiation; end Example; package body Example is package body Instantiation is protected body Instance is procedure Actual_P1 is begin Put_Line("Did Something"); end Actual_P1; end Instance; procedure P1 (Self : in out Instance) is begin Self.Actual_P1; end P1; end Instantiation; end Example; V : Example.Instantiation.Instance; begin Put_Line("Hello, world!"); -- dispatching ... Example.An_Interface'Class (V).P1; -- not dispatching V.P1; end Hello; --=-=-=--