lua-users home
lua-l archive

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


On 06/16/2011 08:53 PM, Roberto Ierusalimschy wrote:
My vote would be for "label foo" or "foo::". The symmetry looks a bit
ugly to me IMO and looks like it should be some kind of expression
(e.g. |foo| is commonly written in text to mean math.abs(foo)), and !
and&  just seem confusing when they mean different things in other
languages.
This would be my preference too. Out of interest, would the grammar
unambiguously support "stat ::= (label | goto) Name" without having to
make label and goto into keywords?
Probably (because there are no other meanings for "name name" and Lua's
parser has full computational power), but it would be messy.

-- Roberto

I think if the "goto" operation itself is a part of the core language, there is a point in introducing a label as a new datatype, much like a function is. If so, it seems appropriate for labels to be declared the same way as functions:
label aaa
-- Some code here
goto aaa

Or the same, closer to what it would be internally:

aaa = label
-- Some code here
goto aaa

If so, the "label" operator should be a no-operand, returning some internal "address" or whatever used to refer to the next operator inside the virtual machine.