Daniel Rall wrote:
> On Sat, 05 Jan 2008, Branko Čibej wrote:
>
>
>> Daniel Rall wrote:
>>
>>> On Fri, 04 Jan 2008, cmpilato_at_tigris.org wrote:
>>> ...
>>>
>>>
>>>> + /* Are we changing the node? */
>>>> + if ((! has_mergeinfo) != (! *had_mergeinfo))
>>>>
>>>>
>>> ...
>>>
>>> I find this expression really difficult to grok at first glance. Is there
>>> a simpler way to do it (without all the negation)?
>>>
>>>
>> Not in C, since it doesn't have a real boolean type. This is a pretty
>> standard way of writing a logical exclusive-or.
>>
>
> Okay, thanks Brane.
>
> (And gross!)
>
Well ... It would seem obvious at first glance if C had grown ^^ along
with && and || during its evolution. But in fact != and ^^ would behave
identically on boolean values, and the only benefit of having ^^ would
be its conversion of !=0 to 1 ... which you can do with !! just as well.
Do you like all the punctuation? :)
-- Brane
P.S.: For a moment there I was going to recommend Python with its
keyword logical operators, but heh, Python doesn't have "xor" either. In
fact, from my experience the use of logical-exclusive-or in code is so
rare compared to its bitwise counterpart, it hardly seems necessary to
have a special operator.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-01-07 06:16:51 CET