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 2002:a24:878c:: with SMTP id f134mr4684801ite.14.1546721205840; Sat, 05 Jan 2019 12:46:45 -0800 (PST) X-Received: by 2002:a9d:148:: with SMTP id 66mr1135885otu.5.1546721205733; Sat, 05 Jan 2019 12:46:45 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.am4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!k10no427769itk.0!news-out.google.com!v141ni336ita.0!nntp.google.com!k10no427767itk.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 5 Jan 2019 12:46:45 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=76.18.64.97; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 76.18.64.97 References: <2a6929c5-72fa-4d84-953a-44ea4597ab38@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <69ee6a46-237c-49d7-b17a-db7a549ba00a@googlegroups.com> Subject: Re: class wide iterable (and indexable) From: Shark8 Injection-Date: Sat, 05 Jan 2019 20:46:45 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 2925 X-Received-Body-CRC: 2095098053 Xref: reader01.eternal-september.org comp.lang.ada:55203 Date: 2019-01-05T12:46:45-08:00 List-Id: On Saturday, January 5, 2019 at 2:21:55 AM UTC-7, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > ... > > In real programs dispatch is rare, thus there is no overhead. > > This is probably true, but then interfaces are even more useless (they > provide nothing that could possibly be of value other than dispatch!). > > > I don't know which overhead Randy meant, though. Maybe, space overhead? > > That is not nearly close to what generics produce in GNAT... > > Dispatching is very expensive for interfaces, in that some form of search is > needed. (Note: I have no idea how GNAT implements them exactly.) It might be > possible to do some sort of link-time assignment of interface identifiers > and link-time tag construction to avoid some of that cost (at the cost of a > lot of space), but that would be such a complex and unusual project > (conventional linkers don't support anything like that) that I've always > considered it impraactical. There are some optimizations that can be done, these three papers show some interesting methods for resolving/optimizing dynamic-calls: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.53.1099&rep=rep1&type=pdf http://web.cs.ucla.edu/~palsberg/tba/papers/dean-grove-chambers-ecoop95.pdf https://scholarworks.umass.edu/cgi/viewcontent.cgi?article=1008&context=cs_faculty_pubs IIUC, the techniques also work in the presence of full-multi dispatch.