lua-users home
lua-l archive

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


On 27/01/2011 17:42, Roberto Ierusalimschy wrote:
If that could save Steve's right arm, we like the idea of break with
labels.

Interesting to have an official opinion...

In Lua, we cannot have traditional labels, because the syntax "foo:"
already has a different meaning. Instead, a simple syntax would be to
add labels only to "do end" blocks, for instance like this:

   do :label:
     ...
   end

Nice idea!

Then, a continue could be written like here:

   while cond do
     do :process_item:

                     break :process_item:

     end
   end

Well, will that execute the cond and exit if not satisfied?
Why not do:

  while cond do :process_item:

                   break :process_item:

  end

directly?

There are several details that could change (other mark instead
of colons, whether the label after break needs marks, whether an
optional [or mandatory] label could be added after the corresponding
'end', etc.), but the basic idea would not change much.

Maybe [process_item]?

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --