comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: tagged record child: override constructor?
Date: Wed, 14 Sep 2005 09:49:13 +0200
Date: 2005-09-14T09:49:06+02:00	[thread overview]
Message-ID: <1idpvzxcxfckw.mrs8nw3eu4ks$.dlg@40tude.net> (raw)
In-Reply-To: 87vf14him5.fsf@ludovic-brenta.org

On Tue, 13 Sep 2005 21:29:06 +0200, Ludovic Brenta wrote:

> Martin Krischik <krischik@users.sourceforge.net> writes:
>> That's because all class members are virtual in Ada.
> 
> I think this needs to be elaborated on.
> 
> All _primitive operations of a tagged type_ are _potentially_
> "virtual" in Ada.  Each caller of such a primitive operation decides,
> at the call site, whether the dispatching is static or dynamic.

Ada's model is quite simple and logical. If T appears as a formal parameter
or the result of a primitive operation of T, then this parameter is
controlled (= the operation can dispatch on it.)

Dispatching is determined not by any site but exclusively by the actual
parameter type. It must be of T'Class.

For this reason re-dispatching never happens. To re-dispatch, one should
explicitly convert T to T'Class.

> In contrast, in (my recollection of) C++, all virtual methods dispatch
> dynamically from all call sites: the decision is not made at the point
> of call but at the point of definition of the method.

C++ model is more tricky and in some aspects more limited. Only the prefix
(distinguished) parameter can be controlled (the "this-parameter".) The
result cannot be controlled as well. There is no difference between T and
T'Class (the source of countless problems.) So all operations re-dispatch
except for constructors and destructors, which don't. I.e. it is rather C++
where the call site determines whether a virtual function dispatches.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2005-09-14  7:49 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-13  5:58 tagged record child: override constructor? sean.gilbertson
2005-09-13  6:39 ` David Trudgett
2005-09-13  7:32 ` Dmitry A. Kazakov
2005-09-13  7:56   ` tmoran
2005-09-13 15:23   ` sean.gilbertson
2005-09-13 17:37     ` Martin Krischik
2005-09-13 19:29       ` Ludovic Brenta
2005-09-14  7:49         ` Dmitry A. Kazakov [this message]
2005-09-14  9:05           ` Maciej Sobczak
2005-09-14 13:20             ` Dmitry A. Kazakov
2005-09-14 13:52               ` Hyman Rosen
2005-09-14 16:47                 ` Dmitry A. Kazakov
2005-09-14 17:16                   ` Hyman Rosen
2005-09-14 20:20                     ` Dmitry A. Kazakov
2005-09-14 20:34                       ` Georg Bauhaus
2005-09-14 20:56                       ` Hyman Rosen
2005-09-15  7:31                         ` Dmitry A. Kazakov
2005-09-15 13:19                           ` Hyman Rosen
2005-09-15 13:45                             ` Maciej Sobczak
2005-09-15 17:45                             ` Dmitry A. Kazakov
2005-09-15 18:54                               ` Hyman Rosen
2005-09-16  9:32                                 ` Dmitry A. Kazakov
2005-09-16 14:52                                   ` Hyman Rosen
2005-09-16 15:33                                     ` Jean-Pierre Rosen
2005-09-16 18:37                                       ` Hyman Rosen
2005-09-16 21:03                                     ` Dmitry A. Kazakov
2005-09-16 21:33                                       ` Hyman Rosen
     [not found]                                         ` <98ox2x9xvj9z.1uh92dslhvt4g.dlg@40tude.net>
2005-09-17 12:47                                           ` Georg Bauhaus
2005-09-17 15:56                                             ` Dmitry A. Kazakov
2005-09-14 16:14           ` Martin Krischik
2005-09-14 16:57             ` Dmitry A. Kazakov
2005-09-14 18:35               ` Martin Krischik
2005-09-14  9:28         ` Alex R. Mosteo
2005-09-14 16:10         ` Martin Krischik
2005-09-13  9:33 ` Georg Bauhaus
2005-09-13 16:37 ` Jeffrey Carter
2005-09-13 18:55   ` Robert A Duff
2005-09-13 22:18     ` Jeffrey Carter
replies disabled

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