comp.lang.ada
 help / color / mirror / Atom feed
* discriminant
@ 1997-01-13  0:00 AGBOH CHARLES
  1997-01-13  0:00 ` discriminant KJPrice
  1997-01-15  0:00 ` discriminant Michael F Brenner
  0 siblings, 2 replies; 13+ messages in thread
From: AGBOH CHARLES @ 1997-01-13  0:00 UTC (permalink / raw)



hello,

q:   what is a discriminant.  Why do some types carry discriminant.  
Why?  

q2:  I have a project.  I have to simulate a scheduler of tasks.  What
would the body the main sccheduler be like.  This is my first ada project
and I haven't a clue how to procceed.






^ permalink raw reply	[flat|nested] 13+ messages in thread
* discriminant
@ 1999-07-11  0:00 fluffy_doo
  1999-07-12  0:00 ` discriminant Roger Racine
  0 siblings, 1 reply; 13+ messages in thread
From: fluffy_doo @ 1999-07-11  0:00 UTC (permalink / raw)


Hi,

I'm having problems with the use of a discriminant for a RECORD
that is meant to hold the value for a High Precision Real Number
(my own type defined in an ADT).  I did *not* get any compilation
time errors for any of the things I have done (described below).

In my .ADS I have the following private structure:

PRIVATE
  TYPE T_Sign_Temp IS (POSITIVE, NEGATIVE, ABSENT);
  SUBTYPE T_Sign IS T_Sign_Temp RANGE POSITIVE..NEGATIVE;

  SUBTYPE T_Digit IS integer RANGE 0..9;
  TYPE T_Mantissa IS ARRAY (1..MAX_MANT_200) OF T_Digit;
  SUBTYPE T_Len_Mantissa IS positive RANGE 1..MAX_SIG_FIG_30;

  SUBTYPE T_Power IS integer RANGE integer'first..integer'last;
  SUBTYPE T_Positive_Power IS T_Power RANGE 0..integer'last;

  TYPE T_Kind IS ( INT, REAL, NONE );

  TYPE T_Number ( kind : T_Kind := NONE ) IS
  RECORD
	Sign : T_Sign := POSITIVE;
	Mant : T_Mantisse := (OTHERS => 0);
	Len : T_Lng_Mantisse := 0;
	CASE kind IS
		WHEN REAL =>	Point : natural RANGE 0..MAX_SIG_FIG_30 := 1;
						Power_R : T_Power := 0;
		WHEN INT =>		Power_I : T_Positive_Power := 0;
		WHEN NONE =>	NULL;
		END CASE;
  END RECORD;

When I assign a value to the Power_R for a real numbrer, the "Point"
field also changes (mysteriously), and after it has changed I can no 
longer assign a new value to it.  On top of this, the new value that
"Point" takes is *outside* my subtype range and no exception is
raised !  It tends to take a value a bit over 500, while its top limit
is a constant with a value of 30 !?!?  I got the value and the
moment of the change occuring from the debugger.

I have tried a large number of variations for a subprogram whose
task is to assign the T_Number fields' values, always with the same
result (problem) I have just described.

I tried with a function and with a procedure, many versions of each.
At first I would assign the fields of my T_Number variable separately,
one after the other, as I went along through a decision tree
structure.

Then I tried putting each field value in a temporary variable and
to assign them to my T_Number variable with the
"My_Num := (REAL, its_sign, its_mantissa, ...);" method at the end
of my subprogram.

At first I had a formal parameter of the T_Kind type (INT or REAL)
for the discriminant that I was passing to the subprogram.  I then
wrote two different subprograms, one for each "kind", so I no longer
had to pass the discriminant in a parameter.  Still the problem
persisted.  I finally decided I could do without the "Point" field,
but I still need to know what I was doing wrong with respect to this
discriminant business.

If anyone can provide me with some light, I would appreciate it.

Thanks in advance.


Marc Galipeau

--
What I really am is "fluffy", no "_dong",
no "_puff", no "_woo", no  nothing, just plain fluffy.






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

end of thread, other threads:[~1999-07-16  0:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-01-13  0:00 discriminant AGBOH CHARLES
1997-01-13  0:00 ` discriminant KJPrice
1997-01-15  0:00 ` discriminant Michael F Brenner
  -- strict thread matches above, loose matches on Subject: below --
1999-07-11  0:00 discriminant fluffy_doo
1999-07-12  0:00 ` discriminant Roger Racine
1999-07-12  0:00   ` discriminant fluffy_doo
1999-07-12  0:00     ` discriminant Roger Racine
1999-07-13  0:00       ` discriminant fluffy_puff
1999-07-13  0:00         ` discriminant Ted Dennison
1999-07-13  0:00           ` discriminant fluffy_dong
1999-07-15  0:00             ` discriminant Ted Dennison
1999-07-16  0:00               ` discriminant fluffy_puff
1999-07-13  0:00         ` discriminant Roger Racine

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