!standard 10.02 (07) 99-03-21 AI95-00172/02 !class confirmation 96-11-16 !status work item 97-03-19 !status received 96-11-16 !priority High !difficulty Easy !subject Which units can be designated as a main program? !summary 99-03-21 A main subprogam is optional -- the implementation must provide a way to create and run an active partition with no main subprogram. A main subprogram must be a subprogram -- the implementation must report an error if the programmer somehow requests that a package or generic declaration be used as the main subprogram. An implementation, may, but need not, allow a subprogram declared within a package to serve as the main program. !question 99-03-21 RM95-10.2(7) states: "The user can optionally designate (in an implementation-defined manner) one subprogram as the main subprogram for the partition. A main program if specified, shall be a subprogram." Must there be a main subprogram? (No.) Can a package serve as a main program? (No.) !response 97-03-21 (See summary.) !appendix 99-03-21 !section 10.2(07) !subject Optional main subprogram? !reference RM95-10.2(7,7.a-d,23,34.e) !from Laurent Guerby 96-10-30 !keywords main subprogram, partition !reference 96-5738.a Laurent Guerby 96-10-30>> !discussion RM95-10.2(7) states: "The user can optionally designate (in an implementation-defined manner) one subprogram as the main subprogram for the partition. [...]" Does it mean that an implementation must provide a way to bind and link a program without a main subprogram (for example giving a package or a list of units)? Note that there's an ACVC 9XBASIC L test (LA1001F) checking: -- OBJECTIVE: -- CHECK THAT A PACKAGE CANNOT BE NAMED AS A MAIN PROGRAM. An implementation must provide a script that "compile and bind" each test, so I'm wondering that if the answer to my question is yes, this test may be invalid in Ada 95 (or may need some extra precision about what is actually checked). -- Laurent Guerby , Team Ada. "Use the Source, Luke. The Source will be with you, always (GPL)." **************************************************************** !section 10.2(07) !subject Optional main subprogram? !reference RM95-10.2(7,7.a-d,23,34.e) !from Laurent Guerby 96-10-30 !keywords main subprogram, partition !reference 96-5738.a Laurent Guerby 96-10-30 !from Bob Duff !reference 96-5741.a Robert A Duff 96-10-31>> !discussion > RM95-10.2(7) states: > > "The user can optionally designate (in an implementation-defined > manner) one subprogram as the main subprogram for the partition. [...]" > > Does it mean that an implementation must provide a way to bind and > link a program without a main subprogram (for example giving a package > or a list of units)? Yes. > Note that there's an ACVC 9XBASIC L test (LA1001F) checking: > > -- OBJECTIVE: > -- CHECK THAT A PACKAGE CANNOT BE NAMED AS A MAIN PROGRAM. > > An implementation must provide a script that "compile and bind" > each test, so I'm wondering that if the answer to my question is yes, > this test may be invalid in Ada 95 (or may need some extra precision > about what is actually checked). It is up to the implementation to decide how one specifies what the main subprogram is, and whether there is one. Since the usual case is to have a main subprogram, a -no-main switch might make sense, but the RM has nothing to say about that. - Bob **************************************************************** !section 10.2(07) !subject Optional main subprogram? !reference RM95-10.2(7,7.a-d,23,34.e) !keywords main subprogram, partition !reference 96-5738.a Laurent Guerby 96-10-30 !reference 96-5741.a Robert A Duff 96-10-31 !from Keith Thompson 96-11-08 !reference 96-5754.a Keith Thompson 96-11-8>> !discussion Laurent Guerby wrote: > RM95-10.2(7) states: > > "The user can optionally designate (in an implementation-defined > manner) one subprogram as the main subprogram for the partition. [...]" > > Does it mean that an implementation must provide a way to bind and > link a program without a main subprogram (for example giving a package > or a list of units)? Bob Duff replied: > Yes. I can understand a partition not having a main subprogram, but what does it mean for a program (e.g., one consisting of a single partition) not to have a main subprogram? I know of no implementations that support this kind of thing. **************************************************************** !section 10.2(07) !subject Optional main subprogram? !reference RM95-10.2(7,7.a-d,23,34.e) !keywords main subprogram, partition !reference 96-5738.a Laurent Guerby 96-10-30 !reference 96-5741.a Robert A Duff 96-10-31 !reference 96-5754.a Keith Thompson 96-11-8 !from Bob Duff !reference 96-5757.a Robert A Duff 96-11-9>> !discussion > I can understand a partition not having a main subprogram, but what does > it mean for a program (e.g., one consisting of a single partition) not > to have a main subprogram? I know of no implementations that support > this kind of thing. Well, if an implementation doesn't support main-subprogram-less programs, then it's not a correct implementation of Ada 95. RM-10.2(7) says so, and AARM-10.2(34.e) points out that this is an extension w.r.t. Ada 83. The purpose is for certain programs that do all their work in library packages, and tasks created by library packages. (And of course, as you note, it makes sense for shared passive partitions and so forth.) In any case, the run-time semantics is described in 10.2(10-17,25). Note "if there is one" in 10.2(12). - Bob **************************************************************** From: Robert Dewar Sent: Monday, March 22, 1999 9:32 AM it is worth mentioning the child unit case here (main program can be a child unit). **************************************************************** From: Robert I. Eachus Sent: Monday, March 22, 1999 10:04 AM Okay, will do, but I assume that the main program can only be a child of a library package or an instance of a generic subprogram due to other rules. Robert I. Eachus **************************************************************** From: Robert A Duff Sent: Monday, March 22, 1999 10:05 AM Several occurrences of "main program" (the Ada 83 term) should be "main subprogram", including one inside an RM quote. (By the way, I suggest that when quoting from the RM, everybody cut and paste from the on-line version, to avoid typos.) > An implementation, may, but need not, allow a subprogram declared > within a package to serve as the main program. The original e-mail isn't included in the AI. Did the questioner ask about this? My memory is that the questioner asked *only* about the optionality. It's not a good idea to answer questions that weren't asked, IMHO. The ARG isn't in the business of publishing random interesting facts about the RM. - Bob **************************************************************** From: Robert I. Eachus Sent: Monday, March 22, 1999 1:21 PM The original question was about an ACVC test which attempted to create a executable without a main program. I added the part about the subprogram within a package so that the AI didn't create more confusion than it eliminated, because it does answer the original question as worded. Saying that as the main program cannot be a package but can be part of one is even more confusing. Robert I. Eachus ****************************************************************