comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <eachus@mitre.org>
Subject: Re: C like op= proposal
Date: 1999/08/18
Date: 1999-08-18T20:55:19+00:00	[thread overview]
Message-ID: <37BB1E9A.F3A5D609@mitre.org> (raw)
In-Reply-To: 7pefco$v7o$1@nnrp1.deja.com



Ted Dennison wrote:
 
> If you are soliciting opinions, I think its beyond ugly.

     Agreed.  There is a very subtle and painful problem with the Ada
notation.  A := A + 1; in Ada 83 could raise an exception.  If it did A
would have to remain unchanged in the exception handler, and if shared,
if read by any other task.  (A was never modified, so no intervening
synchronization point was required.)  This meant that the code could not
use an increment instruction on many processor architectures.  In Ada
95, 11.6(6) among other things allows increments to be used here.

    That was a very strong argument in Ada 83 for implementations and
users to find a better way to get the += semantics.  A lot of proposals
were discussed, including both language "fixes" and implementation
defined extensions.  None of them ever caught on, because as people
learned the language better they discovered that:

    In many cases where a fast increment was needed, the variable was a
loop variable and the problem didn't arise.  (Well once the compiler
writers figured that the "right" Ada sequence to generate for the loop
check is to check before the increment.  Since the variable is never
visible outside the loop, you don't need C or Fortran semantics.)

    In other cases, such as circular buffers, the user is the one who
should do the check:  "if Index = Buffer'Last then Index := Buffer'First
else Index := Index + 1;"  (Of course in Ada 95, you can do this with a
modular type.)

    In many other cases where you wanted a fast increment the better way
in Ada was to write at a higher level for example assigning slices
instead of doing an element by element copy.

    So the need for any feature like this has almost completely gone
away.  (In C, I find I use one of these special forms at least every ten
lines, mostly in loop declarations.  In Ada, I am unlikely to "miss" one
of them in several hundred lines, even if I am doing a direct
translation from C.  (Yes, I know, why translate from C?  It is much
easier on some code than putting in all the missing checks.)
-- 

                                        Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




  reply	other threads:[~1999-08-18  0:00 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-08-15  0:00 C like op= proposal Brian Rogoff
1999-08-15  0:00 ` Ray Blaak
1999-08-15  0:00   ` Brian Rogoff
1999-08-16  0:00     ` Gautier
1999-08-17  0:00       ` Samuel Tardieu
1999-08-17  0:00         ` Gautier
1999-08-17  0:00         ` Andi Kleen
1999-08-18  0:00           ` Robert Dewar
1999-08-17  0:00             ` Brian Rogoff
1999-08-18  0:00               ` Gautier
1999-08-18  0:00               ` Ted Dennison
1999-08-18  0:00                 ` Robert I. Eachus [this message]
1999-08-18  0:00                 ` Jeff Carter
1999-08-18  0:00                   ` Keith Thompson
1999-08-19  0:00                     ` Tarjei T. Jensen
1999-08-19  0:00                       ` Ted Dennison
1999-08-19  0:00                       ` Lance Kibblewhite
1999-08-19  0:00                       ` Robert Dewar
1999-08-20  0:00                         ` P.S. Norby
1999-08-21  0:00                           ` Robert Dewar
1999-08-19  0:00                       ` tmoran
1999-08-19  0:00                     ` Michael F. Yoder
1999-08-21  0:00                       ` Keith Thompson
1999-08-18  0:00               ` Robert Dewar
1999-08-18  0:00                 ` Brian Rogoff
1999-08-19  0:00                   ` Robert Dewar
1999-08-21  0:00                     ` Brian Rogoff
1999-08-23  0:00                     ` Robert A Duff
1999-08-18  0:00             ` Andi Kleen
1999-08-18  0:00         ` Gautier
1999-08-17  0:00       ` John Duncan
1999-08-17  0:00         ` Gautier
1999-08-16  0:00 ` Robert Dewar
replies disabled

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