[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.2.0 (work3) now available
- From: Sean Conner <sean@...>
- Date: Wed, 19 May 2010 17:33:57 -0400
It was thus said that the Great Petite Abeille once stated:
>
> On May 19, 2010, at 8:59 AM, David Kastrup wrote:
>
> > If both do exactly the same, the logical thing to keep would be ipairs,
> > not the numeric loop. Simplifies the language.
>
> FWIW, I would second that. Drop the numeric loop. And keep ipairs
> alongside the generic for statement.
>
> Also, while we are at it, drop the while and repeat statement as well. How
> many loopy [sic] constructs does a language need?
They're there for convenience. Technically, all you need is a conditional
and a way of diverting flow control---basically, if and goto---and from
there you can build up all looping constructs:
for i = 1 , 100 do i = 1
... X:
end ...
i = i + 1
if i <= 100 then goto X end
----------------------------------------------
while morwork do X:
... if not morework then goto Y end
end ...
goto X
Y:
-------------------------------------------------
if foo then do if not foo then goto X end
... ...
end X:
----------------------------------------------------
if foo then do if not foo then goto X end
... ...
else goto Y
... X:
end ...
Y:
----------------------------------------------------
repeat X:
... ...
until done if not done then goto X end
and so on. Even C has the little used do while() construct. The "loopy"
constructs are there as a means to express intent. I hope from the example
above that using "if ... goto" hides the intent and makes it harder to
reason about the code.
-spc (Just be thankful we don't have Common Lisp's LOOP or even
INTERCAL's COMEFROM ... )