TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced 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:
Thu, 15 Jul 1999 09:52:10 +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 (120 lines)
Stanley Allen schrieb:
>
> ------------------------------------------------------------
> package Pack2 is
>
>     type Basic (<>) is abstract tagged limited private;
>
>     procedure Increment (B : in out Basic'Class);
>
>     procedure Operation (B : in out Basic) is abstract;
>
> private
>
>     type Basic is abstract tagged limited
>         record
>             Item : Integer;
>         end record;
>
> end Pack2;
>
> package body Pack2 is
>
>     procedure Increment (B : in out Basic'Class) is
>     begin
>         B.Item := B.Item + 1;
>     end Increment;
>
> end Pack2;
>
> package Pack2.Child is
>
>     type Fancy (N : access Integer) is new Basic with private;
> -------------------------------------------^
> --  Fancy is derived from an unconstrained type, in this view
> --
> --  COMPILER A complains, referencing RM95 3.7(13)
> --  COMPILER B accepts, here is a comment from vendor B:
> --
> --  "COMPILER B is correct here, the declaration of derived
> --  type Fancy in your example is legal.  The full type is
> --  derived from a constrained view of the parent type and
> --  doesn't violate the stated rule."
> --
> --  COMPILER B reports an error if Fancy is not a private type,
> --  but is declared instead as this:


OK, I'm no language lawyer, but my two € cents:

> --
> --  type Fancy (N : access Integer) is new Basic with null record;
> --

This declaration is illegal in any case because there is no private part
which could provide values for the unknown discriminants.

This might also be the solution of the problem, because ultimately the full
view describes the objects of the type, the partial view only describes
what clients may do to and with the object.

Thus a derivation like Fancy in a non-child package should also be impossible
because there in the private part no values for the unknow discriminants
can be supplied because they're invisible.

In the child's private part, the unknown discriminants are visible and thus
values can be provide (in your example, there are none, but that's irrelevant).

As I said, my 2 € (Euro) cents.

>     type Fancy_Ptr is access all Fancy'Class;
>
>     function New_Fancy (Init : access Integer) return Fancy_Ptr;
>
>     procedure Operation (F : in out Fancy);   -- override
>
> private
>
>     type Fancy (N : access Integer) is new Basic with null record;
> -------------------------------------------^
> --  Fancy is derived from a constrained type, in this view
> --
>
> end Pack2.Child;
>
> package body Pack2.Child is
>
>     function New_Fancy (Init : access Integer) return Fancy_Ptr is
>         Temp : Fancy_Ptr;
>     begin
>         Temp := new Fancy (N => Init);
>         Basic (Temp.all).Item := Init.all;
>         return Temp;
>     end New_Fancy;
>
>     procedure Operation (F : in out Fancy) is
>     begin
>         null;
>     end Operation;
>
> end Pack2.Child;
> ---------------------------------------------------------------


                                 o     _      _          _
 --------- __o       __o      /\_    _ \\o   (_)\__/o   (_)
 ------- _`\<,_    _`\<,_    _>(_)  (_)/<_     \_| \    _|/' \/
 ------ (_)/ (_)  (_)/ (_)  (_)         (_)    (_)     (_)'  _\o_
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mein Radunfall
My bike accident


Christoph Grein
Mitglied von Ada-Deutschland
Member of Ada Germany
http:/www.ada-deutschland.de

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

ATOM RSS1 RSS2