dmd warning request: warn for bitwise OR in conditional

Ali Çehreli acehreli at yahoo.com
Sat Jan 23 15:58:36 PST 2010


Nick Sabalausky wrote:
> "Yigal Chripun" <yigal100 at gmail.com> wrote in message 
> news:hjek8e$4j0$1 at digitalmars.com...
>> uint a, b; // init to whatever
>> bool c, d; // ditto
>>
>> auto r1 = a AND b; //  a & b
>> auto r2 = c AND d; // c && d
>> ...
>> AND stands for whatever *single* syntax is chosen for this.
>>
> 
> Yuck, that amounts to language-enforced operator overloading abuse, just 
> like the common mis-design of overloading '+' to mean both 'add' and 
> 'concat'. 

That exists for the assignment operator too (which happens to be a 
misnomer).

   lhs = rhs;

may mean, without any user overloading:

a) assign (destroy the value of lhs and copy the value of rhs)

b) let lhs provide access to the same object that rhs is providing 
access to (as a side effect, if lhs was the single reference to lhs's 
object, then the object may be destroyed in the future)

The behavior depends on whether the type is a value type or a reference 
type.

Ali



More information about the Digitalmars-d mailing list