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.107.162.84 with SMTP id l81mr4457295ioe.21.1498231395328; Fri, 23 Jun 2017 08:23:15 -0700 (PDT) X-Received: by 10.157.73.140 with SMTP id g12mr215009otf.5.1498231395302; Fri, 23 Jun 2017 08:23:15 -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!185no249228itv.0!news-out.google.com!s132ni2919itb.0!nntp.google.com!f20no246805itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 23 Jun 2017 08:23:15 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=194.98.77.127; posting-account=F4OyugoAAABQod8iTn6AU7wMocsaGOvw NNTP-Posting-Host: 194.98.77.127 References: <1ac5a44b-4423-443a-a7bb-2864d9abe78f@googlegroups.com> <1498048151.20885.28.camel@obry.net> <96174ea5-852d-44e9-8535-7c1eb24d5326@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8d3aff06-82df-485f-89e5-a50c326aab05@googlegroups.com> Subject: Re: Ada Annoyances From: raph.amiard@gmail.com Injection-Date: Fri, 23 Jun 2017 15:23:15 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:47079 Date: 2017-06-23T08:23:15-07:00 List-Id: Le mercredi 21 juin 2017 18:12:53 UTC+2, Dmitry A. Kazakov a =C3=A9crit=C2= =A0: > On 2017-06-21 16:52, pytho...@gmail.com wrote: > > I definitely agree that performance is best measured, not guessed > > about. However, the way I see it, this restriction is (at least for my > > use case where I know I don't need tagged types) at best making the > > compiler work much harder to see that it can devirtualize the function > > calls and at worst making my code run slower with no benefit - other > > than providing a slightly nicer syntax. >=20 > In Ada there is no penalty of calling a "method" vs. a "free" function.= =20 > None, whatsoever. This per language type system design and different=20 > from C++. >=20 > I don't consider here the overhead of using any helper types/objects=20 > and/or class-wide objects. That has nothing to do with the type under=20 > consideration being tagged or not. >=20 > The penalty of a tagged type is only this: >=20 > 1. Space to keep the type tag > 2. By-reference passing only, even if the object is small. >=20 > --=20 > Regards, > Dmitry A. Kazakov > http://www.dmitry-kazakov.de Well that's really a strange way to put it:=20 1. In Ada you dispatch via going through the class wide type. But if you do= , then your call *will* go through a virtual table. 2. In C++ only virtual methods dispatch and go through the virtual table. T= he penalty on the type is exactly the same (by-ref passing and tag) 3. The ONLY thing that differs is the granularity of how you choose to disp= atch or not. In C++, this choice is made by the method's implementer. In Ad= a, it is made at the call-site by every caller. It could very well be argued that the C++ choice is a lot better. Most of t= he time, you never want to call a possibly dispatching method in without di= spatching. Ada gives you a little bit more flexibility, at the cost of bein= g much more error prone, because it's easy to make a non dispatching call i= nstead of a dispatching one. Not a good point for Ada !