TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Content-Transfer-Encoding: 8BIT
Sender: "Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
From: Christoph & Ursula Grein <[log in to unmask]>
Date: Mon, 24 May 1999 21:12:42 +0200
Content-Type: text/plain; charset=ISO-8859-1
MIME-Version: 1.0
Reply-To: Christoph & Ursula Grein <[log in to unmask]>
Parts/Attachments: text/plain (93 lines)
Thank you very much for the elucidation.

Tucker Taft schrieb:
Christoph & Ursula Grein wrote:
> What is the difference between declaring overriding operations in the visible
> part and declaring them in the private part?

If you override in the private part, it has no effect outside the
package if the type is untagged.  If the type is tagged, overriding
in the private part is pretty much the same as overriding in the
visible part.  However, you have no opportunity to
change (visibly) the formal parameter names or the default
parameter expressions.


Now I really do not see why I should not be able to add the renaming declaration
(at the end of the code sample) (and Gnat 3.11p compiles and executes it without
So I still do not see any difference between overriding visibly respectively in
the private part (for tagged types).

(For untagged types, the difference is clear; perhaps not so obvious at first.)

I would be very obliged if you please could further explain, perhaps by adding
the relevant chapter and verse.

> Consider the following example:
> ----------------
> package Class is
>   type Root is tagged null record;
>   procedure Operation (R : in Root);
>   type Derived is new Root with null record;
>   -- procedure Operation (D : in Derived);  -- overrides
> private
>   procedure Operation (D : in Derived);  -- overrides
> end Class;
> -----------------
> with Ada.Text_Io;
> use  Ada.Text_Io;
> package body Class is
>   procedure Operation (R : in Root) is
>   begin
>     Put_Line ("Root");
>   end Operation;
>   procedure Operation (D : in Derived) is
>   begin
>     Put_Line ("Derived");
>   end Operation;
> end Class;
> -----------------
> with Class;
> use  Class;
> procedure Tester is
>   R : Root;
>   D : Derived;

  procedure Renamed_Operation (XYZ: in Derived) renames Class.Operation;
  -- Operation is visible, because it's callable. So why should I not be
  -- able to rename it?

> begin
>   -- no dispatching calls
>   Operation (R);  -- visible
>   Operation (D);  -- derived, invisibly overridden

    Renamed_Operation (D);
> end Tester;

Christoph Grein
Member of Ada Germany
[log in to unmask]