From: Simon Wright <simon@pushface.org>
Subject: Re: Private extension of a synchronized interface
Date: Mon, 18 Feb 2019 08:33:37 +0000
Date: 2019-02-18T08:33:37+00:00 [thread overview]
Message-ID: <lyd0npo5r2.fsf@pushface.org> (raw)
In-Reply-To: bc3cde96-2655-4cd7-9b69-aecba3963f71@googlegroups.com
[-- Attachment #1: Type: text/plain, Size: 731 bytes --]
Jere <jhb.chat@gmail.com> 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,
[-- Attachment #2: working example --]
[-- Type: text/plain, Size: 1137 bytes --]
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;
next prev parent reply other threads:[~2019-02-18 8:33 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-16 0:52 Private extension of a synchronized interface Jere
2019-02-17 9:50 ` Dmitry A. Kazakov
2019-02-17 13:46 ` Jere
2019-02-17 14:52 ` Dmitry A. Kazakov
2019-02-17 15:36 ` Jere
2019-02-17 16:28 ` Dmitry A. Kazakov
2019-02-17 20:56 ` Jere
2019-02-17 22:36 ` Simon Wright
2019-02-18 0:36 ` Jere
2019-02-18 8:11 ` Dmitry A. Kazakov
2019-02-18 8:29 ` Simon Wright
2019-02-18 8:42 ` Dmitry A. Kazakov
2019-02-18 8:26 ` Simon Wright
2019-02-18 8:33 ` Simon Wright [this message]
2019-02-18 15:40 ` Jere
2019-02-18 17:24 ` Simon Wright
2019-02-19 11:04 ` Simon Wright
2019-02-20 2:36 ` Jere
2019-02-20 10:46 ` Simon Wright
2019-02-20 15:04 ` Jere
2019-02-18 15:49 ` Jere
2019-02-18 22:06 ` Randy Brukardt
2019-02-18 22:35 ` Randy Brukardt
2019-02-19 10:01 ` Egil H H
2019-02-19 11:29 ` Simon Wright
2019-02-19 11:53 ` Egil H H
2019-02-20 2:32 ` Jere
2019-02-20 13:46 ` Simon Wright
2019-02-20 23:43 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox