From: hammondr@sunroof.crd.ge.com (Richard A Hammond)
Subject: Ada functions versus arrays (i.e. () vs [] )
Date: 28 Feb 90 18:56:35 GMT [thread overview]
Message-ID: <5619@crdgw1.crd.ge.com> (raw)
In-Reply-To: 598@software.software.org
In article <598@software.software.org> blakemor@software.org (Alex Blakemore) writes:
>In article <184@trwacs.UUCP> epstein@trwacs.UUCP (Jeremy Epstein) writes:
>> ... look at how Ada overloads symbols. For
>> example, parentheses are used for parameters as well as subscripts
>> (that's something that totally confuses me as an old-time C programmer).
>This is a strength of Ada not an inconsistency. This way you can change
>between using an array and a function to provide some info ...
>This is consistent with some formal proof methods (like Tony Hoare's)
>which treat array references as function calls. Logically they
>have the same effect. Mathematically a function is essentially a table
>anyway. Of course, there is a difference when you assign to an array
>element.
...
>C has some elegance but why should the programmer have to remember
>when to use [] or () ? just to make the compiler easier to write ?
Last point first: I think the reason is to give the programmer a cue
to what is going on. Remember, the goal of C is to provide constructs
which map in a straightforward way to machine code. Thus, the C
programmer is interested in the difference between an
array reference and a function call. Besides, functions in C have the
attributes of Ada procedures and Ada functions, i.e. the Ada
function is more limited than a C function(no out or in/out parameters).
So in C: a = b(d,e) + f; could modify the value not just of a, but of
what d and/or e pointed to (if they were access types) or d/e themselves
if they are defined via macros as more complicated objects.
In fact, the argument that "an array ref" is the same as a "function call"
is true for mathematical functions but not Ada ones. Ada functions can
have side effects, which is a software engineering deficiency in Ada.
For that reason, I'd want to know when a function call is being made.
Even a function without parameters, which is why I like C's "foo()" better
than Ada's "foo" for calling a parameterless function.
And why I'd like to distinguish between function calls and array refs.
Please, I'm trying to discuss Ada and not Ada versus C, except that
because C does some things wrong doesn't mean you can't steal the
good ideas.
Rich Hammond
next prev parent reply other threads:[~1990-02-28 18:56 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
1990-02-20 16:13 Reasons for dropping Ada Ted Holden
1990-02-20 21:04 ` Richard S D'Ippolito
1990-02-20 23:03 ` Reasons for keeping Ada David Kassover
1990-02-21 0:40 ` Clement Pellerin
1990-02-21 19:02 ` Reasons for dropping Ada Loren Louis Hart
1990-02-22 16:07 ` Mike Coffin
1990-02-22 17:01 ` if UNIX then USE_C ?? (was: Reasons for drop) Dennis M. O'Connor
1990-02-22 21:51 ` Barry Margolin
1990-02-23 19:34 ` Loren Louis Hart
1990-02-25 19:58 ` David Kassover
1990-02-26 12:45 ` John F Nixon
1990-02-26 18:28 ` David Kassover
1990-02-26 20:55 ` John F Nixon
1990-02-26 22:00 ` David Kassover
1990-02-27 18:55 ` Jeremy Epstein
1990-02-28 1:19 ` Alex Blakemore
1990-02-28 18:56 ` Richard A Hammond [this message]
1990-03-01 3:25 ` Ada functions versus arrays (i.e. () vs [] ) Alex Blakemore
1990-03-01 13:11 ` Robert Firth
1990-03-02 10:56 ` Mike Harrison
1990-03-02 23:46 ` Scott Simpson
1990-03-02 10:42 ` Mike Harrison
1990-03-06 19:13 ` Erland Sommarskog
1990-03-08 14:21 ` John Goodenough
1990-03-14 18:19 ` if UNIX then USE_C ?? (was: Reasons for drop) RCAPENER
1990-03-01 0:29 ` David Kassover
1990-03-01 15:11 ` Steve Tynor
1990-03-01 18:29 ` David Kassover
1990-03-02 0:19 ` Robert D. Houk
1990-02-28 19:51 ` Andy DeFaria
1990-02-20 22:21 ` Reasons for dropping Ada Jeffrey M. Schweiger
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox