On Wed, Jan 7, 2009 at 10:53 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
> Hmm... I wonder how hard it would be to change the parser so that when a
> table is being indexed with . or : it acts similar to other languages (such
> as ruby) and interprets everything after the . or : up to the first bit of
> white space explicitly as a name. In ruby (and probably python)
> something.and is legal.
According to "Programming Ruby", "and" (and "or", "not", etc.) should
not be used as a method name (2nd edition, p. 328).
A small Python program:
a.x = 4;
a.or = 3;
Output:
File "temp", line 2
a.or = 3;
^
SyntaxError: invalid syntax
And the question is not whether it is easy or hard to change the parser
to allow such names. The question is whether this would be a good
idea. The concept of reserved words has a long tradition in programming
languages, being adopted by most current languages (C, C++, Java, C#,
Python?, Haskell, Erlang, Pascal, etc.)
(BTW, in Erlang both band and bor are reserved ;).
-- Roberto