lua-users home
lua-l archive

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

> 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;


  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