lua-users home
lua-l archive

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



Now that you mentioned it, I've wondered why 'repeat .. until' ever was in the language to begin with.

I'd ditch that, and bring in 'continue'.  ;)   But that's just me.

-asko


Roberto Ierusalimschy kirjoitti 25.2.2008 kello 14:28:

I'm upset to find that adding 'continue' is not even being considered.
(Just to let you know that there still are ones that miss it).

Here is a fine example of hiden costs of features.

In Lua 5.1, we changed the scope rules for repeat-until, so that the
test is included in the scope of the body. That seemed a nice and
innocent feature, allowing code like this:

 repeat
   ...
   local x = ...
   ...
 until something-with-x

Of course this change would cause no harm...

Now, consider the addition of 'continue':

 repeat
   ...
   if something then continue end
   ...
   local x = ...
   ...
 until something-with-x

We have two options: either the continue jumps into the scope of 'x'
bypassing its declaration/initialization (very bad), or the continue
skips the test altogether (very bad too).

So, it seems that continue is incompatible with this scope rule...

-- Roberto