dmd warning request: warn for bitwise OR in conditional

Nick Sabalausky a at a.a
Sat Jan 23 16:43:20 PST 2010


"Ali Çehreli" <acehreli at yahoo.com> wrote in message 
news:hjg2fo$d28$1 at digitalmars.com...
> 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

I've always seen "b" as just simply "a) assign" where the values being 
copied/destroyed are references instead of, say, chars or floats. 
Conversely, you can "a) assign" an int that's intended as an index into a 
collection and doing so amounts to "b". So that "a" and "b" essentially 
*are* the same.





More information about the Digitalmars-d mailing list