Re: [cmake-developers] $LIST_LENGTH{} syntax

2019-01-22 Thread Ben Boeckel via cmake-developers
On Tue, Jan 22, 2019 at 19:31:43 +0100, tors...@robitzki.de wrote: > Currently, the Code that evaluates the ${}-Syntax only evaluates the key, if > the key is not an empty string: > > const char* cmCommandArgumentParserHelper::ExpandSpecialVariable( > const char* key, const char* var) > { >

Re: [cmake-developers] $LIST_LENGTH{} syntax

2019-01-22 Thread Brad King via cmake-developers
On 1/22/19 1:31 PM, tors...@robitzki.de wrote: > Currently, the Code that evaluates the ${}-Syntax only evaluates the key > > const char* cmCommandArgumentParserHelper::ExpandSpecialVariable( That's the pre-CMP0053 impl. See cmMakefile::ExpandVariablesInStringNew for the modern impl. Only with

Re: [cmake-developers] $LIST_LENGTH{} syntax

2019-01-22 Thread Brad King via cmake-developers
On 1/22/19 10:55 AM, Marc CHEVRIER wrote: > 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() That's where this thread started.

Re: [cmake-developers] $LIST_LENGTH{} syntax (was: Support for list length expression in if()-command?)

2019-01-22 Thread Robert Maynard via cmake-developers
I like some syntax that looks like $LEN{}. I would love to keep the $...{ syntax open for future exentsion such as easy target property set/get ( $[prop_name]{target} ) . This seems to be okay as $ENV, and $CACHE only work on variables, so therefore adding $LEN that also only works on variables

Re: [cmake-developers] real functions (was: $LIST_LENGTH{} syntax)

2019-01-22 Thread Marc CHEVRIER
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

Re: [cmake-developers] real functions (was: $LIST_LENGTH{} syntax)

2019-01-22 Thread Torsten
> Am 22.01.2019 um 16:37 schrieb Brad King : > > 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. Jep, you are right.

Re: [cmake-developers] real functions (was: $LIST_LENGTH{} syntax)

2019-01-22 Thread Brad King via cmake-developers
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

Re: [cmake-developers] real functions (was: $LIST_LENGTH{} syntax)

2019-01-22 Thread Torsten
> Am 22.01.2019 um 13:33 schrieb Brad King : > > On 1/22/19 7:09 AM, tors...@robitzki.de wrote: > >> How about adding the ability to add such function? Like: >> >> procedure(LIST_LENGTH list) >> list(LENGTH list length) >> return(${length}) >> endprocedure() > > We don't have a syntax for

Re: [cmake-developers] $LIST_LENGTH{} syntax (was: Support for list length expression in if()-command?)

2019-01-22 Thread Brad King via cmake-developers
On 1/22/19 7:40 AM, Daniel Franke wrote: > Whats about a Syntax like > > ${list::LENGTH} That would require dispatch after matching `${VAR}` syntax, and that lookup is one of the hottest paths according to profiling. We already have $ENV{} and $CACHE{} syntax. -Brad -- Powered by

Re: [cmake-developers] $LIST_LENGTH{} syntax (was: Support for list length expression in if()-command?)

2019-01-22 Thread Brad King via cmake-developers
On 1/22/19 7:09 AM, tors...@robitzki.de wrote: >> Am 22.01.2019 um 12:42 schrieb Brad King: >> Rather than a special `if` syntax, perhaps we could introduce an >> explicit `$LIST_LENGTH{mylist}` syntax. One would need to experiment >> to see if modifying the variable expansion parser (under

Re: [cmake-developers] Support for list length expression in if()-command?

2019-01-22 Thread Brad King via cmake-developers
On 1/22/19 3:08 AM, tors...@robitzki.de wrote: > three use cases: > > - Checking for empty lists (I’ve showed him that this can be done > by a string compare). > - Checking for lists having more than 1 entry > - Checking for equal size of two lists. For example, if you want > to pass pairs or

Re: [cmake-developers] Support for list length expression in if()-command?

2019-01-22 Thread Torsten
Hi Brad, > Am 14.01.2019 um 12:44 schrieb Brad King : > > I've almost never needed to test the length of a list in CMake > code. It's not very common in my experience. What is your > customer trying to do? Sorry for the late response! I’ve asked him. Mainly, he has three use cases: -