comp.lang.ada
 help / color / mirror / Atom feed
From: Martin <martin.dowie@btopenworld.com>
Subject: Re: How to exit an Ada program with (unix shell) error code?
Date: Wed, 6 May 2009 02:14:42 -0700 (PDT)
Date: 2009-05-06T02:14:42-07:00	[thread overview]
Message-ID: <254636ac-f108-45b3-91c6-35bdae0ef562@o14g2000vbo.googlegroups.com> (raw)
In-Reply-To: r3cMl.200902$4m1.155197@bgtnsc05-news.ops.worldnet.att.net

On May 6, 9:41 am, a...@anon.org (anon) wrote:
> By your logic, who said procedures are portable!

Perhaps you could rephrase that into a meaning sentence?


>  Using RM 10.2 (29), a
> vendor could easily restrict the "main subprograms" to functions only.

No they can't - read the sentence begining "However". In fact, here it
is:

  "However, an implementation is required to support all main
   subprograms that are public parameterless library procedures."

Read it slowly. Read it repeatedly.

Here's a link to it:

http://www.adaic.org/standards/1zrm/html/RM-10-2.html


> And there is no definition in the RM that states a "main subprograms"
> subroutine must be a parameterless library procedure, either.

See above. Especially the link.


> So, its better to have and state that both subprogram types are portable. Then
> one can point out that the "main subprograms" that are procedures are more
> widely used in Ada.

That's would be lying, so probably better not to state this at all.



> In <948d6a6b-d603-4e38-add2-50016c2dc...@s20g2000vbp.googlegroups.com>, Martin <martin.do...@btopenworld.com> writes:
>
> >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~<name>.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 <Main_Subprogram_Name> 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.




  reply	other threads:[~2009-05-06  9:14 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-04  9:08 How to exit an Ada program with (unix shell) error code? reinkor
2009-05-04  9:17 ` Samuel Tardieu
2009-05-04  9:26   ` reinkor
2009-05-04  9:31     ` Ludovic Brenta
2009-05-04  9:47       ` reinkor
2009-05-04  9:54         ` Martin
2009-05-04 11:38           ` sjw
2009-05-04 10:07       ` stefan-lucks
2009-05-04 13:42     ` Robert A Duff
2009-05-04 16:19       ` Martin
2009-05-07  9:48         ` anon
2009-05-04 16:09 ` anon
2009-05-05 10:49   ` Rob Norris
2009-05-05 11:15     ` Georg Bauhaus
2009-05-05 11:43   ` Martin
2009-05-05 14:57     ` Adam Beneschan
2009-05-05 15:34       ` Jean-Pierre Rosen
2009-05-06 15:28         ` Adam Beneschan
2009-05-06 22:10           ` Randy Brukardt
2009-05-07  9:08           ` anon
2009-05-07 10:01             ` Georg Bauhaus
2009-05-07 11:22               ` anon
2009-05-07 12:08                 ` Martin
2009-05-07 13:34                 ` Georg Bauhaus
2009-05-07 16:26             ` Adam Beneschan
2009-05-08 10:17               ` anon
2009-05-12 22:55                 ` Adam Beneschan
2009-05-14  2:55                   ` anon
2009-05-14  8:04                     ` Martin
2009-05-14  8:39                     ` Martin
2009-05-14  8:45                       ` Martin
2009-05-14  9:34                       ` Ludovic Brenta
2009-05-14 10:05                         ` Martin
2009-05-14 12:38                           ` Georg Bauhaus
2009-05-14 15:34                     ` Adam Beneschan
2009-05-15 10:20                       ` anon
2009-05-15 11:19                         ` Martin
2009-05-05 20:48       ` anon
2009-05-05 21:01         ` Adam Beneschan
2009-05-06 11:30         ` Hibou57 (Yannick Duchêne)
2009-05-05 20:31     ` anon
2009-05-05 21:27       ` Martin
2009-05-06  8:41         ` anon
2009-05-06  9:14           ` Martin [this message]
2009-05-06 11:41             ` Georg Bauhaus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox