From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!seas.gwu.edu!mfeldman From: mfeldman@seas.gwu.edu (Michael Feldman) Newsgroups: comp.lang.ada Subject: Re: **** a simple example **** Message-ID: <2132@sparko.gwu.edu> Date: 16 Sep 90 02:51:09 GMT References: <794@babcock.cerc.wvu.wvnet.edu> Reply-To: mfeldman@seas.gwu.edu () Organization: The George Washington University, Washington D.C. List-Id: 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 ---------------------------------------------------------------------------