[cmake-developers] Exclusive Or operator

Robert Dailey rcdailey.lists at gmail.com
Wed Sep 12 12:00:27 EDT 2012


Honestly I'm not really worried about the "band wagon" or what other
languages do. CMake is its own independent entity and domain language,
if the feature is useful then it should have it :) Anyway I was just
wondering if the feature would be accepted & useful. As I said I don't
mind doing the work.

Not every operator needs to short circuit. If you can't short circuit,
then you can't. For example, in C++ you understand what short
circuiting rules are and you work with that. But not every C++
operator allows it.

Also FWIW, in Python you can kind-of get XOR by converting both
operands to boolean:

bool(a) != bool(b)

But we can't cast operands to bool on-the-fly in CMake (AFAIK) so this
wouldn't be feasible.

On Wed, Sep 12, 2012 at 6:49 AM, Brad King <brad.king at kitware.com> wrote:
> On 09/11/2012 05:09 PM, Robert Dailey wrote:
>> I don't see an exlusive or operator in CMake. Could I add one? Would
>> such a feature be accepted?
>>
>> Syntax would be:
>>
>> if( var1 XOR var2 )
>
> Many languages like C, C++, python, lua, etc. do not offer
> logical XOR operators, only bitwise XOR.  Unlike AND/OR/NOT
> the XOR operation cannot be used in short-circuit evaluation
> (CMake's if() command does not currently short-circuit, but
> it could.).
>
> -Brad



More information about the cmake-developers mailing list