comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: record question
Date: Fri, 26 Oct 2001 23:54:14 GMT
Date: 2001-10-26T23:54:14+00:00	[thread overview]
Message-ID: <3BD9F79F.B87BE6EC@acm.org> (raw)
In-Reply-To: 3BD9618C.D154FE0C@icn.siemens.de

Alfred Hilscher wrote:
> 
> procedure RT is
>   type x (i : Integer := 0) is
>     record
>       case i is
>         when 0 => null;
>         when 1..10 => s : STRING (1..10);
>         when others => null;
>       end case;
>     end record;
> 
>   y : x;
> begin
>   y := (1, "ABC       ");  -- this is OK
> 
>   y := (99);   -- but, how do that ?
> 
>   y.i := 99;   -- do not work either, so how assign a value different to
> 1..10 ?
> end RT;

(99) is a parenthesized expression, not an aggregate. An aggregate of
one value must use named notation:

(I => 99)

You may only change a discriminant of an unconstrained record variable
by assigning the entire record at once. Since I is a discriminant of
type X, "Y.I := ..." is illegal.

Thus, you must write:

Y := (I => 99);

-- 
Jeff Carter
"I wave my private parts at your aunties."
Monty Python & the Holy Grail



      parent reply	other threads:[~2001-10-26 23:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-26 13:13 record question Alfred Hilscher
2001-10-26 13:33 ` Petter Fryklund
2001-10-26 14:59   ` Ted Dennison
2001-10-26 13:42 ` Claude SIMON
2001-10-26 15:01   ` Ted Dennison
2001-10-26 15:50     ` Claude SIMON
2001-10-26 21:22 ` Richard Pinkall-Pollei
2001-10-26 23:54 ` Jeffrey Carter [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