* Re: Disriminant question - Waiting desperately for solution :-(
2003-03-07 16:46 ` Matthew Heaney
@ 2003-03-12 9:25 ` prashna
2003-03-12 16:12 ` Gautier
0 siblings, 1 reply; 4+ messages in thread
From: prashna @ 2003-03-12 9:25 UTC (permalink / raw)
>
> The rule is that you can't change the discriminant if the object was
> declared with an explicit discriminant value.
>
Thanks all for helping.
Here is my original code(which I should I have posted earlier but
could not because this is highly confidential and hence I am showing
only part of the code.Hope u ppl understand.) and a runtime error
(discriminant error) is raising.
procedure CLEAR_DISCON (PRIMARY_FPLN_PARAM : in out
SERVER_TYPES.T_PRIMARY_FPLN;
DISCON : in
SERVER_TYPES.T_LEG_INDEX;
REQUEST_STATUS : out
SERVER_TYPES.T_REQUEST_STATUS;
MODIFICATION_REPORT : out
SERVER_TYPES.T_FPLN_MODIF_ORIGIN) is
L_TERM : SERVER_TYPES.T_TERM;
...
...
begin
....
....
L_TERM := (LEG_TYPE => SERVER_TYPES.TF,
FIX =>
PRIMARY_FPLN_PARAM.LEGS.LEGS_ARRAY(0).TERM.FIX);
^^^ exception discriminat error is raised here
--PRIMARY_FPLN_PARAM.LEGS.LEGS_ARRAY(DISCON+1).TERM := L_TERM;
PRIMARY_FPLN_PARAM.LEGS.LEGS_ARRAY(DISCON+1).TERM :=
(LEG_TYPE => SERVER_TYPES.TF,
FIX => ( IDENT => L_TERM.FIX.IDENT,
B_OVERFLY => L_TERM.FIX.B_OVERFLY,
POS => ( LAT => L_TERM.FIX.POS.LAT,
LON => L_TERM.FIX.POS.LON)));
^^^ Is this OK if I correct the previous
error?
....
....
end CLEAR_DISCON;
package SERVER_TYPES is
......
......
type T_FIX is
record
IDENT : FMS_TYPES.T_IDENT (1 .. 7);
B_OVERFLY : BOOLEAN;
POS : FMS_TYPES.T_POSITION;
end record;
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;
type T_LEG (LEG_TYPE : T_LEG_TYPE := NONE) is
record
MARK : T_LEG_INDEX := 0;
TERM : T_TERM (LEG_TYPE);
TURN_DIR : FMS_TYPES.T_TURN_DIR := FMS_TYPES.NONE;
B_DISC_AHEAD : BOOLEAN := FALSE;
STATIC_PARAMETERS : T_LEG_STATIC_PARAMETERS_C;
DISTANCE_CUMUL : FMS_TYPES.T_DISTANCE_NM_C;
end record;
.....
.....
end SERVER_TYPES;
package FMS_TYPES is
.....
.....
subtype T_ANG_REL_DEG is T_DEGREE range -179.99999 .. +180.0;
subtype T_LATITUDE is T_ANG_REL_DEG range -90.0 .. +90.0;
subtype T_LONGITUDE is T_ANG_REL_DEG;
type T_IDENT_INDEX is range 0 .. 30;
type T_CHAR is
(
PROG,
....
....
LOZENGE);
type T_IDENT is array (T_IDENT_INDEX range <>) of T_ISO5_CHAR;
type T_POSITION is record
LAT : T_LATITUDE;
LON : T_LONGITUDE;
end record;
...
...
end FMS_TYPES;
I am using gnat compiler on AIX machine.
Hope this information is enough.
Thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Disriminant question - Waiting desperately for solution :-(
2003-03-12 9:25 ` Disriminant question - Waiting desperately for solution :-( prashna
@ 2003-03-12 16:12 ` Gautier
0 siblings, 0 replies; 4+ messages in thread
From: Gautier @ 2003-03-12 16:12 UTC (permalink / raw)
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 ?
________________________________________________________
Gautier -- http://www.mysunrise.ch/users/gdm/gsoft.htm
NB: For a direct answer, e-mail address on the Web site!
^ permalink raw reply [flat|nested] 4+ 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; 4+ 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] 4+ messages in thread
* Re: Disriminant question - Waiting desperately for solution :-(
2003-03-13 5:40 Disriminant question - Waiting desperately for solution :-( Grein, Christoph
@ 2003-03-13 13:13 ` Gautier
0 siblings, 0 replies; 4+ messages in thread
From: Gautier @ 2003-03-13 13:13 UTC (permalink / raw)
Grein, Christoph:
> 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.
Thank you (and sorry for the wrong information).
I learnt again something about Ada.
In that case L_Term can change discriminant when it wants - strange!
________________________________________________________
Gautier -- http://www.mysunrise.ch/users/gdm/gsoft.htm
NB: For a direct answer, e-mail address on the Web site!
___
PS: I couldn't resist to test - maybe the OP should start with a
simplified example and complicate it until the bug is picked...
with Ada.Text_IO; use Ada.Text_IO;
procedure Discri is
type T_Leg_Type is (Df, Tf, Lif, Tp, Ppos, None);
type T_Fix is new Integer;
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 : T_Term;
begin
Put_Line( T_Leg_Type'image(L_Term.Leg_Type) );
L_Term := ( Leg_Type => Tf, Fix => 0);
Put_Line( T_Leg_Type'image(L_Term.Leg_Type) );
L_Term := ( Leg_Type => Ppos );
Put_Line( T_Leg_Type'image(L_Term.Leg_Type) );
L_Term := ( Leg_Type => Df, Fix => 0);
Put_Line( T_Leg_Type'image(L_Term.Leg_Type) );
Put_Line("Survived !");
end;
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-03-13 13:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-13 5:40 Disriminant question - Waiting desperately for solution :-( Grein, Christoph
2003-03-13 13:13 ` Gautier
-- strict thread matches above, loose matches on Subject: below --
2003-03-07 7:09 Disriminant question prashna
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox