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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,daf1e35a4e978e9d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-22 05:09:18 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: dewar@gnat.com (Robert Dewar) Newsgroups: comp.lang.ada Subject: Re: have to use unrestricted access but just what about access Date: 22 Jun 2002 05:09:18 -0700 Organization: http://groups.google.com/ Message-ID: <5ee5b646.0206220409.1186d72f@posting.google.com> References: <0x8Q8.6779$ZP1.1263481@news11-gui.server.ntli.net> <5ee5b646.0206210345.2d58d8e0@posting.google.com> <3D13CD23.9080404@telepath.com> NNTP-Posting-Host: 205.232.38.243 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1024747758 2498 127.0.0.1 (22 Jun 2002 12:09:18 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 22 Jun 2002 12:09:18 GMT Xref: archiver1.google.com comp.lang.ada:26596 Date: 2002-06-22T12:09:18+00:00 List-Id: Ted Dennison wrote in message news:<3D13CD23.9080404@telepath.com>... > Robert A Duff wrote: > > I agree that this is a nasty restriction in Ada 95 -- one ought to be > > allowed to declare the parameter aliased explicitly, and taggedness > > shouldn't have anything to do with the matter. > > Isn't that what the "access" parameter mode does? Sure, you have to > announce your intentions in the subprogram's interface, but that is > arguably a good thing too. No, you miss the point. Suppose you have a function with a parameter X : integer. Now you want to call another function that expects an access type (perhaps an external C function). You want to be able to pass X'Unchecked_Access to that inner function, but you can't, because you can't make X aliased. I often want to create temp access values referencing parameters, it's a perfectly reasonable requirement, and one that is handled in GNAT by using unrestricted access. of course, just as when you use 'Address, you have to be careful (remember that for objects, Unrestricted_Access in GNAT is nothing more than 'Address and an unchecked conversion to the appropriate pointer type). The advantage of Unrestricted_Access in GNAT is that it encourages using typed interfaces instead of degenerating to using System.Address. It is no more dangerous than 'Address, but just because you are going down to the semantic level of dealing with low level addresses or pointers does not mean you have to give up typing (after all pointers in C are strongly typed, so it is a shame that in a lot of Ada 83 code you get interfaces to C functions where on the Ada side you give up on typing by using 'Address when the C side is strongly typed :-)