comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Inherited Methods and such
Date: Fri, 28 Sep 2007 15:02:52 -0400
Date: 2007-09-28T15:02:52-04:00	[thread overview]
Message-ID: <wccps02fw9v.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 1190843408.713838.128690@g4g2000hsf.googlegroups.com

Maciej Sobczak <see.my.homepage@gmail.com> writes:

> On 26 Wrz, 14:26, Robert A Duff <bobd...@shell01.TheWorld.com> wrote:
>> And why "constructor functions" do not solve
>> it?
>
> Constructor functions in Ada are functions that return new objects
> (most useful for limited types since Ada 2005) can have parameters,
> but they still don't acknowledge the "progressive" nature of the whole
> process.

I think they do, actually.  At least, they can, if you program it that
way.  You can say (presuming T2 is derived from T1):

    function Make_T2 (...) return T2 is
    begin
        return Result : T2 := (Make_T1 (...) with ...) do
            ...
        end return;
    end Make_T2;

Within Make_T1, the 'Tag of its result will be T1'Tag,
even though that is really the parent part of the Result in T2,
whose Tag is T2'Tag.  And a call to this Make_T2 could
be the parent part of some other extension aggregate
in some other constructor function, with some other
(deeper) Tag.

>... This means that no matter whether we use Initialize or
> constructor functions, the final type of the object is established at
> the very beginning and is kept during the whole construction process.

You're right about Initialize, and I agree with you (I don't much like
it).  But constructor functions are different.

> If this process involves some activities on various levels of the type
> inheritance chain, the ugly effects like the one from my example can
> result, because primitive operations can be called bypassing the
> intended order of component construction.
>
>> Are there other languages (c++, perhaps?) that have a complete solution
>> to this problem?
>
> My claim in this lengthy and philosophical discussion is that C++
> provides a complete solution which can be shortly described like this:
> the final type is not established from the very beginning, but is
> progressively moving along the inheritance chain as the subsequent
> constructors of base types complete their work. Thank's to this,
> primitive operations never dispatch further than what can be
> statically reasoned about.

Well, I'd say that Ada is doing the same thing in my above example,
except it's not "changing" the Tag of a single object -- instead,
the result of Make_T1 has its Tag, and then Make_T2 has a different
Tag.  Within Make_T1, you can't dispatch to a T2 operation.

> Implementation-wise, this can be done with "just" changing the tag of
> the object as each base constructor completes.

Right.  Implementation-wise, the Tag of the result of Make_T1 is stored
at the same location in memory as the Tag of the result of Make_T2.
This memory location is overwritten after Make_T1 returns,
during the evaluation of the extension aggregate.  (Well, to
be precise, it's the same location if the type is limited.
For nonlimited, the implementation can choose to make them
the same location, or can copy things.)

- Bob



  parent reply	other threads:[~2007-09-28 19:02 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-17 14:26 Inherited Methods and such shaunpatterson
2007-09-17 15:11 ` Ludovic Brenta
2007-09-17 16:46   ` shaunpatterson
2007-09-17 19:07     ` Ludovic Brenta
2007-09-17 20:22   ` Maciej Sobczak
2007-09-17 21:07     ` Ludovic Brenta
2007-09-18 14:27       ` Maciej Sobczak
2007-09-18 14:27       ` Maciej Sobczak
2007-09-18 15:25         ` Dmitry A. Kazakov
2007-09-18 18:34           ` Ludovic Brenta
2007-09-18 19:29             ` Dmitry A. Kazakov
2007-09-18 19:39               ` Ludovic Brenta
2007-09-18 20:49                 ` Dmitry A. Kazakov
2007-09-18 21:10               ` Simon Wright
2007-09-18 20:39           ` Maciej Sobczak
2007-09-18 21:12             ` Dmitry A. Kazakov
2007-09-19 14:49               ` Maciej Sobczak
2007-09-19 15:16                 ` Dmitry A. Kazakov
2007-09-19 22:13                   ` Maciej Sobczak
2007-09-20  8:12                     ` Dmitry A. Kazakov
2007-09-20 13:52                       ` Maciej Sobczak
2007-09-20 16:22                         ` Dmitry A. Kazakov
2007-09-20 20:45                           ` Maciej Sobczak
2007-09-21 18:59                             ` Dmitry A. Kazakov
2007-09-21 21:02                               ` Maciej Sobczak
2007-09-22  8:48                                 ` Dmitry A. Kazakov
2007-09-22 21:53                                   ` Maciej Sobczak
2007-09-23  8:41                                     ` Dmitry A. Kazakov
2007-09-23 20:36                                       ` Maciej Sobczak
2007-09-24  9:32                                         ` Dmitry A. Kazakov
2007-09-24 15:02                                           ` Maciej Sobczak
2007-09-24 19:20                                             ` Dmitry A. Kazakov
2007-09-25 20:53                                               ` Maciej Sobczak
2007-09-26 10:42                                                 ` Dmitry A. Kazakov
2007-09-26 21:31                                                   ` Maciej Sobczak
2007-09-27 15:02                                                     ` Dmitry A. Kazakov
2007-09-27 21:02                                                       ` Maciej Sobczak
2007-09-26 12:21                                                 ` Robert A Duff
2007-09-26 12:54                                                   ` Dmitry A. Kazakov
2007-09-26 21:37                                                   ` Maciej Sobczak
2007-09-26 23:47                                                     ` Randy Brukardt
2007-09-27 21:08                                                       ` Maciej Sobczak
2007-09-28  0:44                                                         ` Randy Brukardt
2007-09-28 20:32                                                           ` Maciej Sobczak
2007-09-28 22:35                                                             ` Randy Brukardt
2007-09-29 23:58                                                             ` Robert A Duff
2007-09-26 12:26                                                 ` Robert A Duff
2007-09-26 21:50                                                   ` Maciej Sobczak
2007-09-26 22:20                                                     ` Ray Blaak
2007-09-27  0:01                                                     ` Randy Brukardt
2007-09-27 13:39                                                     ` Robert A Duff
2007-09-27 14:54                                                       ` Dmitry A. Kazakov
2007-09-28  0:35                                                         ` Randy Brukardt
     [not found]                                                           ` <7p6gc1s9imfa$.kmvwf5zyf8e9.dlg@40tude.net>
2007-09-28 22:53                                                             ` Randy Brukardt
2007-09-29 20:37                                                               ` Dmitry A. Kazakov
2007-09-27 21:23                                                       ` Maciej Sobczak
2007-09-28 19:12                                                         ` Robert A Duff
2007-09-28 19:02                                                     ` Robert A Duff [this message]
2007-09-28 19:42                                                       ` Robert A Duff
2007-09-28 20:44                                                         ` Maciej Sobczak
2007-09-28 22:40                                                           ` Randy Brukardt
2007-09-29 20:35                                                           ` Dmitry A. Kazakov
2007-09-29 20:52                                                             ` Maciej Sobczak
2007-09-30  8:38                                                               ` Dmitry A. Kazakov
2007-09-29 23:47                                                             ` Robert A Duff
2007-09-29 20:48                                                           ` Maciej Sobczak
2007-09-29 23:39                                                             ` Robert A Duff
2007-09-30  8:38                                                               ` Dmitry A. Kazakov
2007-09-29 23:42                                                           ` Robert A Duff
2007-09-25  1:59                                   ` Randy Brukardt
2007-09-25  8:59                                     ` Dmitry A. Kazakov
2007-09-25 21:02                                       ` Randy Brukardt
2007-09-26 12:42                                         ` Dmitry A. Kazakov
2007-09-18  4:03 ` Steve
replies disabled

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