comp.lang.ada
 help / color / mirror / Atom feed
* Disriminant question
@ 2003-03-07  7:09 prashna
  2003-03-07  8:01 ` tmoran
  2003-03-07 11:17 ` Lutz Donnerhacke
  0 siblings, 2 replies; 11+ messages in thread
From: prashna @ 2003-03-07  7:09 UTC (permalink / raw)


Hi all,
How to change discriminant value dynamically?

For ex, Have look at following program,

procedure DISCRIMINANT1 is
type DISC(some_disc : integer) is
record
  case some_disc is
  when 1 | 2 =>
     int1 : integer;
  when others =>
     flt : float;
  end case;
end record;

DISC1 : DISC(3);
begin
  disc1.some_disc := 1;
  ^^^^^^^^ I have to change the discriminant.Is there any way to do
this.Any tips will be appriciated.
end;

Thanks



^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: Disriminant question - Waiting desperately for solution :-(
@ 2003-03-13  5:40 Grein, Christoph
  2003-03-13 13:13 ` Gautier
  0 siblings, 1 reply; 11+ messages in thread
From: Grein, Christoph @ 2003-03-13  5:40 UTC (permalink / raw)
  To: comp.lang.ada

From: gautier_niouzes@hotmail.com (Gautier)
> 
> type T_TERM (LEG_TYPE : T_LEG_TYPE := NONE) is
>       record
>          case LEG_TYPE is
>             when DF | TF | LIF | TP =>
>                FIX : T_FIX;
>             when PPOS | NONE =>
>                null;
>          end case;
>       end record;
> ...
>    L_TERM : SERVER_TYPES.T_TERM;
> 
> Well, L_TERM has the discriminant LEG_TYPE = NONE.
> Then L_TERM.FIX is a nonsense. This is why...
> 
>       L_TERM := (LEG_TYPE => SERVER_TYPES.TF, 
>                  FIX =>
> 
> ...bombs with a "discriminant error". Fun, isn't it ?

No, your analysis is quite wrong. L_Tern is defined without discriminant in this 
example, so only its _default_ value is None, but it may change. So the 
assignmant to L_Tern should work.

The code snippet is too coarse to come to a conclusion why this error occurs (at 
least I didn't feel like chasing the error in this mess :-).



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

end of thread, other threads:[~2003-03-13 13:13 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-07  7:09 Disriminant question prashna
2003-03-07  8:01 ` tmoran
2003-03-07 11:20   ` Lutz Donnerhacke
2003-03-07 17:59     ` tmoran
2003-03-07 22:32       ` Lutz Donnerhacke
2003-03-07 11:17 ` Lutz Donnerhacke
2003-03-07 16:46   ` Matthew Heaney
2003-03-12  9:25     ` Disriminant question - Waiting desperately for solution :-( prashna
2003-03-12 16:12       ` Gautier
  -- strict thread matches above, loose matches on Subject: below --
2003-03-13  5:40 Grein, Christoph
2003-03-13 13:13 ` Gautier

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