comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: Can you help with an Ada 95 OO Problem
Date: 1997/01/18
Date: 1997-01-18T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023280001801972026220001@news.ni.net> (raw)
In-Reply-To: na.9173d8474e.a50140averon@argonet.co.uk


In article <na.9173d8474e.a50140averon@argonet.co.uk>, David Wallace
<averon@argonet.co.uk> wrote:


>      -- ***************** HELP *********** HELP ***************************
>      --
>      Http.Headers.Init(Obj => Header_Ref);
>
>      Text_Io.Put_Line("General Header Object has be initialised");
>
>      Obj.General_Header_Data := 4;

My Ada95 is a little weak, so I might give you bad info.

The subprogram reference "Http.Headers.Init" doesn't refer to the
superclass implementation of that subprogram, it merely refers to the
specification of the subprogram.  The implementation of course can be
overridden by any descendant.

This appears to be what has happened here.  You called a primitive
operation with an argument of type General_Headers, not Headers, so the
overridden subprogram is what gets called, and in this case infinate
recursion was the result.

This seems awkward at first; refering to the "specification" of the
primitive operation by a different module reference than  the module
containing the implementation.  In fact, Mitch Gart criticized this
language "feature" a while back.  

The trick is always asking, What is the type of the object passed to the
operation?  It's the object that determines what operation gets dispatched
at runtime, not the reference to the *specification* of the operation.

Try a view conversion of the designated object, to get at its primitive
operation:

   Http.Headers.Init (Obj => Http.Headers.Header (Header_Ref.all));

I'm not sure that will work, but try it and let me know (so I can learn, too!).

There was some debate a while back about how to invoke the parent's
implementation of the operation.  There was one case (cited by Mitch) that
required a very un-obvious technique.  Perhaps your difficulties mean
direct language support for "invoke parent's method" would be useful after
all.

matt

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




  reply	other threads:[~1997-01-18  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-18  0:00 Can you help with an Ada 95 OO Problem David Wallace
1997-01-18  0:00 ` Matthew Heaney [this message]
1997-01-19  0:00 ` David Wallace
1997-01-21  0:00   ` Can you help with an Ada 95 OO Problem (Solution !!!) David Wallace
1997-01-20  0:00 ` Can you help with an Ada 95 OO Problem Jon S Anthony
1997-01-21  0:00 ` Jerome Desquilbet
replies disabled

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