lua-users home
lua-l archive

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

On 01/27/2011 11:42 AM, Roberto Ierusalimschy wrote:
   while cond do
     do :process_item:

                     break :process_item:


Do you really need the extra : after the label since both do and break are keywords?

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 the label is attached to the end keyword since (visually) it indicates where you are going.

    while cond do

         break : process_item

      end : process_item

That would allow you to label a break out of a while loop:

   while cond do

      break : while_end

   end : while_end

or a for loop:

   for i=1, 10 do

     break : for_end

   end : for_end