.size questions
jyasskin opened this issue · 4 comments
Can a range of sizes be applied to an integral type?, e.g. uint .size (3..5)
? Probably not.
Is it meaningful to apply a size to a floating type? e.g. float .size 4
? Maybe that would mean that values that can't be expressed in a single-precision float aren't allowed?
Does [*uint] .size 7
mean that the array has to be represented in exactly 7 bytes?
Can a range of sizes be applied to an integral type?, e.g. uint .size (3..5)? Probably not.
Yes. This is not particularly useful as the size is a restriction on the maximum, so the above is equivalent to uint .size 5
. (Which may be why the CDDL tool does not implement the case.)
Is it meaningful to apply a size to a floating type? e.g. float .size 4? Maybe that would mean that values that can't be expressed in a single-precision float aren't allowed?
Currently, .size is not defined for floats. You can help yourself by using float32 in this case.
Does [*uint] .size 7 mean that the array has to be represented in exactly 7 bytes?
.size is not defined for arrays, and I have a hard time to imagine a use case. (Note that .size is currently never about the size the CBOR representation, but about the intrinsic properties of the data item.)
I'm closing this now; please reopen if you believe there should be text changes.
I think the text definition of .size
at https://cbor-wg.github.io/cddl/draft-ietf-cbor-cddl.html#control-operator-size should specify the answers to those questions.
Nothing in the specification currently says which types it's defined for.
Please check if that is better now...
Looks good, thanks.