I know. I understand your motivation, and that the present state of affairs is less than desirable.

However, I still object to your patch on two grounds:

(1) Using the name "==" implies that it is doing an equivalence comparison, similar to C / C++, where the same named operator may be used with multiple types of left and right hand sides.

If we had it in CMake, one *should* logically be able to infer that any type of comparison would be possible: string, variable, int or float numbers, versions. But that wouldn't be true, and so people would have to re-learn their intuition about == and it would just be strange for almost everyone.

(2) We already have 2 ways of doing EQUAL comparisons, and this would be a 3rd, without being complete, and without eliminating either of the other ways...

This 3rd way, while having the nice feature of doing what you want w.r.t. string values, and not doing variable value lookup, would ADD to the confusion still more because it is counter-intuitive as noted above.

Sorry, I just don't see this as a good addition overall.


David



-----Original Message-----
From: Alexander Neundorf <neund...@kde.org>
To: cmake-developers <cmake-developers@cmake.org>
Sent: Sun, Mar 24, 2013 5:23 am
Subject: Re: [cmake-developers] if (FOO == BAR) ...


On Saturday 23 March 2013, David Cole wrote:
Wow, could be a variable on the right, too. So my previous example was
still not 100% safe.

Maybe this construct is 100% safe:

    set(x "${some_var_that_may_eval_to_another_var_name}")
    set(y "some string constant that may also accidentally be a var")
    if(x STREQUAL y)

You can see why the "x${var}" STREQUAL "xSomeString" approach is
appealing after a discussion like this.

Hmm, actually, to me, no.
Now you have ugly code and as Brad noted, you can still construct cases where
it breaks.
That's why I came up with that quick, safe and not-really-dirty patch.

Having said that, I've never been hit by that problem, or at least I'm not
aware of it.

Alex
--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to