Rationale for not allowing overload of && and ||?

Brian Price blprice61 at yahoo.com
Wed Jun 18 13:35:49 PDT 2008


Nick Sabalausky Wrote:

> "Joe Gauterin" <Joseph.Gauterin at googlemail.com> wrote in message 
> news:g3bpl0$1ujc$1 at digitalmars.com...
> > What is the rationale for not allowing overloading of && and ||? It seems 
> > to me that, with the 'lazy' keyword, D is one of the few languages where 
> > overloaded && and || can correctly implement short circuited evaluation.
> 
> If I'm not mistaken, I think you can define an "implicit conversion from 
> this class (or struct?) to ...".  So I assume the reason is, defining an 
> implicit conversion to bool would effectively eliminate all (legitamate) 
> reasons to overload && and ||. The only things that overloading && and || 
> could do that couldn't be accomplished (with better compatability across 
> various types) would be things that would break the intended meaning of && 
> and ||. Buy that's considered bad style when overloading operators anyway. 
> 
 
Bayesian and fuzzy logic both assign non boolean meanings to the operations and/or.  If you cannot overload && and || you cannot express such logic operations in a concise recognizable form.  

Brian




More information about the Digitalmars-d mailing list