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.36.121.142 with SMTP id z136mr1135976itc.36.1510326399450; Fri, 10 Nov 2017 07:06:39 -0800 (PST) X-Received: by 10.157.51.119 with SMTP id u52mr387064otd.6.1510326399330; Fri, 10 Nov 2017 07:06:39 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.am4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!l196no59193itl.0!news-out.google.com!193ni3026iti.0!nntp.google.com!l196no59192itl.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 10 Nov 2017 07:06:38 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.71.208.22; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 173.71.208.22 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <0e68d62f-6e81-4f48-998f-cccdb4c650a1@googlegroups.com> Subject: Re: Comparing Access Types From: Jere Injection-Date: Fri, 10 Nov 2017 15:06:39 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Body-CRC: 3146706999 X-Received-Bytes: 4135 Xref: feeder.eternal-september.org comp.lang.ada:48801 Date: 2017-11-10T07:06:38-08:00 List-Id: On Thursday, November 9, 2017 at 3:33:51 AM UTC-5, Dmitry A. Kazakov wrote: > On 09/11/2017 06:37, Jere wrote: > > > > 1. Address_To_Access_Conversions is out (cannot use an incomplete type) > > 2. I cannot simply do var.all'Address (Again, incomplete type) > > Of course you can. When I use GNAT GPL 2016 I get the following error: 10:33 prefix of "Address" attribute cannot be an incomplete type It works fine for other types of generic formals, but for incomplete types, it fails with an error like this. > > > Is there some way to do this within the Ada standard or am I hamstrung > > due to the incomplete type specification? > > > > Also, why weren't <, >, <=, >= provided for access types. Even if the > > representation of an Access type is implementation defined, surely > > those operators could have been defined. > > No, in general case it cannot, in the spirit of the semantics that A < B > if the physical machine address of A < B. Actually even equality cannot > be for segmented memory but it felt good enough. > I may not understand, but I don't see this as any issue. Even when physical memory is split into pages, banks, segments, etc., it can be organized into unique locations. I'm not suggesting that access values need to map directly to memory addresses but it seems odd that an access type, which holds some unique information about an object, cannot be ordered in some fashion. > > A toned down example: > > > > generic > > type Item_Type(<>); > > type Item_Access is access Item_Type; > > package My_Package is > > > > You have two options: > > 1. Compare addresses, e.g. > > with System; use System; > > function "<" (Left,Right : Some_Type) return Boolean is > begin > return ( Right.Reference /= null > and then > ( Left.Reference = null > or else > Left.Reference.all'Address < Right.Reference.all'Address > ) ); > end "<"; > > 2. A better way is to use the native object's order: > > generic > type Item_Type(<>); > type Item_Access is access Item_Type; > with function "=" (Left, Right : Item_Type) return Boolean is <>; > with function "<" (Left, Right : Item_Type) return Boolean is <>; > package My_Package is > > function "<" (Left,Right : Some_Type) return Boolean is > begin > return ( Right.Reference /= null > and then > ( Left.Reference = null > or else > Left.Reference.all < Right.Reference.all > ) ); > end "<"; > > -- > Regards, > Dmitry A. Kazakov > http://www.dmitry-kazakov.de Ok, that makes sense. If I have to do it that way, then I'll have to push it off to the client in some fashion. Though again, GNAT won't currently let me do the first option yet. Thanks