lua-users home
lua-l archive

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

Peter Hill wrote:
> Hmm, I'm not sure what I think of reserved words in Lua.
> Consider
> 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"]

I do not consider this a problem. A keyword is a keyword. 
In most programming languages, keywords cannot be used 
for variable names nor for record field names. The a.b
notation is syntactic sugar that allows for a record-like 
(struct-like) access to tables. In languages used as C, 
structs which contain keyword names are also illegal. 

Also, this has the solution of the original, 
non sugared notation. IMO, a keyword is always a keyword,
unless it's present in a string, of course.  

> Lexically wise, one could simply defer the word->reserved-word
> conversion to a later stage.

Hmmm.... that would needlessly complicate things, not to 
mention that to me, it would seem confusing. A keyword is 
a keyword. The idea is "use keywords only when 
you want to implement their key function". That's something 
that someone who learns a  programming language should be 
able to rely on.   

"No one knows true heroes, for they speak not of their greatness." -- 
Daniel Remar.
Björn De Meyer