Other notes

Jp Calderone exarkun at divmod.com
Wed Dec 29 13:24:53 EST 2004


On Wed, 29 Dec 2004 11:42:00 -0600, Mike Meyer <mwm at mired.org> wrote:
>bearophileHUGS at lycos.com writes:
> 
> > @infix
> > def interval(x, y): return range(x, y+1) # 2 parameters needed
> >
> > This may allow:
> > assert 5 interval 9 == interval(5,9)
> 
> I don't like the idea of turning words into operators. I'd much rather
> see something like:
> 

  Really?  I like "not", "and", "or", "is", and "in".  It would not be nice 
if they were replaced with punctuation.

  This aside, not even Python 3.0 will be flexible enough to let you define
an infix decorator.  The language developers are strongly against supporting 
macros, which is what an infix decorator would amount to.

  Now, they might be convinced to add a new syntax that makes a function 
into an infix operator.  Perhaps something like this:

    def &(..)(x, y):
        return range(x, y + 1)

  This is much better than supporting macros because it will lead to a 6 
month long debate over the exact syntax and adds exactly zero other 
features to the language (whereas macros let you pick your own syntax 
and give you essentially unlimited other abilities).

  Jp



More information about the Python-list mailing list