lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


David Given wrote:

> It's interesting to note that old versions of the [C++] standard decreed
> that the scope of the loop variable extended until the end of the
enclosing
> scope

I remember that transition, too.

Though my vote is meaningless, I vote for the local scope. The
interpreter should use a variable local to the 'repeat-until' block if
it appears in the 'until' clause - even if that makes it difficult to
create a 'continue'.

For what it's worth, I think Ada does the whole looping business
properly, though Ada does not allow declarations in the middle of a code
block, nor does it support 'continue'. Ada's approach to scoping for a
repeat loop is closer to Rici's - do not even provide a conditional at
the end of the loop:

   Outer: loop
      loop
         exit when K < 0;   -- Exits the innermost containing loop.
         I := K ** 3;
         K := I + 1;
         Put_Line ("I K =>" & I'Img & K'Img);
         exit Outer when I > 15;
      end loop;
   end loop Outer;

If we could start over, then my vote would be to exclude the 'repeat
block until exp' construct from the language entirely in favor of a new
'break' that supports optional loop names and conditionals - or some
syntactic sugar for the latter.

But that's a topic for another thread.

Doug

-
--__-__-____------_--_-_-_-___-___-____-_--_-___--____
Doug Rogers - ICI - V:703.893.2007x220 www.innocon.com
-_-_--_------____-_-_-___-_--___-_-___-_-_---_--_-__-_