comp.lang.ada
 help / color / mirror / Atom feed
From: whraven@usenet-access.com (Richard Pinkall-Pollei)
Subject: Re: record question
Date: 26 Oct 2001 16:22:49 -0500
Date: 2001-10-26T16:22:49-05:00	[thread overview]
Message-ID: <slrn9tjlpq.5g5.whraven@raven.wri> (raw)
In-Reply-To: 3BD9618C.D154FE0C@icn.siemens.de

>assume that I have a record like the one below. I can assign aggregates
>in the case that I have subcomponents, but how do I assign if I don't
>have?
>
> [code example moved to end of message for reference]

The record type you are using is "mutable", since it has a default
discriminant.  Thus, you can change the discriminant, but only if you
provide a complete record or aggregate in the assignment.  Thus, you
would have to use "y := ( i => 99 ) ;" since it assigns a complete
aggregate (since "i" is the only component for this discriminant
value).  You cannot use the "y.i" form, since that would technically
only assign a single component, even though the record has only one
component.

I ran your code fragment through the GNAT 3.13p compiler, just to see
if it was smart enough to realize that "y.i" was, in fact, the only
record component.  The error message resulting from the "y.i"
assignment states that the left hand of the assignment must be a
variable.  I would say that's not the real problem, but I'm not sure
why GNAT flags it this way.

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


-- 
______________________________________________________________________________
Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net



  parent reply	other threads:[~2001-10-26 21:22 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 [this message]
2001-10-26 23:54 ` Jeffrey Carter
replies disabled

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