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,436e4ce138981b82 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-03-12 00:42:56 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!tar-meneldur.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: abstract sub programs overriding Date: Fri, 12 Mar 2004 09:53:36 +0100 Message-ID: References: <1078845298.702789@master.nyc.kbcfp.com> <0ipr40thtf86b520a0qdi003aj87gtuhd4@4ax.com> <1078849973.701176@master.nyc.kbcfp.com> <1078924150.268074@master.nyc.kbcfp.com> <1079014276.527406@master.nyc.kbcfp.com> <67u0505uu3gfmlt8p28e9jkaco0nljquut@4ax.com> <1079019616.621636@master.nyc.kbcfp.com> <1079026002.840030@master.nyc.kbcfp.com> NNTP-Posting-Host: tar-meneldur.cbb-automation.de (212.79.194.119) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1079080974 66873800 I 212.79.194.119 ([77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:6257 Date: 2004-03-12T09:53:36+01:00 List-Id: On Thu, 11 Mar 2004 12:26:28 -0500, Hyman Rosen wrote: >Dmitry A. Kazakov wrote: >> If that would be true, no C++ library would have Init() in each and >> other class. > >As you might already suspect, there is no paucity of poorly designed >C++ code, OO and otherwise. There is also a good deal of C++ that was >written for exception handling disabled, and used Init methods as a >way of detecting failure of construction. > >> But they cannot do it, when dispaching methods need to be called as a >> part of base specific object construction. > >Correct. This makes the chicken-and-egg problem visible to the programmer, >who must then code a workaround. This is C++ helping, not hindering. > >> It quite obvious: "To invoke a service from a derived type" is a more >> complicated way to say "to dispatch". But dispatching is possible on >> class-wide objects only. > >But the distinction between classwide objects and non-classwide objects >exists only in your universe. As a matter of fact, in Ada T and T'Class are different types. I tried to explain you that the problem with constructors in C++ is rooted in equalizing T and T'Class. That in your universe there is no such distinction does not mend the problem. >In Ada you can always view-convert an object >into its classwide type. Yes, this is why a two-stage construction is required for them. The point is very simple - each type needs a constructor. So when T is view-convertible to T'Class, then two constructors have to be applied: one of T, one of T'Class. In the constructor of T you cannot dispatch, in the constructor of T'Class you can do it safely. Observe that should Ada have classes for all types and user-defined constructors too, then for types having different representation of T and T'Class, the objects would be constructed only once by the type specific constructor, exactly how C++ does it. The class-wide constructor would be called only during conversion to T'Class, which would become a true conversion producing a new object. -- Regards, Dmitry Kazakov www.dmitry-kazakov.de