Operators for everything (was Re: Operators for matrix)
Tim Rowe
digitig at cix.co.uk
Mon Jul 24 16:04:00 EDT 2000
In article <m3em4ld5t3.fsf at atrus.jesus.cam.ac.uk>, mwh21 at cam.ac.uk
(Michael Hudson) wrote:
> Sorry, but eh? I fail to understand you, I think.
>
> Example usage of what I'm talking about:
>
> def add(x,y):
> return x + y
>
> 1 @add 1
> ==> 2
My problem is that identifiers that refer to overloaded infix operators
must begin with a @ (and presumably any identifier beginning with @ must
be an overloaded infix operator). Hey, why not force integers to begin
with a %, strings with a $...
I don't like it because it makes programs harder to read. One of the
reasons I don't like Perl is that it tends to look as if the whole program
is obscene and has been censored with $@**!& special symbols! One of the
advantages of Python is that there is little of this nonsense, and I would
hate to see it added to. I don't think extensible infix is worth it.
By the way, /I'd/ expect x add y to set x to x + y, leave y alone and
return None (or x + y if this were comp.lang.c). I'd expect x plus y to
have the behaviour you expect of add. I'm undecided whether that's a
problem with infix or the perennial problem of choosing good identifiers!
More information about the Python-list
mailing list