comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Private extension of a synchronized interface
Date: Mon, 18 Feb 2019 17:24:03 +0000
Date: 2019-02-18T17:24:03+00:00	[thread overview]
Message-ID: <ly7edxnh70.fsf@pushface.org> (raw)
In-Reply-To: 8b43f7fb-34e9-474e-a6b6-5e4e6f94f412@googlegroups.com

Jere <jhb.chat@gmail.com> writes:

> Though the outstanding part of this is we don't know if this is a
> language issue/feature or a GNAT issue (the original problem that is).
>
> Maybe someone from the Arg can comment on what is intended to be
> allowed and not allowed when it comes to extending synchronized
> interfaces.

I think perhaps there is a bug in GNAT after all, and I apologise to all
concerned for hasty remarks.

THIS COMPILES (not with -gnat95, which says 'no selector "V" for private
type "U" defined at line 6'):

   procedure Abstractedness is

      package Sample is
         type T is abstract tagged null record;
         --  or 'type T is interface;'
         procedure V (Self : in out T) is abstract;
         type U is new T with private;
      private
         type U is new T with null record;
         procedure V (Self : in out U);
      end Sample;

      package body Sample is
         procedure V (Self : in out U) is
         begin
            null;
         end V;
      end Sample;

      W : Sample.U;
   begin
      W.V;
   end Abstractedness;

----

The fact that you can implement an abstract operation of a synchronized
interface in a subprogram of the implementation is discussed in the Ada
2005 Rationale 5.3[1]:

   Unlike tagged record types we cannot derive a task or protected type
   from another task or protected type as well. So the derivation
   hierarchy can only be one level deep once we declare an actual task
   or protected type.

   The operations of these various interfaces are declared in the usual
   way and an interface composed of several interfaces has the
   operations of all of them with the same rules regarding duplication
   and overriding of an abstract operation by a null one and so on as
   for normal tagged types.

   When we declare an actual task or protected type then we must
   implement all of the operations of the interfaces concerned. This can
   be done in two ways, either by declaring an entry or protected
   operation in the specification of the task or protected object or by
   declaring a distinct subprogram in the same list of declarations (but
   not both). Of course, if an operation is null then it can be
   inherited or overridden as usual.

[1] https://www.adaic.org/resources/add_content/standards/05rat/html/Rat-5-3.html


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