lua-users home
lua-l archive

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

Shmuel Zeigerman wrote:
Rici Lake wrote:


This sort of thing can be dealt with by using a tailcall, although that means expanding the for statement:


If you really really need to be able to 'return' as well, you can wrap the whole thing in a coroutine. I can't say I've ever encountered this situation, and there are probably better ways to handle it. However:

Isn't it awkward that one needs to invent workarounds such
as tail calls or coroutines or artificial extra loops just
to not use such a basic thing as the "continue" statement?

IIRC, the "continue" patch adds only 3 or so lines to the lua sources.
No, I don't consider "continue" as contamination of lua.
I very much hope to see "continue" as part of lua some time.

Let me add my voice to the group who would really like to see continue in Lua. In the work I am doing, I am looking at translating from Javascript into Lua. With almost every other construct (switch, arithmetic assignment, for loops) there is a simple translation into Lua syntax. But continue would be incredibly difficult to translate, especially given all the edge cases that arise.

For such a simple patch, it seems like a big win.

chris marrin              ,""$, "As a general rule,don't solve puzzles        b`    $  that open portals to Hell" ,,.
        ,.`           ,b`    ,`                            , 1$'
     ,|`             mP    ,`                              :$$'     ,mm
   ,b"              b"   ,`            ,mm      m$$    ,m         ,`P$$
  m$`             ,b`  .` ,mm        ,'|$P   ,|"1$`  ,b$P       ,`  :$1
 b$`             ,$: :,`` |$$      ,`   $$` ,|` ,$$,,`"$$     .`    :$|
b$|            _m$`,:`    :$1   ,`     ,$Pm|`    `    :$$,..;"'     |$:
P$b,      _;b$$b$1"       |$$ ,`      ,$$"             ``'          $$
 ```"```'"    `"`         `""`        ""`                          ,P`