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: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: how to do things like procedure foo(A: string) is bar: string := A; begin; ...;end; Date: Sun, 17 Dec 2017 14:51:48 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <6bedbdee-ca7f-4d2a-83f9-6cc9c53d21cb@googlegroups.com> <1e659202-ab0b-44a5-9549-3e41fa465ab4@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 17 Dec 2017 13:51:48 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="a62f07b5f5b05d916a09b46bbb47255f"; logging-data="5175"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX194VIyiGYFpgQgHcUf43N4Rps3oURsPNNE=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 In-Reply-To: <1e659202-ab0b-44a5-9549-3e41fa465ab4@googlegroups.com> Content-Language: en-US Cancel-Lock: sha1:x6xAUmvQNbM9q8vNPQrzJezjkPc= Xref: reader02.eternal-september.org comp.lang.ada:49498 Date: 2017-12-17T14:51:48+01:00 List-Id: On 12/17/2017 01:40 PM, 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 necessary. A boggus idea of how the whole head + stack works. I'm still not sure, but it does simplify writing things a lot. For unconstrained array types, the bounds of an object can be determined at run time. This applies equally to explicit bounds like S : String (3 .. N); where N is not known until run time, or bounds obtained from an initialization expression not known until run time. "Static" basically means known at compile time. (The actual definition in the ARM is more complicated, but this will work fine in most cases.) What you're really dealing with here is the subtype of the object. These are equivalent to subtype anonymous is String (3 .. N); S : anonymous; and anonymous_c : constant String := Initialization_Expression; subtype anonymous is String (anonymous_c'range); S : anonymous := anonymous_c; Subtypes need not be static. -- Jeff Carter "When Roman engineers built a bridge, they had to stand under it while the first legion marched across. If programmers today worked under similar ground rules, they might well find themselves getting much more interested in Ada!" Robert Dewar 62