Reserved words as identifiers (was Re: Long names are doom ?)

Thomas Wouters thomas at xs4all.net
Sun May 27 17:35:01 EDT 2001


On Sun, May 27, 2001 at 04:13:15PM -0500, Chris Gonnerman wrote:

> specifically, reserved words which would cause a SyntaxError to be
> raised would be rechecked as identifiers.  This shouldn't take much
> work on the part of the parser IMHO although it still looks a bit like
> a Rubik's Cube to me...

Well, I spent one long night (literally; it was just after I'd flown back
from the Python conference, and the jetlag prevented me from sleeping during
normal hours) trying to grasp the Python parser's implementation. To me,
it's a lot worse than a rubik's cube :)

It's not as simple as 'catching' a SyntaxError, though. The identification
of a token and its conformance to the grammar are done in two separate
places, not easy to adapt to what you suggest.

But if you think you can do it, good for you! Do it and make us all happy,
and be *really* flattered by Guido accepting your patch personally :)

> I've seen a language (Clipper 5.0 I think) where the following lines of code
> are actually different:

>     name (var1)
>     name(var1)

> Gah.  Needless to say I don't want a brain damaged mess like that in Python.

I wasn't proposing they be different (they aren't, in current python, and I
doubt anyone on python-dev would accept a patch that would make them
different) but that they be forced unambiguous: 'print(var)', possibly with
whitespace around the parentheses, would be the same as 'print var', and the
interpreter would generate a warning to let the programmer know it was
possibly not what [s]he intended.

Lots-of-commentary-snipped-ly y'rs,

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list