Operator overloading

Hexamorph hexamorph at gmx.net
Fri Jan 25 20:25:06 CET 2008


MartinRinehart at gmail.com wrote:
> 
> Diez B. Roggisch wrote:
>> No, there is no way. You would change general interpreter behavior if
>> you could set arbitrary operators for predefined types.
>>
>> Start grumping...
> 
> Thank you, Diez.
> 
> If I ever design a language, please remind me that complete, easy,
> well-documented access to the working of the internals (and the
> ability to change same) would be very, uh, what's the right word?
> Pythonic?


You mean you want the ability to change for example the + operator 
for ints to something like calculating the cosine instead of doing 
addition?

That will break the whole system in general as other parts of the 
language (or modules, libraries and programs) rely on a certain 
inner behaviour.

There are some languages in which you can do this (Lisp/Scheme for 
example) but messing with the internals is almost never done for 
good reasons.



More information about the Python-list mailing list