From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7d242658229865c X-Google-Attributes: gid103376,public From: Tucker Taft Subject: Re: Abstract Completion Question Date: 1999/03/05 Message-ID: <36DFF8BC.80853D3C@averstar.com>#1/1 X-Deja-AN: 451587773 Content-Transfer-Encoding: 7bit Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.burl.averstar.com References: <7bmjrp$5u5$1@plug.news.pipex.net> Content-Type: text/plain; charset=us-ascii Organization: AverStar (formerly Intermetrics) Burlington, MA USA Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-03-05T00:00:00+00:00 List-Id: Nick Roberts wrote: > > -- 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. A *is* a primitive operation of T2, because it overrides an inherited subprogram (RM95 3.2.3(7)). > ... Upon executing this program under > -- GNAT, Constraint_Error is raised. This behaviour could be a > -- 'surprise' for users (a nasty one). Comments? Perhaps you have run into a GNAT bug, or perhaps the Constraint_Error is due to some other error in your program. From a language point of view, the dispatching call should be going to the body of A containing the Put_Line. > ------------------------------------- > -- Nick Roberts > ------------------------------------- -- -Tucker Taft stt@averstar.com http://www.averstar.com/~stt/ Technical Director, Distributed IT Solutions (www.averstar.com/tools) AverStar (formerly Intermetrics, Inc.) Burlington, MA USA