TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Pascal Obry <[log in to unmask]>
Reply To:
Pascal Obry <[log in to unmask]>
Thu, 23 Aug 2001 09:46:32 +0200
text/plain (61 lines)
Toshitaka KUMANO writes:
 > As for discrete_subtype_definition, the iteration scheme
 >   for D in Some_Decrete_Type range Left .. Right loop
 >     sequence_of_statements
 >   end loop;
 > is equivalent to
 >   declare
 >      D : Some_Decrete_Type := Left;
 >   begin
 >      while D <= Right loop
 >          sequence_of_statements
 >          D := Some_Decrete_Type'Succ (D);
 >      end loop;
 >   end;
 > As we have Succ/Pred for real types now in Ada95, why don't we apply to
 > loop ?

No really. Here is the Float'Succ definition:

238. S'Succ

          For every scalar subtype S:

     239. S'Succ denotes a function with the following specification:

     240.      function S'Succ(Arg : S'Base) return S'Base

     241. For an enumeration type, the function returns the value whose
          position number is one more than that of the value of Arg;
          Constraint_Error is raised if there is no such value of the
          type. For an integer type, the function returns the result of
          adding one to the value of Arg. For a fixed point type, the
          function returns the result of adding small to the value of
          Arg. For a floating point type, the function returns the
          machine number (as defined in *Note 3.5.7::.) immediately
          above the value of Arg;  Constraint_Error is raised if there
          is no such machine number.  *Note 3.5::.

So Float'Succ (R), could be different the first time it is called but after
that it will returns always the same value. Not something usefull for a
loop :)



--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--| "The best way to travel is by means of imagination"