:: Re: [DNG] [OT] [Re: Studying C as t…
Kezdőlap
Delete this message
Reply to this message
Szerző: Irrwahn
Dátum:  
Címzett: dng
Tárgy: Re: [DNG] [OT] [Re: Studying C as told. (For help)
On Tue, 21 Jun 2016 19:31:55 +0900, Simon Walter wrote:
[About short-circuiting logical operators]
> I am thinking we might use single ampersand or pipe (bitwise). Can we
> use bitwise operators as what would be a non-short-circuiting logical
> operator in C (or other languages)?


We could. But it is a kludge, and very bad style.

Consider:

Eager logical AND: ( !!(A) & !!(B) )
Eager logical OR: ( !!(A) | !!(B) )

The double logical NOT "normalizes" the range of possible
values to the set (0;1). Thus you could even get away with
using above with expressions of non-integer type, e.g.
pointers. But at least in my book it'd count as "unwanted
chumminess with the C standard". ;-)

Regards
Urban