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 X-Received: by 2002:ac8:382f:: with SMTP id q44mr4906552qtb.276.1585957541083; Fri, 03 Apr 2020 16:45:41 -0700 (PDT) X-Received: by 2002:a9d:775a:: with SMTP id t26mr8471031otl.178.1585957540898; Fri, 03 Apr 2020 16:45:40 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 3 Apr 2020 16:45:40 -0700 (PDT) In-Reply-To: <94a54092-a56f-4a99-aaec-08dd611c8fd8@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=76.77.182.20; posting-account=W2gdXQoAAADxIuhBWhPFjUps3wUp4RhQ NNTP-Posting-Host: 76.77.182.20 References: <94a54092-a56f-4a99-aaec-08dd611c8fd8@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7d0c6237-da84-4d48-8aa4-764b747975be@googlegroups.com> Subject: Re: Proposal: Auto-allocation of Indefinite Objects From: Stephen Leake Injection-Date: Fri, 03 Apr 2020 23:45:41 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:58305 Date: 2020-04-03T16:45:40-07:00 List-Id: On Friday, April 3, 2020 at 3:48:43 PM UTC-7, Stephen Davies wrote: > Firstly, apologies if this has already been discussed or, > more likely, if it's a really stupid idea for some reason > that I haven't thought of. > > My proposal is that it should (sometimes?) be possible to declare > objects of indefinite types such as String and have the compiler > automatically declare the space for them without the programmer > having to resort to access types. declare Foo : String := ...; begin ... end; Foo is allocated on the stack; size is taken from the initialization expression. with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; declare Foo : Unbounded_String; -- empty begin Foo := To_Unbounded ("hi"); -- allocated on the heap Foo := Foo & To_Unbounded ("bye"); -- allocation grows end; -- deallocated. -- Stephe