comp.lang.ada
 help / color / mirror / Atom feed
From: cosc19z5@Bayou.UH.EDU (Spasmo)
Subject: Re: Ada is 'better' than C because...
Date: 1996/08/13
Date: 1996-08-13T00:00:00+00:00	[thread overview]
Message-ID: <4uoo3b$677@Masala.CC.UH.EDU> (raw)


OBryan Anthony H (aho450s@nic.smsu.edu) wrote:
: William Clodius (clodius@hotspec.lanl.gov) wrote:

: : Not quite. First when passed as an argument to a user defined function
: : a C array looses a lot of its distinction from a pointer, a problem
: : that many other languages do not have. Second, while (almost?) all

:   I have a hard time seeing this as a problem.  It's one of the fantastic 
: advantages of the C language.  An array of any given type can be passed 
: to a user function and treated as an array of any other integral type, 
: converted, processed, etc. in any manner the programmer desires.

Actually it's an awful problem and it's one of the crippling problems
that plagues C.  Since an array is in many respects interchangable
with a pointer you have (once again) opened the door to the types
of disasters that C is infamous for.  I mean you can pass a pointer
to a function, and treat it like an array by accident, or vice versa.
The Ada method is much better.  There is a distinction between arrays
and pointers (hell, they aren't anywhere near the same thing), and
so when you have an array parameter in Ada, it will expect an array.
Still no flexibility is lost since you can declare types of 
unconstrained arrays which means arrays of any size can be passed,
and this of course can be combined with the generic capabilities
of Ada to give you far more flexibility than you could ever hope
to have in C, and something else you don't have in C -- safety.



: : additional capabilities that C arrays lack, the ability to specify
: : array shape in arguments (Fortran I), and various forms of whole array
: : operations, APL, PL/I, Algol 68, and Fortran 90.

: What do you mean by array shape?  C is fully capable of performing whole 
: array operations.  The capability is not embedded in the language, as C 
: is designed to provide only the bare necessicities for program 
: development with all else being provided in function extensions, but the 
: language itself allows for anything a machine is capable of doing.

I'm assuming actually having the size of the array be specified in
the parameter and checked.  In C while you can specify an array
size in a parameter, it does absolutely nothing since you are
free to overrun that size to your heart's content.  As for 
array operations, again I think he may mean doing things like
assignment and equality comparisons on arrays, something that
C again cannot do with any aggregate types.  This limitation
becomes a major pain in the posterior when you get to C++ and
generic subprograms since you end up having to code all sorts
of ugly hacks just to get many generic types to behave properly.


--
Spasmo
"Everyone has secrets, but sometimes you get caught,
 So if it's just between us, my silence can be bought"
	"Blackmail" by Sloppy Seconds





             reply	other threads:[~1996-08-13  0:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-13  0:00 Spasmo [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-07-27  0:00 C is 'better' than Ada because Tim Behrendsen
1996-07-29  0:00 ` Ada is 'better' than C because John Herro
1996-07-30  0:00   ` Brian Rogoff
1996-07-30  0:00     ` Adam Beneschan
1996-07-31  0:00     ` Franz Kruse
1996-08-04  0:00   ` Richard Riehle
1996-08-05  0:00     ` Sandy McPherson
1996-08-06  0:00       ` Ken Garlington
1996-08-06  0:00         ` GAFFNEY.BRIAN
1996-08-07  0:00           ` Ken Garlington
1996-08-08  0:00         ` Theodore E. Dennison
1996-08-08  0:00           ` Frank Lipski
1996-08-09  0:00         ` Sandy McPherson
1996-08-15  0:00         ` Mike Stark
1996-08-07  0:00       ` Bob Kitzberger
1996-08-08  0:00       ` Robert Dewar
1996-08-08  0:00         ` Kevin D. Quitt
1996-08-08  0:00 ` William Clodius
1996-08-09  0:00   ` Kevin D. Quitt
1996-08-09  0:00   ` Robert Dewar
1996-08-12  0:00   ` OBryan Anthony H
1996-08-12  0:00     ` Bob Kurtz
1996-08-12  0:00     ` Lawrence Kirby
1996-08-13  0:00     ` Tom Watson
1996-08-14  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