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-11 06:11:17 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp.abs.net!ash.uu.net!spool.news.uu.net!not-for-mail Date: Thu, 11 Mar 2004 09:10:36 -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: <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> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1079014276.527406@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@aphelion.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1079014276 9344 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:6236 Date: 2004-03-11T09:10:36-05:00 List-Id: Dmitry A. Kazakov wrote: > To dispatch vs. not has to be defined by solely the object type. This > is the only right way, IMO, and Ada conforms to it. "Has to be"? "The only right way"? That's simply your opinion. > Returning to your example, if Type is an abstract type, and > Derived_Type has to have File, accessed by Type via some dispatching > method, then File (a handle to) has to be initialized and opened at > the stage one, and the class-wide constructor of Type may safely use > it at the stage two. Right, but what if you didn't realize that, and didn't code this correctly? Presumably with File, you would get an exception, but there could be other types which would cause subtle errors that could go undetected until much later in the program. The question isn't how to do it right, but what happens when you do it wrong. C++ doesn't let you dispatch to the child in such a case, so the problem is noticed right away. If the parent actually needs some part of the child, that has to be coded explicitly, and that visibility makes an error much less likely.