comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: GNAT bug - still in 2010?
Date: Sun, 31 Oct 2010 14:24:26 -0700 (PDT)
Date: 2010-10-31T14:24:26-07:00	[thread overview]
Message-ID: <1c7d78b4-71fc-4c39-99a3-f9dca111b335@26g2000yqv.googlegroups.com> (raw)
In-Reply-To: a5a4bdce-04ef-4bfd-8ed8-d7d19bfe1ebb@h7g2000yqn.googlegroups.com

On 27 Paź, 21:43, Maciej Sobczak <see.my.homep...@gmail.com> wrote:

> 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.

I will answer myself.
Yes, it is possible and this is what I did.

The only problems were:

1. I have immediately run into another compiler bug due to the fact
that the name of the protected type cannot be used with 'Access, like
here:

>    protected type My_Protected is
>       procedure Do_Something;
>    private
>       Mixin : My_Interface_Mixin (My_Protected'Access);  --  bang!
>    end My_Protected;

This bug seems to be already fixed in newer compilers, so I will not
report it.

2. I have defined the protected type and the mixin in two separate
packages. This required "limited with" for the package where the
protected type was defined, which does not work, as the compiler does
not see the protected type:

--  a.ads
package A is
   protected type PT is
   end PT;
end A;

--  b.ads
limited with A;
package B is
   type PT_Ptr is access PT;   -- "PT" is undefined
end B;

This compiler bug also seems to be fixed in newer versions, so I will
not report it.

I have solved both problems by passing System.Address around to
completely hide dependencies between packages and doing conversions to
recover the original type. It is a hack from hell, but until proper
compilers will become more widely used, I keep it as a valid solution.
Of course, I will welcome all other suggestions.

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



  reply	other threads:[~2010-10-31 21:24 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
2010-10-31 21:24     ` Maciej Sobczak [this message]
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