[comp.lang.ada] Generics: 'Retraction' and an example

emery@MITRE-BEDFORD.ARPA (Emery) (09/06/88)

Earlier I said: 
  "Furthermore, Verdix does NOT require that the body of a generic be
   compiled before its instantiation.  It is possible to write mutually
   dependent generics (each generic instantiates the other) in Verdix,
   where most compilers will gag on such code."

Wayne Wylupski and Dave Bakin replied, citing LRM 12.3(18):

  "Recursive generic instantiation is not allowed in the following
   sense:  if a given generic unit includes an instantiation of a
   second generic unit, then the instance generated by this
   instantiation must not include an instance of the first generic
   unit (whether this instance is generated directly, or indirectly
   by intermediate instantiations)."
  
They're right.  You can't do recursive generic instantiation.

However, here's an example of something that I can do on Verdix that
DEC and (some) other compilers do not like.  I believe this is legal Ada.  

package A is
  
  generic
  package B is
    function foo return integer;
  end B;
  
end A;

package body A is
  x : integer;
  
  package body B is separate;
  
  package my_b is new b;
  -- some compilers don't like this instantiation
  -- DEC (VMS 1.3-24) and Tartan (Sun 2.0) are two that don't 
  -- Verdix (Sun 5.5j) compiles this just fine.
begin
  x := my_b.foo;
end A;

separate (A)
package body B is
  function foo return integer is
  begin
    return 42;  -- life, the universe, and everything...
  end foo;
end B;
				
				dave emery
				emery@mitre-bedford.arpa

cjh@petsd.UUCP (Chris Henrich) (09/08/88)

In article <8809061331.AA11160@mitre-bedford.ARPA> emery@MITRE-BEDFORD.ARPA.UUCP writes:
>
>However, here's an example of something that I can do on Verdix that
>DEC and (some) other compilers do not like.  I believe this is legal Ada.  
I believe so too, and Concurrent Computer Corporation's compiler
seems to handle it correctly.
>
>package A is
>  
>  generic
>  package B is
>    function foo return integer;
>  end B;
>  
>end A;
>
>package body A is
>  x : integer;
>  
>  package body B is separate;
>  
>  package my_b is new b;
>  -- some compilers don't like this instantiation
>  -- DEC (VMS 1.3-24) and Tartan (Sun 2.0) are two that don't 
>  -- Verdix (Sun 5.5j) compiles this just fine.
>begin
>  x := my_b.foo;
>end A;
>
>separate (A)
>package body B is
>  function foo return integer is
>  begin
>    return 42;  -- life, the universe, and everything...
>  end foo;
>end B;
>				
>				dave emery
>				emery@mitre-bedford.arpa
Regards,
Chris

UUCP:       ...!rutgers!petsd!cjh            
Concurrent Computer Corporation is a Perkin-Elmer company.