comp.lang.ada
 help / color / mirror / Atom feed
From: pattis@june.cs.washington.edu (Richard Pattis)
Subject: FOR Iteration Scheme
Date: 18 Jul 88 20:15:33 GMT	[thread overview]
Message-ID: <5320@june.cs.washington.edu> (raw)


  In the process of writing a CS-1 book that uses Ada as its langauge of
discourse, I am trying to describe formally the semantics of the FOR iteration
scheme using other parts of Ada (whose semantics I explain operationally). Is
the following the most accurate statement I can make?  CAUTION: I am in the
process of learning Ada (trying to compose such explanations helps me), so
this may be a naive question.

FOR I IN E1..E2 LOOP
  <body>
END LOOP;

is equivalent to the following code fragment, where the values of E1 and E2
share subtype <Type-Mark> and <ub> and <is> are secret objects generated by
the Ada compiler.

DECLARE
  <is> : <Type-Mark> := E1;
  <ub> : CONSTANT <Type-Mark> := E2;
BEGIN
  IF <is> <= <ub>
    THEN
      LOOP
        DECLARE
          I : <Type-Mark> CONSTANT := <is>;
        BEGIN
          <body>
        END;
        EXIT WHEN <is> = <ub>;
        <is>:= <Type-Mark>'SUCC(<is>);
      END LOOP;
  END IF;
END;

             reply	other threads:[~1988-07-18 20:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1988-07-18 20:15 Richard Pattis [this message]
1988-07-19 20:43 ` FOR Iteration Scheme David E. Emery
  -- strict thread matches above, loose matches on Subject: below --
1988-07-19 13:52 John.Goodenough
replies disabled

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