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: border1.nntp.ams.giganews.com!nntp.giganews.com!weretis.net!feeder4.news.weretis.net!rt.uk.eu.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 08:02:58 +0200 Organization: Ada @ Home Message-ID: References: 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: number.nntp.dca.giganews.com comp.lang.ada:181475 Date: 2013-05-07T08:02:58+02:00 List-Id: Le Tue, 07 May 2013 02:56:34 +0200, Randy Brukardt = a =C3=A9crit: > We eventually realized that access discriminants already had the corre= ct = > semantics so we didn't need a new feature for that. I don't see how: package Storages is type Element_Type =E2=80=A6; -- With the real case, a generic pa= rameter. type Element_Access is access Element_Type; type Instance_Type (Element : Element_Access :=3D null) is limited private; function Create return Instance_Type; private type Instance_Type (Element : Element_Access :=3D null) is null record; -- With the real case, management data. function Create return Instance_Type is (Instance_Type'(Element =3D> null)); end Storages; S1 : Storages.Instance_Type :=3D Storages.Create; S2 : Storages.Instance_Type :=3D S1; -- Illegal. A : Storages.Element_Access :=3D S1.Element; -- However still lega= l. That makes the `Element` member constant (one of the thing I wanted); th= at = does not prevent from copying it. Implicit deference, even if it avoids = = direct use of the access member (syntactic sugar, not added safety, = although a good idea), does not prevent copying it neither, as it requir= es = to expose the access discriminant in the public part. I know no way to = prevent copying this member, except wrapping every use of the access = member in many functions and procedures or using reader/updater callback= s, = which is something I prefer to avoid; that's why I was looking at this A= I = about limited access types (didn't care enough for its status, sorry, I = = note this is indeed =E2=80=9CNo action=E2=80=9D). By the way as a side note, even if using a boolean discriminant for the = = storage allocation status is expressive, using null for the access and = that access as a discriminant, is more resilient, as an error with it wh= en = null, will be more surely caught at runtime whenever compiled without = validity checking, where a not=E2=80=91really existing member, thus retu= rning = probably not=E2=80=91null garbage, may have enough time to break somethi= ng before = being caught. -- = =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