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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada Annoyances Date: Thu, 22 Jun 2017 09:29:20 +0200 Organization: Aioe.org NNTP Server Message-ID: 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> NNTP-Posting-Host: vZYCW951TbFitc4GdEwQJg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 X-Notice: Filtered by postfilter v. 0.8.2 Content-Language: en-US Xref: news.eternal-september.org comp.lang.ada:47054 Date: 2017-06-22T09:29:20+02:00 List-Id: On 22/06/2017 00:45, pythoner6@gmail.com wrote: > On Wednesday, June 21, 2017 at 12:12:53 PM UTC-4, Dmitry A. Kazakov wrote: >> In Ada there is no penalty of calling a "method" vs. a "free" function. >> None, whatsoever. This per language type system design and different >> from C++. > > I would say the same is true of C++ In C++ calls to a method go through the virtual table. In Ada they never do because Ada is strongly typed. This gives you performance and type safety (LSP stuff etc) upon inheritance. Re-dispatch is evil from SW design POV. > Thanks for the clarifications - as mentioned in my previous post, I > think the main misconception I had was about when dynamic dispatch > happens: I rather naively assumed that dynamic dispatch happened > whenever tagged types were involved. It is controlled by the type, because see above, Ada is properly typed. The dispatch never happens on a tagged type T. It always do on a class-wide type T'Class, which is not tagged. T /= T'Class. > After reading this it sounds like using tagged types in Ada is quite > similar to dealing with classes in C++ (i.e. in C++, methods have the > implicit this parameter which is also only ever passed by reference). Not so much similar, C++ type system is broken in that respect. C++ does not distinguish T and T'Class. Semantically C++ class type is sometimes one and sometimes another. E.g. in a constructor or destructor it acts as T. Elsewhere it does as T'Class. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de