[Python-3000] Wither PEP 335 (Overloadable Boolean Operators)?

Phillip J. Eby pje at telecommunity.com
Fri May 25 17:54:50 CEST 2007


At 11:25 AM 5/25/2007 +0200, Neville Grech Neville Grech wrote:
> >From a user's POV, I'm +1 on having overloadable boolean 
> functions. In many cases I had to resort to overload add or neg 
> instead of and & not, I foresee a lot of cases where the and 
> overload could be used to join objects which represent constraints. 
> Overloadable boolean operators could also be used to implement 
> other types of logic (eg: fuzzy logic). Constraining them to just 
> primitive binary operations in my view will be delimiting for a 
> myriad of use cases.
>
>Sure, in some cases, one could overload the neg operator instead of 
>the not but semantically they have different meanings.

Actually, I think that most of the use cases for this PEP would be 
better served by being able to "quote" code, i.e. to create AST 
objects directly from Python syntax.  Then, you can do anything you 
can do in a Python expression (including conditional expressions, 
generator expressions, yield expressions, lambdas, etc.) without 
having to introduce new special methods for any of that stuff.  In 
fact, if new features are added to the language later, they 
automatically become available in the same way.



More information about the Python-3000 mailing list