comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: Ask for Access operator
Date: 2000/05/07
Date: 2000-05-07T00:00:00+00:00	[thread overview]
Message-ID: <8f4rig$cbg$1@nnrp1.deja.com> (raw)
In-Reply-To: ObhR4.4795$C9.100771@typhoon.nyroc.rr.com

In article <ObhR4.4795$C9.100771@typhoon.nyroc.rr.com>,
  "Pete" <tyrone@nowhere.org> wrote:

> if you are using ada95 try this
>
> type Int_Ptr is access all Integer;
> Data : aliased Integer := 5;
> I_Ptr : Int_Prt;
> I_Ptr := Data'Access

Oh dear! Ted's answer was just spot on here, and I wondered
to him off line if someone would post an answer like the
above.

This is almost CERTAINLY wrong advice. It almost CERTAINLY
leads to writing junk C-in-Ada style code. There are very few
cases in which it is legitimately appropriate to use aliased
variables and the Access operator. When you need these features
they are valuable, but they are also very dangerous because
they encourage a nasty low level style of coding that is
quite familiar to C programmers, but quite inappropriate in
Ada. If you are going to learn Ada, you want to learn how to
write Ada in Ada style. If you want to write C, you might
as well write in C :-)

I must say that I see huge overuse of 'Access and aliased in
a lot of Ada95 code.


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




  reply	other threads:[~2000-05-07  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-05-05  0:00 Ask for Access operator carlos
2000-05-05  0:00 ` Ted Dennison
2000-05-07  0:00 ` Pete
2000-05-07  0:00   ` Robert Dewar [this message]
2000-05-09  0:00 ` carlos
2000-05-09  0:00   ` Robert Dewar
2000-05-09  0:00   ` Ted Dennison
replies disabled

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