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!news3.google.com!news.glorb.com!wns13feed!worldnet.att.net!attbi_s52.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: 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_s52 1103273131 67.164.245.153 (Fri, 17 Dec 2004 08:45:31 GMT) NNTP-Posting-Date: Fri, 17 Dec 2004 08:45:31 GMT Organization: Comcast Online Date: Fri, 17 Dec 2004 08:45:31 GMT Xref: g2news1.google.com comp.lang.ada:7021 Date: 2004-12-17T08:45:31+00:00 List-Id: On Fri, 17 Dec 2004 00:28:23 +0000, Jeffrey Carter wrote: > The fact that pointers are generally not needed in Ada except when > creating things such as dynamic data structures has nothing to do with > tagged types. If you create objects of a classwide type, they are put on > the stack if you declare them there, and in a storage pool if you > allocate them there. > Something like ... declare Stack : Obstack'Class := Item'(SomeIndex); begin IsPushed := Push(Item); NewItem := Pop; end; Is what I have in mind. However what I'd like to be able to do( and what I'm working on. ) is something like this... package body obstacks is type obstack is abstract tagged null record; Stack : Obstack'Class; -- Problematic, needs some kind of discriminant. function pkgbodyPush(X : Item) return obstack'class is type NewStack is new Obstack with record Prev : Obstack'Class := Stack; NewItem : Item := X; end record; PushedStack : NewStack; --Again, problematic begin return PushedStack; end pkgbodyPush; And then, every time the internal pkgbodyPush is called we get.. Stack := pkgbodyPush(X); See where I'm going with this? The above code is riddled with problems that I gotta figure out. But that's the gist of it. The "Stack" variable should remain on the "stack" as long as the package body is in scope. That's my assumption at least. I'll know soon enough if I'm wrong. Heh. > I'm not sure what you mean by "extended" here, whether you're referring > to type extension or a value that becomes larger in 'Size, but this > doesn't work the way I think you think it will. Probably not. But then again, that's what experimentation is for. ;-> That's one of the ways I learn new programming methods. By taking a concept to the most absurd extreme I can imagine.