I am not convince that the proposed syntax is a good idea because it introduce 
a new syntax just to solve one action on a list.

What about introducing a syntax similar to the version comparison:

• LENGTH_EQUAL
• LENGTH_GREATER
• LENGTH_LOWER
• etc…

To use it:
if (my_list LENGTH_EQUAL 1)
  # do my stuff
endif()

Or introduce a more general syntax for list management as part of an expression:
$LIST{<op>,<list>[,<arg>,…]}

Where <op>, <list> and <arg> use same semantic as list command.
To use it:
of ($LIST{LENGTH,my_list} EQUAL 1)
  # do my stuff
endif()

The advantage of this syntax is extensibility: More <op> can be added and more 
commands can be introduced (for example $STRING{…}).

Le 22 janv. 2019 à 16:37 +0100, Brad King via cmake-developers 
<cmake-developers@cmake.org>, a écrit :
> On 1/22/19 10:28 AM, tors...@robitzki.de wrote:
> > With `$CACHE{VAR}` and `$ENV{VAR}` we already have the syntax for calling a 
> > „function“.
>
> No, there is no obvious way to pass arguments, handle nested quoting, etc.
> The language was not designed for that. That is a big can of worms I'd rather
> not open just to solve the list length problem which is already only 2 lines.
>
> > Once we have this, it would be possible to define $LIST_LENGTH in the CMake 
> > language
>
> Not as efficiently as a dedicated syntax for the only language construct
> we have that resembles a data structure.
>
> -Brad
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: 
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more 
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake-developers
-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers

Reply via email to