lua-users home
lua-l archive

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


Hi Hugo,

Here are a few references to previous discussions about a continue
statement, seems people work around it or use tail recusion.

http://lua-users.org/lists/lua-l/2005-09/msg00527.html
http://lua-users.org/lists/lua-l/2003-06/msg00454.html

Some customization too, have been made to add continue to lua...
http://lua-users.org/lists/lua-l/2003-06/msg00306.html

Regards
Andrew

On 1/24/07, Hugo Etchegoyen <hetchegoyen@hasar.com> wrote:

 I have been working with Lua for only a few weeks, and I like the language
a lot. It offers a wonderful combination of size, speed, simplicity, ease of
learning and openness so that anybody can extend it and tweak it to taste.

 But being a seasoned C/C++ programmer, there is only one thing I miss a
lot: a continue statement! Please, please, I know that people asking for new
features to be added to a language usually annoy its designers, and
generally for good reason. But I honestly think this would be a great
addition which would cost practically nothing and would benefit the language
and make it more coherent.

 Pascal was a coherent language: it religiously avoided anything that could
break the structured flow of control, so it did not have returns, continues
or breaks. It did not even have elseif! That is why most Pascal programs are
unreadable when they have more than two or three levels of nested ifs and
they tend to overflow the right margin unless programmers use ugly and
confusing indentation tricks.

 Clearly Lua is more like C, since it has return and break. But the absence
of continue complicates the body of loops. Consider this loop, for example:

     for i = 1 to somevalue do
        if some_condition then
           ...
           ...
           ...
        end
     end

 Wouldn't this be nicer?

     for i = 1 to somevalue do
        if not some_condition(i) then continue end
        ...
        ...
        ...
     end

 I know it's a matter of taste, but also of coherence. IMO Pascal was
coherent (but ugly) and Lua is beautiful but still lacks this last touch.

 Regards,
 Hugo Etchegoyen