comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
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
Date: 2017-12-17T14:51:48+01:00	[thread overview]
Message-ID: <p15spk$51n$1@dont-email.me> (raw)
In-Reply-To: <1e659202-ab0b-44a5-9549-3e41fa465ab4@googlegroups.com>

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


  parent reply	other threads:[~2017-12-17 13:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-16 20:56 how to do things like procedure foo(A: string) is bar: string := A; begin; ...;end; Mehdi Saada
2017-12-16 21:49 ` Jeffrey R. Carter
2017-12-17 12:40   ` Mehdi Saada
2017-12-17 13:25     ` Jere
2017-12-17 13:49       ` Jere
2017-12-17 13:51     ` Jeffrey R. Carter [this message]
2017-12-18 22:22     ` Randy Brukardt
2017-12-18  6:39 ` Robert Eachus
2017-12-18 15:34   ` Mehdi Saada
2017-12-18 17:31     ` Anh Vo
2017-12-18 21:14     ` Robert Eachus
2017-12-19 22:52   ` Robert Eachus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox