lua-users home
lua-l archive

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

HyperHacker <> 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.

At the moment a Lua statement that starts with a variable name is always
an expression, which might be a function call or an lvalue part of an
assignment. Lua can parse and compile the expression without worrying
which form of statement it is part of. When it has dealt with the complete
expression it checks its form: if it is a function call then it is a
complete statement; otherwise it must be assignable and followed by a
comma or equals.

Therefore the contenders for label syntax all have a disambiguating token
before the label name so that it cannot be confused with an expression.
Without that Lua's parser would have to undo a partly constructed
assignment expression when it sees the :: marker.

Given the constraints of the parser I prefer @label or ::label without
trailing punctuation. (If you want a terminator you can add one or more

f.anthony.n.finch  <>
Malin, Hebrides: Southerly 5 or 6, occasionally 4 in east. Moderate or rough.
Showers. Moderate or good.