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-18 07:04:16 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!news.octanews.net!ash.uu.net!spool.news.uu.net!not-for-mail Date: Thu, 18 Mar 2004 10:03:57 -0500 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: <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> <1079361579.900651@master.nyc.kbcfp.com> <105f2jql5ge7f0a@corp.supernews.com> <105h3dkion79348@corp.supernews.com> <3vydndmUiYRplsTdRVn-sQ@comcast.com> <105ieithg52qo74@corp.supernews.com> In-Reply-To: <105ieithg52qo74@corp.supernews.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1079622255.263633@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@nightcrawler.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1079622255 10331 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:6409 Date: 2004-03-18T10:03:57-05:00 List-Id: Randy Brukardt wrote: >>What you as an author want is that any object that is correctly >>initialized will be finalized, that any object which is not initialized >>will not be finalized, and there are no objects in the middle. > > Right, but that's a tough property to guarentee, particularly if you want to > to be reasonably secure from abort and the like. C++ does its best to guarantee this, but will abort the program if, during the automatic destruction of objects as a result of a thrown exception, another exception propagates out of one of these destructors. There's only so much you can do in cases like that. Even Ada raises a program error in such cases. But if you write your destructors so that exceptions can never escape (which is the recommended style, because throwing an exception out of a function "means" that the function cannot fulfill its duty, whereas a destructor has no choice in the matter, since the object is being destroyed regardless of what the destructor thinks about it), then C++ provides that guarantee - objects are constructed once and any object which is constructed will be destructed. (Barring manual intervention, of course.) > I think it is best to depend primarily of a valid flag The problem with a valid flag is that it pushes the responsibility for validity testing out to all the methods. One of the goals of having a constructor in OO was to localize object construction in one place, so every other method could assume that the object was in a consistent and valid state. > (For someone who claims to not know Ada very well, Hyman knows Ada very > well. He should join the ARG. :-) We could use him.) :-) It's mostly that I understand in pretty excruciating detail how things work in C++ (and in Java, to some extent), and the reasons for those behaviors. When I see that Ada does something differently, I can try to figure out whether those reasons will have an effect that C++ was designed to avoid. (Note that I'm not claiming C++ is better, I'm just comparing effects of different decisions.)