From: "John G. Volan" <johnv@ac3i.dseg.ti.com>
Subject: Re: maintenance of overriding subprograms
Date: 1997/09/04
Date: 1997-09-04T00:00:00+00:00 [thread overview]
Message-ID: <340F5B87.80B@ac3i.dseg.ti.com> (raw)
In-Reply-To: 340DCE1D.6C5F@bix.com
Tom Moran wrote:
>
> A related error, not, unfortunately, solved by that syntax occurs when a
> maintainer erroneously believes some parameter to have a default, and
> accordingly removes or comments it out in a call, eg
> package Basic is
> type Object_Type is tagged ...
> procedure Create_Object(X : Object_Type;
> Name : in String; Size, Position : in Rectangles);
> ...
> package Fancy is
> type Fancy_Object_Type is new Basic.Object_Type with ...
> procedure Create_Object(X : Fancy_Object_Type;
> Name : in String; Size, Position : in Rectangles;
> Title : in String);
> ...
> A call
> Create_Object(X -- X is a Fancy_Object
> "It's name", The_Size, The_Position, "");
> is erroneously changed to
> Create_Object(X -- X is a Fancy_Object
> "It's name", The_Size, The_Position);
> under the misapprehension that Title defaults to the null string. But
> in fact this has changed from a call on Fancy.Create to an inherited
> call on Basic.Create Manual proofreading of the code is fairly likely
> to miss the error, but what's especially insidious is that the behavior
> is probably quite similar, so the fact there is a problem may not show
> up for some time.
package Basic is
You can avoid this sort of thing by adopting the following practices:
(1) Give controlling subprogram parameters names that reflect their
level of abstraction. Don't use an "inherited" identifier. e.g.:
package Basic is
type Basic_Object_Type is tagged ...
procedure Create
(Basic_Object : in out Basic_Object_Type;
Name : in String;
Size, Position : in Rectangle_Type);
...
package Fancy is
type Fancy_Object_Type is new Basic.Basic_Object_Type with ...
procedure Create
(Fancy_Object : in out Fancy_Object_Type;
Name : in String;
Size, Position : in Rectangle_Type;
Title : in String);
...
(2) Use named parameter association syntax religiously, e.g.:
Fancy.Create
(Fancy_Object => Your_Fancy_Object -- _obviously_ a Fancy_Object
Name => "It's name",
Size => The_Size,
Position => The_Position,
Title => "");
If you then try to change it to:
Fancy.Create
(Fancy_Object => Your_Fancy_Object -- _obviously_ a Fancy_Object
Name => "It's name",
Size => The_Size,
Position => The_Position);
then you get a compilation error.
------------------------------------------------------------------------
Internet.Usenet.Put_Signature
(Name => "John G. Volan",
Employer => "Raytheon/TI Advanced C3I Systems, San Jose, CA",
Work_Email => "jvolan@ti.com",
Home_Email => "johnvolan@sprintmail.com",
Slogan => "Ada95: World's *FIRST* International-Standard OOPL",
Disclaimer => "My employer never defined these opinions, so using " &
"them would be totally erroneous...or is that just " &
"nondeterministic behavior now? :-) ");
------------------------------------------------------------------------
next prev parent reply other threads:[~1997-09-04 0:00 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-09-02 0:00 maintenance of overriding subprograms Stephen Leake
[not found] ` <340DCE1D.6C5F@bix.com>
1997-09-04 0:00 ` John G. Volan [this message]
1997-09-07 0:00 ` Robert Dewar
1997-09-08 0:00 ` Robert A Duff
1997-09-09 0:00 ` Dan Johnston D.B.
1997-09-09 0:00 ` W. Wesley Groleau x4923
1997-09-09 0:00 ` Tom Moran
1997-09-10 0:00 ` Robert Dewar
1997-09-11 0:00 ` Dan Johnston D.B.
1997-09-12 0:00 ` Richard A. O'Keefe
1997-09-12 0:00 ` Samuel Mize
1997-09-18 0:00 ` Shmuel (Seymour J.) Metz
1997-09-24 0:00 ` John G. Volan
1997-09-25 0:00 ` Shmuel (Seymour J.) Metz
1997-09-26 0:00 ` Richard A. O'Keefe
1997-09-12 0:00 ` Robert Dewar
1997-09-05 0:00 ` Robert Dewar
1997-09-05 0:00 ` Stephen Leake
1997-09-05 0:00 ` Matthew Heaney
1997-09-07 0:00 ` Robert A Duff
1997-09-08 0:00 ` W. Wesley Groleau x4923
1997-09-09 0:00 ` Robert A Duff
1997-09-09 0:00 ` Jon S Anthony
1997-09-08 0:00 ` Tom Moran
1997-09-08 0:00 ` Stephen Leake
1997-09-10 0:00 ` Anonymous
-- strict thread matches above, loose matches on Subject: below --
1997-09-10 0:00 Marc Wachowitz
1997-09-29 0:00 Marin David Condic, 561.796.8997, M/S 731-96
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox