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 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!mx05.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Generic access type convention and aliasing Date: Tue, 07 May 2013 21:08:48 +0200 Organization: Ada @ Home Message-ID: References: <5a96b4f0-15d3-4fe2-9e9c-000f59b9c864@googlegroups.com> NNTP-Posting-Host: /5uFWkegPs0CGJSoRIUiIw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.15 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:15405 Date: 2013-05-07T21:08:48+02:00 List-Id: Le Tue, 07 May 2013 19:34:58 +0200, AdaMagica = a =C3=A9crit: > > This is not an access discriminant: Oops someone flagged=E2=80=A6, yes, sorry, I made multiple tests and did= not = notice when I posted (only later and too late). > > Access disciminants are uncopiable. If so, that's *very easily defeated*: procedure Foo is package Storages is type Element_Type is new Integer; type Instance_Type (Element : access Element_Type :=3D null) is limited private; function Create return Instance_Type; private I : aliased Element_Type; type Instance_Type (Element : access Element_Type :=3D null) is null record; function Create return Instance_Type is (Instance_Type'(Element =3D> I'Access)); end Storages; type Pool_Specific_Access is access Storages.Element_Type; type General_Access is access all Storages.Element_Type; S : Storages.Instance_Type :=3D Storages.Create; A1 : Pool_Specific_Access :=3D S.Element; -- Illegal. A2 : access Storages.Element_Type :=3D S.Element; -- However sti= ll = legal. A3 : General_Access :=3D S.Element; -- And the same. begin -- Foo A2.all :=3D 2; end Foo; Far from what limited access type would be. -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [1] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [1] [1]: Epigrams on Programming =E2=80=94 Alan J. =E2=80=94 P. Yale Univers= ity