comp.lang.ada
 help / color / mirror / Atom feed
From: Tapio Kelloniemi <invalid@localhost.localdomain.com>
Subject: Re: Constructing an object
Date: Sun, 02 Oct 2005 11:52:15 GMT
Date: 2005-10-02T11:52:15+00:00	[thread overview]
Message-ID: <PRP%e.31974$Rl5.8306@reader1.news.jippii.net> (raw)
In-Reply-To: wccu0g1colf.fsf@shell01.TheWorld.com

Robert A Duff <bobduff@shell01.TheWorld.com> wrote:
>Tapio Kelloniemi <invalid@localhost.localdomain.com> writes:
>
>>...If this fails
>> and the parent method is not called at run time, Program_Error would
>> be raised. I don't think this is a big problem since in most cases missing
>> parent method call can be identified like missing return statement.
>
>The rules about return statements probably should be static:
>Every path through the function must have a return statement
>or a raise statement.
>
>Instead, we have: There must be at least one return statement
>(never mind that it might be bogus, or might be skipped).
>Plus a run-time check.
>
>The rule you propose about calling the parent could be static,
>too: exactly one call on every path (not inside a loop).

But the idea of the extended syntax (parent statement or attribute) is
to be as useful as possible and I would allow it to be used several
times per subprogram and even to call parent versions of other overridden
subprograms, even in subprograms not declared to be "extending".

Something like:

extending procedure Do_A (Object : Parent) is
begin Do_Something; end;

extending procedure Do_A (Object : Child) is
begin Do_Something_Else; Do_A (Object'Parent); end;

procedure Do_A_And_B (Object : Child) is
begin Do_Something_B; Object'Parent.Do_A; end;
--  The above is extending Do_A though it has no relationship to it.
--  Therefore the parent call is not required, but useful anyway.

--  I'm not very certain about the following idea, but it might be useful
--  in some circustances:
extending procedure Do_A (Object : Grand_Child) is
   pragma No_Parent_Call;
begin
   Do_All;
   --  We have hacked with internal data structures and done the job of
   --  parents Do_A. Calling the praent's operation could be disastrous.
end Do_A;

If the type Parent in my example was declared to be private (or
tagged private) the parent cal would only be allowed when the type
is fully visible, since calling parent's operations when the overridden
ones should actually be called can result in bad things.

-- 
Tapio



  reply	other threads:[~2005-10-02 11:52 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-21  8:46 Constructing an object Maciej Sobczak
2005-09-21 10:16 ` Georg Bauhaus
2005-09-22  7:21   ` Maciej Sobczak
2005-09-21 11:55 ` Dmitry A. Kazakov
2005-09-22  7:28   ` Maciej Sobczak
2005-09-22  7:45     ` Maciej Sobczak
2005-09-22 13:33       ` Dmitry A. Kazakov
2005-09-24  5:23         ` Randy Brukardt
2005-09-24  9:47           ` Dmitry A. Kazakov
2005-09-29  0:12             ` Randy Brukardt
2005-09-29  8:17               ` Dmitry A. Kazakov
2005-09-29 22:21                 ` Randy Brukardt
2005-09-30  8:14                   ` Jean-Pierre Rosen
2005-09-30 19:28                     ` Dmitry A. Kazakov
2005-09-30 17:49                   ` Robert A Duff
2005-10-01  0:44                     ` Randy Brukardt
2005-10-01 10:49                       ` Dmitry A. Kazakov
2005-10-01 11:06                       ` Tapio Kelloniemi
2005-10-01 14:13                         ` Robert A Duff
2005-10-02 11:52                           ` Tapio Kelloniemi [this message]
2005-10-01 15:19                       ` Georg Bauhaus
2005-09-23  5:40 ` Matthew Heaney
2005-09-23  7:18   ` tmoran
2005-09-23  8:23   ` Maciej Sobczak
2005-09-23 12:04     ` Dmitry A. Kazakov
2005-09-23 12:36       ` Matthew Heaney
2005-09-23 13:03         ` Hyman Rosen
2005-09-23 13:41           ` Maciej Sobczak
2005-09-23 14:23           ` Matthew Heaney
2006-01-17  6:28             ` [Offtopic] " James Dennett
2005-09-23 13:42         ` Dmitry A. Kazakov
2005-09-23 14:27           ` Matthew Heaney
2005-09-23 12:24     ` Matthew Heaney
2005-09-24  5:34       ` Randy Brukardt
replies disabled

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