Re: An improved Ada?
From: Matthew Heaney (mheaney_at_on2.com)
Date: 09/29/04
- Next message: Robert Kawulak: "Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl)"
- Previous message: Mark Lorenzen: "Re: Formal and informal type systems?"
- In reply to: jn: "Re: An improved Ada?"
- Next in thread: Randy Brukardt: "Re: An improved Ada?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 29 Sep 2004 14:26:30 -0400
"jn" <jonas.nygren@telia.com> wrote in message
news:311c6b78.0409290905.15ae255d@posting.google.com...
>
>
> package A is
> type X is tagged private;
> type Y is new X with private;
> type Z is new X with private;
>
> type X_Ref is access all X'Class;
> type Y_Ref is access all Y'Class;
> type Z_Ref is access all Z'Class;
>
> function X_A (Xa : access X) return Y_Ref;
> function Z_A (Zv : Z) return Y_Ref;
> private
> type X is tagged
> record
> Xr : X_Ref;
> end record;
> type Y is new X with null record;
> type Z is new X with null record;
> end A;
>
> package body A is
> function X_A (Xa : access X) return Y_Ref is
> begin return null; end;
> function Z_A (Zv : Z) return Y_Ref is
> begin return null; end;
> end A;
>
> with A;
> package B is
> type Y is new A.Y with private;
> type Y_Ref is access all Y'Class;
> type Z is new A.Z with private;
>
> function Y_A (
> Ya : access Y )
> return Integer;
> private
> type Y is new A.Y with
> record
> Value : Integer;
> end record;
> type Z is new A.Z with null record;
> end B;
>
> with A;
> with B;
> procedure T is
> Z : B.Z;
> Yr : B.Y_Ref;
> begin
> Yr := B.Y_Ref ( B.Z_A (Z) );
> Yr := B.Y_Ref (A.X_A (A.X_Ref (Yr)));
> -- why not:
> -- Yr := B.Z_A (Z);
> -- B.Y is a descendant of A.Y that is a descendant of A.X
> -- ret value 'tag' could be checked against Yr tag
> -- why don't the compiler do it, why do I have to do it explicitly
Well, obviously this is wrong. Operation B.Z_A returns type A.Y_Ref, not
B.Y_Ref.
> --
> -- why not:
> -- Yr := B.X_A (Yr);
> -- again, B.Y is a descendant of A.Y that is a descendant of A.X
> -- why is not B.X_A visible, X_A should have been inherited
> -- when A.X_A (Yr) is called, why is not the called dispatched?
> -- I have to convert B.Y_Ref to A.X_Ref explicitly
> -- and again I explicitly have to convert return type
> -- from A.X_Ref to B.Y_Ref, a completely safe conversion
Well, obviously this is wrong. There is no operation X_A that returns type
B.Y_Ref declared in package B. You must be confusing this with the
inherited operation X_A that returns type A.Y_Ref.
- Next message: Robert Kawulak: "Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl)"
- Previous message: Mark Lorenzen: "Re: Formal and informal type systems?"
- In reply to: jn: "Re: An improved Ada?"
- Next in thread: Randy Brukardt: "Re: An improved Ada?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|