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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.182.95.68 with SMTP id di4mr895990obb.4.1392310494004; Thu, 13 Feb 2014 08:54:54 -0800 (PST) X-Received: by 10.50.2.100 with SMTP id 4mr104978igt.8.1392310493762; Thu, 13 Feb 2014 08:54:53 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!c10no20594378igq.0!news-out.google.com!h8ni1igy.0!nntp.google.com!uq10no19064702igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 13 Feb 2014 08:54:53 -0800 (PST) In-Reply-To: <52fccf7b$0$6667$9b4e6d93@newsspool2.arcor-online.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: <52fccf7b$0$6667$9b4e6d93@newsspool2.arcor-online.net> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Procedure defined in package body accessed by separate procedure From: adambeneschan@gmail.com Injection-Date: Thu, 13 Feb 2014 16:54:53 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:18529 Date: 2014-02-13T08:54:53-08:00 List-Id: On Thursday, February 13, 2014 5:58:33 AM UTC-8, G.B. wrote: =20 > > package body Greetings is=20 > > procedure Hello is separate;=20 > > procedure Goodbye is separate;=20 > > procedure proc_body is > > begin > > put_line("body"); > > end; > > end Greetings; > > Greetings-Hello.ada: > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D > > with text_io; > > use Text_IO; > > separate (Greetings) > > procedure Hello is > > begin > > put_line("Hello"); > > Greetings.proc_body;--Compiler error here. Says proc_body is not de= clared in Greetings > > end; >=20 > Linearity of reading seems at work here: proc_body, in body > Greetings, appears after the line that says "Hello is > separate". Therefore, when that line is "evaluated", there > is no procedure proc_body (yet). Yes, that's the reason. The RM says (10.1.3(17)): "Visibility within a subunit is the visibility that would be obtained at th= e place of the corresponding body_stub (within the parent body) if the cont= ext_clause of the subunit were appended to that of the parent body." So that means that the things that are visible to Hello's separate body are= the same things that would be visible at the place the "procedure Hello is= separate" (the body stub) appeared. If there were a *new* "with" or "use"= clause on the separate body, that would make other things visible as well.= In this case, since there is already "with Text_IO; use Text_IO;" on the = body of Greetings, the WITH and USE on the body of Hello doesn't make anyth= ing else visible. (In fact, they're redundant and could be removed. My pe= rsonal preference is to include redundant WITH's and USE's anyway, so that = you don't have to flip between a bunch of source files to figure out what W= ITH's and USE's are in effect.) But anyway, if you wrote all of Hello inli= ne in the body of Greetings, instead of making it separate, you'd get the s= ame error on proc_body; therefore, the same error occurs in the separate bo= dy, since the same identifiers are visible. -- Adam