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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e5eb8ca5dcea2827 X-Google-Attributes: gid103376,public From: Samuel Mize Subject: Re: Ada OO Mechanism Date: 1999/06/08 Message-ID: <7jjpru$2t1b@news2.newsguy.com>#1/1 X-Deja-AN: 487199977 References: <7i05aq$rgl$1@news.orbitworld.net> <374AC676.F7AE0772@lmco.com> <7ieuja$5v9@news1.newsguy.com> <7ifd6l$bmf@sjx-ixn1.ix.netcom.com> <7ihf6i$4hv@dfw-ixnews10.ix.netcom.com> Organization: ImagiNet Communications, Ltd. User-Agent: tin/pre-1.4-981002 ("Phobia") (UNIX) (AIX/3-2) Newsgroups: comp.lang.ada Date: 1999-06-08T00:00:00+00:00 List-Id: Hyman Rosen wrote: > Matthew Heaney writes: ... >> declare >> O : T'Class := Func_Return_T_Tic_Class; >> begin >> In neither case is heap required. > > And despite that, you said before that the size of O is determined > at run-time, not at compile-time. Also, I looked at some of the code > generated by GNAT, and saw references to a secondary_stack_allocate > (or something like that) function. So the storage for S and O is > allocated somewhere, but it's on the stack? Is this something like > alloca? I infer from the name "Func_Return_T_Tic_Class" that this function returns a value of T'Class. It may be of type T, or of a type derived from T. O is allocated on stack, just like any other declare-block variable. (A function/procedure local variable would be just the same.) O will receive that value, and is of the specific type returned, for the duration of the declare block. Next time this block is executed, if Func's return is a different type, O will be of that specific type. O's size is determined at run-time, when it finds out exactly what type of object it has to hold. I should say, of course, that O is allocated on stack on typical architectures, by typical compilers. There is no concept of "stack" and "heap" required by the language, although Ada IS designed to give you control over heap usage on machines where that concept makes sense (as opposed, IIRC and e.g., to Lisp machines). Best, Sam Mize -- Samuel Mize -- smize@imagin.net (home email) -- Team Ada Fight Spam: see http://www.cauce.org/ \\\ Smert Spamonam