comp.lang.ada
 help / color / mirror / Atom feed
* Forcing a tagged type to use a subsequent extention?
@ 1997-04-19  0:00 Denis Mouraux
  1997-04-22  0:00 ` Stephen Leake
  0 siblings, 1 reply; 2+ messages in thread
From: Denis Mouraux @ 1997-04-19  0:00 UTC (permalink / 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/




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Forcing a tagged type to use a subsequent extention?
  1997-04-19  0:00 Forcing a tagged type to use a subsequent extention? Denis Mouraux
@ 1997-04-22  0:00 ` Stephen Leake
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Leake @ 1997-04-22  0:00 UTC (permalink / raw)



Denis Mouraux wrote:
> (a mildly interesting Ada question, with real code)
> 
> (BTW, this is for an assignment at Universite du Quebec a Montreal...)

Then ask your professor, and/or your Teaching Assistant! That's what
they are for, and they can give a much better answer, tailored to your
current understanding, than we can. 

If you ask, and they CAN'T give a good answer, then come back, say they
failed, and we'll give it a try.
-- 
- Stephe




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-04-22  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-04-19  0:00 Forcing a tagged type to use a subsequent extention? Denis Mouraux
1997-04-22  0:00 ` Stephen Leake

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