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.140.161.6 with SMTP id h6mr61325084qhh.1.1448962732809; Tue, 01 Dec 2015 01:38:52 -0800 (PST) X-Received: by 10.182.148.165 with SMTP id tt5mr684758obb.20.1448962732776; Tue, 01 Dec 2015 01:38:52 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!f78no5085947qge.1!news-out.google.com!l1ni1121igd.0!nntp.google.com!mv3no6973760igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 1 Dec 2015 01:38:52 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=94.107.233.114; posting-account=6m7axgkAAADBKh082FfZLdYsJ24CXYi5 NNTP-Posting-Host: 94.107.233.114 References: <3d45e3ed-16ca-4018-bf7b-62830acaca03@googlegroups.com> <44e20a95-703c-4316-8dda-aa2c8d07dfb1@googlegroups.com> <29d3244c-1769-4cb7-8af3-e1b20eb2e1e2@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <925a7e3b-1234-4572-befb-4fa60667f8c3@googlegroups.com> Subject: Re: accessibility check failed From: Serge Robyns Injection-Date: Tue, 01 Dec 2015 09:38:52 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:28610 Date: 2015-12-01T01:38:52-08:00 List-Id: On Tuesday, 1 December 2015 00:22:50 UTC+1, Randy Brukardt wrote: > You rarely need explicit access types in an Ada interface, as "in out T" = and=20 > "access T" are essentially the same for any tagged type T. Ada always all= ows=20 > taking 'Access (or 'Unchecked_Access) of a tagged type parameter. Initially I was using in/out and then I wanted to uni-formalize the interfa= ce because I need to take the access somewhere. Now I'm rewriting it as pe= r some previous suggestion without requiring to store the access parameter. The only thing I do now wished it would be possible is to use multiple inhe= ritance when merging all DOA class implementing their respective interfaces= (in plural). type abstract_interface is new limited interface and I1 and I2 and ....; -- Below is not Ada type concrete is new abstract_interface with I1_Impl and I2_Impl and ...; Now I'm using mixin's but this require to write all overrides to call their= respective implementations. type concrete is new abstract_interface with record I1 : T_I1_Impl; I2 : T_I2_Impl; .... end record; > Claw ("Class Library for Ada and Windows", see rrsoftware.com) uses almos= t=20 > no access types in its public interface, yet almost everything is=20 > referential under the covers. Works fine, and puts all of the pain on the= =20 > implementor of the library (where it belongs) and not on the clients (lik= e=20 > access types do). (The one place where we had to use an access type was i= n a=20 > single function return where return-by-copy didn't have the proper effect= .=20 > That's pretty rare.) I'll attempt to build my interface the same way. However I need to be able to change the returned object and have it reflect= ed in the store. > To answer your original question, once you use anonymous access types, al= l=20 > accessibility checks become dynamic. That is, the accessibility of the=20 > actual object is checked, no matter how many levels it's passed through.= =20 > Most likely, someone is operating on a local object and made a call on th= e=20 > routine that's failing. Bob Duff calls that a "tripping hazard", and it= =20 > means that you can never reliably save anonymous access parameters outsid= e=20 > of the original subprogram (you can do it in the subprogram with a local= =20 > anonymous access object -- a hack on top of a hack, IMHO). Now I do understand better why I found references on the web suggesting usi= ng named access types instead of anonymous.=20 I've given the ARM section 3.10.2 a read to understand better this whole th= ing. All I can say is that it isn't certainly not late evening lecture. A= nd I my case, I'm using a return and a qualified expression in one statemen= t, for which I found a lot of "rules". > In Ada 2012, you can "protect" an anonymous access with a precondition us= ing=20 > a membership test (but warning: these aren't tested in the ACATS and I do= n't=20 > know if anyone has implemented them correctly). Something like: >=20 > type Global_Access is access all Object; >=20 > function Something (Acc : access Object; ...) return ... > with Pre =3D> Acc in Global_Access; >=20 > In this case, if the object designated by Acc isn't defined globally, the= =20 > precondition will fail, so you can safely assign Acc to an object of=20 > Global_Access in the body of Something. But, of course, that exposes part= of=20 > your implementation in the precondition, so it's not clear that's a good= =20 > thing. Thanks. Serge