comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@gnat.com (Robert Dewar)
Subject: Re: have to use unrestricted access but just what about access
Date: 22 Jun 2002 05:09:18 -0700
Date: 2002-06-22T12:09:18+00:00	[thread overview]
Message-ID: <5ee5b646.0206220409.1186d72f@posting.google.com> (raw)
In-Reply-To: 3D13CD23.9080404@telepath.com

Ted Dennison <dennison@telepath.com> 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 :-)



  reply	other threads:[~2002-06-22 12:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-19 23:32 have to use unrestricted access but just what about access chris.danx
2002-06-20  8:41 ` chris.danx
2002-06-20 12:10 ` SteveD
2002-06-20 14:22 ` Robert A Duff
2002-06-21 11:45   ` Robert Dewar
2002-06-22  0:49     ` Robert A Duff
2002-06-22  1:05       ` Ted Dennison
2002-06-22 12:09         ` Robert Dewar [this message]
2002-07-20  4:59     ` Craig Carey
2002-07-20 17:47       ` Robert A Duff
2002-07-21  8:45         ` Craig Carey
2002-06-20 16:05 ` Robert Dewar
2002-06-20 17:11   ` chris.danx
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox