lua-users home
lua-l archive

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


David Jeske wrote:
> I don't miss break and continue. I find their use ambigiuous, and anything
> you can do with them, can be done with standard blocks easily.

I agree with the ambiguity of the break statement. And, although I also
agree that it's easy to simulate a break statement with standard blocks,
I still think it's much easier to stop a loop at once with a break
within the loop block. At least when we are sure of where our break
statement will take us to...  

> I really prefer Java's incarnation of the "break" statement. It's a
> combination of the break concept and a "goto". 

This sound's too much like a goto statement. IMHO, it would be cleaner
if we could label a block and then break out of the block - something
like this:

-- finds for the first occurence of an element in a matrix
done: begin
  i = 0
  while i < m do
    j = 0
    while j < n do
      if matrix[i][j] == wanted then
        break done
      j = j + 1
    i = i + 1

Dijkstra would like it better, for sure. :-)

PS: This was one of the neat ideas Roberto mentioned to me.