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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,474d28ddf953b3c1 X-Google-Attributes: gid103376,public X-Google-Thread: 1014db,8e3b3db66f3b0061 X-Google-Attributes: gid1014db,public X-Google-Thread: f4fd2,8e3b3db66f3b0061 X-Google-Attributes: gidf4fd2,public X-Google-Thread: fd443,8e3b3db66f3b0061 X-Google-Attributes: gidfd443,public X-Google-Thread: 109fba,8e3b3db66f3b0061 X-Google-Attributes: gid109fba,public X-Google-ArrivalTime: 1994-12-16 11:35:54 PST Newsgroups: alt.lang.design,comp.lang.c,comp.lang.c++,comp.lang.lisp,comp.lang.ada Path: nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!rutgers!sgigate.sgi.com!sgiblab!uhog.mit.edu!bloom-beacon.mit.edu!news.bu.edu!inmet!dsd!bobduff From: bobduff@dsd.camb.inmet.com (Bob Duff) Subject: Re: Reference Counting (was Re: Searching Method for Incremental Garbage Collection) Message-ID: Sender: news@inmet.camb.inmet.com Organization: Intermetrics, Inc. References: Date: Fri, 16 Dec 1994 19:35:54 GMT Xref: nntp.gmd.de comp.lang.c:72318 comp.lang.c++:83014 comp.lang.lisp:9610 comp.lang.ada:17547 Date: 1994-12-16T19:35:54+00:00 List-Id: In article , Henry G. Baker wrote: >Another common example is a function that returns an object of >arbitrary size. You don't know how much space to allocate for it >on the stack, and if you simply redefine the stack frame to include >the object (which was stack-allocated by the called function), then >you may waste huge amounts of space on the stack. So you're better >off allocating it in a heap, but remembering that you have only >one pointer to it. Some Ada compilers allocate those things on the heap. However, others (most, I believe) allocate those things on the stack. When the function returns, the result object is copied from wherever it is down to where it belongs. There are numerous complicated optimizations that can be done to avoid the copying in many cases. Some compilers use the normal run-time stack, whereas others have a secondary stack for these kinds of things, but either way, the principle is the same. - Bob -- Bob Duff bobduff@inmet.com Oak Tree Software, Inc. Ada 9X Mapping/Revision Team (Intermetrics, Inc.)