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!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: When to use formal discrete type? Date: Wed, 29 Nov 2017 15:05:59 -0600 Organization: JSA Research & Innovation Message-ID: References: Injection-Date: Wed, 29 Nov 2017 21:06:00 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="28296"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:49265 Date: 2017-11-29T15:05:59-06:00 List-Id: "Victor Porton" wrote in message news:ovn0bv$1rto$1@gioia.aioe.org... ... > It there a noticeable difference in performance if I generalize? That clearly is compiler specific, and also specific to how the type is used. Janus/Ada, for example, uses generic sharing, so the code generated for a formal discrete type and a formal private type are very different. (In most cases, the formal private type will win, but not if there are a lot of components of that type). OTOH, GNAT generally uses template expansion. In such a case, the final code isn't much different than if you had written it yourself without using the generic. So it probably doesn't matter much. The main difference is the promise given to the instantator. A private type implies that any non-limited type will work (assuming that it has the operations given in the generic spec). So you may want to consider what happens if someone instantiates your generic with some record type. If that would be a real problem, then the formal discrete type would be better (as it better documents what actually works). Randy.