comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: Pointer function parameter
Date: 2000/10/21
Date: 2000-10-21T00:00:00+00:00	[thread overview]
Message-ID: <8ss8vo$69a$1@nnrp1.deja.com> (raw)
In-Reply-To: Pine.LNX.4.10.10010191126450.17222-100000@lexis.di.fct.unl.pt

In article
<Pine.LNX.4.10.10010191126450.17222-100000@lexis.di.fct.unl.pt>,
  comp.lang.ada@ada.eu.org wrote:
> The "in this vein" is there for a reason: in the vein of using
> Ada access types for the same purposes you use C pointer types
> for--and only in this vein--, attribute Access is in fact the
> Ada equivalent of the C address operator &.

But unless you are writing C code in Ada, you do NOT use Ada
access types "for the same purposes you use C pointer types
for". That's the important point.
>
> The equivalent strito senso--not in the vein above--is of
course attribute
> Address. But if you use Address everywhere where you use & in
the
> equivalent C program, you miss a great part of the gain of
using Ada
> instead of C.

Ah, but what you are missing is that most normally the Ada
approach is to use access types all over the place as required
but almost NEVER to use the 'Access attribute.

Sure if you want to write C code in Ada you can, but you
are also missing a "great part of the gain in writing Ada"
if you create dangerous aliasing all over the place by using
the 'Access attribute and aliased objects and types.

> (Perhaps you read "Address" where it says "Access" in my first
reply?)

No, not at all. The critical point here is that normally, other
than when interfacing to foreign code, or building certain
static data structures, you do not want to use EITHER attribute.
Yes, of course 'Access is preferable to 'Address, but the far
more important point is not to use either in ordinary code
except in rare cases.

When we discussed adding 'Access to the language, we recognized
that, although it was useful in specialized cases, it opened
up a Pandora's box of very bad programming practice, and, sad
to say, I see far too many programmers opening this box! A
C programmer has as much trouble seeing that the use of
pointers needs limiting as an old style Fortran programmer
has in seeing that gotos need limiting

> And surely there is a _lot_ of uses of access types besides
interfacing to
> C: virtually all dynamic data structures (linked lists, trees,
etc.)
> require them.

Yes, of course, but in Ada, you use pointers for these
purposes WITHOUT using the 'Access attribute. If you find
yourself using 'Access to implement linked lists, trees etc,
you are most likely doing something wrong (wrong in the sense
of not taking advantage of Ada).


Sent via Deja.com http://www.deja.com/
Before you buy.




  parent reply	other threads:[~2000-10-21  0:00 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-19  0:00 Pointer function parameter Mario Amado Alves
2000-10-19  0:00 ` Marin David Condic
2000-10-19  0:00 ` tmoran
2000-10-19  0:00   ` Ted Dennison
2000-10-21  0:00   ` Robert Dewar
2000-10-23  0:00     ` Alejandro Villanueva
2000-10-24  0:00       ` Robert A Duff
2000-10-24  0:00         ` Alejandro Villanueva
2000-10-24  0:00           ` Ted Dennison
2000-10-24  0:00             ` Lutz Donnerhacke
2000-10-24 22:32           ` Mats Weber
2000-10-30 15:24           ` Robert A Duff
2000-10-30 15:44             ` Ken Garlington
2000-10-30 18:53               ` Florian Weimer
2000-10-31  1:48                 ` Robert Dewar
2000-10-31 12:40                   ` Ken Garlington
2000-10-31 14:08                     ` Larry Kilgallen
2000-11-01 17:59             ` Mats Weber
2000-11-03  0:00               ` Florian Weimer
2000-11-04  0:00                 ` RAM size, was " tmoran
2000-10-21  0:00 ` Robert Dewar [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-10-16  0:00 Mary
2000-10-17  0:00 ` Gautier
2000-10-17  0:00 ` Mario Amado Alves
2000-10-18  0:00   ` Florian Weimer
2000-10-18  0:00   ` Robert Dewar
2000-10-17  0:00 ` tmoran
replies disabled

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