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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.ada Subject: Re: How to get Ada to =?utf-8?Q?=E2=80=9Ccross?= the =?utf-8?Q?ch?= =?utf-8?Q?asm=E2=80=9D=3F?= Date: Sat, 05 May 2018 16:06:57 -0700 Organization: A noiseless patient Spider Message-ID: <87d0y97lda.fsf@nightsong.com> References: <1c73f159-eae4-4ae7-a348-03964b007197@googlegroups.com> <878t9nemrl.fsf@nightsong.com> <87h8nl50rw.fsf@nightsong.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="a1b938f69dddc3836c7a58a524d03b55"; logging-data="3159"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+gvnDMq6vuDyerjwwWaHnD" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cancel-Lock: sha1:DhTftAIlZs6eV/1mrlY8qjuXVKY= sha1:kCsQAjsKUOBUpknXAVJp0LVpO/I= Xref: reader02.eternal-september.org comp.lang.ada:52021 Date: 2018-05-05T16:06:57-07:00 List-Id: Niklas Holsti writes: > One reason is that when a function evaluates an expression that > creates an object of a large, dynamic size (eg. an array expression) > on the secondary stack, this object can be returned /in situ/ as the > function's return value, without being copied. Ok, but that pattern is so common that allocating the space in the primary stack before calling the function is a standard optimization that every serious C++ compiler knows how to do. Then the function writes the result into the primary stack and the caller can still use it after the function returns. Could Ada not do it the same way?