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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9c8533728e8d73d0 X-Google-Attributes: gid103376,public From: evans@evans.pgh.pa.us (Arthur Evans Jr) Subject: Re: Please help a beginner! (second try) Date: 1996/02/19 Message-ID: #1/1 X-Deja-AN: 140059481 references: <4g517q$438@helios.herts.ac.uk> organization: Ada Consulting newsgroups: comp.lang.ada Date: 1996-02-19T00:00:00+00:00 List-Id: In article <4g517q$438@helios.herts.ac.uk>, kst1ju@herts.ac.uk (Ryan) wrote: > Could somebody please help me with what I am sure is a simple > problem. [snip] > > with TEXT_IO; > package INT_IO is new TEXT_IO.INTEGER_IO(INTEGER); > with INT_IO; > > procedure proc1 is > begin > TEXT_IO.PUT("Hello"); > -- fails ... "TEXT_IO not defined" > INT_IO.PUT(2); > -- accepted > end proc1; > > procedure main is > begin > TEXT_IO.PUT("Hello"); > -- fails ... "TEXT_IO not defined" > INT_IO.PUT(2); > -- fails ... "INT_IO not defined" > end main; We are taught to use white space, including vertical spacing, to make programs easier to read. Here's an interesting example where the use of white space has obscured what is actually happening. An Ada compiler interprets the above like this, where the only changes I have made are to layout: -------------------------------------------- -- 1st compliation unit with TEXT_IO; package INT_IO is new TEXT_IO.INTEGER_IO(INTEGER); -------------------------------------------- -- 2nd compilation unit with INT_IO; procedure proc1 is begin TEXT_IO.PUT("Hello"); -- fails ... "TEXT_IO not defined" INT_IO.PUT(2); -- accepted end proc1; -------------------------------------------- -- 3rd compilation unit procedure main is begin TEXT_IO.PUT("Hello"); -- fails ... "TEXT_IO not defined" INT_IO.PUT(2); -- fails ... "INT_IO not defined" end main; Now it's clear that "with TEXT_IO" applies to only the instantiation of TEXT_IO.INTEGER_IO and so TEXT_IO is not visible in the 2nd and 3rd units. Further, "WITH INT_IO" apllies to only the 2nd unit. Add some "with" clauses and all should be well. Art Evans Arthur Evans Jr, PhD Phone: 412-963-0839 Ada Consulting FAX: 412-963-0927 461 Fairview Road Pittsburgh PA 15238-1933 evans@evans.pgh.pa.us