comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Private extension of a synchronized interface
Date: Mon, 18 Feb 2019 16:06:18 -0600
Date: 2019-02-18T16:06:18-06:00	[thread overview]
Message-ID: <q4fa8q$23s$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: fd975d66-8e70-4e86-8a75-efc6061ef25c@googlegroups.com


"Jere" <jhb.chat@gmail.com> 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?
> 



  parent reply	other threads:[~2019-02-18 22:06 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
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 [this message]
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