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!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.109.56.24.8.mobile.3.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: How to get Ada to =?windows-1252?Q?=93cross?= the =?windows-1252?Q?chasm=94=3F?= Date: Tue, 08 May 2018 10:28:13 +0200 Organization: JSA Research & Innovation Message-ID: <87efimtuua.fsf@jacob-sparre.dk> References: <1c73f159-eae4-4ae7-a348-03964b007197@googlegroups.com> <878t9nemrl.fsf@nightsong.com> <87h8nl50rw.fsf@nightsong.com> <87d0y97lda.fsf@nightsong.com> <87o9hsu3er.fsf@jacob-sparre.dk> <87efimy7x5.fsf@nightsong.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: franka.jacob-sparre.dk; posting-host="109.56.24.8.mobile.3.dk:109.56.24.8"; logging-data="24162"; mail-complaints-to="news@jacob-sparre.dk" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:yXSF+CKaZ+uXwesSHV5veHqq4/0= Xref: reader02.eternal-september.org comp.lang.ada:52097 Date: 2018-05-08T10:28:13+02:00 List-Id: Paul Rubin writes: > Jacob Sparre Andersen writes: >> Paul Rubin wrote: >>> Then the function writes the result into the primary stack and the >>> caller can still use it after the function returns. >> >> How would you do it with this example? ... >> procedure Random_String is ... > > I couldn't tell quite what that example was doing, but C++ > std::strings are allocated on the heap, so it looks to me like the > return value is a single pointer. Std::vector should be similar while > std:array is just for fixed size arrays. I think C++ may be more > willing in general than Ada to heap-allocate data, which is freed when > it goes out of scope. Imagine it wasn't a string, but some other explicitly fixed size array. I can't see how the compiler in this case can preallocate the array on the primary stack as you write above. It the explanation that C++ simply doesn't allow functions to return indefinite types, and thus prevents the programmers from using the stack for indefinite types? Greetings, Jacob -- "Human beings just can't not communicate."