lua-users home
lua-l archive

Reserved Words

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


Hmm, I'm not sure what I think of reserved words in Lua.
Consider
 x.abc
which is syntactic sugar for
 x["abc"]
Apparently this only applies for identifiers, not reserved words, so that
 x.break
is illegal, and NOT the same as
 x["break"]
Likewise
 x = {abc=5, break=6}
is an error, rather that the expected sequence
 x = {["abc"], ["break"]=6}
Now it is probably a good idea in most languages to outlaw redefining key
operational words (like "if" etc) when they appear in a statement context
but in Lua, which is heavily data & string based, areas which are described
as syntactic sugar for string constants seem an inappropriate place to rule
out certain words.
Lexically wise, one could simply defer the word->reserved-word conversion to
a later stage.
Thoughts anyone?
*Peter Hill*

AltStyle によって変換されたページ (->オリジナル) /