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 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-11 08:17:35 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!eusc.inter.net!news.eusc.inter.net!boavista.snafu.de!news From: Michael Erdmann Newsgroups: comp.lang.ada Subject: Re: Endless loop by dispatching Date: Fri, 11 Jul 2003 17:19:06 +0200 Organization: [Posted via] Inter.net Germany GmbH Message-ID: <3F0ED56A.9090807@snafu.de> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.eusc.inter.net 1057936654 11962 213.73.70.131 (11 Jul 2003 15:17:34 GMT) X-Complaints-To: abuse@eusc.inter.net To: Jean-Pierre Rosen User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en In-Reply-To: Xref: archiver1.google.com comp.lang.ada:40198 Date: 2003-07-11T17:19:06+02:00 List-Id: Jean-Pierre Rosen wrote: > > You missed the point :-) > I understood this mean while. It seems that the case A.Object(This) does not change the tag. I have checked the RM but i found nothing, but this seems to be accepted as normal behaviour in the community. > Serialize is a general entry point, which dispatches to Write. If you call it again from Write, it will redispatch > to Write, hence the loop. > > Now do you think that Write of B is really Serialize of A, plus something else? > Isn't it *Write* of A, plus something else? If you change your package to > > package body B is > > procedure Write( > This : in Object ) is > begin > A.Write( A.Object( This ) ); > Put_Line( "Q =" & Natural'Image(This.Q)); > end Write; > > end B; > > It will be OK. > > Oh, by the way, why do you need Serialize at all? Since all it does is call Write, why don't you > call Write directly? > Maybe the conseded code i have sent was missleading. Since the procedure Serialize is intended to do more then just i put it here as pseudocode: procedure Serialze( this : in Object'Class ) is Serialize( Super( This ) ); F := Get( Attribute( this'Tag ) ) while F /= null loop Unbounded_String'Output( S, F.Name ); Write( This, F.Id ); F := Next(...); end loop; end Serialize: Using write directly is possible but then i have to put the code of serialze everwhere were i want to do the trick. I there would be something like the Super operation yielding the references to the super class then everthing would be fine, i guess! Michael