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!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: Why forbid local generic instantiations? Date: Tue, 29 Jan 2019 01:35:10 -0600 Organization: JSA Research & Innovation Message-ID: References: <100ce3ee-71f7-46c7-a24c-dc9c0d280c4f@googlegroups.com> Injection-Date: Tue, 29 Jan 2019 07:35:12 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="4076"; 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; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader01.eternal-september.org comp.lang.ada:55395 Date: 2019-01-29T01:35:10-06:00 List-Id: You're right in saying that there wouldn't be "more code than a usual package", but I'd also have complained had you said that "an ordinary package body has no run-time impact". In Ada, pretty much everything has a run-time impact (at least in the general case, there are specific cases that don't). Randy. "Jeffrey R. Carter" wrote in message news:q2hasc$23g$1@dont-email.me... > On 1/25/19 10:23 PM, Randy Brukardt wrote: >> "Jeffrey R. Carter" wrote in message >> news:q2fdui$9vn$1@dont-email.me... >> ... >>> Perhaps such people don't know that instantiation takes place during >>> compilation and has no run-time impact. >> >> I agree with most of what you said, but this statement is false, since >> the >> instance is elaborated at the point of the instantation. Depending on the >> generic, that could be a substantial amount of execution time. (Note that >> is >> even more true for a code-shared implementation like Janus/Ada, since the >> elaboration of the instance creates the instantiation descriptor.) > > I can't tell from what you've written if what I said is wrong or if we're > saying basically the same thing in different ways. I'm not familiar with > the way shared-code generics are instantiated. Macro-expansion > instantiation is straightforward. > > The rule I learned (Ada 83) was: Instantiation happens during compilation; > elaboration happens during run time. > > In more detail: Instantiation is the process whereby a compiler > effectively replaces an instantiation with a regular pkg (the instance). > The result is no different from having written the resulting regular pkg > instead of the instantiation, except for possible code sharing with other > instantiations of the same generic [ignoring the case of an instantiation > in a pkg spec]. > > All pkgs, regular or generic instances, are elaborated during run time. > That elaboration can be as complex as the developer wants. In the case of > a pkg in a subprogram, that elaboration happens every time the subprogram > is called. > > That's what I learned back when dinosaurs ruled the earth. I gather from > what you've written that a shared-code compiler may increase the amount of > elaboration by some (hopefully small, fixed?) amount, so it's not > technically correct unless the increase is small enough to be considered > negligible. I think it's correct for compilers that do macro-expansion > instantiation, and close enough for the rule to be correct as a 1st-order > approximation. > > If I'm wrong, I'd like to be corrected. > > -- > Jeff Carter > "I feel as though somebody stepped on my tongue > with muddy feet." > Never Give a Sucker an Even Break > 112