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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.107.183.193 with SMTP id h184mr10915401iof.129.1513517109912; Sun, 17 Dec 2017 05:25:09 -0800 (PST) X-Received: by 10.157.69.72 with SMTP id p8mr659983oti.4.1513517109392; Sun, 17 Dec 2017 05:25:09 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.kjsl.com!usenet.stanford.edu!g80no564770itg.0!news-out.google.com!s63ni881itb.0!nntp.google.com!g80no564765itg.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 17 Dec 2017 05:25:08 -0800 (PST) In-Reply-To: <1e659202-ab0b-44a5-9549-3e41fa465ab4@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.71.208.22; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 173.71.208.22 References: <6bedbdee-ca7f-4d2a-83f9-6cc9c53d21cb@googlegroups.com> <1e659202-ab0b-44a5-9549-3e41fa465ab4@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <99db6133-01df-4dfd-afd7-9521f937e79d@googlegroups.com> Subject: Re: how to do things like procedure foo(A: string) is bar: string := A; begin; ...;end; From: Jere Injection-Date: Sun, 17 Dec 2017 13:25:09 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:49495 Date: 2017-12-17T05:25:08-08:00 List-Id: On Sunday, December 17, 2017 at 7:41:02 AM UTC-5, Mehdi Saada wrote: > Fine. It means a variable's bounds must be known at initizialisation, not= compilation ? I had a boggus idea of what "static" means, or when it's nec= essary. A boggus idea of how the whole head + stack works. I'm still not su= re, but it does simplify writing things a lot. > Thanks. I don't write compilers, but there are different ways to attack that proble= m. =20 My guess is that when Foo is called and has an unconstrained String type, t= hen=20 the compiler probably pushes the length of the String to the stack as well = as=20 the string itself (or perhaps the string object stores it for unconstrained= =20 strings..again...don't know the implementations used). Then inside of Foo = when=20 it goes to allocate stack space, it can use those fields to calculate how m= uch=20 stack it needs for the local string vars that are initialized. There hones= tly=20 might be a completely different implementation (perhaps Randy or another=20 compiler writer can chime in), but the point is there are ways for it to be= =20 done. Now if constrained subtypes of String are used: type Name_String is String(1..10); procedure foo(L,R : Name_String); Then everything can be done at compile time.