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.186.105 with SMTP id fj9mr2331040obc.5.1392359407233; Thu, 13 Feb 2014 22:30:07 -0800 (PST) X-Received: by 10.50.82.98 with SMTP id h2mr22479igy.3.1392359407073; Thu, 13 Feb 2014 22:30:07 -0800 (PST) Path: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!uq10no19880598igb.0!news-out.google.com!h8ni8igy.0!nntp.google.com!c10no21410793igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 13 Feb 2014 22:30:06 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=217.156.151.254; posting-account=hmWHQgoAAACLFyAR0aQ0yGOulYRXLN_V NNTP-Posting-Host: 217.156.151.254 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: ashwath30jul77@gmail.com Injection-Date: Fri, 14 Feb 2014 06:30:07 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Original-Bytes: 4004 Xref: number.nntp.dca.giganews.com comp.lang.ada:184849 Date: 2014-02-13T22:30:06-08:00 List-Id: On Thursday, February 13, 2014 10:24:53 PM UTC+5:30, adambe...@gmail.com wr= ote: > On Thursday, February 13, 2014 5:58:33 AM UTC-8, G.B. wrote: >=20 > =20 >=20 > > > package body Greetings is=20 >=20 > > > procedure Hello is separate;=20 >=20 > > > procedure Goodbye is separate;=20 >=20 > > > procedure proc_body is >=20 > > > begin >=20 > > > put_line("body"); >=20 > > > end; >=20 > > > end Greetings; >=20 >=20 >=20 > > > Greetings-Hello.ada: >=20 > > > =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 >=20 > > > with text_io; >=20 > > > use Text_IO; >=20 > > > separate (Greetings) >=20 > > > procedure Hello is >=20 > > > begin >=20 > > > put_line("Hello"); >=20 > > > Greetings.proc_body;--Compiler error here. Says proc_body is not = declared in Greetings >=20 > > > end; >=20 > >=20 >=20 > > Linearity of reading seems at work here: proc_body, in body >=20 > > Greetings, appears after the line that says "Hello is >=20 > > separate". Therefore, when that line is "evaluated", there >=20 > > is no procedure proc_body (yet). >=20 >=20 >=20 > Yes, that's the reason. The RM says (10.1.3(17)): >=20 >=20 >=20 > "Visibility within a subunit is the visibility that would be obtained at = the place of the corresponding body_stub (within the parent body) if the co= ntext_clause of the subunit were appended to that of the parent body." >=20 >=20 >=20 > So that means that the things that are visible to Hello's separate body a= re 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 "us= e" clause on the separate body, that would make other things visible as wel= l. In this case, since there is already "with Text_IO; use Text_IO;" on th= e body of Greetings, the WITH and USE on the body of Hello doesn't make any= thing else visible. (In fact, they're redundant and could be removed. My = personal preference is to include redundant WITH's and USE's anyway, so tha= t you don't have to flip between a bunch of source files to figure out what= WITH's and USE's are in effect.) But anyway, if you wrote all of Hello in= line in the body of Greetings, instead of making it separate, you'd get the= same error on proc_body; therefore, the same error occurs in the separate = body, since the same identifiers are visible. >=20 >=20 >=20 > -- Adam Thanks for response Adam. Is this compiler specific?It seems to compile when Tartan compiler is used = :S