title: When does generic instantiation occur (i.e., what does the word mean)?
body: <p>This question is based on a discussion (now deleted) in response to <a href="https://stackoverflow.com/q/9630086/827263">this question</a>.  It's more about terminology than actual programming semantics.</p>
  
  <p>What exactly is generic "instantiation"?  Does it occur at compile time or at run time?</p>
  
  <p>I'll refer to the <a href="http://www.ada-auth.org/standards/12rm/RM.pdf" rel="nofollow noreferrer">latest draft</a> of the Ada 2012 standard.</p>
  
  <p>The meaning of the term <em>generic_instantiation</em> is clear; it's a syntactic construct, something like</p>
  
  <pre><code>package Inst is new Generic_Package(This =&gt; That);
  </code></pre>
  
  <p>My question is about the verb "instantiate".</p>
  
  <p>I've always thought of "instantiation" as something that occurs at compile time.  It's the expansion of a generic template, and it occurs when the compiler encounters a <em>generic_instantiation</em> in a compilation unit.</p>
  
  <p>But other sources refer to "instantiation" taking place, at least optionally, at run time.</p>
  
  <p><a href="http://en.wikipedia.org/wiki/Generic_programming#Generics_in_Ada" rel="nofollow noreferrer">This Wikipedia article</a> says:</p>
  
  <blockquote>
    <p>To <em>instantiate</em> a generic unit, the programmer passes <em>actual</em>
    parameters for each formal. The generic instance then behaves just
    like any other unit. It is possible to instantiate generic units at
    run-time, for example inside a loop.</p>
  </blockquote>
  
  <p>which seems to imply that instantiation can occur either at compile time or at run time.  I think this is referring to the <em>elaboration</em> of the <em>generic_instantiation</em>, which does occur at run time -- but then, all elaboration occurs at run time, yes?</p>
  
  <p>I found it surprisingly difficult to get a definitive answer to this from the Ada RM.  There is no glossary entry (Annex N) for "instantiation" or "instantiate".</p>
  
  <p>The closest I could find was this statement in 12.2 (Generic Bodies) paragraph 2, under "Dynamic Semantics":</p>
  
  <blockquote>
    <p>The elaboration of a generic body has no other effect than to
    establish that the generic unit can from then on be instantiated
    without failing the Elaboration_Check.</p>
  </blockquote>
  
  <p>which <em>indirectly</em> implies that instantiation is a run-time event.</p>
  
  <p>Does the verb "instantiate" properly refer to a compile-time event (expanding a generic template)?  To a run-time event (elaborating a <em>generic_instantiation</em>)?  If the latter, what do we call the former?  Is the Ada RM as clear as it needs to be on this point?</p>