comp.lang.ada
 help / color / mirror / Atom feed
From: Nick Roberts <nick.roberts@acm.org>
Subject: Re: Abstract Operations On A Tagged Record
Date: Mon, 01 Nov 2004 18:09:56 +0000
Date: 2004-11-01T18:09:56+00:00	[thread overview]
Message-ID: <2uncfjF2c34toU1@uni-berlin.de> (raw)
In-Reply-To: <3qqhd.16031$ta5.3884@newsread3.news.atl.earthlink.net>

Marin David Condic wrote:

> Thanks for the response. As both you and Dimitry observed, I rather 
> neglected to toss in the class parameter. I should have put in an 
> example with a base class operation that looked like:
> 
> procedure Some_Op (The_Thing : in out Some_Tagged_Type'Class)
>       is abstract ;

Although this declaration isn't actually illegal, it probably isn't
what you intended, Marin. Since Some_Op is not a primitive operation of
any named type, it cannot be inherited, and so cannot be overridden. It
therefore does not ensure that an operation is implemented by any
derived type.

I'm fairly certain that you require something like:

   procedure Some_Op (The_Thing : in out Some_Tagged_Type;
                      The_Params: in     Some_Parameter_Type'Class)
                                                          is abstract ;

where Some_Parameter_Type is a tagged type (it could also be abstract)
from which you derive types to specify particular variations and their
specific parameter values, just as I (and Dmitry) illustrated.

At the point where you /call/ Some_Op, you may well provide a class wide
actual parameter, for The_Thing, for The_Params, or both, e.g.:

   declare
      This_Thing:   constant Some_Tagged_Type'Class := From_Outer_Space;
      These_Params: constant Some_Parameter_Type'Class := What_To_Do;
   begin
      Some_Op( This_Thing, These_Params );

The call of Some_Op, in this example, will dispatch on the actual type
of the class wide object This_Thing. Because it dispatches, it will call
an concrete (non-abstract) overriding of Some_Op, for a concrete actual
type (derived from Some_Tagged_Type).

Does this make sense?

-- 
Nick Roberts



  reply	other threads:[~2004-11-01 18:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-30 13:04 Abstract Operations On A Tagged Record Marin David Condic
2004-10-30 14:34 ` Dmitry A. Kazakov
2004-10-30 16:07 ` Nick Roberts
2004-11-01 12:58   ` Marin David Condic
2004-11-01 18:09     ` Nick Roberts [this message]
2004-11-01 22:27       ` Marin David Condic
2004-11-06 13:17       ` Marin David Condic
replies disabled

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