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!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Private extension of a synchronized interface Date: Mon, 18 Feb 2019 16:06:18 -0600 Organization: JSA Research & Innovation Message-ID: References: Injection-Date: Mon, 18 Feb 2019 22:06:18 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="2172"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader01.eternal-september.org comp.lang.ada:55572 Date: 2019-02-18T16:06:18-06:00 List-Id: "Jere" wrote in message news:fd975d66-8e70-4e86-8a75-efc6061ef25c@googlegroups.com... > I'll get to my ultimate goal later, but while following various > rabbit trails, I came across a situation I couldn't solve. GNAT > allows you to make private extensions to synchronized interfaces > and it allows you to complete those private extensions with > protected types. I can't, however, figure out how it overrides > the abstract procedures and functions of the synchronized interface. > > If I don't specify an override and try to call the procedure, it complains > that the procedure is abstract. If I try to override the abstract > function, it complains that the signature doesn't match the one in > the protected body. I don't know if this is a GNAT issue or > something that Ada doesn't allow. Here is some test code. It > compiles as is, but there are two parts that if you uncomment > either one of those it fails to compile. > > *********************************************************** > > 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; > > type Instance is synchronized new An_Interface with private; > > -- 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); > > private > > -- Some hidden implementation types, constants, etc. > > -- Instance full view is a protected type > protected type Instance is new An_Interface with > procedure p1; > private > -- some hidden stuff; > end Instance; > > end Example; > > package body Example is > > protected body Instance is > procedure p1 is > begin > Put_Line("Did Something"); > end p1; > end Instance; > > end Example; > > v : Example.Instance; > > begin > Put_Line("Hello, world!"); > > -- The following line gives the error: > -- call to abstract procedure must be dispatching > > --v.p1; > end Hello; > > *********************************************************** > > My ultimate goal is not having to declare a bunch of extra > types and packages in the public view to only use them in the > private view of the protected object. I'd prefer that all > of the private stuff actually be in a private section. So > I'm not tied to interfaces, but it was one attempt at getting > stuff moved down to the private section. But while I went > down the interfaces rabbit hole, I just found the issue I > ran into odd. > > Does anyone know how to create the correct overrides for > the example above? >