[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: case statement for Lua
- From: lhf@... (Luiz Henrique de Figueiredo)
- Date: Mon, 14 Apr 1997 07:56:38 -0300
We're *not* considering adding a case statement for Lua right now, but I once
saw a syntax that seemed ok. I think it was in a toy language (or maybe it was
Turing).
CASE a + b DO Selection is done with a case
0 => b := b * b statement. The selector may be a
END variable or an expression. Each
1 => b := b + a branch begins with 1 constant
a := a + 1 followed by '=>' and the statements
END to execute. The first branch with a
ELSE a := a + 1 constant matching the selector is
b := 0 executed. An optional ELSE clause
END may be the last branch. If no branch
matches, control passes to the
statement following the CASE.
If not yacc conflicts exist, I'd probably go for the simpler
CASE a + b DO
0 : b = b * b
END
1 : b = b + a
a = a + 1
END
ELSE a = a + 1
b = 0
END
In any case (no pun intended), anyone is allowed to add statements to Lua,
*as long as they do not distribute the variant and still call it Lua*.
--lhf