comp.lang.ada
 help / color / mirror / Atom feed
From: Dave Thompson <david.thompson1@worldnet.att.net>
Subject: Re: Objects and the Stack?
Date: Mon, 27 Dec 2004 04:34:16 GMT
Date: 2004-12-27T04:34:16+00:00	[thread overview]
Message-ID: <6t2vs09a86cbbjeei08af6cdqap1j10l2n@4ax.com> (raw)
In-Reply-To: pan.2004.12.17.15.01.13.949959@nowhere.net

On Fri, 17 Dec 2004 19:52:24 GMT, Freejack <freejack@nowhere.net>
wrote:

> On Fri, 17 Dec 2004 11:46:11 +0000, Nick Roberts wrote:
<snip>
> > Ada has no equivalent of alloca() in C. It might be interesting to 
> > experiment with a compiler extension to provide this facility. Certain 
> > algorithms might benefit from it.
> > 
> >     declare
> >        Name: String := "";
> >        pragma Extensible_Object(Name);
> >     begin
> >        ...
> >        Name := Name & ':'; -- changes its size
> >        ...
> > 
> > It's an idea.
> 
> I think the florist bindings have an Interface to the brk() and sbrk()
> system calls, which is how it's usually done in C/Asm.

I don't know any C implementation that uses s/brk for an individual
object; the overhead of hitting the kernel every time would be too
high, and anyway it's limited to only (one object at) the end of the
data area. What's usual is to get hunks of (heap) space from s/brk,
mmap, or similar, and parcel it out by malloc, calloc, and realloc.
s/brk only on systems that have it of course, that is Unix-like ones.
And not at all for stack, which as Nick noted can usually be accessed
by alloca(), although that is not standard (neither C nor POSIX).

> Perhaps by declaring the Objects to be Controlled, and then putting in
> calls to brk() one might achieve the same effect.
> 
Controlled doesn't affect allocation at all, only destruction and
copying. Using 'new' would almost certainly put you in the heap, but
the probability of landing exactly at the end of the data area is low
at best, and probably zero on some implementations.

- David.Thompson1 at worldnet.att.net



  parent reply	other threads:[~2004-12-27  4:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-16 22:27 Objects and the Stack? Freejack
2004-12-16 23:13 ` Nick Roberts
2004-12-20 14:50   ` Marc A. Criley
2004-12-20 16:22     ` Marius Amado Alves
2004-12-20 18:31       ` Dmitry A. Kazakov
2004-12-17  0:28 ` Jeffrey Carter
2004-12-17  8:45   ` Freejack
2004-12-17 11:11     ` Martin Dowie
2004-12-17 11:46     ` Nick Roberts
2004-12-17 19:52       ` Freejack
2004-12-18  4:02         ` Nick Roberts
2004-12-27  4:34         ` Dave Thompson [this message]
2004-12-18 19:41       ` Warren W. Gay VE3WWG
2004-12-18 20:50         ` Freejack
2004-12-18 21:15           ` Dmitry A. Kazakov
2004-12-27  4:34         ` Dave Thompson
2004-12-18  0:12     ` Jeffrey Carter
2004-12-18  0:43       ` Jeffrey Carter
replies disabled

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