comp.lang.ada
 help / color / mirror / Atom feed
* Variable initialized to <>
@ 2014-10-14 18:02 Mab
  2014-10-14 18:22 ` mockturtle
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mab @ 2014-10-14 18:02 UTC (permalink / raw)



What does it mean to initialize variables to an unspecified range <>:

For example:
Record1: Rec_Type1 :=
    (ID     => <>,
     Label  => <>,
     Active => <>);

I'm aware of <> used in an array definition to indicate unspecified range but not sure what it means to initialize to a variable as shown above. The variables above can be of any types.

Thanks


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Variable initialized to <>
  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
  2 siblings, 0 replies; 4+ messages in thread
From: mockturtle @ 2014-10-14 18:22 UTC (permalink / raw)


On Tuesday, October 14, 2014 8:02:42 PM UTC+2, Mab wrote:
> What does it mean to initialize variables to an unspecified range <>:
> 
> 
> 
> For example:
> 
> Record1: Rec_Type1 :=
>     (ID     => <>,
>      Label  => <>,
>      Active => <>) 
> I'm aware of <> used in an array definition to indicate unspecified range but not sure what it means to initialize to a variable as shown above. The variables above can be of any types.
> 
> 
> 
> Thanks

Roughly, it means "initialize the component with the default value." See paragraph 19.1/2 of RM 4.3.1 [ http://ada-auth.org/standards/12rm/html/RM-4-3-1.html ] for the exact wording.   This notation allow you to use the default value for a component in an aggregate (where, I think you know, you must specify *all* the components).

Riccardo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Variable initialized to <>
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Jeffrey Carter @ 2014-10-14 18:29 UTC (permalink / raw)


On 10/14/2014 11:02 AM, Mab wrote:
> 
> What does it mean to initialize variables to an unspecified range <>:
> 
> For example:
> Record1: Rec_Type1 :=
>     (ID     => <>,
>      Label  => <>,
>      Active => <>);

Record1 is a variable; ID, Label, and Active are component names in a record
aggregate. ARM 4.3.1(19.1/2) explains the use of <> in a record aggregate.

http://www.adaic.org/resources/add_content/standards/12rm/html/RM-4-3-1.html

ARM 4.3.3(23.1/2) explains its use in array aggregates.

-- 
Jeff Carter
"If you think you got a nasty taunting this time,
you ain't heard nothing yet!"
Monty Python and the Holy Grail
23


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Variable initialized to <>
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Georg Bauhaus @ 2014-10-14 20:45 UTC (permalink / raw)


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);




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-14 20:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox