comp.lang.ada
 help / color / mirror / Atom feed
From: Richard D Riehle <laoXhai@ix.netcom.com>
Subject: Re: Software landmines (was: Why C++ is successful)
Date: 1998/08/28
Date: 1998-08-28T14:06:58-05:00	[thread overview]
Message-ID: <6s6v4i$mht@dfw-ixnews8.ix.netcom.com> (raw)
In-Reply-To: m3g1eithld.fsf@mheaney.ni.net

In article <m3g1eithld.fsf@mheaney.ni.net>,
	Matthew Heaney <matthew_heaney@acm.org> wrote:

In response to Richard Riehle's question about initialization
of values with the assignment statement, 

>
>The issue lies in the difference between "assignment" and "binding."

 I ran to my bookshelf to find an entry in any computer science text
 on "binding" in the context you have used it.  None.  Reference, please.

>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.

 I understand the distinction, and your reference to Eiffel, below, is 
 correct.  

>In the example above, 
>   Zero : constant := 0;
>is a binding operation, not an assignment operation.  The name Zero is
>bound to a value.

 So, in this respect, C++ initialization lists better express the
 "binding" requirement than Ada assignments.  
 
>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?

 Your function example is interesting.  In an Eiffel feature
 declaration, the syntatical placement for "is" in declaring
 a function is the same as Ada rather than as you prefer. 

>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;
>
This is true.  A feature declaration in Eiffel is the same for any
declaration.  This is called by Bertrand, "the principle of minimum
surprise."   When referencing any feature in an Eiffel class, the 
client of the class sees attributes identically to functions.  An
"is" is used only for constant or routine feature. Non-constant
attributes are not initialized with a "is" keyword. Also, the Eiffel
model for "attachment" and "reattachment" more closely approximates
what you and Robert are describing as alternatives to excessive use
of the assignment statement.

With that understanding in place, I suggest that, in using the
assignment operation for defining constants, the difference between
"binding" and "assignment" is a rather subtle semantic issue for most
practical programmers.  Also, several consecutive assignment statements
in Ada will often be more readable than the parentheticaly clauses
of function returns that serve as their substitute.  Ada, unlike Eiffel,
is not designed to reduce the number of assignment statements.  

The suggestion that we use fewer assignment statements is liable to 
create the same mess that "gotoless" programming fomented in the COBOL
world.  Robert knows that pre-ANSI 85 COBOL was inadequately designed
to support programs without GO TO statements.  Only with the advent
of "END ..." constructs did COBOL become more amenable to reducing the
number of GO TO's.  Ada is designed to encourage the use of the 
assigment statement.  Suggesting that we do not use it so often is 
probably counterproductive and can only be realized with some important
changes in the language.

You have already noted some of these, Matthew.

Richard Riehle
richard@adaworks.com
http://www.adaworks.com


 




  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   ` dennison
1998-08-25  0:00   ` Andi Kleen
1998-08-25  0:00     ` Brian Rogoff
1998-08-28  0:00   ` Matthew Heaney
1998-08-28  0:00     ` Richard D Riehle [this message]
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                   ` 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                         ` Charles Hixson
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                                 ` Bob Collins
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                                       ` 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-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-09-22  0:00                                       ` Charles H. Sampson
1998-08-21  0:00                                 ` Ell
1998-08-21  0:00                               ` John Goodsen
1998-08-21  0:00                                 ` Ell
1998-08-21  0:00                                   ` Ell
1998-08-20  0:00                         ` Gerry Quinn
1998-08-16  0:00                   ` Jay Martin
1998-08-17  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