[Python-Dev] Wrappers and keywords

Ken Manheimer klm@zope.com
Thu, 17 Apr 2003 18:02:20 -0400 (EDT)


On Thu, 17 Apr 2003, Skip Montanaro wrote:

> Adding new syntactic sugar is less problem than adding keywords for two
> reasons:
> 
>     * old code may have used the new keyword as a variable (because it
>       wasn't a keyword)
> 
>     * old code won't have used the new syntactic sugar (because it wasn't
>       proper syntax)

(If i recall correctly, minting new keywords is particularly onerous
in python because of its simple parser.  Specifically, you can't use
keywords for variable names anywhere, even outside the syntactic
construct which involves the keyword.  Hence the need to use 'klass'
instead of 'class' for parameter names, no variables named 'from',
etc.  'import's recent aliasing refinement -

  import x as y

was implemented without making "as" a keyword specifically to avoid
this drawback.  "as" gets its role there purely by virtue of the
import syntax, not as a new keyword - and so you can use "as" as a
variable name, etc.  The scheme for qualifying function definitions
with [...] would have the same virtue - not requiring the qualifiers
to be new keywords...)

-- 
Ken
klm@zope.com