Closed jrandolf-2 closed 1 year ago
@whimboo @jgraham could you please take a look?
The difference is not readily apparent. You see the difference when you consider arrays.
For example, consider the following:
apple = ( uint )
banana = ( apple )
mango = [
banana
]
banana-2 = { apple }
mango-2 = [
banana-2
]
banana
is a type alias, so what this means is mango = [apple]
in TS. banana-2
is a type, so what this means is mango-2 = [banana-2]
because types are not spread.
Fun fact:
You can have the CDDL test = ( test )
which is valid, but literally means nothing for tooling because you can't determine if test
is a group name or a type name. If you had test = ( test .default 5 )
, the test
would be a type because .default
can only be used on types.
CDDL doesn't allow composition with non-groups.
Basically, you have the following ABNF:
When you you don't use parenthesis, it matches the first branch, but this is bad because for maps (types declared with { ... }), this is not valid ("If the memberkey is not given, the entry can only be used for matching arrays, not for maps." (Ctrl + F this)).
Thus we need to declare the base types with parenthesis.
See https://www.rfc-editor.org/rfc/rfc8610.html#appendix-C for the relevant spec.
Preview | Diff