Other notes
Mike Meyer
mwm at mired.org
Wed Dec 29 13:38:02 EST 2004
Jp Calderone <exarkun at divmod.com> writes:
> 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.
They can't be turned into operators - they already are.
> 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.
Could you please explain how allowing new infix operators amount to
supporting macros?
> 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)
And while you're at it, explain how this method of defining new infix
operators differs from using decorators in such a way that it doesn't
amount to supporting macros.
<mike
--
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list
mailing list