From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,14aa27db81ce3b40 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!s20g2000vbp.googlegroups.com!not-for-mail From: Martin Newsgroups: comp.lang.ada Subject: Re: How to exit an Ada program with (unix shell) error code? Date: Tue, 5 May 2009 14:27:31 -0700 (PDT) Organization: http://groups.google.com Message-ID: <948d6a6b-d603-4e38-add2-50016c2dcc9d@s20g2000vbp.googlegroups.com> References: <49ba30c9-a1e6-4346-8618-d256f87ac301@s31g2000vbp.googlegroups.com> <8ef6052e-4f51-416b-bae7-ff83d7024267@t11g2000vbc.googlegroups.com> NNTP-Posting-Host: 81.156.240.174 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1241558851 3040 127.0.0.1 (5 May 2009 21:27:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 5 May 2009 21:27:31 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s20g2000vbp.googlegroups.com; posting-host=81.156.240.174; posting-account=g4n69woAAACHKbpceNrvOhHWViIbdQ9G User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.10) Gecko/2009042315 Firefox/3.0.10,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5697 Date: 2009-05-05T14:27:31-07:00 List-Id: On May 5, 9:31=A0pm, a...@anon.org (anon) wrote: > Martin. > > =A0 You misread RM 10.2 (29), its quoted below. > > Both of the subprograms types are valid and portable and even though > RM 10.2 (29) allows a vendor to restrict the main subprogram. Adacore > (GNAT) and IBM which follow the RM to the letter have decided to allow > and support both main subprograms types in Ada 83/95/2005 specs. > > Note: At this time Adacore and IBM are the only ones supporting Ada 2005. > > Now, in the GNAT design the "GNATBIND" process actually wraps the main > subprogram ( "procedure main" or a "function main return integer" ) withi= n > a function called "main" within a package called "ada_main". =A0And if th= e > "main" subprogram is a procedure, the binder function "main" calls this > procedure and returns the exit status which is normally set to zero unles= s it > is altered by "Ada.Command_Line.Set_Exit_Status". But if main subprogram > is a function type of partition, then the binder function "main" returns = the > value returned from the partition "function main" to the OS as the exit > status. To see this, just compile any program and then bind it. Check the > resulting output files "b~.adb" and its spec file before linking. > > Note: normally during linking the linker "GNATLINK" deletes the > binder source/object files. > > So both of these are valid in the RM. =A0It just that most programmers pr= efer > the "Procedure" type of partitions design. > > -- > -- main subprograms as a procedure > -- > procedure main is > =A0 begin -- main > =A0 =A0 =A0null ; > =A0 end main ; > -- > -- or main subprograms as a public parameterless function > -- > function main return integer is > =A0 begin -- main > =A0 =A0 =A0return ( 0 ) ; -- 0 :=3D normal exit status. > =A0 end main ; > > Ada RM -- quoted > > =A0 RM 10.2 Program Execution > =A0 =A0... > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Implementation Permiss= ions > =A0 =A0... > > 29 =A0 =A0An implementation may restrict the kinds of subprograms it supp= orts as > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ------------ > main subprograms. However, an implementation is required to support all m= ain > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ---------------- > subprograms that are public parameterless library procedures. > ----------- > > =A0 RM 10.1 Separate Compilation > > 1 =A0 =A0 A program unit is either a package, a task unit, a protected un= it, a > protected entry, a generic unit, or an explicitly declared subprogram oth= er > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0------------------------------ > than an enumeration literal. Certain kinds of program units can be separa= tely > compiled. Alternatively, they can appear physically nested within other > program units. You forgot to underline the important bit - "procedures". Not "subprograms", not "functions or procedures" - just "procedures". The _only_ subprogram that _must_ be supported is: procedure is ... Yes an implementation is free to support other forms (including functions) but they are not portable. Lord only know why your quoting 10.1 - it's nothing to do with main procedures. Cheers -- Martin