* Re: Procedures and Functions
@ 1996-09-04 0:00 W. Wesley Groleau (Wes)
0 siblings, 0 replies; only message in thread
From: W. Wesley Groleau (Wes) @ 1996-09-04 0:00 UTC (permalink / 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
---------------------------------------------------------------------------
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1996-09-04 0:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-09-04 0:00 Procedures and Functions W. Wesley Groleau (Wes)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox