comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Software landmines (was: Why C++ is successful)
Date: 1998/08/28
Date: 1998-08-28T00:00:00+00:00	[thread overview]
Message-ID: <m3g1eithld.fsf@mheaney.ni.net> (raw)
In-Reply-To: 6rsg0d$pcj@dfw-ixnews3.ix.netcom.com

Richard D Riehle <laoXhai@ix.netcom.com> writes:

> >... most programmers furiously overuse assignments, and it is
> >far too common to see a variable assignment used to establish a constant
> >value 
> 
>   I am not sure what you mean.  If I want to define constants,
> 
>           Zero : constant := 0;
>           Null_List := some-value;
> 
>   how do I set the initial value without assignment.  For private
>   members in C++ this is really easy without assignment.  I can use
>   (must use) an initialization list.  In Ada we have to have an 
>   assignment somewhere to make this happen.

The issue lies in the difference between "assignment" and "binding."
The problem with Ada is that the syntax for both is the same, so
whenever people see ":=" they always think of assignment, even when it
really means binding.

In the example above, 

   Zero : constant := 0;

is a binding operation, not an assignment operation.  The name Zero is
bound to a value.

Indeed, any time you see the keyword "constant" in a declaration, then
you should treat that to mean "bind," not "assign."

Ada is wildly inconsistent wrt binding.  To bind a name to a function, I
use the keyword "is":

function F (X : T1) return T2 is
begin
   <body>
end F;

means the same thing as

type FT is function (X : T1) return T2;

F : constant FT := begin <body> end;

Why not use the operator "is" everywhere binding is intended?

I think it's true that in Eiffel, binding doesn't use the assignment
operator, it uses the keyword "is", as in

   Zero : Integer is 0;

which is the equivalent of

   Zero : constant Integer := 0;

in Ada.

So when Robert says "programmers misuse assignment," he means (I think)
that they are using assignment when they really want to use binding.
The latter use is indicating by the presence of the keyword "constant".

Unfortunately, the syntax for binding in Ada also uses the assignment
operator, so Ada programmers blur the distinction between binding and
assignment (if they are aware of it at all).  I regard this as a flaw in
the language.




  parent reply	other threads:[~1998-08-28  0:00 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-08-22  0:00 Software landmines (was: Why C++ is successful) dewar
1998-08-23  0:00 ` Dale Stanbrough
1998-08-23  0:00   ` dewar
1998-08-23  0:00   ` Andi Kleen
1998-08-24  0:00 ` Richard D Riehle
1998-08-25  0:00   ` Andi Kleen
1998-08-25  0:00     ` Brian Rogoff
1998-08-25  0:00   ` dennison
1998-08-28  0:00   ` Matthew Heaney [this message]
1998-08-28  0:00     ` Richard D Riehle
1998-08-29  0:00       ` Matthew Heaney
1998-09-06  0:00         ` John G. Volan
1998-09-07  0:00           ` Mats Weber
1998-09-07  0:00             ` dewarr
1998-09-08  0:00               ` Tucker Taft
1998-09-08  0:00                 ` Precalculation of parameters (was: Software landmines) dennison
1998-09-09  0:00                   ` Tucker Taft
1998-09-09  0:00                     ` dennison
1998-09-10  0:00                       ` Tucker Taft
1998-09-10  0:00                         ` dewarr
1998-09-16  0:00               ` Software landmines (was: Why C++ is successful) Matthew Heaney
1998-08-29  0:00       ` Matthew Heaney
     [not found]   ` <35eca5d9.4354839@news.geccs.gecm.com>
1998-09-01  0:00     ` Richard D Riehle
  -- strict thread matches above, loose matches on Subject: below --
1998-08-06  0:00 Why C++ is successful Robert Dewar
1998-08-07  0:00 ` harald.mueller
1998-08-07  0:00   ` Brian Rogoff
1998-08-07  0:00     ` Timothy Welch
1998-08-08  0:00       ` Robert Dewar
1998-08-08  0:00         ` Jeffrey C. Dege
1998-08-10  0:00           ` Laurent GUERBY
1998-08-12  0:00             ` Andy Ward
1998-08-14  0:00               ` Robert Dewar
1998-08-14  0:00                 ` Software landmines (was: Why C++ is successful) dennison
1998-08-15  0:00                   ` Thaddeus L. Olczyk
1998-08-16  0:00                   ` Jay Martin
1998-08-17  0:00                     ` Robert Dewar
1998-08-16  0:00                   ` Robert Dewar
1998-08-17  0:00                     ` dennison
1998-08-18  0:00                       ` adam
1998-08-19  0:00                         ` Tucker Taft
1998-08-19  0:00                           ` adam
1998-08-19  0:00                       ` ell
1998-08-19  0:00                         ` adam
1998-08-19  0:00                           ` Dan Higdon
1998-08-20  0:00                             ` adam
1998-08-20  0:00                               ` Dan Higdon
     [not found]                               ` <m33eagru5g.fsf@mheaney.ni.net>
1998-08-31  0:00                                 ` Frank Adrian
1998-08-31  0:00                                   ` Robert I. Eachus
1998-08-31  0:00                                     ` Biju Thomas
1998-08-31  0:00                                       ` Robert Martin
1998-09-01  0:00                                         ` Martin Dowie
1998-09-01  0:00                                       ` Robert I. Eachus
1998-09-02  0:00                                         ` dennison
1998-09-01  0:00                                   ` dewarr
1998-09-06  0:00                                 ` Jonathan Guthrie
1998-08-20  0:00                           ` Ell
1998-08-21  0:00                             ` Ell
1998-08-21  0:00                               ` Larry Brasfield
1998-08-21  0:00                                 ` Jeffrey C. Dege
1998-08-20  0:00                                   ` Phlip
1998-08-21  0:00                                   ` Larry Brasfield
     [not found]                                   ` <DOSXjHE9T6DM9Jw9nAyaPxfz@news.rdc1.bc.wave.home.com>
1998-08-22  0:00                                     ` dewar
1998-08-24  0:00                                       ` dennison
1998-08-28  0:00                                         ` Matthew Heaney
1998-08-28  0:00                                           ` dennison
1998-08-30  0:00                                             ` Matthew Heaney
1998-09-06  0:00                                               ` John G. Volan
1998-08-31  0:00                                             ` Robert I. Eachus
1998-08-24  0:00                                       ` Martin Dowie
1998-08-24  0:00                                         ` Martin Dowie
1998-08-24  0:00                                           ` Mark A Biggar
1998-08-25  0:00                                             ` Martin Dowie
1998-08-25  0:00                                               ` Mark A Biggar
1998-08-26  0:00                                                 ` Martin Dowie
1998-08-25  0:00                                         ` adam
1998-09-22  0:00                                       ` Charles H. Sampson
1998-08-21  0:00                                 ` Ell
1998-08-21  0:00                                 ` Bob Collins
1998-08-21  0:00                               ` John Goodsen
1998-08-21  0:00                                 ` Ell
1998-08-21  0:00                                   ` Ell
1998-08-19  0:00                         ` Charles Hixson
1998-08-20  0:00                         ` Gerry Quinn
replies disabled

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