comp.lang.ada
 help / color / mirror / Atom feed
From: mfeldman@seas.gwu.edu (Michael Feldman)
Subject: Re: **** a simple example ****
Date: 16 Sep 90 02:51:09 GMT	[thread overview]
Message-ID: <2132@sparko.gwu.edu> (raw)
In-Reply-To: 794@babcock.cerc.wvu.wvnet.edu

In article <794@babcock.cerc.wvu.wvnet.edu> siping@cathedral.cerc.wvu.wvnet.edu (Siping Liu) writes:
>I am a beginer of ADA and I have a very simple question
                   ^^^ not to be fussy, but please spell it Ada, not ADA.
>which my book didn't tell me how to do it.
>
>At the top level, can I have one procedure calling another
>procedure? My book (software engineering with ada by Grady Booch)
>says so but my compiler tells me "proc1" is not declared:
It is OK, but since proc1 and proc2 are distinct compilation units, proc2
cannot "see" proc1 unless you make it visible with a context clause, i.e.
a "with". I compiled and ran the following under 3 different compilers
without any problems. Note that it makes no difference, in Ada, whether 
these two procedures are in distinct source files or in one file. Even if
they are in the same file Proc1 is not visible to Proc2 without the "with".
This is different from C, for example, where Proc1 would be visible if it
preceded Proc2 in the source file. Not in Ada, though.

with Text_IO;
procedure Proc1 is
  begin
    Text_IO.Put_Line("Procedure 1 was called OK");
  end Proc1;

with Text_IO;
with Proc1; -- NOTE THIS CONTEXT CLAUSE
procedure Proc2 is
  begin
    Text_IO.Put_Line("Procedure 1 is being called here");
    Proc1;
  end Proc2;

---------------------------------------------------------------------------
Prof. Michael Feldman
Department of Electrical Engineering and Computer Science
The George Washington University
Washington, DC 20052
202-994-5253
mfeldman@seas.gwu.edu
---------------------------------------------------------------------------

      parent reply	other threads:[~1990-09-16  2:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-09-14 22:38 **** a simple example **** Siping Liu
1990-09-15 13:47 ` stt
1990-09-16  2:51 ` Michael Feldman [this message]
replies disabled

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