TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Proportional Font
Show Text Part by Default
Condense Mail Headers

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

Print Reply
Content-Transfer-Encoding:
8BIT
Sender:
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Subject:
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.
But...

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.

-Tuck

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
complaint).
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

http://home.T-Online.de/home/Christ-Usch.Grein
[log in to unmask]

ATOM RSS1 RSS2