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!newshub.sdsu.edu!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s54.POSTED!53ab2750!not-for-mail From: Freejack Subject: Re: Objects and the Stack? User-Agent: Pan/0.14.2.91 (As She Crawled Across the Table) Message-ID: Newsgroups: comp.lang.ada References: <32fv82F3l9al7U1@individual.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 67.164.245.153 X-Complaints-To: abuse@comcast.net X-Trace: attbi_s54 1103403047 67.164.245.153 (Sat, 18 Dec 2004 20:50:47 GMT) NNTP-Posting-Date: Sat, 18 Dec 2004 20:50:47 GMT Organization: Comcast Online Date: Sat, 18 Dec 2004 20:50:47 GMT Xref: g2news1.google.com comp.lang.ada:7057 Date: 2004-12-18T20:50:47+00:00 List-Id: On Sat, 18 Dec 2004 14:41:33 -0500, Warren W. Gay VE3WWG wrote: > The difference between what alloca() gets you and what you > get in the declare block is a minor difference: > > -- Pseudo Ada here (Ada-ised C code for alloca()) > declare > My_String : String_Access := Alloca(String(1..8)); > begin > ... > Put_Line(My_String.all); > > -- Real Ada here > declare > My_String : String(1..8); > begin > ... > Put_Line(My_String); > > Apart from getting a pointer from alloca(), I don't see any > advantage. Both forms allocate from the stack frame. > >> declare >> Name: String := ""; >> pragma Extensible_Object(Name); >> begin >> ... >> Name := Name & ':'; -- changes its size >> ... >> >> It's an idea. > > This is taking the alloca() idea further than I think it > goes. I could be wrong here, but can you realloc() an > alloca() region? If so, that is something that Ada does > in fact lack (including a realloc() in general, which I > pine for when growing arrays). > > Warren. Hmmm... Perhaps we could do that, and even more, by using Tasks and/or Protected Objects. After all, on a platform with stack frames, doesn't instantiation of a new task initialize a new stack frame? A Task Storage_Pool would also be a Pool of stack frames? I'll have to go look it up, but if there is a way to declare Tasks or Protected Objects as Controlled or Limited_Controlled within a Storage_Pool(or perhaps in the general storage_pool), then it might be possible. Another possibility would be duplicating exactly the current task in another task with a larger stack frame, switching control to the new task, and killing off the old one, or keeping it around if the current new task shrinks to the point where it's larger stack frame is no longer needed. I'm gonna have to read up on that. And look at some compiler source. Freejack