[comp.lang.ada] Restrictions on Ada Main Programs

rh@MITRE-BEDFORD.ARPA (Rich Hilliard - Mitre Software Center) (12/01/86)

I always thought I understood Ada RM 10.1 (8):

	... An implementation may impose certain requirements on the
	parameters and on the result, if any, of a main program (these
	requirements must be stated in Appendix F).  In any case,
	every implementation is required to allow, at least, main
	programs that are parameterless procedures, and every main
	program must be a subprogram that is a library unit.


In particular, I thought "parameters" referred to run-time parameters
- those supplied in a call.  Now I find an implementation that rejects
generic instantiations of otherwise "parameterless" procedures owing
to the presence of a generic formal parameter (see below) and citing
this paragraph.  Is this a legitimate interpretation or merely an
implementor error?  


	generic 
	  Default : Integer := 10;
	procedure Generic_Install;


	procedure Generic_Install is 
	  Site_Selectable_Parameter : Integer;  
	begin
	  Site_Selectable_Parameter := Default;
	end Generic_Install;


	with Generic_Install;
	procedure Install is new Generic_Install;
	--  	  ^^^^^^^
	-- RM 10.1(8): instantiation install can not be a main program
	-- A parameterless integer function or procedure is required

Mendal@SIERRA.STANFORD.EDU (Geoff Mendal) (12/06/86)

The implementation is correct to reject your generic instantiation
as a main program.  A careful reading of LRM 10.1(8) shows that
only a SUBPROGRAM that is a library unit can be a main program.
While 10.1(2) allows generic instantations to be library units,
a subprogram is not the same as a generic instantiation.  Using the
syntagmas in 10.1(2) and the prose in 10.1(8) we find that only
a "proper" subprogram (not an instantiation) can be a main program.

However, I really like the attempt to use the instantiation.  Very
clever in any regard.

And now for the traditional leading question:

  The following compilation unit is compiled in the program library:
     generic
     procedure Main;
  Without deleting or explicitly "emptying" the program library, how
  can one compile a main program named "Main"?

gom (one of the "McKinsy brothers of Ada" as defined by EVB)
-------

rh@MITRE-BEDFORD.ARPA (Rich Hilliard - Mitre Software Center) (12/12/86)

Last week, I posted a question on Ada main programs (see end of this
message).  Geoff Mendal has pointed out to me that I goofed, he
writes:

	The implementation is correct to reject your generic
	instantiation as a main program.  A careful reading of LRM
	10.1(8) shows that only a SUBPROGRAM that is a library unit
	can be a main program.  While 10.1(2) allows generic
	instantations to be library units, a subprogram is not the
	same as a generic instantiation.  Using the syntagmas in
	10.1(2) and the prose in 10.1(8) we find that only a "proper"
	subprogram (not an instantiation) can be a main program.


Now, more questions:

There ARE compilers which accept generic instantiations as main
programs - that's what got me wondering about this in the first place.
Are such implementations non-conforming?

What is the rationale for distinguishing generic instantiations from
"first-class" library units?



> Subject: Restrictions on Ada Main Programs 
> Date: Mon, 01 Dec 86 11:01:53 EST
> From: Rich Hilliard - Mitre Software Center <rh>
> 
> I always thought I understood Ada RM 10.1 (8):
> 
> 	... An implementation may impose certain requirements on the
> 	parameters and on the result, if any, of a main program (these
> 	requirements must be stated in Appendix F).  In any case,
> 	every implementation is required to allow, at least, main
> 	programs that are parameterless procedures, and every main
> 	program must be a subprogram that is a library unit.
> 
> 
> In particular, I thought "parameters" referred to run-time parameters
> - those supplied in a call.  Now I find an implementation that rejects
> generic instantiations of otherwise "parameterless" procedures owing
> to the presence of a generic formal parameter (see below) and citing
> this paragraph.  Is this a legitimate interpretation or merely an
> implementor error?  
> 
> 
> 	generic 
> 	  Default : Integer := 10;
> 	procedure Generic_Install;
> 
> 
> 	procedure Generic_Install is 
> 	  Site_Selectable_Parameter : Integer;  
> 	begin
> 	  Site_Selectable_Parameter := Default;
> 	end Generic_Install;
> 
> 
> 	with Generic_Install;
> 	procedure Install is new Generic_Install;
> 	--  	  ^^^^^^^
> 	-- RM 10.1(8): instantiation install can not be a main program
> 	-- A parameterless integer function or procedure is required