Overloading the tilde operator?

Neil Cerutti horpner at yahoo.com
Fri Feb 2 09:01:46 EST 2007


On 2007-02-02, Ben Finney <bignose+hates-spam at benfinney.id.au> wrote:
> James Stroud <jstroud at mbi.ucla.edu> writes:
>> Ben Finney wrote:
>> > The Python runtime parser is designed to parse Python, not
>> > some arbitrary language that someone chooses to implement in
>> > Python.
>>
>> You haven't addressed why the limitation isn't arbitrary.
>
> Good thing I wasn't trying to do that, then. I was pointing out
> the source of the limitation.
>
> The Python syntax parser must follow the rules of the Python
> language. If you accept that premise, it follows that the '~'
> operator is unary only. If you *don't* accept that premise, I
> have no help to offer.

There's been only one (or two?) languages in history that
attempted to provide programmers with the ability to implement
new infix operators, including defining precedence level and
associativity (I can't think of the name right now).

C++, for example, works the same way as Python here. You can
override most of the operators, but you cannot change their
arity, associativity, or precedence level.

-- 
Neil Cerutti
Let us join David and Lisa in the celebration of their wedding and bring their
happiness to a conclusion. --Church Bulletin Blooper



More information about the Python-list mailing list