You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
In the documentation, I am unable to find any information on how null or empty values are treated. In my mind, with experience in other languages, I would assume that an empty value would be implicitly convertible to any object type, but not to "primitive" types like ints or booleans. However, since CMake fundamentally lacks such a distinction, it's unclear what types are allowed to be "null" / empty, and what are not. The current implementation appears to treat null values as desc, which on the surface seems fine, but it makes selecting the types for parameters that might be empty difficult.
Describe the solution you'd like
In newer languages, types are non-nullable by default, but have a variant type that allows null. This variant type is usually denoted by a ? character following the type. So if we have a non-null class type, we would also have a nullable class? type.
Since CMake does not have a true concept of null, and we want to allow an empty string to be used as a desc, then we would have to make desc and desc? be equivalent.
Describe alternatives you've considered
Another alternative would be to simply allow an empty value to be implicitly convertible to any type, effectively making all types nullable. This has the disadvantage of looser type checking, especially since undefined variables simply resolve to an empty string
Additional context
Discovered while adding cpp_assert_signature checks to CMakeTest code, since many of the asserts must allow empty values or values of a specific type
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
In the documentation, I am unable to find any information on how null or empty values are treated. In my mind, with experience in other languages, I would assume that an empty value would be implicitly convertible to any object type, but not to "primitive" types like ints or booleans. However, since CMake fundamentally lacks such a distinction, it's unclear what types are allowed to be "null" / empty, and what are not. The current implementation appears to treat null values as
desc
, which on the surface seems fine, but it makes selecting the types for parameters that might be empty difficult.Describe the solution you'd like
In newer languages, types are non-nullable by default, but have a variant type that allows null. This variant type is usually denoted by a
?
character following the type. So if we have a non-nullclass
type, we would also have a nullableclass?
type.Since CMake does not have a true concept of null, and we want to allow an empty string to be used as a
desc
, then we would have to makedesc
anddesc?
be equivalent.Describe alternatives you've considered
Another alternative would be to simply allow an empty value to be implicitly convertible to any type, effectively making all types nullable. This has the disadvantage of looser type checking, especially since undefined variables simply resolve to an empty string
Additional context
Discovered while adding
cpp_assert_signature
checks to CMakeTest code, since many of the asserts must allow empty values or values of a specific typeThe text was updated successfully, but these errors were encountered: