comp.lang.ada
 help / color / mirror / Atom feed
From: Denis Mouraux <mouraux@microtec.net>
Subject: Forcing a tagged type to use a subsequent extention?
Date: 1997/04/19
Date: 1997-04-19T00:00:00+00:00	[thread overview]
Message-ID: <33584CA6.52ADE15B@microtec.net> (raw)


Hi! I think the best way to explain my problem is this piece of code:

package A is
  type Object_Type is abstract tagged limited private;
  (...)
private -- A
  type Element_Type is tagged
    record
      (...)
    end record;
  subtype Index is Integer range 1..Max;
  type Vector_Type is array (Index) of Element_Type;
  type Object_Type is abstract tagged limited
    record
      Vector : Vector_Type;
      N      : Natural := 0;
    end record;
end A;

package A.B is -- <------- This is a child of A!
  type Object_Type is limited private;
  (...)
private -- A.B
  type Element_Type is new A.Element_Type with
    record
      Extra : Some_Type; -- I add something here
    end record;
  type Object_Type is new A.Object_Type with
    record
      (...) -- I add something here too
    end record;
end A.B;

  Now, what I'm trying to do is use the new Element_Type defined in A.B
inside the array of the new Object_Type defined in A.B.  So if Object is
defined as being of type A.B.Object_Type, I could write something like
Object.Vector(i).Extra... Of course, Object_Type is private, so that
would be in the body of A.B.  But in the way the code is now, I can't do
that, because of course the Element is of type A.Element, which does not
contain any field named Extra.
  I'm pretty sure I read something about that somewhere a few months
ago, but I could'nt find it again (I tried the LRM, the FAQs,
Lovelace...):  I think there was some way to tell the parent type
(Object_Type or Vector_Type probably) to use the latest definition of
its component of Element_Type.  Or maybe it was Element_Type itself that
was told to "become" any new definition of itself in a child package...
Any help will be appreciated. Thanks!

(BTW, this is for an assignment at Universite du Quebec a Montreal...)

 

    o_                         Denis Mouraux
 ____<\_____________________________________

 email --> mouraux@microtec.net
 WWW   --> http://www.microtec.net/~mouraux/




             reply	other threads:[~1997-04-19  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-19  0:00 Denis Mouraux [this message]
1997-04-22  0:00 ` Forcing a tagged type to use a subsequent extention? Stephen Leake
replies disabled

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