Long names are doom ?

Tim Peters tim.one at home.com
Sun May 27 17:41:08 EDT 2001


[Thomas Wouters]
> There are basically two choices wrt. allowing reserved words as
> vrbl names:
>
> 1) allow them everywhere, in any situation. ...
> ...
> 2) Allow them in certain locations only, like calling functions
> with keyword arguments, attribute-referencing/assignment and 'def'
> statements inside classes (but not outside.) ...
> ...
> Guido agreed with #2 already (pending implementation). I'm
> not sure what his opinion of #1 is,

I'll channel him, then:  no way.  Most keywords in Python serve to
distinguish among *kinds* of statements, via the "first word" on a line.  If
the first word is "def", it's a function definition; if "else", an else
stmt; etc.  This is helpful for people and simple parsing tools more than
for Python's parser.  But people and simple tools won't be bamboozled by
keywords in, e.g., attribute positions, not any more than they're bamboozled
now by keywords inside string literals.

As a first cut, you might, e.g., try replacing

dotted_name: NAME ('.' NAME)*

with

dotted_name: NAME ('.' anyname)*
anyname: NAME | 'and' | 'assert' | 'break' | ... | 'while'

i.e. explicitly list all the reserved words as alternatives in a new
more-inclusive NAME-like production.

Then see what breaks and fix it <wink>.





More information about the Python-list mailing list