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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fba93c19bb4e7dbd,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-11 01:18:01 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!news.eusc.inter.net!boavista.snafu.de!news From: Michael Erdmann Newsgroups: comp.lang.ada Subject: Q: Endless loop by dispatching Date: Fri, 11 Jul 2003 10:22:54 +0200 Organization: [Posted via] Inter.net Germany GmbH Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.eusc.inter.net 1057911409 3933 213.73.70.234 (11 Jul 2003 08:16:49 GMT) X-Complaints-To: abuse@eusc.inter.net User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en Xref: archiver1.google.com comp.lang.ada:40185 Date: 2003-07-11T10:22:54+02:00 List-Id: Dear all, i got a problem with the following code fragment below. The Idea is that the procedure Serialize defines the strategy how to display object which are derived from A.Object. Searialize simply dispatches into the class by calling a procedure Write, which does the job for the class. package A is type Object is tagged record P1 : Natural := 1; P2 : Natural := 2; end record; procedure Write( This : in Object ); procedure Serialize( This : in Object'Class ); end A; package body A is procedure Serialize( This : in Object'Class ) is begin Write( This ); end Serialize; procedure Write( This : in Object ) is begin Put_Line( "P1 =" & Natural'Image( This.P1 ) ); Put_Line( "P2 =" & Natural'Image( This.P2 ) ); end Write; end A; In the following fragment i am defining a package B with an derived objec B.Object as below. When an instance of B.Object shall be serialized, the element of the super class (A.Object) shall be serialzed as well. The code looks nice and compiles but does not work, since the Serialize dispatches again with Object.B even ther was a a case given A.Object( This ). package B is type Object is new A.Object with record Q : Natural := 2; end record; procedure Write( This : in Object ); end B; .......... package body B is procedure Write( This : in Object ) is begin A.Serialize( A.Object( This ) ); Put_Line( "Q =" & Natural'Image(This.Q)); end Write; end B; Does any body know, what this loop causes?! I am not sure if this is a bug or simply i missed the point. Michael