comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: GNAT bug - still in 2010?
Date: Wed, 27 Oct 2010 13:43:24 -0700 (PDT)
Date: 2010-10-27T13:43:24-07:00	[thread overview]
Message-ID: <a5a4bdce-04ef-4bfd-8ed8-d7d19bfe1ebb@h7g2000yqn.googlegroups.com> (raw)
In-Reply-To: ia9iva$o2o$1@news.eternal-september.org

On 27 Paź, 18:11, "Alexander S. Mentis" <f...@invalid.invalid> wrote:

> Yes, under Windows it demonstrates the same behavior.

Thank you. It is a real shame.

I thought that it might be possible to work around the problem with a
mix-in - that is, instead of deriving the protected type from
interface, move the interface down as a component of the protected
type. The additional type derived from the interface would take the
access discriminant pointing to the enclosing protected object and
delegate dispatching calls to the protected object.
Something like this:

   package P is
      type My_Interface is limited interface;
      procedure Do_Something (X : in out My_Interface) is abstract;
   end P;

   type My_Protected;
   type My_Interface_Mixin (Parent : access My_Protected) is
     new P.My_Interface with null record;

   --  the top-level protected type is no longer
   --  derived from My_Interface...:
   protected type My_Protected is
      procedure Do_Something;
   private
      --  ...and instead the derived type is now here,
      --  bound to the enclosing object:
      Mixin : My_Interface_Mixin (My_Protected'Access);
   end My_Protected;

   overriding
   procedure Do_Something (X : in out My_Interface_Mixin) is
   begin
      --  delegate to the enclosing protected object
      X.Parent.all.Do_Something;
   end Do_Something;

   protected body My_Protected is
      procedure Do_Something is
      begin
         null;
      end Do_Something;
   end My_Protected;


Guess what? The compiler crashes again. Does it deserve a distinct bug
report?

In any case, I would like to ask you whether the above approach makes
sense as a programming technique. It does not compile :-), but I would
like to know if from the idiomatic point of view it is constructed
properly.
What bothers me is whether it is possible to declare overriding
operation Do_Something for My_Interface_Mixin after the completion of
My_Protected - that is, isn't My_Interface_Mixin already frozen there?

(what a mess)

--
Maciej Sobczak * http://www.inspirel.com



  reply	other threads:[~2010-10-27 20:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-27 15:00 GNAT bug - still in 2010? Maciej Sobczak
2010-10-27 16:11 ` Alexander S. Mentis
2010-10-27 20:43   ` Maciej Sobczak [this message]
2010-10-31 21:24     ` Maciej Sobczak
2010-11-01  9:23       ` Maciej Sobczak
2010-10-27 21:09 ` Georg Bauhaus
2010-10-27 21:21   ` Maciej Sobczak
2010-10-27 21:56     ` Simon Wright
2010-10-28  8:31       ` Maciej Sobczak
2010-10-28  7:17 ` Timo Warns
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox