comp.lang.ada
 help / color / mirror / Atom feed
From: trent@unix.SRI.COM (Ray Trent)
Subject: Re: Collective response to := messages
Date: 29 Nov 88 21:08:27 GMT	[thread overview]
Message-ID: <24856@sri-unix.SRI.COM> (raw)
In-Reply-To: 8811282217.AA04896@ajpo.sei.cmu.edu

In an article mendal@ANNA.STANFORD.EDU (Geoff Mendal) writes:
>>The Ada apolgists would have us write the semantics for ensuring
>>LCD form for the type Fraction into *each and every operator*
>>that acts upon 2 items of this type, instead of having that 
>
>First, assignment is NOT an operator.  It is a basic operation.

The argument is that it should be. (and is, in any sensible 
(i.e. non-Ada) definition of the word operator) That there is no
reason to have "basic" operators that are "special".

>One of the examples that I deleted above was "A := B / C;"
>where A, B, and C were of some ADT (Fraction).  If I understand the
>argument for placing the semantics in assignment instead of having the
>programmer define the semantics in each user-defined operation, then
>how would the semantics of passing the expression "B / C" to some
>subprogram formal be handled?  There is no "assignment" here.  The

Fine, perhaps a better example is assigning to an object that should 
be garbage-collected before assignment. (always, or the program 
will be erroneous (not in the Ada sense)) Which makes more sense, 
putting garbage collection in assignment, or assuming the programmer 
will always call a garbage collector while assigning? Even if
the programmer is a code maintainer, and not the designer?

If you are wondering why I chose my original example, consider
A := (B / C * D) + ... + (Q / (3/4)). (all variables are of type fraction,
and an appropriate "/"(A,B : INTEGER) is defined) Do you still want
LCD maintainance in the arithmetic operations? Of course, you could 
always force A := LCD(foo). What if someone wants to modify the program? 
Aren't they going to wonder/forget about this? If you are worried
about passing the expression B / C as a parameter, my answer is: 
if you have a procedure where LCDness is necessary for proving something,
you can *always* simply make "in" parameters "in out" parameters. This 
*ensures* that an input variable will be in LCD form. (if assignment is
overloadable and is overloaded as suggested) "Requiring" a A := LCD(B/C)
does not ensure the validity of something passed to a sub-program.

If assignment were overloadable, the writer of an Ada spec for
operations involving fractions could be *sure* of always having something
in LCD form when passed to a subprogram by overloading ":=" and passing
all variables as "in out" parameters. The only other way to do this
is force *all* subprograms to perform LCDing on their outputs (or inputs)
whether that condition is necessary or not. This would make the operation
A := <very complicated expression with *many* arithmetic operations>
extremely slow (potentially). The LRM explicitly says that intermediate
results need not follow the constraints of the ADT. 

>being that Ada is more readable/understandable/etc. than assembly.  So
>why is it that defining a mapping from some pre-processor to Ada is
>met with such cynicism?  It simply provides an additional layer of

Because it is used to justify inconsistent language constructs. If 
I had a nickel for every time someone said, "you don't need to 
change the language, just use a pre-processor" I'd drown in them.
Point one: any such preprocessor needs to be standardized to the
level that the language is, or it defeats the purpose of the language.
Point two: If such a preprocessor *is* in fact standarized to the level that 
the language is, there is no discernable difference between changing
the language and adding a preprocessor. Point three: the argument is that 
assignment should not be overloadable because it is not understandable
(though more readable). It makes no real difference whether you put
assignment overloading into a pre-processor or into the language. 
The pre-processing source is what will be maintained and used. 
It is identically as understandable if the language is changed as
it is if a processing step is added. Perhaps more so. If the language
is changed, no one will *assume* that assignment cannot be overloaded.
Tacking on a preprocessor is the coward's way out.

>a sad commentary that there are still Ada programmers out there who
>still do not understand the need for and utility of an APSE.  You can

It's needed because the language was designed in an inconsistant and 
inflexible manner in the first place. What would you say about a 
preprocessor that converts C into Ada. Is programming in C then
as good as programming in Ada? (don't laugh, it can be done, especially
if you use unchecked programming) I don't think so.

Another change I'd like to see. (upward compatible this time) Allow:

  if A in B | C | D | Q | Y | N then
    ...
  end if;

I.e. an extension of the membership idea. It's ridiculous to me that

  case A is 
    when B | C => ...
  end case;

is valid but the above (or some equivilent) is not. I argue that such
a construct is both more readable and more understandable than
 
  if A = B or A = C or else ... or else A = N then
    ...
  end if;

and also makes the Ada language more internally consistent. (and thus
easier to use) I also argue that compiler vendors are likely to 
implement the former more efficiently than the latter. This is especially
true when the comparands are of a large enumerated type. (hashing, and all)

Anyway, enough diatribe for today.
-- 
"Our little lives get complicated
 It's a simple thing
 Simple as a flower
 And that's a complicated thing"                     ../ray\..

  parent reply	other threads:[~1988-11-29 21:08 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1988-11-28 22:19 Collective response to := messages Geoff Mendal
1988-11-29 14:39 ` Dennis Doubleday
1988-11-29 21:08 ` Ray Trent [this message]
1988-11-30 14:37   ` Stephe Leake
1988-12-01 14:54     ` David S. Rosenblum
1988-12-02 20:21       ` William Thomas Wolfe,2847,
1988-12-04 21:15         ` David S. Rosenblum
1988-12-04 23:27           ` William Thomas Wolfe,2847,
1988-12-05 14:46             ` David S. Rosenblum
1988-12-05 21:23               ` William Thomas Wolfe,2847,
1988-12-07 17:33                 ` Stephe Leake
1988-12-07 16:03               ` Definition of pass by reference Robert Eachus
1988-12-07 17:15             ` Collective response to := messages Stephe Leake
1988-12-07 16:07       ` Stephe Leake
1988-12-09  3:15         ` David S. Rosenblum
1988-12-01 21:31     ` Ray Trent
1988-12-07 16:21       ` Stephe Leake
1988-11-30 16:29   ` David S. Rosenblum
1988-11-30 18:29     ` William Thomas Wolfe,2847,
1988-11-30 22:28       ` David S. Rosenblum
1988-12-01  3:09         ` William Thomas Wolfe,2847,
1988-12-01 15:16           ` David S. Rosenblum
1988-12-02 19:31             ` William Thomas Wolfe,2847,
1988-12-04 21:03               ` David S. Rosenblum
1988-12-05  2:34                 ` William Thomas Wolfe,2847,
1988-12-05 14:07                   ` David S. Rosenblum
1988-12-07 17:26                     ` Stephe Leake
1988-12-06 19:16                 ` Collective response to := messa stt
1988-12-09  3:39                   ` David S. Rosenblum
1988-11-30 19:13     ` CORRECTION Re: Collective response to := messages David S. Rosenblum
1988-12-01 18:31     ` Ray Trent
1988-12-02 14:49       ` David S. Rosenblum
1988-12-05 17:33         ` Collective response to := messa stt
1988-11-30 18:24   ` Collective response to := messages Robert Eachus
1988-12-02 14:58     ` David S. Rosenblum
1988-12-02 19:34   ` Mark C. Adolph
1988-12-05 17:15     ` Collective response to := messa stt
1988-11-29 21:44 ` Collective response to := messages William Thomas Wolfe,2847,
  -- strict thread matches above, loose matches on Subject: below --
1989-07-26 20:34 Memory Access Question tony
1989-07-27 13:06 ` richard a hammond
1989-07-27 18:53   ` Ray Trent
1989-07-28  0:48     ` Mike Murphy
1989-08-02 13:23       ` Mike Walsh
1989-08-02 20:20         ` Mike Murphy
1989-07-29  0:00 ` Brian Sullivan
1988-12-05  6:53 Collective response to := messages Erland Sommarskog
1988-12-03 22:53 Erland Sommarskog
1988-12-04 20:41 ` William Thomas Wolfe,2847,
1988-12-05  5:47   ` Richard A. O'Keefe
1988-12-05 12:45     ` William Thomas Wolfe,2847,
1988-12-06  1:54       ` Richard A. O'Keefe
1988-12-06 20:43         ` William Thomas Wolfe,2847,
1988-12-03 21:08 Erland Sommarskog
1988-12-04 20:30 ` William Thomas Wolfe,2847,
1988-11-14 13:20 Ada language revision Stanley Roger Allen, AdaDude
1988-11-15 23:28 ` Wilmer Rivers
1988-11-16 19:06   ` William Thomas Wolfe,2847,
1988-11-17 15:34     ` Stephe Leake
1988-11-18 16:39       ` Steve Tynor
1988-11-18 19:22       ` Ron Guilmette
1988-11-23 22:22       ` William Thomas Wolfe,2847,
1988-11-29 15:35         ` Stephe Leake
1988-11-18  0:32     ` Ron Guilmette
1988-11-22 14:37       ` Stephe Leake
1988-11-23 13:37         ` Dennis Doubleday
1988-11-23 19:41           ` Steve Tynor
1988-11-23 21:14             ` Richard Pattis
1988-11-25 20:36             ` Robert Firth
1988-11-29 15:12           ` limited private types Stephe Leake
1988-12-01 23:06             ` Ron Guilmette
1988-12-05  1:48               ` Paul Stachour
1988-12-05 12:31                 ` Reference Semantics William Thomas Wolfe,2847,
1988-12-06  0:29                   ` Paul Stachour
1988-12-07  1:07                     ` Reference Semantics, assignment overloading, etc Ray Trent
1988-12-08 17:36                       ` Reference Semantics, assignment ryer
1988-12-06 16:56               ` limited private types ryer
1988-12-06 20:09               ` stt
1988-12-07 15:51               ` Stephe Leake
1988-11-21 15:40   ` Ada language revision stt
replies disabled

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