[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: syntax
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 20 Feb 2008 13:52:14 -0300
> But why is it that keywords cannot be used as names? There are patches
> etc. around that allow it, and I don't really see the problem with it
> (but maybe that's just me). Except that you could maybe "hide" certain
> keywords if you use its name in _G or something, but I'd say that is
> the programmer's responsibility, like many things in Lua. Isn't the
> Lua filosophy to not enforce/restrict, but to empower the programmer
> and assume some measure of common sense?
Lua uses a quite traditional approach to scanning and parsing. In this
approach, a reserved word is recognized by the scanner ("lexer") and
then becomes something as different from an identifier as "+" or ">=".
Of course we can change Lua to accept things like t.while. But, from
the point of view of the compiler, this is as weird as accepting t.+
or t.>= (which also could be actually accepted).
>From a more practical point of view, accepting these extra
constructions compromise the robustness of the grammar, that is,
how it behaves before erroneous input. (I must confess that the
current robustness is already somewhat low.)