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,56131a5c3acc678e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-09 00:22:14 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!tar-atanamir.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Question about OO programming in Ada Date: Tue, 09 Dec 2003 09:26:33 +0100 Message-ID: <7e1btv8eahe6eh5jhm33h6a4m2j24r0s1n@4ax.com> References: <5JmdnUF_9o_ABE-iRTvUrg@rapidnet.com> <1273941.m4G3ZzughP@linux1.krischik.com> NNTP-Posting-Host: tar-atanamir.cbb-automation.de (212.79.194.116) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1070958132 76007517 212.79.194.116 ([77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:3262 Date: 2003-12-09T09:26:33+01:00 List-Id: On Mon, 08 Dec 2003 11:55:02 -0600, Chad Bremmon wrote: >Dmitry A. Kazakov wrote: > >> On Mon, 08 Dec 2003 08:42:28 GMT, Hyman Rosen >> wrote: >> >>>Chad Bremmon wrote: >> >>>>Because Ada 95 is strongly typed, the compiler can figure out at compile >>>>time which function to call, based on the type. This ensures that >>>>dispatching is done during compile time. You still have the look and >>>>feel of polymorphism, without the non-deterministic nature of runtime >>>>dispatching. >>> >>>What makes you think that C++ is any different in this regard? >> >> C++ does not distinguish class-wide and specific types. The same >> object is treated as a class-wide or specific depending on the >> run-time call context. For example: >> >> class X >> { >> public : >> virtual void Foo (); >> virtual void Baz () >> { >> Foo (); >> } >> ... >> >> Is the call to Foo from Baz dispatching? The answer is, well, >> sometimes it will. Arguably C++ is not strongly typed because no type >> could be addressed to implicit "this" in Baz, and so to the actual >> type [*). > >This function would NEVER dispatch in Ada95. Unless the parameter to a >class is of a Tagged_Type'Class, there is no possibility for dynamic >runtime dispatcing, period. End of story. You can't get there! > >If you still disagree, code it up and show it to me! Alas, you are wrong. Ada 95 supports redispatch. It means that you can: procedure Baz (X : in out Object) is begin Foo (X'Class (Object)); -- This redispatches end Baz; IMO it is a breach of the concept which has to be closed. In rare cases when redispatch is actually needed Rosen trick would do the work. -- Regards, Dmitry Kazakov http://www.dmitry-kazakov.de