comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: Where are returned values stored?
Date: Wed, 09 Jun 2004 03:03:51 -0400
Date: 2004-06-09T03:03:51-04:00	[thread overview]
Message-ID: <VrSdnTyDFtHFK1vdRVn-uA@comcast.com> (raw)
In-Reply-To: <tjsXkypBlsee@eisner.encompasserve.org>

Larry Kilgallen wrote:

> Merely having hardware capable of 64-bit addressing does not speed the
> copying of that 2 Gigabyte string, so performance might be awful.  On
> the other hand, there is a greater likelyhood the program will run to
> completion, which is a correctness issue.

I don't know if you missed the point or not.  Yes, it is a correctness 
issue, and all Ada compiler developers will choose an implementation 
model which is correct over one that is 'mostly' correct and faster. 
But there is an implicit expectation that the programmers understand 
these issues well enough to choose a solution which is both correct, and 
tolerant of these 'hidden' assumptions.

For example, if I write a program to 'read a file a line at a time.'  If 
I don't either know what system enforced maximum line length is or 
choose a arbitrary length and change algorithms for lines longer than 
that length, I have failed to use good software engineering practice.

Notice that there is no inherent 'magic number' for when a line gets 
processed differently.  I tend to use 132 characters, some people I know 
prefer 253, or 255, or 1023.  The actual number doesn't matter that 
much.  Just that you know you won't have nasty problems if someone gives 
you a non-text file.

Similarly, Ada allows me to put arbitrary objects on the stack at 
run-time.  But that means that it is my responsibility as a software 
engineer to insure that the stack won't overflow.  There are often only 
one or two declarations that I have to "worry about" in a program, but 
IMHO knowing which ones those are and how to do the necessary analysis 
is software engineering, not programming.

This is why I used to say that learning Ada is 95% software engineering 
and 5% syntax.  This analysis is often don't "off to one side" and at 
best results in a one-line comment in the source code.  But Ada puts the 
onus of doing this sort of thinking directly on the programmer.  Ada 
makes implementing whatever you decide easy.  But it can't decide for you.

I used to teach that when these situations come up, Ada asks you a 
question.  There was a discussion here about Apples and Oranges the 
other day which illustrates my point exactly.  If the requirements say 
count "at least 100" apples, how do you define the subtype?  There will 
be an upper bound, but it is up to the programmer to choose a sensible one.

-- 

                                           Robert I. Eachus

"The terrorists rejoice in the killing of the innocent, and have 
promised similar violence against Americans, against all free peoples, 
and against any Muslims who reject their ideology of murder. Their 
barbarism cannot be appeased, and their hatred cannot be satisfied. 
There's only one way to deal with terror: We must confront the enemy and 
stay on the offensive until these killers are defeated." -- George W. Bush




  reply	other threads:[~2004-06-09  7:03 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-26 19:46 Where are returned values stored? (follow up to yesterday's question) James Alan Farrell
2004-05-26 20:44 ` Simon Wright
2004-05-27  7:51   ` Dmitry A. Kazakov
2004-05-27  9:39 ` Where are returned values stored? Marius Amado Alves
2004-05-27 17:05   ` Warren W. Gay VE3WWG
2004-05-27 20:24     ` James Alan Farrell
2004-05-28 20:33       ` Warren W. Gay VE3WWG
2004-05-29  7:03         ` Martin Krischik
2004-05-29 13:19           ` Larry Kilgallen
2004-05-30  7:10             ` Martin Krischik
2004-06-02  3:14         ` Robert I. Eachus
2004-05-30 21:17     ` Nick Roberts
2004-05-31 12:58       ` Warren W. Gay VE3WWG
2004-06-02  4:07         ` Robert I. Eachus
2004-06-02 12:42           ` Warren W. Gay VE3WWG
2004-06-03  2:00             ` Nick Roberts
2004-06-03  4:34             ` Robert I. Eachus
2004-06-03 16:06               ` Warren W. Gay VE3WWG
2004-06-03 16:13               ` Nick Roberts
2004-06-07  1:53                 ` Robert I. Eachus
2004-06-07 13:09                   ` Larry Kilgallen
2004-06-09  7:03                     ` Robert I. Eachus [this message]
2004-06-05 17:13             ` Simon Wright
2004-05-27 17:11   ` Martin Krischik
2004-05-27 17:07 ` Where are returned values stored? (follow up to yesterday's question) Martin Krischik
replies disabled

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