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

* Re: discriminant
  1997-01-13  0:00 discriminant AGBOH CHARLES
@ 1997-01-13  0:00 ` KJPrice
  1997-01-15  0:00 ` discriminant Michael F Brenner
  1 sibling, 0 replies; 13+ messages in thread
From: KJPrice @ 1997-01-13  0:00 UTC (permalink / raw)
  To: AGBOH CHARLES


AGBOH CHARLES wrote:
> 
> 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.

You should look at one of the fine textbooks written by the readers and
contributors of this newgroup.  For a list of available intor to Ada
programming textbooks, you might look at the following web page:

http://www.adahome.com/shop/intro.html

or, for a more general list of books:

http://www.adahome.com/shop

most of the books cover discriminants and tasking.




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

* Re: discriminant
  1997-01-13  0:00 discriminant AGBOH CHARLES
  1997-01-13  0:00 ` discriminant KJPrice
@ 1997-01-15  0:00 ` Michael F Brenner
  1 sibling, 0 replies; 13+ messages in thread
From: Michael F Brenner @ 1997-01-15  0:00 UTC (permalink / raw)



q: what is a discriminant. Why do some types carry discriminant.
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.

A: A discriminant is an element of an object that that tells you which
of several choices of forms the object takes. It is a little like
God creating animals with a paramete called gender. The gender
then Discriminates between various genders and also Determines what
parts are glued onto the animal. Ada records can have discriminants
which determine what elements are glued onto the record in each
instance. In the following Free (copyleft) code, variable length
character strings are defined to have a discriminant which is the
length which then decides how many characters are included in the 
record. 

You could have downloaded this code from the Net, but if you had
access to Net search utilities, you would not have posted such
a basic question to a newsgroup. You could also have gotten a very
similar package to this from the PAL, a text book, or several
universities. You should get on the Net as soon as possible.

Meanwhile, the most effective way to learn how to do discriminants is
to do them, and the fastest way to do them is to see a working example
of one. The following example was written by me and has no bugs.

The sentence that is contains no bugs means the following: it is not
warranted or guaranteed, but it has been tested for each of the 
preconditions it was designed for, and every one is welcome to come
up with additional preconditions, which would require it to be
enhanced or further tested, if you desire it to meet those preconditions.
Since it is subject to the Ada modification to the FSF GPPL, you are
welcome to make those modifications yourself, even if you are a 
commercial company, but you may not do anything that would detract
from the Free status of the code.

The design is fully represented by the test program that follows
the package, and, like all software, any uses of the package not
tested by the test program, should first be done by upgrading the
test package to test the software for what you wish it would do.

packagy variable_string_control is
  pragma elaborate_body (variable_string_control);

-- Variable strings are each allocated to any maximum length, and vary
-- from 0 to that maximum in length. Compiler enforces specifying that
-- maximum length when each variable is declared.

   type variable_strings (size: natural) is private;
   null_variable_string: constant variable_strings;

-- The concatenation of variable_strings is an unconstrained string.

  function "&" (left: variable_strings;
                right: variable_strings)
                return string;
  function "&" (left: string;
                right: variable_strings)
                return string;
  function "&" (left: variable_strings;
                right: string)
                return string;

-- When strings agree up to the minimum of their lengths,
-- the shorter string is considered less than the longer string.

  function "<" (left, right: variable_strings) return boolean;
  function ">" (left, right: variable_strings) return boolean;

-- The assignment method is used to change variable_strings.

  procedure assign(message: in out variable_strings; value: string);
  procedure assign(message: in out variable_strings; value: variable_strings);

-- The concatenation method is used to append a string onto the end
-- of a variable_string.

  procedure concat(onto: in out variable_strings; appendage: string);

-- The ELEMENT method returns a column of a variable_string just like
-- array references get columns from ordinary_strings.

  function element (message: variable_strings;
                    col: natural) return character;

-- The IMAGE method returns the string image of a variable_string.

  function image (message: variable_strings) return string;

-- The in_place_lower_case function converts
-- alphabetic character from upper to lower
-- case, ignoring all other characters.
-- It is done in place on a variable_string.

  procedure in_place_lower_case (message: in out variable_strings);

-- The in_place_truncate method is a procedure instead of a function,
-- for efficiency.

  procedure in_place_truncate (message: in out variable_strings;
                               ch: character := ' ');

-- The in_place_upper_case function converts
-- alphabetic character from lower to upper
-- case, ignoring all other characters.

  procedure in_place_upper_case (message: in out variable_strings);

-- The LENGTH method returns the length of the variable_string.

  function length (message: variable_strings) return natural;

-- The SAME method is the equality operator for variable_strings. To
-- be equal, the two strings must be of the same length, and agree
-- for each of their characters.

  function same (left, right: variable_strings) return boolean;
  function same (left: variable_strings; right: string) return boolean;

-- The set_element method sets a character in a single column
-- of a variable_string like array references do for character
-- strings.

  procedure set_element (message: in out variable_strings;
                         col: natural;
                         value:  character);

-- The set_length method truncates a string to a given length or else
-- extends its current length with blanks.

  procedure set_length (message: in out variable_strings;
                        new_length: natural);

-- The SLICE method emulates array slices for variable_strings. The
-- SUBSTR method is similar, but based on length instead of final column.
-- The two-argument SUBSTR gets all characters on or after the given column.
-- All of these permit the START argument to take on a value equal to the
-- length of the variable_string plus 1, returning the null ordinary_string.

  function slice  (message: variable_strings;
                   start, finish: natural) return string;
  function substr (message: variable_strings;
                   start, length: natural) return string;
  function substr (message: variable_strings;
                   start: natural) return string;

-- The variable_string method converts an ordinary_string to a variable string.

  function variable_string (size: natural;
                            message: string) return variable_strings;

private
  type variable_strings (size: natural) is record
    length: integer := -1; -- Causes arrays of strings to fully Allocate.
    list:   string (1..size);
  end record;

  null_variable_string: constant variable_strings (0) :=
    (size => 0, length => 0, list => string'(""));
end variable_string_control;                                             


package body variable_string_control is

 type char_to_char is array (character) of character;
 to_lower_case,
 to_upper_case: char_to_char;
 initialized: boolean := False;

 not_init:     exception;
 out_of_range: exception;
 too_long:     exception;

 procedure initialize_variable_strings is
   cc: character;
 begin
   for c in char_to_char'range loop
     to_lower_case(c) := c;
     to_upper_case(c) := c;
   end loop;

   for c in character'('a')..'z' loop
     cc                  := character'val (character'pos (c) - 32);
     to_upper_case(c)    := cc;
     to_lower_case(cc)   := c;
   end loop;
 end initialize_variable_strings;

 procedure is_okay (message: variable_strings) is
 begin
   if message.length < 0 then
     raise not_init;
   end if;
 end is_okay;

 function "&" (left: variable_strings;
               right: variable_strings)
               return string is
   hold: variable_strings (left.length + right.length);
 begin
   is_okay (left);
   is_okay (right);
   assign (hold, left);
   concat (hold, right.list(1..right.length));
   return hold.list(1..hold.length);
 end "&";

 function "&" (left: string; right: variable_strings) return string is
   hold: variable_strings (left'length + right.length);
 begin
   is_okay (right);
   assign (hold, left);
   concat (hold, right.list(1..right.length));
   return hold.list(1..hold.length);
 end "&";

 function "&" (left: variable_strings; right: string)    return string is
   hold: variable_strings (left.length + right'length);
 begin
   is_okay (left);
   assign (hold, left);
   concat (hold, right);
   return hold.list(1..hold.length);
 end "&";

 function "<" (left, right: variable_strings) return boolean is
 begin
   is_okay(left);
   is_okay(right);
   if    left.length < right.length then
     return left.list(1..left.length)  <= right.list(1..left.length);
   elsif left.length = right.length then
     return left.list(1..left.length)  <  right.list(1..left.length);
   else -- left.length > right.length
     return left.list(1..right.length) <  right.list(1..right.length);
   end if;
 end "<";

 function ">" (left, right: variable_strings) return boolean is
 begin
   is_okay(left);
   is_okay(right);
   if    left.length < right.length then
     return left.list(1..left.length)  >  right.list(1..left.length);
   elsif left.length = right.length then
     return left.list(1..left.length)  >  right.list(1..left.length);
   else -- left.length > right.length
     return left.list(1..right.length) >= right.list(1..right.length);
   end if;
 end ">";

 procedure assign (message: in out variable_strings; value: string) is
 begin
   if value'length > message.size then
     raise too_long;
   else
     message.length := value'length;
     message.list (1..value'length) := value;
   end if;
 end assign;

 procedure assign (message: in out variable_strings;
                   value: variable_strings) is
 begin
   is_okay (value);
   if value.length > message.size then
     raise too_long;
   end if;
   message.length:=value.length;
   message.list (1..value.length) := value.list (1..value.length);
 end assign;

 procedure concat (onto: in out variable_strings; appendage: string) is
   new_length: constant integer := onto.length + appendage'length;
 begin
   is_okay (onto);
   if    new_length > onto.size then
     raise too_long;
   else
     onto.list(onto.length+1..new_length) := appendage;
     onto.length := new_length;
   end if;
 end concat;

 function element (message: variable_strings;
                   col: natural) return character is
 begin
   is_okay (message);
   if    col not in 1..message.length then
     raise out_of_range;
   end if;
   return message.list (col);
 end element;

 function image (message: variable_strings) return string is
 begin
   is_okay (message);
   if message.length=0 then return "";
   else                     return message.list (1..message.length);
   end if;
 end image;

 procedure in_place_lower_case (message: in out variable_strings) is
 begin
   is_okay (message);
   if not initialized then
     initialize_variable_strings;
   end if;
   for i in 1..message.length loop
     message.list(i) := to_lower_case (message.list(i));
   end loop;
 end in_place_lower_case;

 procedure in_place_truncate (message: in out variable_strings;
                              ch: character := ' ') is
 begin
   is_okay (message);

   -- This is a good example of an Ada loop. Compare the following
   -- loop to loops in other computer languages familiar to you, to
   -- see how easy it is to check this loop for termination and for
   -- effectiveness. Also compare how easy it is to see that the
   -- loop is not "off by 1." This style was created in 1978 as part
   -- of the DOD-I HOLWG goals, long before DOD-1 was named Ada as
   -- part of the solution to ever increasing software maintenance
   -- costs. It uses the idea that structured code must have a single
   -- entrance at the top, but may (and often should) have multiple exits.

   loop
     exit when message.length = 0;
     exit when message.list (message.length) /= ch;
     message.length := message.length - 1;
   end loop;
 end in_place_truncate;

 procedure in_place_upper_case (message: in out variable_strings) is
 begin
   is_okay (message);
   if not initialized then
     initialize_variable_strings;
   end if;
   for i in 1..message.length loop
     message.list(i) := to_upper_case (message.list(i));
   end loop;
 end in_place_upper_case;

 function length (message: variable_strings) return natural is
 begin
   is_okay (message);
   return message.length;
 end length;

 function same (left, right: variable_strings) return boolean is
 begin
   is_okay (left);
   is_okay(right);
   return left.length=right.length and then
          left.list(1..left.length) = right.list(1..left.length);
 end same;

 function same   (left: variable_strings; right: string) return boolean is
 begin
   is_okay (left);
   return left.length=right'length and then
          left.list(1..left.length) = right;
 end same;

 procedure set_element (message: in out variable_strings;
                        col: natural;
                        value: character) is
 begin
   is_okay (message);
   if    col > message.size then
     raise out_of_range;
   elsif col = message.length+1 then
     message.length     := message.length + 1;
     message.list (col) := value;
   elsif col > message.length then
     raise too_long;
   else
     message.list (col) := value;
   end if;
 end set_element;

 procedure set_length (message: in out variable_strings;
                       new_length: natural) is
   hold_length: integer := message.length;
 begin
   if hold_length > message.size then
     raise too_long;
   end if;
   message.length := new_length;
   if hold_length < 0 then
     for i in 1..message.size loop
       message.list (i) := ' ';
     end loop;
   end if;
   if    hold_length > 0 then
     for i in hold_length+1 .. new_length loop
       message.list (i) := ' ';
     end loop;
   end if;
 end set_length;

 function slice (message: variable_strings;
                 start, finish: natural) return string is
   hold: variable_strings (finish+1-start);
 begin
   is_okay (message);
   if    start not in 1..message.length then
     raise out_of_range;
   elsif finish not in 0..message.length then
     raise out_of_range;
   end if;
   if finish < start then
     return "";
   else
     hold.length := finish+1-start;
     hold.list (1..hold.length) := message.list (start..finish);
     return hold.list (1..hold.length);
   end if;
 end slice;

 function substr (message: variable_strings;
                  start, length: natural) return string is
 begin
   is_okay (message);
   return slice (message, start, start+length-1);
 end substr;

 function substr (message: variable_strings;
                  start: natural)
                  return string is
 begin
   is_okay (message);
   return slice (message, start, message.length);
 end substr;

 function variable_string (size: natural;
                           message: string) return variable_strings is
   temp: variable_strings (size);
 begin
   if message'length > size then
     raise too_long;
   end if;
   temp.length := message'length;
   if message'length>0 then
     temp.list (1..message'length) := message;
   end if;
   return temp;
 end variable_string;

end variable_string_control;

-- Status is a package with tell and telln (like text_io.put and
-- text_io.put_line, only it puts it to both the console and the
-- error accumulation file. It also provides the method REPORT
-- which does a telln and then raises an exception. 

with variable_string_control;
with status;
procedure tsstrvar is
  use variable_string_control;
  use status;

  test_message: constant string := " Now  is tHe time k1!";

  procedure test_assign_1 is
    x: variable_strings (4);
  begin
    assign(x,"");
    if image(x)/="" then
      report("Failed variable_strings.test_assign_1 bad null");
    end if;
    assign(X,"A");
    if image(x)/="A" then
      report("Failed var_str.test_assing_2");
    end if;
    status.telln("test_assign_1 passed");
  end test_assign_1;

  procedure test_case_1 is
    message: variable_strings (5000) :=
             variable_string  (5000, "okay, I have - UPs &  96 Downs");
    upped:   variable_strings (200):=
             variable_string  (200, "OKAY, I HAVE - UPS &  96 DOWNS");
    lowed:   variable_strings (200) :=
             variable_string  (200, "okay, i have - ups &  96 downs");
    work:    variable_strings(60);
  begin
    assign(work,"abc");
    in_place_upper_case(work);
    if not same(work,"ABC") then
      report("Failed variable_strings.test_case_1 abc [" & work & ']');
    end if;

    assign(work,message);
    in_place_upper_case(work);
    if not same (work, upped) then
      report("Failed variable_strings.test_case_1 a [" & work & ']');
    end if;

    assign(work,message);
    in_place_lower_case(work);

    if not same (work, lowed) then
      report("Failed variable_strings.test_case_1 b");
    end if;
  end test_case_1;

  procedure test_concat_1 is
    f,g,h,k: variable_strings (5);
  begin
    assign(f, "A");
    assign(g, "B");
    assign(h, "AB");
    assign(k, f&g);
    if not same (k,h) then
      report("Failed variable_strings.test_concat_1 a ");
    end if;
  end test_concat_1;

  procedure test_element_1 is
    d: variable_strings(3) := variable_string (3, "");
  begin
    set_element (d, 1, 'a');
    set_element (d, 2, 'b');
    set_element (d, 3, 'c');
    if element (d, 2) /= 'b' then
      report("Failed variable_strings.test_element_1 a ");
    end if;
  end test_element_1;

  procedure test_in_place_truncate_1 is
    message: variable_strings(10) := variable_string(10, "abc  ");
  begin
    in_place_truncate (message);
    if not same (message, "abc") then
      report("Failed variable_strings.test_in_place_truncate_1 a");
    end if;
    if length(message)/=3 then
      report("Failed variable_strings.length b");
    end if;
  end test_in_place_truncate_1;

  procedure test_lessthan_1 is
  begin
    if         variable_string(25, "abc")<variable_string(25, "ab")   then
      report("Failed variable_strings test <1 got abc<ab");
    elsif not (variable_string(25, "ab") <variable_string(25, "abc")) then
      report("Failed variable_strings test <1 got ab>=abc");
    elsif      variable_string(25, "ac") <variable_string(25, "ab")   then
      report("Failed variable_strings test <1 got ac<ab");
    elsif not (variable_string(25, "ab") <variable_string(25, "ac"))  then
      report("Failed variable_strings test <1 got ab>=ac");
    elsif      variable_string(25, "abc")<variable_string(25, "aa")   then
      report("Failed variable_strings test <1 got abc<aa");
    elsif not (variable_string(25, "aa") <variable_string(25, "abc")) then
      report("Failed variable_strings test <1 got aa>=abc");
    elsif      variable_string(25, "ac") <variable_string(25, "abc")  then
      report("Failed variable_strings test <1 got ac<abc");
    elsif not (variable_string(25, "abc")<variable_string(25, "ac"))  then
      report("Failed variable_strings test <1 got abc>=ac");
    elsif not (variable_string(25, "abc")>variable_string(25, "ab"))  then
      report("Failed variable_strings test >1 got abc<ab");
    elsif not (variable_string(25, "abc")<variable_string(25, "ac"))  then
      report("Failed variable_strings test <1 got abc>=ac");
    elsif     (variable_string(25, "ab") >variable_string(25, "abc")) then
      report("Failed variable_strings test <1 got ab>=abc");
    elsif not (variable_string(25, "ac") >variable_string(25, "ab"))  then
      report("Failed variable_strings test <1 got ac<ab");
    elsif     (variable_string(25, "ab") >variable_string(25, "ac"))  then
      report("Failed variable_strings test <1 got ab>=ac");
    elsif not (variable_string(25, "abc")>variable_string(25, "aa"))  then
      report("Failed variable_strings test <1 got abc<aa");
    elsif     (variable_string(25, "aa") >variable_string(25, "abc")) then
      report("Failed variable_strings test <1 got aa>=abc");
    elsif not (variable_string(25, "ac") >variable_string(25, "abc"))  then
      report("Failed variable_strings test <1 got ac<abc");
    end if;
  end test_lessthan_1;

  procedure test_same_1 is
    SS: constant string :="Now is the time for all good men to come to the";
    a,b,c,d: variable_strings(100);
  begin
    assign(a,"Now");
    assign(b,"Now");
    assign(c,"Now ");
    assign(d," Now");
    if not same (a, b) then
      report("Failed variable_strings.test_same_1 1");
    elsif same (a,c) then
      report("Failed variable_strings.test_same_1 2");
    elsif same (a,d) then
      report("Failed variable_strings.test_same_1 3");
    end if;
    assign(c,SS);
    assign(d,SS);
    if not same (c,d) then
      report("Failed variable_strings.test_same_1 4");
    end if;
  end test_same_1;

  procedure test_slice_1 is
    x, y, z: variable_strings(10);
    okay: constant string := "abcd";
  begin
    assign(x, "abc");
    assign(y, okay(2..3));
    assign(z, slice(x, 2, 3));
    if not same (y,z) then
      report("Failed variable_strings.test_slice_1 a");
    end if;
    assign(z, substr(x,2,2));
    if not same (z,y) then
      report("Failed variable_strings.test_slice_1 b");
    end if;
    if substr(z,1,0)/="" then
      report("Failed variable_strings.test_slice_1 c");
    end if;
  end test_slice_1;

  procedure test_variable_string is
    temp: constant string:= "(abcdefg)";
    temp_fixed: variable_strings(10);
  begin
    temp_fixed:= variable_string (10, temp (2..8));
    if not same(temp_fixed, "abcdefg") then
      report ("Failed variable_string_MANAGMENT.fixed string A");
    end if;
  end test_variable_string;

begin
  test_variable_string;
  test_assign_1;
  test_case_1;
  test_concat_1;
  test_element_1;
  test_in_place_truncate_1;
  test_lessthan_1;
  test_same_1;
  test_slice_1;
  status.telln("tsstrvar passed");
end tsstrvar;




^ 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

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


In article <3789bfc2.97977684@news.dsuper.net> fluffy_doo@dsuper.net writes:
>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 had to make a couple of changes to your source to get it to compile without 
warnings or errors.  Specifically, note that the spelling of "mantissa" is not 
consistent.  I assume those were typos in your message.  When I corrected 
those, I got a warning about Len raising Constraint_Error (it is assigned a 
value of 0, which is outside its range), so I changed it to have an initial 
value of 1.  After that, I created a test, which worked fine on the latest 
GNAT (3.12a) on Windows NT.

What version of what compiler are you using on what host?
Can you provide a complete test that fails?

Roger Racine




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

* Re: discriminant
  1999-07-12  0:00 ` discriminant Roger Racine
@ 1999-07-12  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-12  0:00 UTC (permalink / raw)


On Mon, 12 Jul 1999 13:11:20 GMT, in comp.lang.ada you wrote:

(Sorry about the e-mail Roger, I pushed the wrong button.)

>I had to make a couple of changes to your source to get it to compile without 
>warnings or errors.  Specifically, note that the spelling of "mantissa" is not 
>consistent.  I assume those were typos in your message.

Yes my stuff was with french based terminology and I forgot to change
a couple of "Mantisse" to "Mantissa" when I transcribed for this news
exchange.

>When I corrected 
>those, I got a warning about Len raising Constraint_Error (it is assigned a 
>value of 0, which is outside its range), so I changed it to have an initial 
>value of 1.

Yes, 1 is what it should be.

>After that, I created a test, which worked fine on the latest 
>GNAT (3.12a) on Windows NT.
>
>What version of what compiler are you using on what host?

Aonix :		ObjectAda for Windows V7.1.105 (special edition).
OS :		Windows 95 (4.00.950)
machine :	P150

>Can you provide a complete test that fails?

There's no failure, and there *should* be one.  I was using the
debugger while checking something else when I noticed the problem I've
described (which made it difficult or impossible to continue the
original check with the debugger I was trying to make).  Maybe it's a
debugger problem.  Maybe it's just not showing me the actual value for
the variable I'm looking at.

Anyway, I'll make some changes so the var names and comments
correspond to English terms and I'll make another post with the
attachment containing the function that returns a T_Number type.  I
should probably also include the function that makes the reciprocal
conversion ( T_Number => String ) so that you can at least output to
the screen.

Keep in mind though that both functions have errors in them, they're
earlier versions.  The errors are not related to the problem I'm
discussing here.  Also, in the current versions there is no longer a
"Point" field with the "kind = REAL" discriminant.  The whole point of
this post and my previous one is not the actual value returned or
output of my String => T_Number function but what goes on inside it:
assigning a new value to the "Power_R" field affects an unwanted and
unexplained change in the value of the "Point"  field, and the new
value of the "Point" field is *outside* the field's range.  When I
then try to assign a new value to Point, a few lines of code down, its
value doesn't change, like it's locked in, but the debugger doesn't
complain.  This is what I see with the debugger.

I've got to go to school now.  I'll do it tonight.

Thanks for helping.


Marc

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

* Re: discriminant
  1999-07-12  0:00   ` discriminant fluffy_doo
@ 1999-07-12  0:00     ` Roger Racine
  1999-07-13  0:00       ` discriminant fluffy_puff
  0 siblings, 1 reply; 13+ messages in thread
From: Roger Racine @ 1999-07-12  0:00 UTC (permalink / raw)


In article <378c1097.184220259@news.dsuper.net> fluffy_doo@dsuper.net writes:
>On Mon, 12 Jul 1999 13:11:20 GMT, in comp.lang.ada you wrote:
>>After that, I created a test, which worked fine on the latest 
>>GNAT (3.12a) on Windows NT.
>>
>>What version of what compiler are you using on what host?

>Aonix :         ObjectAda for Windows V7.1.105 (special edition).
>OS :            Windows 95 (4.00.950)
>machine :       P150

>>Can you provide a complete test that fails?

>There's no failure, and there *should* be one.  I was using the
>debugger while checking something else when I noticed the problem I've
>described (which made it difficult or impossible to continue the
>original check with the debugger I was trying to make).  Maybe it's a
>debugger problem.  Maybe it's just not showing me the actual value for
>the variable I'm looking at.

>Anyway, I'll make some changes so the var names and comments
>correspond to English terms and I'll make another post with the
>attachment containing the function that returns a T_Number type.  I
>should probably also include the function that makes the reciprocal
>conversion ( T_Number => String ) so that you can at least output to
>the screen.

>Keep in mind though that both functions have errors in them, they're
>earlier versions.  The errors are not related to the problem I'm
>discussing here.  Also, in the current versions there is no longer a
>"Point" field with the "kind = REAL" discriminant.  The whole point of
>this post and my previous one is not the actual value returned or
>output of my String => T_Number function but what goes on inside it:
>assigning a new value to the "Power_R" field affects an unwanted and
>unexplained change in the value of the "Point"  field, and the new
>value of the "Point" field is *outside* the field's range.  When I
>then try to assign a new value to Point, a few lines of code down, its
>value doesn't change, like it's locked in, but the debugger doesn't
>complain.  This is what I see with the debugger.

>I've got to go to school now.  I'll do it tonight.

>Thanks for helping.

It looks like my test was similar to your code.  I simply tried to assign a
value to the Power_R field without changing anything else.  I did it three
times in a row without any problems using GNAT.  

I just used the AONIX compiler (same version as you) to see 
what happens, and your behavior is seen (the value of Point is changed 
to a garbage value, at least as seen in the debugger).

It looks like it is an AONIX bug.  

Roger Racine






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

* Re: discriminant
  1999-07-12  0:00     ` discriminant Roger Racine
@ 1999-07-13  0:00       ` fluffy_puff
  1999-07-13  0:00         ` discriminant Roger Racine
  1999-07-13  0:00         ` discriminant Ted Dennison
  0 siblings, 2 replies; 13+ messages in thread
From: fluffy_puff @ 1999-07-13  0:00 UTC (permalink / raw)


On Mon, 12 Jul 1999 20:00:38 GMT, rracine@draper.com (Roger Racine)
wrote:

>It looks like it is an AONIX bug.  
>
>Roger Racine

Thanks a lot.  I guess I won't have to play translator. Good.

Besides the problem we just addressed I recently realized that the
Aonix debugger doesn't handle ASCII characters above 127.  I think
it's a bit silly to have a compiler that allows the use of accented
characters for variable and type names and releasing with it a
debugger that can't see them.  But then again it was free so I suppose
I shouldn't complain.

Is there a significant difference between GNAT and Aonix in the number
of bugs they have ?  I recently dowloaded GNAT but haven't used it
yet.  I noticed it's quite a bit smaller than the Aonix package, but
still I would prefer less bugs and less features than the opposite.
I've been told the Aonix debugger also does some funny things with
pointers sometimes.

Thanks again.


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

* Re: discriminant
  1999-07-13  0:00       ` discriminant fluffy_puff
@ 1999-07-13  0:00         ` Roger Racine
  1999-07-13  0:00         ` discriminant Ted Dennison
  1 sibling, 0 replies; 13+ messages in thread
From: Roger Racine @ 1999-07-13  0:00 UTC (permalink / raw)


In article <378a9c0e.2792962@news.dsuper.net> fluffy_puff@dsuper.net writes:
>Is there a significant difference between GNAT and Aonix in the number
>of bugs they have ?  I recently dowloaded GNAT but haven't used it
>yet.  I noticed it's quite a bit smaller than the Aonix package, but
>still I would prefer less bugs and less features than the opposite.
>I've been told the Aonix debugger also does some funny things with
>pointers sometimes.

I have not used the Aonix product enough to give you a good comparison.  I am 
currently using GNAT on a project that requires inexpensive access to the 
source to the runtime routines.  Since GNAT is unique in this respect, no 
evaluation was done.

Sorry.

Roger Racine




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

* Re: discriminant
  1999-07-13  0:00       ` discriminant fluffy_puff
  1999-07-13  0:00         ` discriminant Roger Racine
@ 1999-07-13  0:00         ` Ted Dennison
  1999-07-13  0:00           ` discriminant fluffy_dong
  1 sibling, 1 reply; 13+ messages in thread
From: Ted Dennison @ 1999-07-13  0:00 UTC (permalink / raw)


In article <378a9c0e.2792962@news.dsuper.net>,
  fluffy_puff@dsuper.net wrote:
> On Mon, 12 Jul 1999 20:00:38 GMT, rracine@draper.com (Roger Racine)
> wrote:

> Is there a significant difference between GNAT and Aonix in the number
> of bugs they have ?  I recently dowloaded GNAT but haven't used it
> yet.  I noticed it's quite a bit smaller than the Aonix package, but

Not a *significant* difference. But there do seem (to me) to be less,
and the ones that are there are *different* bugs.

--
T.E.D.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




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

* Re: discriminant
  1999-07-13  0:00         ` discriminant Ted Dennison
@ 1999-07-13  0:00           ` fluffy_dong
  1999-07-15  0:00             ` discriminant Ted Dennison
  0 siblings, 1 reply; 13+ messages in thread
From: fluffy_dong @ 1999-07-13  0:00 UTC (permalink / raw)


On Tue, 13 Jul 1999 16:18:58 GMT, Ted Dennison <dennison@telepath.com>
wrote:

>Not a *significant* difference. But there do seem (to me) to be less,
>and the ones that are there are *different* bugs.

Less with GNAT or less with Aonix ?


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

* Re: discriminant
  1999-07-13  0:00           ` discriminant fluffy_dong
@ 1999-07-15  0:00             ` Ted Dennison
  1999-07-16  0:00               ` discriminant fluffy_puff
  0 siblings, 1 reply; 13+ messages in thread
From: Ted Dennison @ 1999-07-15  0:00 UTC (permalink / raw)


In article <378ba226.69898725@news.dsuper.net>,
  fluffy_dong@dsuper.net wrote:
> On Tue, 13 Jul 1999 16:18:58 GMT, Ted Dennison <dennison@telepath.com>
> wrote:
>
> >Not a *significant* difference. But there do seem (to me) to be less,
> >and the ones that are there are *different* bugs.
>
> Less with GNAT or less with Aonix ?

Gnat. But the difference is not that large, and could just be
conincidence on my part.

--
T.E.D.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.




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

* Re: discriminant
  1999-07-15  0:00             ` discriminant Ted Dennison
@ 1999-07-16  0:00               ` fluffy_puff
  0 siblings, 0 replies; 13+ messages in thread
From: fluffy_puff @ 1999-07-16  0:00 UTC (permalink / raw)


On Thu, 15 Jul 1999 15:33:20 GMT, Ted Dennison <dennison@telepath.com>
wrote:

>> Less with GNAT or less with Aonix ?
>
>Gnat. But the difference is not that large, and could just be
>conincidence on my part.

Thank you.

I guess I couldn't really gauge the comparative value of each product
from "number of bugs" anyway since the *nature* of each bug, and
cons�quently its perturbing effect(s), has to be taken into account.
It's easy to imagine a certain bug having more of an impact than five
other ones combined, depending on how one uses the software.  A
distinction between a bug in the text editor, the debugger, the
compiler, or the linker, for example, is sort of important.

I was just hoping other people would comment and I could get a vague
idea of the stengths and weaknesses of each.

Thanks again.


Marc
--
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 --
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 Roger Racine
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
  -- strict thread matches above, loose matches on Subject: below --
1997-01-13  0:00 discriminant AGBOH CHARLES
1997-01-13  0:00 ` discriminant KJPrice
1997-01-15  0:00 ` discriminant Michael F Brenner

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