Hello Team Ada, This is a proposal of extension to Ada, about loop_parameter_specification. Any comments ? Excuse me if this is one of discussed issues. ----------------------------------------------------------------------- Proposal : In Ada95, 5.5(4) defines loop_parameter_specification ::= defining_identifier in [reverse] discrete_subtype_definition My proposal is to add "real_subtype_definition" such as, for R in Some_Real_Type range 1.0 .. 2.0 loop..... or for R in Some_Real_Type loop [typically Some_Real_Type might be of fixed-point, such as BAMS] ----------------------------------------------------------------------- Behavior : 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 ? ----------------------------------------------------------------------- Example : with Ada.Text_IO; procedure Sample is First : constant := 1.0; Last : constant := 2.0; -- %%% FLOATING type Some_Real_Type is new Float; -- %%% FIXED -- type Some_Real_Type is delta 0.1 range 0.0 .. 3.0; -- -- for Some_Real_Type'Small use 0.1; procedure Statements (Value : in Some_Real_Type) is use Ada.Text_IO; begin Put_Line (Some_Real_Type'Image (Value)); end Statements; begin -- %%% Case 1 : Universal Real %%% -- for R in 1.0 .. 2.0 loop -- Statements; -- end loop; -- %%% Case 2 : Explicitly Typed %%% -- for R in Some_Real_Type range 1.0 .. 2.0 loop -- Statements; -- end loop; -- %%% Case 3 : Qualified %%% -- for R in Some_Real_Type range Some_Real_Type'(1.0) .. 2.0 loop -- Statements; -- end loop; declare R : Some_Real_Type := First; begin while R <= Last loop Statements (R); R := Some_Real_Type'Succ (R); end loop; end; end Sample Note : In the example, Case 1 is not feasible because we can find out what Succ is, for universal real. So the extension should prohibit this case. In Case 2 or Case 3, however, we can define Succ/Pred without question. ----------------------------------------------------------------------- Merits : - The extension makes the language more orthogonal. - The extension helps programmer, typically, to write some rigorous test driver for numeric computation, or so. Regards, -- ------------------------------------------------------------------------ Toshitaka KUMANO <[log in to unmask]>