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

Jarrett Billingsley kb3ctd2 at yahoo.com
Wed Jun 18 14:49:10 PDT 2008


"Brian Price" <blprice61 at yahoo.com> wrote in message 
news:g3brj5$2370$1 at digitalmars.com...
> 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.

& and |? 





More information about the Digitalmars-d mailing list