comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pogner.demon.co.uk>
Subject: Re: Delegating operations to parent (generic formal type)
Date: 2000/08/28
Date: 2000-08-28T00:00:00+00:00	[thread overview]
Message-ID: <x7vaedxqoin.fsf@pogner.demon.co.uk> (raw)
In-Reply-To: x7vem4xvjtz.fsf@pogner.demon.co.uk

(This is a repost, in the hope someone can help!!)

The code below is accepted by GNAT (3.13a1, 3.12p at least) but not by
APEX 3.2.0b (Solaris) or the OA special edition (7.2).

The problem arises in the body of Containers.Maps.Synchronized.

APEX says it can't resolve the call Initialize (Map_Base (M)) in
Containers.Maps.Synchronized.Initialize.

OA ditto, followed by a fatal assertion error (or was it a bad memory
access?) in the instantiation.

This is a pretty common idiom in Smalltalk (super bind, super
initialize) -- is there an Ada equivalent that would help here? I
can't see why the compilers don't see the Initialize(Map_Base)
operation, we're in a child package and should be able to see the
private operations of Map_Base -- which include those of Controlled.

=============================================================================
with Ada.Finalization;
package Containers is
  type Container is abstract tagged private;
private
  type Container is abstract new Ada.Finalization.Controlled with null record;
end Containers;

package Containers.Maps is
  type Map is abstract new Container with private;
  procedure Bind (M : in out Map) is abstract;
private
  type Map is abstract new Container with null record;
end Containers.Maps;

package Containers.Maps.Unbounded is
  type Unbounded_Map is new Map with private;
  procedure Bind (M : in out Unbounded_Map);
private
  type Unbounded_Map is new Map with null record;
  procedure Initialize (M : in out Unbounded_Map);
end Containers.Maps.Unbounded;

package body Containers.Maps.Unbounded is
  procedure Bind (M : in out Unbounded_Map) is
  begin
    null;
  end Bind;
  procedure Initialize (M : in out Unbounded_Map) is
  begin
    null;
  end Initialize;
end Containers.Maps.Unbounded;

generic
  type Map_Base is new Containers.Maps.Map with private;
package Containers.Maps.Synchronized is
  type Synchronized_Map is new Map_Base with private;
  procedure Bind (M : in out Synchronized_Map);
private
  type Synchronized_Map is new Map_Base with null record;
  procedure Initialize (M : in out Synchronized_Map);
end Containers.Maps.Synchronized;

package body Containers.Maps.Synchronized is
  procedure Bind (M : in out Synchronized_Map) is
  begin
    Bind (Map_Base (M));                         -- this is OK in APEX
  end Bind;
  procedure Initialize (M : in out Synchronized_Map) is
  begin
    Initialize (Map_Base (M));                   -- this is complained about
  end Initialize;
end Containers.Maps.Synchronized;

with Containers.Maps.Synchronized;
with Containers.Maps.Unbounded;
package User is
  package Synchronized_Unbounded_Map
  is new Containers.Maps.Synchronized
     (Map_Base => Containers.Maps.Unbounded.Unbounded_Map);
end User;




  parent reply	other threads:[~2000-08-28  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-13  0:00 Delegating operations to parent (generic formal type) Simon Wright
2000-07-13  0:00 ` tmoran
2000-07-14  0:00   ` Simon Wright
2000-07-14  0:00 ` Simon Wright
2000-07-15  0:00   ` Simon Wright
2000-08-28  0:00 ` Simon Wright [this message]
2000-08-29  0:00   ` Tucker Taft
2000-09-06  5:25     ` Simon Wright
2000-09-07 21:56       ` Tucker Taft
replies disabled

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