From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Why forbid local generic instantiations?
Date: Tue, 29 Jan 2019 01:35:10 -0600
Date: 2019-01-29T01:35:10-06:00 [thread overview]
Message-ID: <q2ovnf$3vc$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: q2hasc$23g$1@dont-email.me
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" <spam.jrcarter.not@spam.not.acm.org> wrote in message
news:q2hasc$23g$1@dont-email.me...
> On 1/25/19 10:23 PM, Randy Brukardt wrote:
>> "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> 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
next prev parent reply other threads:[~2019-01-29 7:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-25 9:43 Why forbid local generic instantiations? joakimds
2019-01-25 16:36 ` Jeffrey R. Carter
2019-01-25 21:23 ` Randy Brukardt
2019-01-26 9:56 ` Jeffrey R. Carter
2019-01-29 7:35 ` Randy Brukardt [this message]
2019-01-25 21:34 ` Randy Brukardt
2019-01-26 11:11 ` G.B.
2019-01-28 11:43 ` joakimds
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox