Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify how the type system handles null / empty values #111

Open
AutonomicPerfectionist opened this issue Aug 16, 2023 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@AutonomicPerfectionist
Copy link
Contributor

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

@AutonomicPerfectionist AutonomicPerfectionist added the enhancement New feature or request label Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant