From: "W. Wesley Groleau (Wes)" <wwgrol@PSESERV3.FW.HAC.COM>
Subject: Re: Procedures and Functions
Date: 1996/09/04
Date: 1996-09-04T00:00:00+00:00 [thread overview]
Message-ID: <9609041330.AA04703@most> (raw)
:> "with Text_Io; use Text_Io;
:> procedure one is
:> function one (...)return stuff is separate;
:> procedure two(...) is separatoe;
:> begin
:> ...
:> end one
:> begin
:> ...
:> end two"
:>
:> This bears no relation to correct Ada syntax. I suspect you should not
:> be using subunits at all at this stage of understanding.
If you saw half of the silliness R. Dewar has to put up with (including
at least one class-A screw-up from me) you'd be impressed with how nice
he is on the net.
I'll try to help a little, but what you really need is gnatinfo.txt AND
a good beginner's book on Ada. If you've done a lot of programming in
other languages, I suggest "Ada as a Second Language"
Also, since this is an Ada question and not a gnat question, I'm
transplanting the thread to the comp.lang.ada newsgroup. If you don't
have Usenet news, I'll tell you (by e-mail) how you can still participate
(also by e-mail).
So here's lesson one:
A procedure, function, package, or task can be defined in three ways.
Two of these ways only identify the item (and its parameters, for
subprograms). For functions, these are like this:
-- function specification:
function One ( Parameter : Parameter_Type ) return Result_Type;
-- function stub:
function One ( Parameter : Parameter_Type )
return Result_Type is separate;
-- function body:
function One ( Parameter : Parameter_Type )
return Result_Type is
begin
......
Note that all three are identical up to the "is" or ";"
GNAT wants only one compilation unit per file. A spec or a body can be
a compilation unit, or a spec, a stub, or a body can be BETWEEN the
"is" and "begin" of another body. A stub and a body for the same routine
can NOT be in the same area. A stub can not be a compilation unit, but
it indicates that the body IS a _separate_ compilation unit.
You'll have to check your book or one of the on-line tutorials for
other details.
---------------------------------------------------------------------------
W. Wesley Groleau (Wes) Office: 219-429-4923
Hughes Defense Communications (MS 10-40) Home: 219-471-7206
Fort Wayne, IN 46808 (Unix): wwgrol@pseserv3.fw.hac.com
---------------------------------------------------------------------------
reply other threads:[~1996-09-04 0:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox