comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <bauhaus@futureapps.invalid>
Subject: Re: Variable initialized to <>
Date: Tue, 14 Oct 2014 22:45:09 +0200
Date: 2014-10-14T22:45:09+02:00	[thread overview]
Message-ID: <m1k20m$204$1@dont-email.me> (raw)
In-Reply-To: <0660a64b-cbd1-4fee-a454-3231351b622c@googlegroups.com>

On 14.10.14 20:02, Mab wrote:
> I'm aware of <> used in an array definition to indicate unspecified range but not sure what it means to initialize to a variable

"<>" is also known as a "box". Where you see "<>", you'll typically
get what's in a box for whatever the context is indicating.
A black box, of sorts. Others have given pointers to the specifics.

The box can also appear with type and with generic formals, e.g.,
to mean "hidden", or  "automatically chosen" when instantiating.
The latter means that something in the context matches a generic
formal that is somehow marked with "<>". The former could mean
hidden discriminants only written in the private part (including
none at all), thus making the type publicly indefinite.

There is also a formal enumeration type, which I like to think of
as a parenthesized list of names that runs from here ("<...")
to there ("...>"), and is therefore written "(<>)" in generics.

generic
    type T is private;
    type I is (<>);
    type Seq is array (I range <>) of T;
    with function "+" (X, Y : T) return T is <>;
function Sum (A : Seq; Surplus : T) return T;


If there is a type Xyz that has "+" definied as one of its operations,
then the box at the end of the last generic formal, i.e. of  "+",
indicates that the "+" of Xyz needs not be mentioned when instantiating
generic Sum with Xyz for T:

    type Line is array (Positive range <>) of Xyz;

    function My_Sum is new Sum
      (T => Xyz,
       I => Positive,
       Seq => Line);




      parent reply	other threads:[~2014-10-14 20:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-14 18:02 Variable initialized to <> Mab
2014-10-14 18:22 ` mockturtle
2014-10-14 18:29 ` Jeffrey Carter
2014-10-14 20:45 ` Georg Bauhaus [this message]
replies disabled

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