From: "Nick Roberts" <Nick.Roberts@dial.pipex.com>
Subject: Abstract Completion Question
Date: 1999/03/04
Date: 1999-03-04T00:00:00+00:00 [thread overview]
Message-ID: <7bmjrp$5u5$1@plug.news.pipex.net> (raw)
-- Consider the following code:
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_1 is
package P1 is
type T1 is abstract tagged null record;
procedure A (X: in T1) is abstract;
end;
type T2 is new P1.T1 with
record
Data: String(1..10) := "***DATA***";
end record;
procedure A (X: in T2) is
begin
Put_Line(X.Data);
end;
type T1CA is access all P1.T1'Class;
Y: aliased T2;
Z: T1CA := Y'Access;
begin
P1.A(Z.all); -- dispatching call
end;
-- The operation "A" of type "T2" is overridden, so fulfilling the promise
-- of type "T1" (as far as Ada is concerned). This program compiles
-- and runs (GNAT 3.11p Win32), but nevertheless "A" is not a primitive
-- operation of "T2" (because it is not declared in a package spec), so
-- "A" cannot be dispatched to. Upon executing this program under
-- GNAT, Constraint_Error is raised. This behaviour could be a
-- 'surprise' for users (a nasty one). Comments?
-------------------------------------
-- Nick Roberts
-------------------------------------
next reply other threads:[~1999-03-04 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-04 0:00 Nick Roberts [this message]
1999-03-05 0:00 ` Abstract Completion Question Robert A Duff
1999-03-06 0:00 ` Nick Roberts
1999-03-05 0:00 ` Tucker Taft
1999-03-06 0:00 ` Nick Roberts
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox