[Python-Dev] Integer division transition

Guido van Rossum guido@python.org
Tue, 07 Nov 2000 08:33:46 -0500


> > > It's a new keyword though, which has a much
> > > higher threshold for acceptance than a new two-character operator
> > > symbol.
> 
> > It could be non-reserved, since a div b is currently
> > a syntax error.
> 
> Except for the fact our current parser can't handle the 'a div b' syntax
> without making 'div' a reserved word, which also makes 'x.div', 'class div:'
> and 'def div():' invalid syntax. It might be work around-able, but .... :P

No, we *could* use the 'import as' trick: define the syntax as

term: factor (('*'|'/'|'%'|NAME) factor)*

and add a check that NAME is "div" in the compiler.

But I don't know how comfy I am with a proliferation of hacks like
this -- and it's likely to cause more confusing error messages.

--Guido van Rossum (home page: http://www.python.org/~guido/)