comp.lang.ada
 help / color / mirror / Atom feed
From: blakemor@software.org (Alex Blakemore)
Subject: Re: Ada functions versus arrays (i.e. () vs [] )
Date: 1 Mar 90 03:25:26 GMT	[thread overview]
Message-ID: <608@software.software.org> (raw)
In-Reply-To: 5619@crdgw1.crd.ge.com

I previously posted the next two lines AB
> >C has some elegance but why should the programmer have to remember
> >when to use [] or () ?  

In article <5619@crdgw1.crd.ge.com> hammondr@sunroof.crd.ge.com (Richard A Hammond) writes:
> ...  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.

That is not Ada's goal (as most compilers remind us :-)
The question is what you mean by "what is going on".
The important thing for the caller is the type and content of whatever
name (args) returns, not how/when it is computed.  (That is important too,
but the responsibility for that lies with the code providing the service.)

> The C programmer is interested in the difference between an
> array reference and a function call.

So are Ada programmers, no one is keeping that information from you.
You are free to go look in the package spec any time to see what exactly 
you are referencing.  And if you dont like the way it is implemented,
you can change it IN EXACTLY ONE PLACE. The meaning of calling programs
is not changed if the switch between array/function implements the same
abstract function.  Only their efficiency changes.

(i.e. Ada allows you do it right, there are still ways to mess it up such as ...)

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

I agree that side effects are best avoided - they definitely mess up this
scheme.  I assume the language designers left them in for the 
very few times when they are justifiable (e.g. next_random_number).
Quite possibly a language design error forced on them by C programmers :-)

At least this syntactic overloading is consistent with other Ada features,
such as private types.  One of the things I love about Ada is being able
to encapsulate the representation of a type or object using a private type.
Again, this doesnt mean the user of the type shouldn't know how it is
implemented.  It means he can confidently change the representation
in one place and easily reason about how that change will affect
the rest of the program (if at all).

--
-------------------------------------------------------------------------
Alex Blakemore             blakemore@software.org          (703) 742-7125
Software Productivity Consortium   2214 Rock Hill Road Herndon, VA  22070
------------------------   Eschew Obfuscation !!! -----------------------

  reply	other threads:[~1990-03-01  3:25 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                     ` Ada functions versus arrays (i.e. () vs [] ) Richard A Hammond
1990-03-01  3:25                       ` Alex Blakemore [this message]
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