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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.157.31.24 with SMTP id x24mr907930otd.69.1498127386748; Thu, 22 Jun 2017 03:29:46 -0700 (PDT) X-Received: by 10.157.82.166 with SMTP id f38mr51557oth.8.1498127386715; Thu, 22 Jun 2017 03:29:46 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!f20no701898itb.0!news-out.google.com!s132ni1662itb.0!nntp.google.com!f20no701897itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 22 Jun 2017 03:29:46 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=68.114.51.240; posting-account=HN9B-woAAACqJDcuOavWYdk7s1Vm8fv7 NNTP-Posting-Host: 68.114.51.240 References: <1ac5a44b-4423-443a-a7bb-2864d9abe78f@googlegroups.com> <1498048151.20885.28.camel@obry.net> <96174ea5-852d-44e9-8535-7c1eb24d5326@googlegroups.com> <98b98b8b-2f56-4d14-9989-3df51b08d97e@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Ada Annoyances From: pythoner6@gmail.com Injection-Date: Thu, 22 Jun 2017 10:29:46 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:47055 Date: 2017-06-22T03:29:46-07:00 List-Id: On Thursday, June 22, 2017 at 3:29:23 AM UTC-4, Dmitry A. Kazakov wrote:=20 > In C++ calls to a method go through the virtual table. In Ada they never= =20 > do because Ada is strongly typed. This gives you performance and type=20 > safety (LSP stuff etc) upon inheritance. Re-dispatch is evil from SW=20 > design POV. C++ is also strongly typed (though one might consider Ada a bit more strong= ly typed), and the vtable is used only if a method is marked virtual. What do you mean by "re-dispatch" here? How is it different from the dynami= c dispatch that happens in Ada with class-wide types? > It is controlled by the type, because see above, Ada is properly typed.= =20 > The dispatch never happens on a tagged type T. It always do on a=20 > class-wide type T'Class, which is not tagged. T /=3D T'Class. Yes, this is exactly this (rather crucial) distinction I didn't really unde= rstand. Part of it I think was that the word class didn't have the right as= sociations in my mind, coming from C++ where a class is just one kind of ty= pe. In Ada it seems that class refers to a type and it's descendants, e.g. = a class of types. > Not so much similar, C++ type system is broken in that respect. C++ does= =20 > not distinguish T and T'Class. Semantically C++ class type is sometimes= =20 > one and sometimes another. E.g. in a constructor or destructor it acts=20 > as T. Elsewhere it does as T'Class. In C++ it is potentially more confusing, as something of type T is always e= xactly of type T (because it usually lives on the stack and therefore must = have a statically known size), but a reference or pointer to T might be of = a derived type. Whether or not a method is dynamically dispatched using the= vtable is determined by whether or not the method is marked as virtual. While I'm not so sure that I'd go so far to say that the C++ way is broken,= now that I understand how Ada works a bit better, I would probably agree t= hat Ada's solution is cleaner.