TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Proportional Font
Show Text Part by Default
Condense Mail Headers

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

Print Reply
Sender:
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Date:
Thu, 23 Aug 2001 17:59:55 +0900
Reply-To:
Toshitaka KUMANO <[log in to unmask]>
Subject:
MIME-Version:
1.0
Content-Transfer-Encoding:
7bit
Content-Type:
text/plain; charset="us-ascii"
Organization:
Mitsubishi Electric Corporation
From:
Toshitaka KUMANO <[log in to unmask]>
Parts/Attachments:
text/plain (36 lines)
Jean-Pierre Rosen wrote:
> >   declare
> >      D : Some_Decrete_Type := Left;
> >   begin
> >      while D <= Right loop
> >          sequence_of_statements
> >          D := Some_Decrete_Type'Succ (D);
> >      end loop;
> >   end;
> >
> FYI: this equivalence is wrong, a for loop is never equivalent to a while loop (unlike what C people think)

> Hint: look at what happens when D=Some_Discrete_Type'Last

Yes, you are right. Thank you.
This is my silly bug.

How about if rewriting like below ?

   if Left <= Right then
      declare
         D : Some_Decrete_Type := Left;
      begin
         loop
            sequence_of_statements
            exit when D >= Right;
            D := Some_Decrete_Type'Succ (D);
         end loop;
      end
   end if;

Regards,
--
------------------------------------------------------------------------
   Toshitaka KUMANO <[log in to unmask]>

ATOM RSS1 RSS2