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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,29d8139471e3f53e X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Preventing type extensions Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <87iq2bfenl.fsf@mid.deneb.enyo.de> <81799aab-a2e8-4390-8f42-abceaa5fc032@m1g2000vbh.googlegroups.com> <5c0d7798-ba09-4bd0-a28f-f1b028cce927@y3g2000vbm.googlegroups.com> <9df21c09-f611-4088-811c-c092452adffc@e20g2000vbn.googlegroups.com> <37ae2382-9f7d-4790-be5f-e380b9220d75@s19g2000vbr.googlegroups.com> <170a6a4f-d441-4f86-8fbf-8f15da34a094@26g2000yqv.googlegroups.com> Date: Fri, 8 Oct 2010 22:12:34 +0200 Message-ID: <15tfsmrui4zdx.1juxzginm2o0j$.dlg@40tude.net> NNTP-Posting-Date: 08 Oct 2010 22:12:32 CEST NNTP-Posting-Host: 2555f5d0.newsspool3.arcor-online.net X-Trace: DXC=2H21]k5baD9RadXUBHgFh3McF=Q^Z^V384Fo<]lROoR18kFT\^nE^;m9[6LHn;2LCV>[WjD;;HOC0mh^Ff`5 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:14451 Date: 2010-10-08T22:12:32+02:00 List-Id: On Fri, 8 Oct 2010 06:58:14 -0700 (PDT), Cyrille wrote: >> Not at all, in other languages either a subprogram is a method (part of >> the dispatch table), or it applies to a single type. Class-wide >> operations are not dispatched, but still can be applied to a whole >> hierarchy. OK, I dismiss "void *" parameters... > > Looks to me this is the other way around. for instance, in C++ either > a subprogram is a method or it is what you call a class-wide > operation. or a free function. 1. method = polymorphic on the class (=primitive in Ada) 2. class-wide = non-polymorphic on the class (=class-wide in Ada) 3. free = non-polymorphic on the type (=other in Ada) > That is to say, when your subprogram has a (ref) parameter > of class C, you can pass it an object of any subclass of C and natural > calls to method of that object will dispatch to the appropriate one. True, but it is not T, it is T&. Just like T'Class is not T in Ada, T& is not T in C++. It is rather so that C++ does not have specific types for dispatching (covariant) operations. Except than in constructors and destructors, implicit "*this" is "class-wide". In constructor and destructor "*this" is type-specific. Explicit arguments and results are class-wide when references. They are type-specific otherwise. I.e. the behavior is determined not only by the type but also by the context... Isn't Ada's model much more simple and consistent than the above mess? > Note also that C++ offers a choice between static dispatch and dynamic > dispatch. I find it misleading. IMO there is only one dispatch, that is when the method's implementation is selected according to the type tag. Whether the tag is statically known or not is IMO irrelevant. An explicit call to a function in the form T::f() is not dispatch to me, it is a call to a free function named T::f(). -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de