From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7aeecd1069c28415 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail From: Dave Thompson Newsgroups: comp.lang.ada Subject: Re: Objects and the Stack? Message-ID: <6t2vs09a86cbbjeei08af6cdqap1j10l2n@4ax.com> References: <32fv82F3l9al7U1@individual.net> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 27 Dec 2004 04:34:16 GMT NNTP-Posting-Host: 12.76.19.129 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1104122056 12.76.19.129 (Mon, 27 Dec 2004 04:34:16 GMT) NNTP-Posting-Date: Mon, 27 Dec 2004 04:34:16 GMT Organization: AT&T Worldnet Xref: g2news1.google.com comp.lang.ada:7222 Date: 2004-12-27T04:34:16+00:00 List-Id: On Fri, 17 Dec 2004 19:52:24 GMT, Freejack wrote: > On Fri, 17 Dec 2004 11:46:11 +0000, Nick Roberts wrote: > > 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