Other notes

Mike Meyer mwm at mired.org
Thu Dec 30 16:16:42 EST 2004


Jp Calderone <exarkun at divmod.com> writes:

> On Wed, 29 Dec 2004 12:38:02 -0600, Mike Meyer <mwm at mired.org> wrote:
>>Jp Calderone <exarkun at divmod.com> writes:
>> >   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?
>
>   You misread - I said "what an infix decorator would amount to".  Adding 
> new infix operators is fine and in no way equivalent to macros.

You misread, I said "allowing new infix oerpators 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.
>
>   Simple.  You can't do anything except define a new infix operator with 
> the hypothetical "def &( <operator> )" syntax.  With real macros, you can 
> define new infix operators, along with any other syntactic construct your
> heart desires.

You failed to answer the question. We have two proposed methods for
adding new infix operators. One uses decorators, one uses a new magic
syntax for infix operators. Neither allows you to do anything except
declare new decorators. For some reason, you haven't explained yet,
you think that using decorators to declare infix operators would
amount to macros, yet using a new syntax wouldn't. Both require
modifying the grammer of the language accepted by the parser. How is
it that one such modification "amounts to macros", whereas the other
doesn't?

        <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