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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:a5d:954c:: with SMTP id a12mr9136725ios.14.1550278328446; Fri, 15 Feb 2019 16:52:08 -0800 (PST) X-Received: by 2002:aca:4b89:: with SMTP id y131mr115237oia.3.1550278328281; Fri, 15 Feb 2019 16:52:08 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!y42no126315ita.0!news-out.google.com!d79ni145itc.0!nntp.google.com!y42no126309ita.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 15 Feb 2019 16:52:07 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=70.109.61.2; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 70.109.61.2 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Private extension of a synchronized interface From: Jere Injection-Date: Sat, 16 Feb 2019 00:52:08 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:55521 Date: 2019-02-15T16:52:07-08:00 List-Id: 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?