<div>On Tue, Dec 6, 2011 at 6:39 PM, David Cole <span dir="ltr"><<a href="mailto:david.cole@kitware.com">david.cole@kitware.com</a>></span> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">> Plus the option in the list that is the default must be</div><div class="im">
> specified in 2 different locations. I think a cleaner solution could be<br>
> implemented:<br>
><br>
> set( BaseName "binary;octal;decimal;hexidecimal" CACHE LIST "Documentation"<br>
> )<br>
><br>
> The first item in the list would be the default.<br>
><br>
<br>
</div>So you propose that<br>
<div class="im"><br>
set( BaseName "binary;octal;decimal;hexidecimal" CACHE LIST "Documentation")<br>
<br>
</div>yields "${BaseName}" equal to "binary"?<br>
<br>
That would be rather odd, since the existing:<br>
<br>
set( BaseName "binary;octal;decimal;hexidecimal" CACHE STRING "Documentation")<br>
<br>
yields "${BaseName}" equal to "binary;octal;decimal;hexidecimal"...<br>
<br>
And everywhere else in the CMake documentation we treat STRING and<br>
LIST as interchangeable entities, where a LIST is simply a string that<br>
has semi-colon delimiters between the items of the list...<br>
<br>
If we were to make a change like this to add to the "set" command, I'd<br>
prefer to see something like the following:<br>
<br>
set( BaseName "binary" CACHE STRING "Documentation"<br>
CONSTRAIN_TO_STRINGS "binary;octal;decimal;hexidecimal")<br>
<br>
The type of the cache entry in question is most definitely a STRING,<br>
and furthermore in this case a non-list STRING. I don't think we want<br>
it to be a list. We want to give a list of values to which to<br>
constrain the string....<br></blockquote><div><br></div><div>Here you are still repeating the default value twice, which is error prone. If I change that 1 item in one location, I have to change it in another. I should only have to edit it once should I need to.</div>
<div><br></div><div>It is a list of literal objects. I would rather see your revised implementation look like this (again revised):</div><div><br></div><div>set( BaseName "binary;octal;decimal;hexidecimal" CACHE LIST "Documentation" DEFAULT 0 )</div>
<div><br></div><div>In this case you set the default value explicitly by index, that way you do not have to repeat the value itself.</div><div><br></div><div>Or you could do this:</div><div><br></div><div>set( BaseName 0 CACHE LIST "Documentation" ITEMS "binary;octal;decimal;hexidecimal" )</div>
<div><br></div><div>In this second case, "LIST" is just syntactic sugar for "STRING", and the CMake compiler will replace the list index (in this case 0) with the corresponding string value in the list provided after the ITEMS parameter, which in this case would be "binary". This is basically the same as your revised example, but without the duplication of the "binary" item in the list.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">> Wouldn't this work and be slightly cleaner and more straight-forward? Plus<br>
> you could keep the documentation for this feature contained to the 'set'<br>
> command in the docs like other cache variable types. I just don't think<br>
> lists should be handled differently.<br>
<br>
</div>Perhaps you still need to make the mental leap that a list is a<br>
string, and that a string is a list, in the CMake language?</blockquote><div><br></div><div>The fact that a list is a string is an implementation detail of CMake itself. As a user of CMake I shouldn't need to concern myself with such matters. I think of a collection of items in CMake as a list. The syntax is different for lists as well. There are non-literal parts of the string that are treated special by CMake, which makes it not a string at all actually. Strings are literal objects that get no extra processing beyond escape sequences.</div>
<div><br></div><div>Perhaps the mental leap is the inverse of what you propose: A list is not a string and should not be a string (although the syntax differences between them are minor). Also keep in mind that I'm talking about state of mind. The CMake code might argue against me, but when I'm using CMake code I don't care about what CMake is calling a list. </div>
</div>