comp.lang.ada
 help / color / mirror / Atom feed
* Main procedure inside a package?
@ 2006-05-03 12:40 wojtek
  2006-05-03 13:39 ` Pascal Obry
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: wojtek @ 2006-05-03 12:40 UTC (permalink / raw)


Hello,

Is it possible for the main procedure to be inside a package? The
compiler is GNAT.

--
Thanks,
Wojtek




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Main procedure inside a package?
  2006-05-03 12:40 Main procedure inside a package? wojtek
@ 2006-05-03 13:39 ` Pascal Obry
  2006-05-03 16:12   ` Jean-Pierre Rosen
  2006-05-03 16:04 ` Martin Dowie
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Pascal Obry @ 2006-05-03 13:39 UTC (permalink / raw)
  To: wojtek

wojtek@power.com.pl a �crit :
> Is it possible for the main procedure to be inside a package? The
> compiler is GNAT.

No, the main procedure must be a library level procedure. I think that
there is another restriction: this procedure should not have parameters
(I have no easy way to check that right now).

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Main procedure inside a package?
  2006-05-03 12:40 Main procedure inside a package? wojtek
  2006-05-03 13:39 ` Pascal Obry
@ 2006-05-03 16:04 ` Martin Dowie
  2006-05-03 16:47 ` Martin Krischik
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Martin Dowie @ 2006-05-03 16:04 UTC (permalink / raw)


wojtek@power.com.pl wrote:
> Hello,
> 
> Is it possible for the main procedure to be inside a package? The
> compiler is GNAT.

That would make your program potentially non-portable. The only form of 
main procedure" that is required to be supported is "However, an 
implementation is required to support all main subprograms that are 
public parameterless library procedures." (RM 10.2.27)
Cheers
-- Martin



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Main procedure inside a package?
  2006-05-03 13:39 ` Pascal Obry
@ 2006-05-03 16:12   ` Jean-Pierre Rosen
  2006-05-03 18:04     ` Frank J. Lhota
  2006-05-09  0:32     ` Robert A Duff
  0 siblings, 2 replies; 10+ messages in thread
From: Jean-Pierre Rosen @ 2006-05-03 16:12 UTC (permalink / raw)


Pascal Obry a �crit :
> wojtek@power.com.pl a �crit :
>> Is it possible for the main procedure to be inside a package? The
>> compiler is GNAT.
> 
> No, the main procedure must be a library level procedure. I think that
> there is another restriction: this procedure should not have parameters
> (I have no easy way to check that right now).
> 

Anything can be a main subprogram (the restriction was for 83), however 
only parameterless library procedures are guaranteed to be portable:

LRM 10.2(29):
An implementation may restrict the kinds of subprograms it supports as 
main subprograms. However, an implementation is required to support all 
main subprograms that are public parameterless library procedures.

How to define the main subprogram (including the case where it is not a 
library procedure) is implementation defined, i.e. RTFM!
-- 
---------------------------------------------------------
            J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Main procedure inside a package?
  2006-05-03 12:40 Main procedure inside a package? wojtek
  2006-05-03 13:39 ` Pascal Obry
  2006-05-03 16:04 ` Martin Dowie
@ 2006-05-03 16:47 ` Martin Krischik
  2006-05-04 20:28   ` Wojtek
  2006-05-03 19:41 ` Rolf
  2006-05-11  8:34 ` Sathish Veluswamy
  4 siblings, 1 reply; 10+ messages in thread
From: Martin Krischik @ 2006-05-03 16:47 UTC (permalink / raw)


wojtek@power.com.pl wrote:

> Is it possible for the main procedure to be inside a package? The
> compiler is GNAT.

No.

The compiler would not know which procedure should be main because the main
procedure can be called anything you like.

However It can be a child procedure to a package. I use this feature quite
often when I have packages just for one program. Works like this:

package My_Package is
end My_Package;

procedure My_Package.My_Main is
begin
 ....
end My_Package.My_Main;

Martin
-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Main procedure inside a package?
  2006-05-03 16:12   ` Jean-Pierre Rosen
@ 2006-05-03 18:04     ` Frank J. Lhota
  2006-05-09  0:32     ` Robert A Duff
  1 sibling, 0 replies; 10+ messages in thread
From: Frank J. Lhota @ 2006-05-03 18:04 UTC (permalink / raw)


Jean-Pierre Rosen wrote:
> Anything can be a main subprogram (the restriction was for 83), however 
> only parameterless library procedures are guaranteed to be portable:
> 
> LRM 10.2(29):
> An implementation may restrict the kinds of subprograms it supports as 
> main subprograms. However, an implementation is required to support all 
> main subprograms that are public parameterless library procedures.
> 
> How to define the main subprogram (including the case where it is not a 
> library procedure) is implementation defined, i.e. RTFM!

Even for Ada 83, a main program was not required to be a parameterless 
library procedure. I recall seeing at least one validated Ada 83 
compiler that also allowed the main program to be a library level 
parameterless function returning an integer. The result of such a 
function sets the return code of the resulting process.

For both Ada 83 and Ada 95, however, the only portable form for a main 
program is a library parameterless library procedure.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Main procedure inside a package?
  2006-05-03 12:40 Main procedure inside a package? wojtek
                   ` (2 preceding siblings ...)
  2006-05-03 16:47 ` Martin Krischik
@ 2006-05-03 19:41 ` Rolf
  2006-05-11  8:34 ` Sathish Veluswamy
  4 siblings, 0 replies; 10+ messages in thread
From: Rolf @ 2006-05-03 19:41 UTC (permalink / raw)


> Is it possible for the main procedure to be inside a package? The
> compiler is GNAT.

with My_Package;
procedure Main is begin My_Package.Main; end;




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Main procedure inside a package?
  2006-05-03 16:47 ` Martin Krischik
@ 2006-05-04 20:28   ` Wojtek
  0 siblings, 0 replies; 10+ messages in thread
From: Wojtek @ 2006-05-04 20:28 UTC (permalink / raw)


Thank you.




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Main procedure inside a package?
  2006-05-03 16:12   ` Jean-Pierre Rosen
  2006-05-03 18:04     ` Frank J. Lhota
@ 2006-05-09  0:32     ` Robert A Duff
  1 sibling, 0 replies; 10+ messages in thread
From: Robert A Duff @ 2006-05-09  0:32 UTC (permalink / raw)


Jean-Pierre Rosen <rosen@adalog.fr> writes:

> Pascal Obry a �crit :
> > wojtek@power.com.pl a �crit :
> >> Is it possible for the main procedure to be inside a package? The
> >> compiler is GNAT.
> > No, the main procedure must be a library level procedure. I think that
> > there is another restriction: this procedure should not have parameters
> > (I have no easy way to check that right now).
> 
> Anything can be a main subprogram (the restriction was for 83), however
> only parameterless library procedures are guaranteed to be portable:
> 
> LRM 10.2(29):
> An implementation may restrict the kinds of subprograms it supports as
> main subprograms. However, an implementation is required to support all
> main subprograms that are public parameterless library procedures.

True, but most Ada implementations support only the minimum required,
here -- no main functions, no parameters on main procedures, and no main
procedures nested in packages.

- Bob



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Main procedure inside a package?
  2006-05-03 12:40 Main procedure inside a package? wojtek
                   ` (3 preceding siblings ...)
  2006-05-03 19:41 ` Rolf
@ 2006-05-11  8:34 ` Sathish Veluswamy
  4 siblings, 0 replies; 10+ messages in thread
From: Sathish Veluswamy @ 2006-05-11  8:34 UTC (permalink / raw)


First u have to know that package cannot be executed directly. more
than that if u create a main procedure inside the package then the
compiler is unable to identify that main procedure and that main
procedure will be treated as a normal procedure inside that particular
package.




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-05-11  8:34 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-03 12:40 Main procedure inside a package? wojtek
2006-05-03 13:39 ` Pascal Obry
2006-05-03 16:12   ` Jean-Pierre Rosen
2006-05-03 18:04     ` Frank J. Lhota
2006-05-09  0:32     ` Robert A Duff
2006-05-03 16:04 ` Martin Dowie
2006-05-03 16:47 ` Martin Krischik
2006-05-04 20:28   ` Wojtek
2006-05-03 19:41 ` Rolf
2006-05-11  8:34 ` Sathish Veluswamy

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