lua-users home
lua-l archive

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


Walter Cruz wrote:
What about a switch statement too ?

Sometimes is boring put if, else if, else if, else if :)

There are many examples of how to implement a switch statement:

http://lua-users.org/wiki/SwitchStatement

If a new control structure were to be added to Lua, there are much more interesting control structures out there than poor ol' switch.

An example proposal would replace both while-do-end and repeat-until with a single construct. Dahl's loop-while-repeat statement is more general than either of the two other loops, and it allows for more elegant expression:

loop
  line = io.read()
while line
  io.write(line)
repeat

I'm not seriously proposing this change for Lua, but I've been wanting to use this control structure ever since I learned of it and I know of no language which implements it.

					-Mark