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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,436e4ce138981b82 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-03-14 13:33:07 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!cycny01.gnilink.net!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny03.gnilink.net.POSTED!0e8a908a!not-for-mail From: Hyman Rosen User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: abstract sub programs overriding References: <1078776213.376775@master.nyc.kbcfp.com> <1078839257.157439@master.nyc.kbcfp.com> <5cmr40t76va200betf07b7bd6er05ltto9@4ax.com> <1078845298.702789@master.nyc.kbcfp.com> <0ipr40thtf86b520a0qdi003aj87gtuhd4@4ax.com> <1078849973.701176@master.nyc.kbcfp.com> <1078924150.268074@master.nyc.kbcfp.com> <1078934469.744922@master.nyc.kbcfp.com> <1078949096.760629@master.nyc.kbcfp.com> <1079013337.572283@master.nyc.kbcfp.com> <9_mdnfzBlfEC3M_d4p2dnA@comcast.com> In-Reply-To: <9_mdnfzBlfEC3M_d4p2dnA@comcast.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Sun, 14 Mar 2004 21:33:06 GMT NNTP-Posting-Host: 162.83.246.241 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny03.gnilink.net 1079299986 162.83.246.241 (Sun, 14 Mar 2004 16:33:06 EST) NNTP-Posting-Date: Sun, 14 Mar 2004 16:33:06 EST Xref: archiver1.google.com comp.lang.ada:6326 Date: 2004-03-14T21:33:06+00:00 List-Id: Robert I. Eachus wrote: > Hyman Rosen wrote: >>> procedure Initialize(Object: in out Child) is >>> begin >>> Object := (Parent_Type with ...); >>> Do_Something_Else(Object); >>> end Initialize; >> >> If I'm not mistaken, this code will cause Finalize to be called on Object >> before the assignment takes place, which means that it's possible for Finalize >> to be called on an object before any Initialize for it has completed. > > No. Why not? If Object is of a Controlled type, and this code is performing an assignment to it, doesn't that cause Finalize to be called on the object before the assignment takes place? > And what DK and I have been saying is that there is no problem, because > of the "two stage" initialization of Ada tagged types. OK, I'm going to leave this be for now because any examples I have tried to devise seem terribly contrived. If I can come up with a reasonable scenario, I'll post it. > So "down casting" to a child type in the body of the package which > declares the parent is not illegal as such. Note that I have never suggested downcasting to a child type. I have just suggested view converting to the parent's classwide type, and then calling a dispatching routine on this classwide type. I certainly don't know enough about Ada's elaboration order rules to know whether they would prevent the scenario I'm thinking of. I accept that the whole thing is unlikely.