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.42.104.195 with SMTP id s3mr1061723ico.0.1383321994356; Fri, 01 Nov 2013 09:06:34 -0700 (PDT) X-Received: by 10.182.61.51 with SMTP id m19mr35110obr.30.1383321994293; Fri, 01 Nov 2013 09:06:34 -0700 (PDT) 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!o2no13960842qas.0!news-out.google.com!9ni3876qaf.0!nntp.google.com!i2no4973224qav.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 1 Nov 2013 09:06:34 -0700 (PDT) In-Reply-To: <398b83e9-3735-4c8d-a7e4-f4331bfc4f2b@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=RxNzCgoAAACA5KmgtFQuaU-WaH7rjnAO NNTP-Posting-Host: 66.126.103.122 References: <398b83e9-3735-4c8d-a7e4-f4331bfc4f2b@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <4228b8a5-2876-444f-babd-c5fb853446c9@googlegroups.com> Subject: Re: Why formal_part is not a declarative region? From: Adam Beneschan Injection-Date: Fri, 01 Nov 2013 16:06:34 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:17578 Date: 2013-11-01T09:06:34-07:00 List-Id: On Thursday, October 31, 2013 11:57:25 PM UTC-7, Maxim Reznik wrote: > Hi all, >=20 > I read ARM "8.1 Declarative Region" for good sleep. >=20 > I wounder why formal_part neither access_to_subprogram_definition isn't i= ncluded in list of declarative regions? >=20 > Consider next example: >=20 > type T is > access function (A : Integer) return > access function (A : Float) return Boolean; >=20 > According to ARM there is declarative region for T. It contains two decla= ration of A, but this is illegal. >=20 > What is wrong? I'm not sure if anything is "wrong", except that I tried your construct on = two compilers and neither one reported an error. But from the looks of thi= ngs in the RM, this should be an error. =20 If the parameter names were accessible to some other code, then we'd certai= nly want to make it an error, to avoid confusion. Consider this entry fami= ly case: protected body PT is entry E1 (for X in 1..5) (X : in out Integer) when True is begin ... end E1; end PT; Obviously, this should be illegal (although at least one compiler doesn't p= roduce an error message), since using X inside the entry body would be ambi= guous. If subprogram formal parts were made into their own declarative reg= ions, it would make it complicated to make code like this illegal. So it s= eems reasonable to say that both X declarations are part of the same declar= ative region, and are therefore illegal. Access-to-subprogram declarations are a little different, since as far as I= know, the parameter names are dummies--they can't be used for anything. (= I could be wrong, especially if they can now be used in predicates.) Howev= er, the syntax for access-to-subprogram declarations uses the same syntax r= ules and syntactic category names as regular subprogram declarations, and I= think it would be a pain to try to tweak the rules so that parameter lists= in access-subprogram declarations and other kinds of declarations are trea= ted differently. Clearly there's no pressing need to do so, since there's = almost no benefit to allowing the two parameter names to be the same in you= r example declaration. =20 -- Adam