comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: Where are returned values stored?
Date: Sun, 06 Jun 2004 21:53:20 -0400
Date: 2004-06-06T21:53:20-04:00	[thread overview]
Message-ID: <fpadncjkKI4MV17dRVn-uQ@comcast.com> (raw)
In-Reply-To: <2i910dFk02i0U1@uni-berlin.de>

Nick Roberts wrote:

> Are you (Robert) talking about the main (control, primary) stack? I suspect
> most (in fact, all) tasks will use this, even if not much. The IA-32
> actually demands the existence of a valid stack (SS:ESP must be valid)
> before it will execute anything. I suppose this trick could be used with a
> secondary stack. I suppose it could apply to tasks prior to the start of
> their execution.

The secondary stack.  Ada task that don't need a primary stack are 
usually now replaced by protected objects, which don't have a stack of 
their own.

> However, it doesn't really detract form the point that, when the stacks
> /are/ used, they must be allocated somewhere in your address space.

But my point was that it is a consequence of good software engineering 
in Ada that very few tasks ever need the secondary stack.

This is a "meta-point" that needs to be made again and again.  Ada 
compilers use many 'solutions' that assume that "under normal 
circumstances" performance will be fine.  Normal circumstances for Ada 
includes decent software engineering practice.  There are lots of 
'newbie' questions, like this one, where the answer has to reference 
software engineering practice to describe WHY things are done the way 
they are done.

In this case, the assumption is that in Ada, functions do not normally 
return 'large' objects, but that large is defined in terms of 
performance in the execution environment, not some arbitrary limit.  So 
if a program uses some function that returns a multi-megabyte String, in 
some execution environments this will be a problem.  But if Integer is a 
32-bit type, the language will allow you to try to return a 2 Gigabyte 
String.  On most hardware, you will fail, but if you are running your 
program on a 64-bit system with more 4 Gigs of memory, performance won't 
be bad at all.

Of course the right thing to do for 'huge' Strings is to put them in 
records, and if necessary go the extra effort to return not the record 
but an access type designating it.  In practice though, these huge 
Strings are not manipulated that way.  You use Unbounded_String, and the 
implementation does the necessary magic for you.

-- 

                                           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-07  1:53 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 [this message]
2004-06-07 13:09                   ` Larry Kilgallen
2004-06-09  7:03                     ` Robert I. Eachus
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